RBMBackedTimestampSet implements TimestampSet { @Override public void add(final Instant instant) { if (instant.isBefore(MIN_TIME) || instant.isAfter(MAX_TIME)) { throw new IllegalArgumentException("Invalid instant of " + instant); } rbm.add(toInt(instant.toEpochMilli())); } RBMBackedTimestampSet(final TimeBucket timeBucket);  RBMBackedTimestampSet(final TimeBucket timeBucket, final Instant... instants); @Override void add(final Instant instant); @Override void add(final Collection<Instant> instants); @Override SortedSet<Instant> getTimestamps(); @Override long getNumberOfTimestamps(); @Override Instant getEarliest(); @Override Instant getLatest(); void applyTimeRangeMask(final Long startMillis, final Long endMillis); TimeBucket getTimeBucket(); @JsonIgnore RoaringBitmap getRbm(); void setRbm(final RoaringBitmap rbm); void addAll(final RBMBackedTimestampSet other); @JsonIgnore RBMBackedTimestampSet getShallowClone(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void shouldSerialiseAndDeserialise() throws SerialisationException { final RBMBackedTimestampSet boundedTimestampSet = new RBMBackedTimestampSet(CommonTimeUtil.TimeBucket.SECOND); IntStream.range(0, 20) .forEach(i -> { boundedTimestampSet.add(Instant.ofEpochMilli(i * 1000L)); }); final byte[] json = JSONSerialiser.serialise(boundedTimestampSet, true); final RBMBackedTimestampSet deserialisedObj = JSONSerialiser.deserialise(json, RBMBackedTimestampSet.class); assertEquals(boundedTimestampSet, deserialisedObj); }
@Test public void testGet() { testGet(instants); final SortedSet<Instant> randomDates = new TreeSet<>(); IntStream.range(0, 100) .forEach(i -> randomDates.add(Instant.ofEpochMilli(instant1.toEpochMilli() + i * 12345678L))); testGet(randomDates); }