Search in sources :

Example 1 with DateRange

use of com.datastax.dse.driver.api.core.data.time.DateRange 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;
}
Also used : DateRangeBound(com.datastax.dse.driver.api.core.data.time.DateRangeBound) DateRange(com.datastax.dse.driver.api.core.data.time.DateRange) ZonedDateTime(java.time.ZonedDateTime)

Example 2 with DateRange

use of com.datastax.dse.driver.api.core.data.time.DateRange 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;
}
Also used : DateRangeBound(com.datastax.dse.driver.api.core.data.time.DateRangeBound) DateRange(com.datastax.dse.driver.api.core.data.time.DateRange) ZonedDateTime(java.time.ZonedDateTime)

Example 3 with DateRange

use of com.datastax.dse.driver.api.core.data.time.DateRange 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;
}
Also used : DateRangeBound(com.datastax.dse.driver.api.core.data.time.DateRangeBound) DateRange(com.datastax.dse.driver.api.core.data.time.DateRange) ZonedDateTime(java.time.ZonedDateTime)

Example 4 with DateRange

use of com.datastax.dse.driver.api.core.data.time.DateRange in project java-driver by datastax.

the class DateRangeCodecTest method should_encode_and_decode.

@Test
@UseDataProvider("dateRanges")
public void should_encode_and_decode(DateRange dateRange) {
    TypeCodec<DateRange> codec = DseTypeCodecs.DATE_RANGE;
    DateRange decoded = codec.decode(codec.encode(dateRange, ProtocolVersion.DEFAULT), ProtocolVersion.DEFAULT);
    assertThat(decoded).isEqualTo(dateRange);
}
Also used : DateRange(com.datastax.dse.driver.api.core.data.time.DateRange) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 5 with DateRange

use of com.datastax.dse.driver.api.core.data.time.DateRange 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;
}
Also used : DateRangeBound(com.datastax.dse.driver.api.core.data.time.DateRangeBound) DateRange(com.datastax.dse.driver.api.core.data.time.DateRange) ZonedDateTime(java.time.ZonedDateTime)

Aggregations

DateRange (com.datastax.dse.driver.api.core.data.time.DateRange)7 DateRangeBound (com.datastax.dse.driver.api.core.data.time.DateRangeBound)4 ZonedDateTime (java.time.ZonedDateTime)4 Test (org.junit.jupiter.api.Test)2 LineString (com.datastax.dse.driver.api.core.data.geometry.LineString)1 Point (com.datastax.dse.driver.api.core.data.geometry.Point)1 Polygon (com.datastax.dse.driver.api.core.data.geometry.Polygon)1 DefaultLineString (com.datastax.dse.driver.internal.core.data.geometry.DefaultLineString)1 DefaultPoint (com.datastax.dse.driver.internal.core.data.geometry.DefaultPoint)1 DefaultPolygon (com.datastax.dse.driver.internal.core.data.geometry.DefaultPolygon)1 Row (com.datastax.oss.driver.api.core.cql.Row)1 GenericRecordImpl (com.datastax.oss.sink.pulsar.GenericRecordImpl)1 PulsarRecordImpl (com.datastax.oss.sink.pulsar.PulsarRecordImpl)1 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 ByteBuffer (java.nio.ByteBuffer)1 Schema (org.apache.pulsar.client.api.Schema)1 GenericSchema (org.apache.pulsar.client.api.schema.GenericSchema)1 RecordSchemaBuilder (org.apache.pulsar.client.api.schema.RecordSchemaBuilder)1 Test (org.junit.Test)1