com.datastax.driver.core.TypeCodec.bigint()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中com.datastax.driver.core.TypeCodec.bigint()方法的一些代码示例,展示了TypeCodec.bigint()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TypeCodec.bigint()方法的具体详情如下:
包路径:com.datastax.driver.core.TypeCodec
类名称:TypeCodec
方法名:bigint

TypeCodec.bigint介绍

[英]Return the default codec for the CQL type bigint. The returned codec maps the CQL type bigint into the Java type Long. The returned instance is a singleton.
[中]返回CQL类型bigint的默认编解码器。返回的编解码器将CQL类型bigint映射为Java类型Long。返回的实例是一个单例。

代码示例

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
public ByteBuffer serialize(ProtocolVersion protocolVersion) {
 return TypeCodec.bigint().serialize(value, protocolVersion);
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
Token deserialize(ByteBuffer buffer, ProtocolVersion protocolVersion) {
 return new M3PToken(TypeCodec.bigint().deserialize(buffer, 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 long compose_long(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
{
  assert value != null && value.remaining() > 0;
  return (long) UDHelper.deserialize(TypeCodec.bigint(), protocolVersion, value);
}

代码示例来源:origin: io.zipkin.java/zipkin-storage-cassandra

/**
 * Truncates timestamp to milliseconds and converts to binary for using with setBytesUnsafe() to
 * avoid allocating java.util.Date
 */
public ByteBuffer serialize(long timestamp) {
 return TypeCodec.bigint().serialize(timestamp / 1000L, protocolVersion);
}

代码示例来源:origin: io.zipkin/zipkin-cassandra-core

/** Truncates timestamp to milliseconds and converts to binary for using with setBytesUnsafe() to avoid allocating java.util.Date */
private ByteBuffer serializeTs(long timestamp) {
  return TypeCodec.bigint().serialize(timestamp / 1000, protocolVersion);
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

protected long compose_long(ProtocolVersion protocolVersion, int argIndex, ByteBuffer value)
{
  assert value != null && value.remaining() > 0;
  return (long) UDHelper.deserialize(TypeCodec.bigint(), protocolVersion, value);
}

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

@Override
public ByteBuffer serialize(ProtocolVersion protocolVersion) {
  return TypeCodec.bigint().serialize(value, protocolVersion);
}

代码示例来源:origin: io.zipkin.zipkin2/zipkin-storage-cassandra-v1

/**
 * Truncates timestamp to milliseconds and converts to binary for using with setBytesUnsafe() to
 * avoid allocating java.util.Date
 */
public ByteBuffer serialize(long timestamp) {
 return TypeCodec.bigint().serialize(timestamp / 1000L, protocolVersion);
}

代码示例来源: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: io.zipkin.zipkin2/zipkin-storage-cassandra-v1

/**
  * Reads timestamp binary value directly (getBytesUnsafe) to avoid allocating java.util.Date, and
  * converts to microseconds.
  */
 public long deserialize(Row row, String name) {
  return 1000L * TypeCodec.bigint().deserialize(row.getBytesUnsafe(name), protocolVersion);
 }
}

代码示例来源:origin: io.zipkin.java/zipkin-storage-cassandra

/**
  * Reads timestamp binary value directly (getBytesUnsafe) to avoid allocating java.util.Date, and
  * converts to microseconds.
  */
 public long deserialize(Row row, String name) {
  return 1000L * TypeCodec.bigint().deserialize(row.getBytesUnsafe(name), protocolVersion);
 }
}

代码示例来源:origin: com.yugabyte/cassandra-driver-core

@Override
Token deserialize(ByteBuffer buffer, ProtocolVersion protocolVersion) {
  return new M3PToken(TypeCodec.bigint().deserialize(buffer, protocolVersion));
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
public Cluster.Builder createClusterBuilder() {
 return Cluster.builder()
   .withCodecRegistry(
     new CodecRegistry()
       .register(
         new NumberBoxCodec<Integer>(TypeCodec.cint()),
         new NumberBoxCodec<Long>(TypeCodec.bigint()),
         new NumberBoxCodec<Float>(TypeCodec.cfloat()),
         new NumberBoxCodec<Double>(TypeCodec.cdouble()),
         new NumberBoxCodec<BigInteger>(TypeCodec.varint()),
         new NumberBoxCodec<BigDecimal>(TypeCodec.decimal())));
}

代码示例来源: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: com.datastax.cassandra/cassandra-driver-core

ByteBuffer routingKey = TypeCodec.bigint().serialize(33L, ProtocolVersion.NEWEST_SUPPORTED);
bs.setRoutingKey(routingKey);
  TypeCodec.bigint().serialize(42L, ProtocolVersion.NEWEST_SUPPORTED);
ByteBuffer routingKeyK1Part =
  TypeCodec.varchar().serialize("hello_world", ProtocolVersion.NEWEST_SUPPORTED);

代码示例来源: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

@Override
public Cluster.Builder createClusterBuilder() {
 return Cluster.builder()
   .withCodecRegistry(
     new CodecRegistry()
       .register(
         new NumberBoxCodec<Integer>(TypeCodec.cint()),
         new NumberBoxCodec<Long>(TypeCodec.bigint()),
         new NumberBoxCodec<Float>(TypeCodec.cfloat()),
         new NumberBoxCodec<Double>(TypeCodec.cdouble()),
         new NumberBoxCodec<BigInteger>(TypeCodec.varint()),
         new NumberBoxCodec<BigDecimal>(TypeCodec.decimal())));
}

代码示例来源: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);
}

相关文章