/** * Get versions of columns only within the specified timestamp range, * [minStamp, maxStamp). * @param minStamp minimum timestamp value, inclusive * @param maxStamp maximum timestamp value, exclusive * @throws IOException * @return this for invocation chaining */ public Get setTimeRange(long minStamp, long maxStamp) throws IOException { tr = new TimeRange(minStamp, maxStamp); return this; }
/** * 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. * @param minStamp minimum timestamp value, inclusive * @param maxStamp maximum timestamp value, exclusive * @see #setMaxVersions() * @see #setMaxVersions(int) * @return this */ public Scan setTimeRange(long minStamp, long maxStamp) throws IOException { tr = new TimeRange(minStamp, maxStamp); return this; }
/** * Sets the TimeRange to be used on the Get for this append. * <p> * This is useful for when you have counters that only last for specific * periods of time (ie. counters that are partitioned by time). By setting * the range of valid times for this append, you can potentially gain * some performance with a more optimal Get operation. * Be careful adding the time range to this class as you will update the old cell if the * time range doesn't include the latest cells. * <p> * This range is used as [minStamp, maxStamp). * @param minStamp minimum timestamp value, inclusive * @param maxStamp maximum timestamp value, exclusive * @return this */ public Append setTimeRange(long minStamp, long maxStamp) { tr = new TimeRange(minStamp, maxStamp); return this; }
/** * Sets the TimeRange to be used on the Get for this increment. * <p> * This is useful for when you have counters that only last for specific * periods of time (ie. counters that are partitioned by time). By setting * the range of valid times for this increment, you can potentially gain * some performance with a more optimal Get operation. * Be careful adding the time range to this class as you will update the old cell if the * time range doesn't include the latest cells. * <p> * This range is used as [minStamp, maxStamp). * @param minStamp minimum timestamp value, inclusive * @param maxStamp maximum timestamp value, exclusive * @throws IOException if invalid time range * @return this */ public Increment setTimeRange(long minStamp, long maxStamp) throws IOException { tr = new TimeRange(minStamp, maxStamp); return this; }
public static TimeRange at(long ts) { if (ts < 0 || ts == Long.MAX_VALUE) { throw new IllegalArgumentException("invalid ts:" + ts); } return new TimeRange(ts, ts + 1); }
/** * Get versions of columns with the specified timestamp. * @param timestamp version timestamp * @return this for invocation chaining */ public Get setTimestamp(long timestamp) { try { 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); throw e; } return this; }
/** * Get versions of columns only within the specified timestamp range, * [minStamp, maxStamp) on a per CF bases. 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. * Column Family time ranges take precedence over the global time range. * * @param cf the column family for which you want to restrict * @param minStamp minimum timestamp value, inclusive * @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; }
/** * Get versions of columns with the specified timestamp. 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 * defaut. * @param timestamp version timestamp * @see #setMaxVersions() * @see #setMaxVersions(int) * @return this */ public Scan setTimestamp(long timestamp) { try { 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); throw e; } return this; }
/** * @return Make a TimeRange from current state of <code>this</code>. */ TimeRange toTimeRange() { long min = getMin(); long max = getMax(); // Initial TimeRangeTracker timestamps are the opposite of what you want for a TimeRange. Fix! if (min == INITIAL_MIN_TIMESTAMP) { min = TimeRange.INITIAL_MIN_TIMESTAMP; } if (max == INITIAL_MAX_TIMESTAMP) { max = TimeRange.INITIAL_MAX_TIMESTAMP; } return new TimeRange(min, max); }
private static TimeRange protoToTimeRange(HBaseProtos.TimeRange timeRange) throws IOException { long minStamp = 0; long maxStamp = Long.MAX_VALUE; if (timeRange.hasFrom()) { minStamp = timeRange.getFrom(); } if (timeRange.hasTo()) { maxStamp = timeRange.getTo(); } return new TimeRange(minStamp, maxStamp); }
public static TimeRange toTimeRange(HBaseProtos.TimeRange timeRange) { return timeRange == null ? TimeRange.allTime() : new TimeRange(timeRange.hasFrom() ? timeRange.getFrom() : 0, timeRange.hasTo() ? timeRange.getTo() : Long.MAX_VALUE); }
@Test public void testTimeRangeInitialized() { TimeRangeTracker src = getTimeRangeTracker(); TimeRange tr = new TimeRange(System.currentTimeMillis()); assertFalse(src.includesTimeRange(tr)); }
/** * Get versions of columns only within the specified timestamp range, * [minStamp, maxStamp). * @param minStamp minimum timestamp value, inclusive * @param maxStamp maximum timestamp value, exclusive * @throws IOException * @return this for invocation chaining */ public Get setTimeRange(long minStamp, long maxStamp) throws IOException { tr = new TimeRange(minStamp, maxStamp); return this; }
/** * 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. * @param minStamp minimum timestamp value, inclusive * @param maxStamp maximum timestamp value, exclusive * @see #setMaxVersions() * @see #setMaxVersions(int) * @return this */ public Scan setTimeRange(long minStamp, long maxStamp) throws IOException { tr = new TimeRange(minStamp, maxStamp); return this; }
@Test public void testSimpleInRange() { TimeRangeTracker trr = getTimeRangeTracker(); trr.includeTimestamp(0); trr.includeTimestamp(2); assertTrue(trr.includesTimeRange(new TimeRange(1))); }
TimeRange range10 = new TimeRange(1, time + 10); Result r = table.append(new Append(ROW).addColumn(TEST_FAMILY, QUAL, Bytes.toBytes("b")) .setTimeRange(range10.getMin(), range10.getMax())); time = EnvironmentEdgeManager.currentTime(); mee.setValue(time); TimeRange range2 = new TimeRange(1, time+20); List<Row> actions = Arrays.asList(new Row[] {
@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()); }
TimeRange range10 = new TimeRange(1, time+10); hTableInterface.increment(new Increment(ROW_A).addColumn(TEST_FAMILY, qualifierCol1, 10L) .setTimeRange(range10.getMin(), range10.getMax())); TimeRange range2 = new TimeRange(1, time+20); List<Row> actions = Arrays.asList(new Row[] { new Increment(ROW_A).addColumn(TEST_FAMILY, qualifierCol1, 2L)
private static TimeRange protoToTimeRange(HBaseProtos.TimeRange timeRange) throws IOException { long minStamp = 0; long maxStamp = Long.MAX_VALUE; if (timeRange.hasFrom()) { minStamp = timeRange.getFrom(); } if (timeRange.hasTo()) { maxStamp = timeRange.getTo(); } return new TimeRange(minStamp, maxStamp); }
public static TimeRange toTimeRange(HBaseProtos.TimeRange timeRange) { return timeRange == null ? TimeRange.allTime() : new TimeRange(timeRange.hasFrom() ? timeRange.getFrom() : 0, timeRange.hasTo() ? timeRange.getTo() : Long.MAX_VALUE); }