@Override public void run() { for (long key : data.keys) { trt.includeTimestamp(key); } } }
@Test public void testLegacySerialization() throws IOException { ByteArrayOutputStream data = new ByteArrayOutputStream(); DataOutputStream output = new DataOutputStream(data); output.writeLong(100); output.writeLong(200); TimeRangeTracker tgt = TimeRangeTracker.parseFrom(data.toByteArray()); assertEquals(100, tgt.getMin()); assertEquals(200, tgt.getMax()); }
@Test public void testSimpleInRange() { TimeRangeTracker trr = getTimeRangeTracker(); trr.includeTimestamp(0); trr.includeTimestamp(2); assertTrue(trr.includesTimeRange(new TimeRange(1))); }
justification="Intentional") void includeTimestamp(final long timestamp) { long initialMinTimestamp = getMin(); if (timestamp < initialMinTimestamp) { long curMinTimestamp = initialMinTimestamp; while (timestamp < curMinTimestamp) { if (!compareAndSetMin(curMinTimestamp, timestamp)) { curMinTimestamp = getMin(); } else { long curMaxTimestamp = getMax(); if (!compareAndSetMax(curMaxTimestamp, timestamp)) { curMaxTimestamp = getMax(); } else {
public CompositeImmutableSegment(CellComparator comparator, List<ImmutableSegment> segments) { super(comparator, segments); this.segments = segments; for (ImmutableSegment s : segments) { this.timeRangeTracker.includeTimestamp(s.getTimeRangeTracker().getMax()); this.timeRangeTracker.includeTimestamp(s.getTimeRangeTracker().getMin()); this.keySize += s.getDataSize(); } }
/** * Check if this storeFile may contain keys within the TimeRange that * have not expired (i.e. not older than oldestUnexpiredTS). * @param timeRange the timeRange to restrict * @param oldestUnexpiredTS the oldest timestamp that is not expired, as * determined by the column family's TTL * @return false if queried keys definitely don't exist in this StoreFile */ boolean passesTimerangeFilter(TimeRange timeRange, long oldestUnexpiredTS) { if (timeRangeTracker == null) { return true; } else { return timeRangeTracker.includesTimeRange(timeRange) && timeRangeTracker.getMaximumTimestamp() >= oldestUnexpiredTS; } }
System.out.println(seqid); } else if (Bytes.compareTo(e.getKey(), Bytes.toBytes("TIMERANGE")) == 0) { TimeRangeTracker timeRangeTracker = new TimeRangeTracker(); Writables.copyWritable(e.getValue(), timeRangeTracker); System.out.println(timeRangeTracker.getMinimumTimestamp() + "...." + timeRangeTracker.getMaximumTimestamp()); } else if (Bytes.compareTo(e.getKey(), FileInfo.AVG_KEY_LEN) == 0 || Bytes.compareTo(e.getKey(), FileInfo.AVG_VALUE_LEN) == 0) {
public boolean shouldSeek(TimeRange tr, long oldestUnexpiredTS) { return !isEmpty() && (tr.isAllTime() || timeRangeTracker.includesTimeRange(tr)) && timeRangeTracker.getMax() >= oldestUnexpiredTS; }
/** * Constructor. * @param c Comparator */ public DefaultMemStore(final Configuration conf, final KeyValue.KVComparator c) { this.conf = conf; this.comparator = c; this.cellSet = new CellSkipListSet(c); this.snapshot = new CellSkipListSet(c); timeRangeTracker = new TimeRangeTracker(); snapshotTimeRangeTracker = new TimeRangeTracker(); this.size = new AtomicLong(DEEP_OVERHEAD); this.snapshotSize = 0; if (conf.getBoolean(USEMSLAB_KEY, USEMSLAB_DEFAULT)) { String className = conf.get(MSLAB_CLASS_NAME, HeapMemStoreLAB.class.getName()); this.allocator = ReflectionUtils.instantiateWithCustomCtor(className, new Class[] { Configuration.class }, new Object[] { conf }); } else { this.allocator = null; } }
/**------------------------------------------------------------------------ * Empty C-tor to be used only for CompositeImmutableSegment */ protected ImmutableSegment(CellComparator comparator) { super(comparator, TimeRangeTracker.create(TimeRangeTracker.Type.NON_SYNC)); }
@Override public long getMaxTimestamp() { return timeRange == null? Long.MAX_VALUE: timeRangeTracker.getMax(); }
this.reader.timeRange = data == null ? null : TimeRangeTracker.parseFrom(data).toTimeRange(); } catch (IllegalArgumentException e) { LOG.error("Error reading timestamp range data from meta -- " +
@Test public void testTimeRangeInitialized() { TimeRangeTracker src = getTimeRangeTracker(); TimeRange tr = new TimeRange(System.currentTimeMillis()); assertFalse(src.includesTimeRange(tr)); }
@Override public OptionalLong getMinimumTimestamp() { return timeRangeTracker == null ? OptionalLong.empty() : OptionalLong.of(timeRangeTracker.getMin()); }
/** * @param data the serialization data. It can't be null! * @return An instance of NonSyncTimeRangeTracker filled w/ the content of serialized * NonSyncTimeRangeTracker in <code>timeRangeTrackerBytes</code>. * @throws IOException */ public static TimeRangeTracker parseFrom(final byte[] data) throws IOException { return parseFrom(data, Type.NON_SYNC); }
/** * Copy Constructor * @param trt source TimeRangeTracker */ public TimeRangeTracker(final TimeRangeTracker trt) { set(trt.getMinimumTimestamp(), trt.getMaximumTimestamp()); }