/** * Represents interval [minStamp, maxStamp) * @param minStamp the minimum timestamp, inclusive * @param maxStamp the maximum timestamp, exclusive * @throws IllegalArgumentException if either <0, * @deprecated This is made @InterfaceAudience.Private in the 2.0 line and above and may be * changed to private or removed in 3.0. */ @Deprecated @InterfaceAudience.Private public TimeRange(long minStamp, long maxStamp) { check(minStamp, maxStamp); this.minStamp = minStamp; this.maxStamp = maxStamp; this.allTime = isAllTime(minStamp, maxStamp); }
public boolean shouldSeek(TimeRange tr, long oldestUnexpiredTS) { return !isEmpty() && (tr.isAllTime() || timeRangeTracker.includesTimeRange(tr)) && timeRangeTracker.getMax() >= oldestUnexpiredTS; }
@Override public Result preAppend(final ObserverContext<RegionCoprocessorEnvironment> e, final Append append) throws IOException { NavigableMap<byte [], List<Cell>> map = append.getFamilyCellMap(); for (Map.Entry<byte [], List<Cell>> entry : map.entrySet()) { for (Cell cell : entry.getValue()) { String appendStr = Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); if (appendStr.equals("b")) { tr10 = append.getTimeRange(); } else if (appendStr.equals("c") && !append.getTimeRange().isAllTime()) { tr2 = append.getTimeRange(); } } } return null; } }
@Override public Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> e, final Increment increment) throws IOException { NavigableMap<byte [], List<Cell>> map = increment.getFamilyCellMap(); for (Map.Entry<byte [], List<Cell>> entry : map.entrySet()) { for (Cell cell : entry.getValue()) { long incr = Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); if (incr == 10) { tr10 = increment.getTimeRange(); } else if (incr == 2 && !increment.getTimeRange().isAllTime()) { tr2 = increment.getTimeRange(); } } } return super.preIncrement(e, increment); } }
@Test public void testRangeConstruction() throws IOException { TimeRange defaultRange = TimeRange.allTime(); assertEquals(0L, defaultRange.getMin()); assertEquals(Long.MAX_VALUE, defaultRange.getMax()); assertTrue(defaultRange.isAllTime()); TimeRange oneArgRange = new TimeRange(0L); assertEquals(0L, oneArgRange.getMin()); assertEquals(Long.MAX_VALUE, oneArgRange.getMax()); assertTrue(oneArgRange.isAllTime()); TimeRange oneArgRange2 = new TimeRange(1); assertEquals(1, oneArgRange2.getMin()); assertEquals(Long.MAX_VALUE, oneArgRange2.getMax()); assertFalse(oneArgRange2.isAllTime()); TimeRange twoArgRange = new TimeRange(0L, Long.MAX_VALUE); assertEquals(0L, twoArgRange.getMin()); assertEquals(Long.MAX_VALUE, twoArgRange.getMax()); assertTrue(twoArgRange.isAllTime()); TimeRange twoArgRange2 = new TimeRange(0L, Long.MAX_VALUE - 1); assertEquals(0L, twoArgRange2.getMin()); assertEquals(Long.MAX_VALUE - 1, twoArgRange2.getMax()); assertFalse(twoArgRange2.isAllTime()); TimeRange twoArgRange3 = new TimeRange(1, Long.MAX_VALUE); assertEquals(1, twoArgRange3.getMin()); assertEquals(Long.MAX_VALUE, twoArgRange3.getMax()); assertFalse(twoArgRange3.isAllTime()); }
/** * Represents interval [minStamp, maxStamp) * @param minStamp the minimum timestamp, inclusive * @param maxStamp the maximum timestamp, exclusive * @throws IllegalArgumentException if either <0, * @deprecated This is made @InterfaceAudience.Private in the 2.0 line and above and may be * changed to private or removed in 3.0. */ @Deprecated @InterfaceAudience.Private public TimeRange(long minStamp, long maxStamp) { check(minStamp, maxStamp); this.minStamp = minStamp; this.maxStamp = maxStamp; this.allTime = isAllTime(minStamp, maxStamp); }
/** * Represents interval [minStamp, maxStamp) * @param minStamp the minimum timestamp, inclusive * @param maxStamp the maximum timestamp, exclusive * @throws IllegalArgumentException if either <0, * @deprecated This is made @InterfaceAudience.Private in the 2.0 line and above and may be * changed to private or removed in 3.0. */ @Deprecated @InterfaceAudience.Private public TimeRange(long minStamp, long maxStamp) { check(minStamp, maxStamp); this.minStamp = minStamp; this.maxStamp = maxStamp; this.allTime = isAllTime(minStamp, maxStamp); }
/** {@inheritDoc} */ @Override public void adapt(Increment operation, ReadModifyWriteRow readModifyWriteRow) { if (!operation.getTimeRange().isAllTime()) { throw new UnsupportedOperationException( "Setting the time range in an Increment is not implemented"); } for (Map.Entry<byte[], NavigableMap<byte[], Long>> familyEntry : operation.getFamilyMapOfLongs().entrySet()) { String familyName = Bytes.toString(familyEntry.getKey()); // Bigtable applies all increments present in a single RPC. HBase applies only the last // mutation present, if any. We remove all but the last mutation for each qualifier here: List<Cell> mutationCells = CellDeduplicationHelper.deduplicateFamily(operation, familyEntry.getKey()); for (Cell cell : mutationCells) { readModifyWriteRow.increment( familyName, ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()), Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()) ); } } } }
/** {@inheritDoc} */ @Override public void adapt(Increment operation, ReadModifyWriteRow readModifyWriteRow) { if (!operation.getTimeRange().isAllTime()) { throw new UnsupportedOperationException( "Setting the time range in an Increment is not implemented"); } for (Map.Entry<byte[], NavigableMap<byte[], Long>> familyEntry : operation.getFamilyMapOfLongs().entrySet()) { String familyName = Bytes.toString(familyEntry.getKey()); // Bigtable applies all increments present in a single RPC. HBase applies only the last // mutation present, if any. We remove all but the last mutation for each qualifier here: List<Cell> mutationCells = CellDeduplicationHelper.deduplicateFamily(operation, familyEntry.getKey()); for (Cell cell : mutationCells) { readModifyWriteRow.increment( familyName, ByteString.copyFrom( cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()), Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()) ); } } } }
/** * Given a Scan, build a RowFilter that include matching columns * * @param scan a {@link org.apache.hadoop.hbase.client.Scan} object. * @param hooks a {@link com.google.cloud.bigtable.hbase.adapters.read.ReadHooks} object. * @return a {@link com.google.bigtable.v2.RowFilter} object. */ public Filters.Filter buildFilter(Scan scan, ReadHooks hooks) { ChainFilter chain = FILTERS.chain(); Optional<Filters.Filter> familyFilter = createColumnFamilyFilter(scan); if (familyFilter.isPresent()) { chain.filter(familyFilter.get()); } if (scan.getTimeRange() != null && !scan.getTimeRange().isAllTime()) { chain.filter(createTimeRangeFilter(scan.getTimeRange())); } if (scan.getMaxVersions() != Integer.MAX_VALUE) { chain.filter(createColumnLimitFilter(scan.getMaxVersions())); } Optional<Filters.Filter> userFilter = createUserFilter(scan, hooks); if (userFilter.isPresent()) { chain.filter(userFilter.get()); } return chain; }
/** * Given a {@link Scan}, build a {@link Filters.Filter} that include matching columns * * @param scan a {@link Scan} object. * @param hooks a {@link ReadHooks} object. * @return a {@link Filters.Filter} object. */ public Filters.Filter buildFilter(Scan scan, ReadHooks hooks) { ChainFilter chain = FILTERS.chain(); Optional<Filters.Filter> familyFilter = createColumnFamilyFilter(scan); if (familyFilter.isPresent()) { chain.filter(familyFilter.get()); } if (scan.getTimeRange() != null && !scan.getTimeRange().isAllTime()) { chain.filter(createTimeRangeFilter(scan.getTimeRange())); } if (scan.getMaxVersions() != Integer.MAX_VALUE) { chain.filter(createColumnLimitFilter(scan.getMaxVersions())); } Optional<Filters.Filter> userFilter = createUserFilter(scan, hooks); if (userFilter.isPresent()) { chain.filter(userFilter.get()); } return chain; }
@Override public Result preAppend(final ObserverContext<RegionCoprocessorEnvironment> e, final Append append) throws IOException { NavigableMap<byte [], List<Cell>> map = append.getFamilyCellMap(); for (Map.Entry<byte [], List<Cell>> entry : map.entrySet()) { for (Cell cell : entry.getValue()) { String appendStr = Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); if (appendStr.equals("b")) { tr10 = append.getTimeRange(); } else if (appendStr.equals("c") && !append.getTimeRange().isAllTime()) { tr2 = append.getTimeRange(); } } } return null; } }
@Override public Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> e, final Increment increment) throws IOException { NavigableMap<byte [], List<Cell>> map = increment.getFamilyCellMap(); for (Map.Entry<byte [], List<Cell>> entry : map.entrySet()) { for (Cell cell : entry.getValue()) { long incr = Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); if (incr == 10) { tr10 = increment.getTimeRange(); } else if (incr == 2 && !increment.getTimeRange().isAllTime()) { tr2 = increment.getTimeRange(); } } } return super.preIncrement(e, increment); } }
logger.info("MaxResultSize = " + scan.getMaxResultSize()); logger.info("Filters = " + scan.getFilter()); if (!scan.getTimeRange().isAllTime()) { logger.info("TimeRange = " + scan.getTimeRange());
@Test public void testRangeConstruction() throws IOException { TimeRange defaultRange = TimeRange.allTime(); assertEquals(0L, defaultRange.getMin()); assertEquals(Long.MAX_VALUE, defaultRange.getMax()); assertTrue(defaultRange.isAllTime()); TimeRange oneArgRange = new TimeRange(0L); assertEquals(0L, oneArgRange.getMin()); assertEquals(Long.MAX_VALUE, oneArgRange.getMax()); assertTrue(oneArgRange.isAllTime()); TimeRange oneArgRange2 = new TimeRange(1); assertEquals(1, oneArgRange2.getMin()); assertEquals(Long.MAX_VALUE, oneArgRange2.getMax()); assertFalse(oneArgRange2.isAllTime()); TimeRange twoArgRange = new TimeRange(0L, Long.MAX_VALUE); assertEquals(0L, twoArgRange.getMin()); assertEquals(Long.MAX_VALUE, twoArgRange.getMax()); assertTrue(twoArgRange.isAllTime()); TimeRange twoArgRange2 = new TimeRange(0L, Long.MAX_VALUE - 1); assertEquals(0L, twoArgRange2.getMin()); assertEquals(Long.MAX_VALUE - 1, twoArgRange2.getMax()); assertFalse(twoArgRange2.isAllTime()); TimeRange twoArgRange3 = new TimeRange(1, Long.MAX_VALUE); assertEquals(1, twoArgRange3.getMin()); assertEquals(Long.MAX_VALUE, twoArgRange3.getMax()); assertFalse(twoArgRange3.isAllTime()); }
if (!timeRange.isAllTime()) { HBaseProtos.TimeRange.Builder timeRangeBuilder = HBaseProtos.TimeRange.newBuilder();
if (!timeRange.isAllTime()) { HBaseProtos.TimeRange.Builder timeRangeBuilder = HBaseProtos.TimeRange.newBuilder();
if (!timeRange.isAllTime()) { HBaseProtos.TimeRange.Builder timeRangeBuilder = HBaseProtos.TimeRange.newBuilder();