com.datastax.driver.core.utils.Bytes.toRawHexString()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(86)

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

Bytes.toRawHexString介绍

[英]Converts a blob to its CQL hex string representation.

A CQL blob string representation consist of the hexadecimal representation of the blob bytes.
[中]将blob转换为其CQL十六进制字符串表示形式。
CQL blob字符串表示法由blob字节的十六进制表示法组成。

代码示例

代码示例来源:origin: prestodb/presto

@Test
public void testPartitionKeyPredicate()
{
  String sql = "SELECT *" +
      " FROM " + TABLE_ALL_TYPES_PARTITION_KEY +
      " WHERE key = 'key 7'" +
      " AND typeuuid = '00000000-0000-0000-0000-000000000007'" +
      " AND typeinteger = 7" +
      " AND typelong = 1007" +
      " AND typebytes = from_hex('" + toRawHexString(ByteBuffer.wrap(toByteArray(7))) + "')" +
      " AND typetimestamp = TIMESTAMP '1969-12-31 23:04:05'" +
      " AND typeansi = 'ansi 7'" +
      " AND typeboolean = false" +
      " AND typedecimal = 128.0" +
      " AND typedouble = 16384.0" +
      " AND typefloat = REAL '2097152.0'" +
      " AND typeinet = '127.0.0.1'" +
      " AND typevarchar = 'varchar 7'" +
      " AND typevarint = '10000000'" +
      " AND typetimeuuid = 'd2177dd0-eaa2-11de-a572-001b779c76e7'" +
      " AND typelist = '[\"list-value-17\",\"list-value-27\"]'" +
      " AND typemap = '{7:8,9:10}'" +
      " AND typeset = '[false,true]'" +
      "";
  MaterializedResult result = execute(sql);
  assertEquals(result.getRowCount(), 1);
}

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

/**
 * Converts a blob to its CQL hex string representation.
 *
 * <p>A CQL blob string representation consist of the hexadecimal representation of the blob
 * bytes.
 *
 * @param bytes the blob/bytes to convert to a string.
 * @return the CQL string representation of {@code bytes}. If {@code bytes} is {@code null}, this
 *     method returns {@code null}.
 */
public static String toRawHexString(ByteBuffer bytes) {
 if (bytes == null) return null;
 if (bytes.remaining() == 0) {
  return "";
 }
 char[] array = new char[2 * (bytes.remaining())];
 return toRawHexString(bytes, array, 0);
}

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

/**
 * Converts a blob to its CQL hex string representation.
 *
 * <p>A CQL blob string representation consist of the hexadecimal representation of the blob bytes
 * prefixed by "0x".
 *
 * @param bytes the blob/bytes to convert to a string.
 * @return the CQL string representation of {@code bytes}. If {@code bytes} is {@code null}, this
 *     method returns {@code null}.
 */
public static String toHexString(ByteBuffer bytes) {
 if (bytes == null) return null;
 if (bytes.remaining() == 0) return "0x";
 char[] array = new char[2 * (bytes.remaining() + 1)];
 array[0] = '0';
 array[1] = 'x';
 return toRawHexString(bytes, array, 2);
}

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

@Override
public String toString() {
 return Bytes.toRawHexString(generateCompleteOutput());
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

/**
 * Converts a blob to its CQL hex string representation.
 * <p/>
 * A CQL blob string representation consist of the hexadecimal
 * representation of the blob bytes prefixed by "0x".
 *
 * @param bytes the blob/bytes to convert to a string.
 * @return the CQL string representation of {@code bytes}. If {@code bytes}
 * is {@code null}, this method returns {@code null}.
 */
public static String toHexString(ByteBuffer bytes) {
  if (bytes == null)
    return null;
  if (bytes.remaining() == 0)
    return "0x";
  char[] array = new char[2 * (bytes.remaining() + 1)];
  array[0] = '0';
  array[1] = 'x';
  return toRawHexString(bytes, array, 2);
}

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

/**
 * Converts a blob to its CQL hex string representation.
 * <p/>
 * A CQL blob string representation consist of the hexadecimal
 * representation of the blob bytes.
 *
 * @param bytes the blob/bytes to convert to a string.
 * @return the CQL string representation of {@code bytes}. If {@code bytes}
 * is {@code null}, this method returns {@code null}.
 */
public static String toRawHexString(ByteBuffer bytes) {
  if (bytes == null)
    return null;
  if (bytes.remaining() == 0) {
    return "";
  }
  char[] array = new char[2 * (bytes.remaining())];
  return toRawHexString(bytes, array, 0);
}

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

/**
 * Converts a blob to its CQL hex string representation.
 * <p/>
 * A CQL blob string representation consist of the hexadecimal
 * representation of the blob bytes prefixed by "0x".
 *
 * @param bytes the blob/bytes to convert to a string.
 * @return the CQL string representation of {@code bytes}. If {@code bytes}
 * is {@code null}, this method returns {@code null}.
 */
public static String toHexString(ByteBuffer bytes) {
  if (bytes == null)
    return null;
  if (bytes.remaining() == 0)
    return "0x";
  char[] array = new char[2 * (bytes.remaining() + 1)];
  array[0] = '0';
  array[1] = 'x';
  return toRawHexString(bytes, array, 2);
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

/**
 * Converts a blob to its CQL hex string representation.
 * <p/>
 * A CQL blob string representation consist of the hexadecimal
 * representation of the blob bytes.
 *
 * @param bytes the blob/bytes to convert to a string.
 * @return the CQL string representation of {@code bytes}. If {@code bytes}
 * is {@code null}, this method returns {@code null}.
 */
public static String toRawHexString(ByteBuffer bytes) {
  if (bytes == null)
    return null;
  if (bytes.remaining() == 0) {
    return "";
  }
  char[] array = new char[2 * (bytes.remaining())];
  return toRawHexString(bytes, array, 0);
}

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

/**
 * Converts a blob to its CQL hex string representation.
 * <p/>
 * A CQL blob string representation consist of the hexadecimal
 * representation of the blob bytes.
 *
 * @param bytes the blob/bytes to convert to a string.
 * @return the CQL string representation of {@code bytes}. If {@code bytes}
 * is {@code null}, this method returns {@code null}.
 */
public static String toRawHexString(ByteBuffer bytes) {
  if (bytes == null)
    return null;
  if (bytes.remaining() == 0) {
    return "";
  }
  char[] array = new char[2 * (bytes.remaining())];
  return toRawHexString(bytes, array, 0);
}

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

/**
 * Converts a blob to its CQL hex string representation.
 * <p/>
 * A CQL blob string representation consist of the hexadecimal
 * representation of the blob bytes prefixed by "0x".
 *
 * @param bytes the blob/bytes to convert to a string.
 * @return the CQL string representation of {@code bytes}. If {@code bytes}
 * is {@code null}, this method returns {@code null}.
 */
public static String toHexString(ByteBuffer bytes) {
  if (bytes == null)
    return null;
  if (bytes.remaining() == 0)
    return "0x";
  char[] array = new char[2 * (bytes.remaining() + 1)];
  array[0] = '0';
  array[1] = 'x';
  return toRawHexString(bytes, array, 2);
}

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

/**
 * Converts a blob to its CQL hex string representation.
 * <p>
 * A CQL blob string representation consist of the hexadecimal
 * representation of the blob bytes prefixed by "0x".
 *
 * @param bytes the blob/bytes to convert to a string.
 * @return the CQL string representation of {@code bytes}. If {@code bytes}
 * is {@code null}, this method returns {@code null}.
 */
public static String toHexString(ByteBuffer bytes) {
  if (bytes == null)
    return null;
  if (bytes.remaining() == 0)
    return "0x";
  char[] array = new char[2 * (bytes.remaining() + 1)];
  array[0] = '0';
  array[1] = 'x';
  return toRawHexString(bytes, array, 2);
}

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

@Override
public String toString() {
  return Bytes.toRawHexString(generateCompleteOutput());
}

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

@Override
public String toString() {
  return Bytes.toRawHexString(generateCompleteOutput());
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

@Override
public String toString() {
  return Bytes.toRawHexString(generateCompleteOutput());
}

代码示例来源:origin: prestosql/presto

@Test
public void testPartitionKeyPredicate()
{
  String sql = "SELECT *" +
      " FROM " + TABLE_ALL_TYPES_PARTITION_KEY +
      " WHERE key = 'key 7'" +
      " AND typeuuid = '00000000-0000-0000-0000-000000000007'" +
      " AND typeinteger = 7" +
      " AND typelong = 1007" +
      " AND typebytes = from_hex('" + toRawHexString(ByteBuffer.wrap(toByteArray(7))) + "')" +
      " AND typetimestamp = TIMESTAMP '1969-12-31 23:04:05'" +
      " AND typeansi = 'ansi 7'" +
      " AND typeboolean = false" +
      " AND typedecimal = 128.0" +
      " AND typedouble = 16384.0" +
      " AND typefloat = REAL '2097152.0'" +
      " AND typeinet = '127.0.0.1'" +
      " AND typevarchar = 'varchar 7'" +
      " AND typevarint = '10000000'" +
      " AND typetimeuuid = 'd2177dd0-eaa2-11de-a572-001b779c76e7'" +
      " AND typelist = '[\"list-value-17\",\"list-value-27\"]'" +
      " AND typemap = '{7:8,9:10}'" +
      " AND typeset = '[false,true]'" +
      "";
  MaterializedResult result = execute(sql);
  assertEquals(result.getRowCount(), 1);
}

代码示例来源:origin: com.facebook.presto/presto-cassandra

@Test
public void testPartitionKeyPredicate()
{
  String sql = "SELECT *" +
      " FROM " + TABLE_ALL_TYPES_PARTITION_KEY +
      " WHERE key = 'key 7'" +
      " AND typeuuid = '00000000-0000-0000-0000-000000000007'" +
      " AND typeinteger = 7" +
      " AND typelong = 1007" +
      " AND typebytes = from_hex('" + toRawHexString(ByteBuffer.wrap(toByteArray(7))) + "')" +
      " AND typetimestamp = TIMESTAMP '1969-12-31 23:04:05'" +
      " AND typeansi = 'ansi 7'" +
      " AND typeboolean = false" +
      " AND typedecimal = 128.0" +
      " AND typedouble = 16384.0" +
      " AND typefloat = REAL '2097152.0'" +
      " AND typeinet = '127.0.0.1'" +
      " AND typevarchar = 'varchar 7'" +
      " AND typevarint = '10000000'" +
      " AND typetimeuuid = 'd2177dd0-eaa2-11de-a572-001b779c76e7'" +
      " AND typelist = '[\"list-value-17\",\"list-value-27\"]'" +
      " AND typemap = '{7:8,9:10}'" +
      " AND typeset = '[false,true]'" +
      "";
  MaterializedResult result = execute(sql);
  assertEquals(result.getRowCount(), 1);
}

相关文章