private DurationCodec() { super(DataType.duration(), Duration.class); }
private List<TestTable> tablesWithMapsOfPrimitives() { List<TestTable> tables = Lists.newArrayList(); for (Map.Entry<DataType, Object> keyEntry : samples.entrySet()) { // Duration not supported as Map key DataType keyType = keyEntry.getKey(); if (keyType == DataType.duration()) continue; Object keySample = keyEntry.getValue(); for (Map.Entry<DataType, Object> valueEntry : samples.entrySet()) { DataType valueType = valueEntry.getKey(); Object valueSample = valueEntry.getValue(); tables.add( new TestTable( DataType.map(keyType, valueType), ImmutableMap.builder().put(keySample, valueSample).build(), "1.2.0")); } } return tables; }
private List<TestTable> tablesWithCollectionsOfPrimitives() { List<TestTable> tables = Lists.newArrayList(); for (Map.Entry<DataType, Object> entry : samples.entrySet()) { DataType elementType = entry.getKey(); Object elementSample = entry.getValue(); tables.add( new TestTable( DataType.list(elementType), Lists.newArrayList(elementSample, elementSample), "1.2.0")); // Duration not supported in Set if (elementType != DataType.duration()) tables.add( new TestTable(DataType.set(elementType), Sets.newHashSet(elementSample), "1.2.0")); } return tables; }
.put(DataType.smallint(), Short.MAX_VALUE) .put(DataType.cint(), Integer.MAX_VALUE) .put(DataType.duration(), Duration.from("PT30H20M")) .put(DataType.text(), "text") .put(DataType.timestamp(), new Date(872835240000L))
private DurationCodec() { super(DataType.duration(), Duration.class); }
if (datatype != DataType.duration()) values.add(String.format("v_%s frozen<tuple<set<%s>>>", values.size(), datatype)); if (datatype != DataType.duration()) values.add( String.format("v_%s frozen<tuple<map<%s, %s>>>", values.size(), datatype, datatype)); if (datatype == DataType.duration()) continue; if (datatype == DataType.duration()) continue;
DATA_TYPE_PRIMITIVES.remove(DataType.duration());
/** * Validates that columns using the duration type are properly represented in {@link * TableMetadata}. * * @jira_ticket JAVA-1347 * @test_category metadata */ @Test(groups = "short") public void should_parse_column_metadata() { // column metadata TableMetadata table = cluster().getMetadata().getKeyspace(keyspace).getTable("test_duration"); assertThat(table.getColumn("c1")).hasType(DataType.duration()); assertThat(table.asCQLQuery()).contains("c1 duration"); } }
String className = CBUtil.readString(buffer); if (DataTypeClassNameParser.isDuration(className)) { return DataType.duration(); } else if (DataTypeClassNameParser.isUserType(className) || DataTypeClassNameParser.isTupleType(className)) {
@DataProvider public static Object[][] cqlAndValue() { return new Object[][] { {DataType.blob(), ByteBuffer.allocate(0), TypeCodec.blob()}, {DataType.cboolean(), true, TypeCodec.cboolean()}, {DataType.smallint(), (short) 42, TypeCodec.smallInt()}, {DataType.tinyint(), (byte) 42, TypeCodec.tinyInt()}, {DataType.cint(), 42, TypeCodec.cint()}, {DataType.bigint(), 42L, TypeCodec.bigint()}, {DataType.counter(), 42L, TypeCodec.counter()}, {DataType.cdouble(), 42D, TypeCodec.cdouble()}, {DataType.cfloat(), 42F, TypeCodec.cfloat()}, {DataType.varint(), new BigInteger("1234"), TypeCodec.varint()}, {DataType.decimal(), new BigDecimal("123.45"), TypeCodec.decimal()}, {DataType.varchar(), "foo", TypeCodec.varchar()}, {DataType.ascii(), "foo", TypeCodec.ascii()}, {DataType.timestamp(), new Date(42), TypeCodec.timestamp()}, {DataType.date(), LocalDate.fromDaysSinceEpoch(42), TypeCodec.date()}, {DataType.time(), 42L, TypeCodec.time()}, {DataType.uuid(), UUID.randomUUID(), TypeCodec.uuid()}, {DataType.timeuuid(), UUID.randomUUID(), TypeCodec.timeUUID()}, {DataType.inet(), mock(InetAddress.class), TypeCodec.inet()}, {DataType.duration(), Duration.from("1mo2d3h"), TypeCodec.duration()} }; }
private List<TestTable> tablesWithMapsOfPrimitives() { List<TestTable> tables = Lists.newArrayList(); for (Map.Entry<DataType, Object> keyEntry : samples.entrySet()) { // Duration not supported as Map key DataType keyType = keyEntry.getKey(); if (keyType == DataType.duration()) continue; Object keySample = keyEntry.getValue(); for (Map.Entry<DataType, Object> valueEntry : samples.entrySet()) { DataType valueType = valueEntry.getKey(); Object valueSample = valueEntry.getValue(); tables.add( new TestTable( DataType.map(keyType, valueType), ImmutableMap.builder().put(keySample, valueSample).build(), "1.2.0")); } } return tables; }
private List<TestTable> tablesWithCollectionsOfPrimitives() { List<TestTable> tables = Lists.newArrayList(); for (Map.Entry<DataType, Object> entry : samples.entrySet()) { DataType elementType = entry.getKey(); Object elementSample = entry.getValue(); tables.add( new TestTable( DataType.list(elementType), Lists.newArrayList(elementSample, elementSample), "1.2.0")); // Duration not supported in Set if (elementType != DataType.duration()) tables.add( new TestTable(DataType.set(elementType), Sets.newHashSet(elementSample), "1.2.0")); } return tables; }
@DataProvider public static Object[][] cql() { return new Object[][] { {DataType.blob(), TypeCodec.blob()}, {DataType.cboolean(), TypeCodec.cboolean()}, {DataType.smallint(), TypeCodec.smallInt()}, {DataType.tinyint(), TypeCodec.tinyInt()}, {DataType.cint(), TypeCodec.cint()}, {DataType.bigint(), TypeCodec.bigint()}, {DataType.counter(), TypeCodec.counter()}, {DataType.cdouble(), TypeCodec.cdouble()}, {DataType.cfloat(), TypeCodec.cfloat()}, {DataType.varint(), TypeCodec.varint()}, {DataType.decimal(), TypeCodec.decimal()}, {DataType.varchar(), TypeCodec.varchar()}, {DataType.ascii(), TypeCodec.ascii()}, {DataType.timestamp(), TypeCodec.timestamp()}, {DataType.date(), TypeCodec.date()}, {DataType.time(), TypeCodec.time()}, {DataType.uuid(), TypeCodec.uuid()}, {DataType.timeuuid(), TypeCodec.timeUUID()}, {DataType.inet(), TypeCodec.inet()}, {DataType.duration(), TypeCodec.duration()} }; }
@DataProvider public static Object[][] cqlAndJava() { return new Object[][] { {DataType.blob(), ByteBuffer.class, TypeCodec.blob()}, {DataType.cboolean(), Boolean.class, TypeCodec.cboolean()}, {DataType.smallint(), Short.class, TypeCodec.smallInt()}, {DataType.tinyint(), Byte.class, TypeCodec.tinyInt()}, {DataType.cint(), Integer.class, TypeCodec.cint()}, {DataType.bigint(), Long.class, TypeCodec.bigint()}, {DataType.counter(), Long.class, TypeCodec.counter()}, {DataType.cdouble(), Double.class, TypeCodec.cdouble()}, {DataType.cfloat(), Float.class, TypeCodec.cfloat()}, {DataType.varint(), BigInteger.class, TypeCodec.varint()}, {DataType.decimal(), BigDecimal.class, TypeCodec.decimal()}, {DataType.varchar(), String.class, TypeCodec.varchar()}, {DataType.ascii(), String.class, TypeCodec.ascii()}, {DataType.timestamp(), Date.class, TypeCodec.timestamp()}, {DataType.date(), LocalDate.class, TypeCodec.date()}, {DataType.time(), Long.class, TypeCodec.time()}, {DataType.uuid(), UUID.class, TypeCodec.uuid()}, {DataType.timeuuid(), UUID.class, TypeCodec.timeUUID()}, {DataType.inet(), InetAddress.class, TypeCodec.inet()}, {DataType.duration(), Duration.class, TypeCodec.duration()} }; }
.put(DataType.smallint(), Short.MAX_VALUE) .put(DataType.cint(), Integer.MAX_VALUE) .put(DataType.duration(), Duration.from("PT30H20M")) .put(DataType.text(), "text") .put(DataType.timestamp(), new Date(872835240000L))
/** * Validates that columns using the duration type are properly represented in {@link * TableMetadata}. * * @jira_ticket JAVA-1347 * @test_category metadata */ @Test(groups = "short") public void should_parse_column_metadata() { // column metadata TableMetadata table = cluster().getMetadata().getKeyspace(keyspace).getTable("test_duration"); assertThat(table.getColumn("c1")).hasType(DataType.duration()); assertThat(table.asCQLQuery()).contains("c1 duration"); } }
String className = CBUtil.readString(buffer); if (DataTypeClassNameParser.isDuration(className)) { return DataType.duration(); } else if (DataTypeClassNameParser.isUserType(className) || DataTypeClassNameParser.isTupleType(className)) {
@DataProvider public static Object[][] cqlAndValue() { return new Object[][] { {DataType.blob(), ByteBuffer.allocate(0), TypeCodec.blob()}, {DataType.cboolean(), true, TypeCodec.cboolean()}, {DataType.smallint(), (short) 42, TypeCodec.smallInt()}, {DataType.tinyint(), (byte) 42, TypeCodec.tinyInt()}, {DataType.cint(), 42, TypeCodec.cint()}, {DataType.bigint(), 42L, TypeCodec.bigint()}, {DataType.counter(), 42L, TypeCodec.counter()}, {DataType.cdouble(), 42D, TypeCodec.cdouble()}, {DataType.cfloat(), 42F, TypeCodec.cfloat()}, {DataType.varint(), new BigInteger("1234"), TypeCodec.varint()}, {DataType.decimal(), new BigDecimal("123.45"), TypeCodec.decimal()}, {DataType.varchar(), "foo", TypeCodec.varchar()}, {DataType.ascii(), "foo", TypeCodec.ascii()}, {DataType.timestamp(), new Date(42), TypeCodec.timestamp()}, {DataType.date(), LocalDate.fromDaysSinceEpoch(42), TypeCodec.date()}, {DataType.time(), 42L, TypeCodec.time()}, {DataType.uuid(), UUID.randomUUID(), TypeCodec.uuid()}, {DataType.timeuuid(), UUID.randomUUID(), TypeCodec.timeUUID()}, {DataType.inet(), mock(InetAddress.class), TypeCodec.inet()}, {DataType.duration(), Duration.from("1mo2d3h"), TypeCodec.duration()} }; }
@DataProvider public static Object[][] cql() { return new Object[][] { {DataType.blob(), TypeCodec.blob()}, {DataType.cboolean(), TypeCodec.cboolean()}, {DataType.smallint(), TypeCodec.smallInt()}, {DataType.tinyint(), TypeCodec.tinyInt()}, {DataType.cint(), TypeCodec.cint()}, {DataType.bigint(), TypeCodec.bigint()}, {DataType.counter(), TypeCodec.counter()}, {DataType.cdouble(), TypeCodec.cdouble()}, {DataType.cfloat(), TypeCodec.cfloat()}, {DataType.varint(), TypeCodec.varint()}, {DataType.decimal(), TypeCodec.decimal()}, {DataType.varchar(), TypeCodec.varchar()}, {DataType.ascii(), TypeCodec.ascii()}, {DataType.timestamp(), TypeCodec.timestamp()}, {DataType.date(), TypeCodec.date()}, {DataType.time(), TypeCodec.time()}, {DataType.uuid(), TypeCodec.uuid()}, {DataType.timeuuid(), TypeCodec.timeUUID()}, {DataType.inet(), TypeCodec.inet()}, {DataType.duration(), TypeCodec.duration()} }; }
@DataProvider public static Object[][] cqlAndJava() { return new Object[][] { {DataType.blob(), ByteBuffer.class, TypeCodec.blob()}, {DataType.cboolean(), Boolean.class, TypeCodec.cboolean()}, {DataType.smallint(), Short.class, TypeCodec.smallInt()}, {DataType.tinyint(), Byte.class, TypeCodec.tinyInt()}, {DataType.cint(), Integer.class, TypeCodec.cint()}, {DataType.bigint(), Long.class, TypeCodec.bigint()}, {DataType.counter(), Long.class, TypeCodec.counter()}, {DataType.cdouble(), Double.class, TypeCodec.cdouble()}, {DataType.cfloat(), Float.class, TypeCodec.cfloat()}, {DataType.varint(), BigInteger.class, TypeCodec.varint()}, {DataType.decimal(), BigDecimal.class, TypeCodec.decimal()}, {DataType.varchar(), String.class, TypeCodec.varchar()}, {DataType.ascii(), String.class, TypeCodec.ascii()}, {DataType.timestamp(), Date.class, TypeCodec.timestamp()}, {DataType.date(), LocalDate.class, TypeCodec.date()}, {DataType.time(), Long.class, TypeCodec.time()}, {DataType.uuid(), UUID.class, TypeCodec.uuid()}, {DataType.timeuuid(), UUID.class, TypeCodec.timeUUID()}, {DataType.inet(), InetAddress.class, TypeCodec.inet()}, {DataType.duration(), Duration.class, TypeCodec.duration()} }; }