use of com.datastax.dse.driver.api.core.data.time.DateRangeBound in project nosqlbench by nosqlbench.
the class DateRangeDuring method apply.
@Override
public DateRange apply(long value) {
ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochMilli(value), zoneid);
DateRangeBound lower = DateRangeBound.lowerBound(date, precision);
DateRangeBound upper = DateRangeBound.upperBound(date, precision);
DateRange dateRange = new DateRange(lower, upper);
return dateRange;
}
use of com.datastax.dse.driver.api.core.data.time.DateRangeBound in project nosqlbench by nosqlbench.
the class DateRangeFunc method apply.
@Override
public DateRange apply(long value) {
ZonedDateTime lowerDate = ZonedDateTime.ofInstant(Instant.ofEpochMilli(lower.applyAsLong(value)), zoneid);
DateRangeBound lower = DateRangeBound.lowerBound(lowerDate, precision);
ZonedDateTime upperDate = ZonedDateTime.ofInstant(Instant.ofEpochMilli(upper.applyAsLong(value)), zoneid);
DateRangeBound upper = DateRangeBound.upperBound(upperDate, precision);
DateRange dateRange = new DateRange(lower, upper);
return dateRange;
}
use of com.datastax.dse.driver.api.core.data.time.DateRangeBound in project nosqlbench by nosqlbench.
the class DateRangeOnOrBefore method apply.
@Override
public DateRange apply(long value) {
ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochMilli(value), zoneid);
DateRangeBound lower = DateRangeBound.UNBOUNDED;
DateRangeBound upper = DateRangeBound.upperBound(date, precision);
DateRange dateRange = new DateRange(lower, upper);
return dateRange;
}
use of com.datastax.dse.driver.api.core.data.time.DateRangeBound in project java-driver by datastax.
the class DateRangeCodec method encode.
@Nullable
@Override
public ByteBuffer encode(@Nullable DateRange dateRange, @NonNull ProtocolVersion protocolVersion) {
if (dateRange == null) {
return null;
}
byte rangeType = encodeType(dateRange);
int bufferSize = 1;
DateRangeBound lowerBound = dateRange.getLowerBound();
Optional<DateRangeBound> maybeUpperBound = dateRange.getUpperBound();
bufferSize += lowerBound.isUnbounded() ? 0 : 9;
bufferSize += maybeUpperBound.map(upperBound -> upperBound.isUnbounded() ? 0 : 9).orElse(0);
ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
buffer.put(rangeType);
if (!lowerBound.isUnbounded()) {
put(buffer, lowerBound);
}
maybeUpperBound.ifPresent(upperBound -> {
if (!upperBound.isUnbounded()) {
put(buffer, upperBound);
}
});
return (ByteBuffer) buffer.flip();
}
use of com.datastax.dse.driver.api.core.data.time.DateRangeBound in project nosqlbench by nosqlbench.
the class DateRangeOnOrAfter method apply.
@Override
public DateRange apply(long value) {
ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochMilli(value), zoneid);
DateRangeBound lower = DateRangeBound.lowerBound(date, precision);
DateRangeBound upper = DateRangeBound.UNBOUNDED;
DateRange dateRange = new DateRange(lower, upper);
return dateRange;
}
Aggregations