本文整理了Java中com.datastax.driver.core.TypeCodec.cboolean()
方法的一些代码示例,展示了TypeCodec.cboolean()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TypeCodec.cboolean()
方法的具体详情如下:
包路径:com.datastax.driver.core.TypeCodec
类名称:TypeCodec
方法名:cboolean
[英]Return the default codec for the CQL type boolean. The returned codec maps the CQL type boolean into the Java type Boolean. The returned instance is a singleton.
[中]返回CQL类型布尔值的默认编解码器。返回的编解码器将CQL类型的布尔值映射为Java类型的布尔值。返回的实例是一个单例。
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private static boolean checkWasApplied(
List<ByteBuffer> firstRow, ColumnDefinitions metadata, ProtocolVersion protocolVersion) {
// If the column is not present or not a boolean, we assume the query
// was not a conditional statement, and therefore return true.
if (firstRow == null) return true;
int[] is = metadata.findAllIdx("[applied]");
if (is == null) return true;
int i = is[0];
if (!DataType.cboolean().equals(metadata.getType(i))) return true;
// Otherwise return the value of the column
ByteBuffer value = firstRow.get(i);
if (value == null || value.remaining() == 0) return false;
return TypeCodec.cboolean().deserializeNoBoxing(value, protocolVersion);
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@DataProvider
public static Object[][] value() {
return new Object[][] {
{ByteBuffer.allocate(0), TypeCodec.blob()},
{Boolean.TRUE, TypeCodec.cboolean()},
{(short) 42, TypeCodec.smallInt()},
{(byte) 42, TypeCodec.tinyInt()},
{42, TypeCodec.cint()},
{42L, TypeCodec.bigint()},
{42D, TypeCodec.cdouble()},
{42F, TypeCodec.cfloat()},
{new BigInteger("1234"), TypeCodec.varint()},
{new BigDecimal("123.45"), TypeCodec.decimal()},
{"foo", TypeCodec.varchar()},
{new Date(42), TypeCodec.timestamp()},
{LocalDate.fromDaysSinceEpoch(42), TypeCodec.date()},
{UUID.randomUUID(), TypeCodec.uuid()},
{mock(InetAddress.class), TypeCodec.inet()},
{Duration.from("1mo2d3h"), TypeCodec.duration()}
};
}
代码示例来源:origin: jsevellec/cassandra-unit
protected boolean compose_boolean(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
{
assert value != null && value.remaining() > 0;
return (boolean) UDHelper.deserialize(TypeCodec.cboolean(), protocolVersion, value);
}
}
代码示例来源:origin: com.strapdata.cassandra/cassandra-all
protected boolean compose_boolean(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
{
assert value != null && value.remaining() > 0;
return (boolean) UDHelper.deserialize(TypeCodec.cboolean(), protocolVersion, value);
}
}
代码示例来源:origin: org.apache.cassandra/cassandra-all
protected boolean compose_boolean(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
{
assert value != null && value.remaining() > 0;
return (boolean) UDHelper.deserialize(TypeCodec.cboolean(), protocolVersion, value);
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@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()}
};
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/** Ensures that primitive types are correctly handled and wrapped when necessary. */
@Test(groups = "unit")
public void should_wrap_primitive_types() {
assertThat(TypeCodec.cboolean()).accepts(Boolean.class).accepts(Boolean.TYPE).accepts(true);
assertThat(TypeCodec.cint()).accepts(Integer.class).accepts(Integer.TYPE).accepts(42);
assertThat(TypeCodec.bigint()).accepts(Long.class).accepts(Long.TYPE).accepts(42L);
assertThat(TypeCodec.cfloat()).accepts(Float.class).accepts(Float.TYPE).accepts(42.0F);
assertThat(TypeCodec.cdouble()).accepts(Double.class).accepts(Double.TYPE).accepts(42.0D);
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
private static boolean checkWasApplied(List<ByteBuffer> firstRow, ColumnDefinitions metadata, ProtocolVersion protocolVersion) {
// If the column is not present or not a boolean, we assume the query
// was not a conditional statement, and therefore return true.
if (firstRow == null)
return true;
int[] is = metadata.findAllIdx("[applied]");
if (is == null)
return true;
int i = is[0];
if (!DataType.cboolean().equals(metadata.getType(i)))
return true;
// Otherwise return the value of the column
ByteBuffer value = firstRow.get(i);
if (value == null || value.remaining() == 0)
return false;
return TypeCodec.cboolean().deserializeNoBoxing(value, protocolVersion);
}
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
private static boolean checkWasApplied(List<ByteBuffer> firstRow, ColumnDefinitions metadata, ProtocolVersion protocolVersion) {
// If the column is not present or not a boolean, we assume the query
// was not a conditional statement, and therefore return true.
if (firstRow == null)
return true;
int[] is = metadata.findAllIdx("[applied]");
if (is == null)
return true;
int i = is[0];
if (!DataType.cboolean().equals(metadata.getType(i)))
return true;
// Otherwise return the value of the column
ByteBuffer value = firstRow.get(i);
if (value == null || value.remaining() == 0)
return false;
return TypeCodec.cboolean().deserializeNoBoxing(value, protocolVersion);
}
}
代码示例来源:origin: com.yugabyte/cassandra-driver-core
private static boolean checkWasApplied(List<ByteBuffer> firstRow, ColumnDefinitions metadata, ProtocolVersion protocolVersion) {
// If the column is not present or not a boolean, we assume the query
// was not a conditional statement, and therefore return true.
if (firstRow == null)
return true;
int[] is = metadata.findAllIdx("[applied]");
if (is == null)
return true;
int i = is[0];
if (!DataType.cboolean().equals(metadata.getType(i)))
return true;
// Otherwise return the value of the column
ByteBuffer value = firstRow.get(i);
if (value == null || value.remaining() == 0)
return false;
return TypeCodec.cboolean().deserializeNoBoxing(value, protocolVersion);
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@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()}
};
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@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()}
};
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
@DataProvider
public static Object[][] value() {
return new Object[][] {
{ByteBuffer.allocate(0), TypeCodec.blob()},
{Boolean.TRUE, TypeCodec.cboolean()},
{(short) 42, TypeCodec.smallInt()},
{(byte) 42, TypeCodec.tinyInt()},
{42, TypeCodec.cint()},
{42L, TypeCodec.bigint()},
{42D, TypeCodec.cdouble()},
{42F, TypeCodec.cfloat()},
{new BigInteger("1234"), TypeCodec.varint()},
{new BigDecimal("123.45"), TypeCodec.decimal()},
{"foo", TypeCodec.varchar()},
{new Date(42), TypeCodec.timestamp()},
{LocalDate.fromDaysSinceEpoch(42), TypeCodec.date()},
{UUID.randomUUID(), TypeCodec.uuid()},
{mock(InetAddress.class), TypeCodec.inet()},
{Duration.from("1mo2d3h"), TypeCodec.duration()}
};
}
代码示例来源:origin: apache/gora
break;
case "boolean":
typeCodec = TypeCodec.cboolean();
break;
case "counter":
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
@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()}
};
}
代码示例来源:origin: org.apache.gora/gora-cassandra
this.cluster.getConfiguration().getCodecRegistry().register(new OptionalCodec<>(TypeCodec.bigint()));
this.cluster.getConfiguration().getCodecRegistry().register(new OptionalCodec<>(TypeCodec.blob()));
this.cluster.getConfiguration().getCodecRegistry().register(new OptionalCodec<>(TypeCodec.cboolean()));
this.cluster.getConfiguration().getCodecRegistry().register(new OptionalCodec<>(TypeCodec.cdouble()));
this.cluster.getConfiguration().getCodecRegistry().register(new OptionalCodec<>(TypeCodec.cfloat()));
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
/** Ensures that primitive types are correctly handled and wrapped when necessary. */
@Test(groups = "unit")
public void should_wrap_primitive_types() {
assertThat(TypeCodec.cboolean()).accepts(Boolean.class).accepts(Boolean.TYPE).accepts(true);
assertThat(TypeCodec.cint()).accepts(Integer.class).accepts(Integer.TYPE).accepts(42);
assertThat(TypeCodec.bigint()).accepts(Long.class).accepts(Long.TYPE).accepts(42L);
assertThat(TypeCodec.cfloat()).accepts(Float.class).accepts(Float.TYPE).accepts(42.0F);
assertThat(TypeCodec.cdouble()).accepts(Double.class).accepts(Double.TYPE).accepts(42.0D);
}
代码示例来源:origin: apache/gora
this.cluster.getConfiguration().getCodecRegistry().register(new OptionalCodec<>(TypeCodec.bigint()));
this.cluster.getConfiguration().getCodecRegistry().register(new OptionalCodec<>(TypeCodec.blob()));
this.cluster.getConfiguration().getCodecRegistry().register(new OptionalCodec<>(TypeCodec.cboolean()));
this.cluster.getConfiguration().getCodecRegistry().register(new OptionalCodec<>(TypeCodec.cdouble()));
this.cluster.getConfiguration().getCodecRegistry().register(new OptionalCodec<>(TypeCodec.cfloat()));
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
@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()}
};
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
@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()}
};
}
内容来源于网络,如有侵权,请联系作者删除!