Skip to content
Permalink
Browse files
Revert "HBASE-17249 Get/Scan's setTimeRange/setColumnFamilyTimeRange …
…can take the TimeRange reference as the parameter instead of creating a new setColumnFamilyTimeRange instance. (huaxiang sun)"

This reverts commit 61220e4.
  • Loading branch information
huaxiangsun committed Aug 25, 2017
1 parent ac1fe07 commit 2e87396236b4d142940b19250bacbef2c15af3d5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 88 deletions.
@@ -73,6 +73,7 @@ public class Get extends Query
private boolean cacheBlocks = true;
private int storeLimit = -1;
private int storeOffset = 0;
private TimeRange tr = new TimeRange();
private boolean checkExistenceOnly = false;
private boolean closestRowBefore = false;
private Map<byte [], NavigableSet<byte []>> familyMap = new TreeMap<>(Bytes.BYTES_COMPARATOR);
@@ -222,19 +223,9 @@ public Get addColumn(byte [] family, byte [] qualifier) {
* @throws IOException
* @return this for invocation chaining
*/
@Override
public Get setTimeRange(long minStamp, long maxStamp) throws IOException {
return (Get) super.setTimeRange(minStamp, maxStamp);
}

/**
* Get versions of columns only within the specified timestamp range,
* @param tr Input TimeRange
* @return this for invocation chaining
*/
@Override
public Get setTimeRange(TimeRange tr) {
return (Get) super.setTimeRange(tr);
tr = new TimeRange(minStamp, maxStamp);
return this;
}

/**
@@ -245,7 +236,7 @@ public Get setTimeRange(TimeRange tr) {
public Get setTimeStamp(long timestamp)
throws IOException {
try {
super.setTimeRange(timestamp, timestamp + 1);
tr = new TimeRange(timestamp, timestamp+1);
} catch(Exception e) {
// This should never happen, unless integer overflow or something extremely wrong...
LOG.error("TimeRange failed, likely caused by integer overflow. ", e);
@@ -254,16 +245,10 @@ public Get setTimeStamp(long timestamp)
return this;
}

@Override
public Get setColumnFamilyTimeRange(byte[] cf, long minStamp, long maxStamp) {
@Override public Get setColumnFamilyTimeRange(byte[] cf, long minStamp, long maxStamp) {
return (Get) super.setColumnFamilyTimeRange(cf, minStamp, maxStamp);
}

@Override
public Get setColumnFamilyTimeRange(byte[] cf, TimeRange tr) {
return (Get) super.setColumnFamilyTimeRange(cf, tr);
}

/**
* Get all available versions.
* @return this for invocation chaining
@@ -403,6 +388,14 @@ public int getRowOffsetPerColumnFamily() {
return this.storeOffset;
}

/**
* Method for retrieving the get's TimeRange
* @return timeRange
*/
public TimeRange getTimeRange() {
return this.tr;
}

/**
* Method for retrieving the keys in the familyMap
* @return keys in the current familyMap
@@ -17,7 +17,6 @@
*/
package org.apache.hadoop.hbase.client;

import java.io.IOException;
import java.util.Map;

import org.apache.hadoop.hbase.shaded.com.google.common.collect.Maps;
@@ -44,7 +43,6 @@ public abstract class Query extends OperationWithAttributes {
protected Consistency consistency = Consistency.STRONG;
protected Map<byte[], TimeRange> colFamTimeRangeMap = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
protected Boolean loadColumnFamiliesOnDemand = null;
protected TimeRange tr = new TimeRange();
/**
* @return Filter
*/
@@ -64,36 +62,6 @@ public Query setFilter(Filter filter) {
return this;
}

/**
* @return TimeRange
*/
public TimeRange getTimeRange() {
return tr;
}

/**
* Sets the TimeRange to be used by this Query
* @param tr TimeRange
* @return Query
*/
public Query setTimeRange(TimeRange tr) {
this.tr = tr;
return this;
}

/**
* Sets the TimeRange to be used by this Query
* [minStamp, maxStamp).
* @param minStamp minimum timestamp value, inclusive
* @param maxStamp maximum timestamp value, exclusive
* @throws IOException
* @return this for invocation chaining
*/
public Query setTimeRange(long minStamp, long maxStamp) throws IOException {
tr = new TimeRange(minStamp, maxStamp);
return this;
}

/**
* Sets the authorizations to be used by this Query
* @param authorizations
@@ -257,16 +225,12 @@ public boolean doLoadColumnFamiliesOnDemand() {
* @param maxStamp maximum timestamp value, exclusive
* @return this
*/

public Query setColumnFamilyTimeRange(byte[] cf, long minStamp, long maxStamp) {
colFamTimeRangeMap.put(cf, new TimeRange(minStamp, maxStamp));
return this;
}

public Query setColumnFamilyTimeRange(byte[] cf, TimeRange tr) {
colFamTimeRangeMap.put(cf, tr);
return this;
}

/**
* @return A map of column families to time ranges
*/
@@ -141,7 +141,9 @@ public class Scan extends Query {
private long maxResultSize = -1;
private boolean cacheBlocks = true;
private boolean reversed = false;
private Map<byte[], NavigableSet<byte[]>> familyMap = new TreeMap<>(Bytes.BYTES_COMPARATOR);
private TimeRange tr = new TimeRange();
private Map<byte [], NavigableSet<byte []>> familyMap =
new TreeMap<byte [], NavigableSet<byte []>>(Bytes.BYTES_COMPARATOR);
private Boolean asyncPrefetch = null;

/**
@@ -350,7 +352,7 @@ public Scan addColumn(byte [] family, byte [] qualifier) {
}

/**
* Set versions of columns only within the specified timestamp range,
* Get versions of columns only within the specified timestamp range,
* [minStamp, maxStamp). Note, default maximum versions to return is 1. If
* your time range spans more than one version and you want all versions
* returned, up the number of versions beyond the default.
@@ -360,18 +362,9 @@ public Scan addColumn(byte [] family, byte [] qualifier) {
* @see #setMaxVersions(int)
* @return this
*/
@Override
public Scan setTimeRange(long minStamp, long maxStamp) throws IOException {
return (Scan) super.setTimeRange(minStamp, maxStamp);
}

/**
* Set versions of columns only within the specified timestamp range,
* @param tr Input TimeRange
* @return this for invocation chaining
*/
public Scan setTimeRange(TimeRange tr) {
return (Scan) super.setTimeRange(tr);
tr = new TimeRange(minStamp, maxStamp);
return this;
}

/**
@@ -387,7 +380,7 @@ public Scan setTimeRange(TimeRange tr) {
public Scan setTimeStamp(long timestamp)
throws IOException {
try {
super.setTimeRange(timestamp, timestamp + 1);
tr = new TimeRange(timestamp, timestamp+1);
} catch(Exception e) {
// This should never happen, unless integer overflow or something extremely wrong...
LOG.error("TimeRange failed, likely caused by integer overflow. ", e);
@@ -396,16 +389,10 @@ public Scan setTimeStamp(long timestamp)
return this;
}

@Override
public Scan setColumnFamilyTimeRange(byte[] cf, long minStamp, long maxStamp) {
@Override public Scan setColumnFamilyTimeRange(byte[] cf, long minStamp, long maxStamp) {
return (Scan) super.setColumnFamilyTimeRange(cf, minStamp, maxStamp);
}

@Override
public Scan setColumnFamilyTimeRange(byte[] cf, TimeRange tr) {
return (Scan) super.setColumnFamilyTimeRange(cf, tr);
}

/**
* Set the start row of the scan.
* <p>
@@ -816,6 +803,13 @@ public int getCaching() {
return this.caching;
}

/**
* @return TimeRange
*/
public TimeRange getTimeRange() {
return this.tr;
}

/**
* @return RowFilter
*/
@@ -385,12 +385,13 @@ public static Get toGet(final ClientProtos.Get proto) throws IOException {
if (proto.getCfTimeRangeCount() > 0) {
for (HBaseProtos.ColumnFamilyTimeRange cftr : proto.getCfTimeRangeList()) {
TimeRange timeRange = protoToTimeRange(cftr.getTimeRange());
get.setColumnFamilyTimeRange(cftr.getColumnFamily().toByteArray(), timeRange);
get.setColumnFamilyTimeRange(cftr.getColumnFamily().toByteArray(),
timeRange.getMin(), timeRange.getMax());
}
}
if (proto.hasTimeRange()) {
TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
get.setTimeRange(timeRange);
get.setTimeRange(timeRange.getMin(), timeRange.getMax());
}
if (proto.hasFilter()) {
FilterProtos.Filter filter = proto.getFilter();
@@ -778,7 +779,7 @@ public static Get toGet(final MutationProto proto, final CellScanner cellScanner
}
if (proto.hasTimeRange()) {
TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
get.setTimeRange(timeRange);
get.setTimeRange(timeRange.getMin(), timeRange.getMax());
}
for (NameBytesPair attribute : proto.getAttributeList()) {
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
@@ -966,12 +967,13 @@ public static Scan toScan(
if (proto.getCfTimeRangeCount() > 0) {
for (HBaseProtos.ColumnFamilyTimeRange cftr : proto.getCfTimeRangeList()) {
TimeRange timeRange = protoToTimeRange(cftr.getTimeRange());
scan.setColumnFamilyTimeRange(cftr.getColumnFamily().toByteArray(), timeRange);
scan.setColumnFamilyTimeRange(cftr.getColumnFamily().toByteArray(),
timeRange.getMin(), timeRange.getMax());
}
}
if (proto.hasTimeRange()) {
TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
scan.setTimeRange(timeRange);
scan.setTimeRange(timeRange.getMin(), timeRange.getMax());
}
if (proto.hasFilter()) {
FilterProtos.Filter filter = proto.getFilter();
@@ -511,12 +511,13 @@ public static Get toGet(final ClientProtos.Get proto) throws IOException {
if (proto.getCfTimeRangeCount() > 0) {
for (HBaseProtos.ColumnFamilyTimeRange cftr : proto.getCfTimeRangeList()) {
TimeRange timeRange = protoToTimeRange(cftr.getTimeRange());
get.setColumnFamilyTimeRange(cftr.getColumnFamily().toByteArray(), timeRange);
get.setColumnFamilyTimeRange(cftr.getColumnFamily().toByteArray(),
timeRange.getMin(), timeRange.getMax());
}
}
if (proto.hasTimeRange()) {
TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
get.setTimeRange(timeRange);
get.setTimeRange(timeRange.getMin(), timeRange.getMax());
}
if (proto.hasFilter()) {
FilterProtos.Filter filter = proto.getFilter();
@@ -900,7 +901,7 @@ public static Get toGet(final MutationProto proto, final CellScanner cellScanner
}
if (proto.hasTimeRange()) {
TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
get.setTimeRange(timeRange);
get.setTimeRange(timeRange.getMin(), timeRange.getMax());
}
for (NameBytesPair attribute : proto.getAttributeList()) {
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
@@ -1096,12 +1097,13 @@ public static Scan toScan(
if (proto.getCfTimeRangeCount() > 0) {
for (HBaseProtos.ColumnFamilyTimeRange cftr : proto.getCfTimeRangeList()) {
TimeRange timeRange = protoToTimeRange(cftr.getTimeRange());
scan.setColumnFamilyTimeRange(cftr.getColumnFamily().toByteArray(), timeRange);
scan.setColumnFamilyTimeRange(cftr.getColumnFamily().toByteArray(),
timeRange.getMin(), timeRange.getMax());
}
}
if (proto.hasTimeRange()) {
TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
scan.setTimeRange(timeRange);
scan.setTimeRange(timeRange.getMin(), timeRange.getMax());
}
if (proto.hasFilter()) {
FilterProtos.Filter filter = proto.getFilter();

0 comments on commit 2e87396

Please sign in to comment.