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

x33g5p2x  于2022-01-28 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(128)

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

Row.getBytes介绍

[英]Returns the ith value of this row as a byte array.

Note that this method validate that the column is of type BLOB. If you want to retrieve the bytes for any type of columns, use #getBytesUnsafe(int) instead.
[中]以字节数组的形式返回此行的第i个值。
请注意,此方法验证列是否为BLOB类型。如果要检索任何类型列的字节,请改用#getBytesUnsafe(int)。

代码示例

代码示例来源:origin: apache/usergrid

@Override
  public Map<String, String> buildResultsCQL( final ResultSet resultSet ) {
    final Map<String, String> results = new HashMap<>();
    resultSet.all().forEach( row -> {
      @SuppressWarnings("unchecked")
      List<Object> keys = (List) deserializeMapEntryKey(row.getBytes("key"));
      String value = (String)DataType.text().deserialize( row.getBytes("value"),
        ProtocolVersion.NEWEST_SUPPORTED );
      // the actual string key value is the last element
      results.put((String)keys.get(keys.size() -1), value);
    });
    return results;
  }
}

代码示例来源:origin: apache/usergrid

ByteBuffer partitionKey = unique.getBytes("key");
ByteBuffer column = unique.getBytesUnsafe("column1");

代码示例来源:origin: apache/usergrid

@Override
public DatabaseQueueMessageBody loadMessageData(final UUID messageId ){
  logger.trace("loadMessageData {}", messageId);
  Clause messageIdClause = QueryBuilder.eq( COLUMN_MESSAGE_ID, messageId );
  Statement select = QueryBuilder.select().from( TABLE_MESSAGE_DATA).where(messageIdClause);
  Row row = cassandraClient.getApplicationSession().execute(select).one();
  if ( row == null ) {
    return null;
  }
  return new DatabaseQueueMessageBody(
      row.getBytes( COLUMN_MESSAGE_DATA),
      row.getString( COLUMN_CONTENT_TYPE));
}

代码示例来源:origin: apache/usergrid

@Override
public Map<String, Object> getTokenInfo(UUID tokenUUID){
  Preconditions.checkNotNull(tokenUUID, "token UUID is required");
  List<ByteBuffer> tokenProperties = new ArrayList<>();
  TOKEN_PROPERTIES.forEach( prop ->
    tokenProperties.add(DataType.serializeValue(prop, ProtocolVersion.NEWEST_SUPPORTED)));
  final ByteBuffer key = DataType.uuid().serialize(tokenUUID, ProtocolVersion.NEWEST_SUPPORTED);
  final Clause inKey = QueryBuilder.eq("key", key);
  final Clause inColumn = QueryBuilder.in("column1", tokenProperties );
  final Statement statement = QueryBuilder.select().all().from(TOKENS_TABLE)
    .where(inKey)
    .and(inColumn)
    .setConsistencyLevel(cassandraConfig.getDataStaxReadCl());
  final ResultSet resultSet = session.execute(statement);
  final List<Row> rows = resultSet.all();
  Map<String, Object> tokenInfo = new HashMap<>();
  rows.forEach( row -> {
    final String name = (String)DataType.text()
      .deserialize(row.getBytes("column1"), ProtocolVersion.NEWEST_SUPPORTED);
    final Object value = deserializeColumnValue(name, row.getBytes("value"));
    if (value == null){
      throw new RuntimeException("error deserializing token info for property: "+name);
    }
    tokenInfo.put(name, value);
  });
  logger.trace("getTokenInfo, info: {}", tokenInfo);
  return tokenInfo;
}

代码示例来源:origin: kairosdb/kairosdb

rowKey = CassandraDatastore.DATA_POINTS_ROW_KEY_SERIALIZER.fromByteBuffer(record.getBytes(0), m_clusterName);

代码示例来源:origin: apache/usergrid

private V readValueCQL(CacheScope scope, K key, TypeReference typeRef){
  Preconditions.checkNotNull(scope, "scope is required");
  Preconditions.checkNotNull(key, "key is required");
  final String rowKeyString = scope.getApplication().getUuid().toString();
  final int bucket = BUCKET_LOCATOR.getCurrentBucket(rowKeyString);
  // determine column name based on K key to string
  final String columnName = key.toString();
  final Clause inKey = QueryBuilder.eq("key", getPartitionKey(scope, rowKeyString, bucket) );
  final Clause inColumn = QueryBuilder.eq("column1", DataType.text().serialize(columnName, ProtocolVersion.NEWEST_SUPPORTED) );
  final Statement statement = QueryBuilder.select().all().from(SCOPED_CACHE_TABLE)
    .where(inKey)
    .and(inColumn)
    .setConsistencyLevel(cassandraConfig.getDataStaxReadCl());
  final ResultSet resultSet = session.execute(statement);
  final com.datastax.driver.core.Row row = resultSet.one();
  if (row == null){
    if(logger.isDebugEnabled()){
      logger.debug("Cache value not found for key {}", key );
    }
    return null;
  }
  try {
    return MAPPER.readValue(row.getBytes("value").array(), typeRef);
  } catch (IOException ioe) {
    logger.error("Unable to read cached value", ioe);
    throw new RuntimeException("Unable to read cached value", ioe);
  }
}

代码示例来源:origin: apache/ignite

return row.getBytes(col);
  ByteBuffer buf = row.getBytes(col);
  return buf == null ? null : buf.array();
ByteBuffer buf = row.getBytes(col);

代码示例来源:origin: apache/usergrid

private ByteBuffer getValueCQL( MapScope scope, String key, final ConsistencyLevel consistencyLevel ) {
  Clause in = QueryBuilder.in("key", getMapEntryPartitionKey(scope, key) );
  Statement statement = QueryBuilder.select().all().from(MAP_ENTRIES_TABLE)
    .where(in)
    .setConsistencyLevel(consistencyLevel);
  ResultSet resultSet = session.execute(statement);
  com.datastax.driver.core.Row row = resultSet.one();
  return row != null ? row.getBytes("value") : null;
}

代码示例来源:origin: apache/nifi

protected static Object getCassandraObject(Row row, int i, DataType dataType) {
  if (dataType.equals(DataType.blob())) {
    return row.getBytes(i);

代码示例来源:origin: apache/ignite

return settings.getSerializer().deserialize(row.getBytes(col));

代码示例来源:origin: apache/usergrid

@Override
public MapKeyResults getAllKeys(final MapScope scope, final String cursor, final int limit ){
  final int[] buckets = BUCKET_LOCATOR.getAllBuckets( scope.getName() );
  final List<ByteBuffer> partitionKeys = new ArrayList<>(NUM_BUCKETS.length);
  for (int bucket : buckets) {
    partitionKeys.add(getMapKeyPartitionKey(scope, bucket));
  }
  Clause in = QueryBuilder.in("key", partitionKeys);
  Statement statement;
  if( isBlank(cursor) ){
    statement = QueryBuilder.select().all().from(MAP_KEYS_TABLE)
      .where(in)
      .setFetchSize(limit);
  }else{
    statement = QueryBuilder.select().all().from(MAP_KEYS_TABLE)
      .where(in)
      .setFetchSize(limit)
      .setPagingState(PagingState.fromString(cursor));
  }
  ResultSet resultSet = session.execute(statement);
  PagingState pagingState = resultSet.getExecutionInfo().getPagingState();
  final List<String> keys = new ArrayList<>();
  Iterator<Row> resultIterator = resultSet.iterator();
  int size = 0;
  while( resultIterator.hasNext() && size < limit){
    size++;
    keys.add((String)DataType.text().deserialize(resultIterator.next().getBytes("column1"), ProtocolVersion.NEWEST_SUPPORTED));
  }
  return new MapKeyResults(pagingState != null ? pagingState.toString() : null, keys);
}

代码示例来源:origin: kairosdb/kairosdb

ByteBuffer bytes = row.getBytes(0);
ByteBuffer value = row.getBytes(1);
long timestamp = getColumnTimestamp(m_rowKey.getTimestamp(), columnTime);

代码示例来源:origin: Impetus/Kundera

retVal = row.getBytes(columnName);
if (member != null && retVal != null && entity != null)

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

@Override
public ByteBuffer getBytes(String name)
{
  return row.getBytes(name);
}

代码示例来源:origin: jsevellec/cassandra-unit

@Override
public ByteBuffer getBytes(int i)
{
  return row.getBytes(i);
}

代码示例来源:origin: jsevellec/cassandra-unit

@Override
public ByteBuffer getBytes(String name)
{
  return row.getBytes(name);
}

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

private void testByteRows(int key) throws Throwable {
 // Build small ByteBuffer sample
 ByteBuffer bb = ByteBuffer.allocate(58);
 bb.putShort((short) 0xCAFE);
 bb.flip();
 // Write data
 for (int i = 0; i < 1000000; ++i) {
  session()
    .execute(
      insertInto("wide_byte_rows")
        .value("k", key)
        .value("i", bb)
        .setConsistencyLevel(ConsistencyLevel.QUORUM));
 }
 // Read data
 ResultSet rs = session().execute(select("i").from("wide_byte_rows").where(eq("k", key)));
 // Verify data
 for (Row row : rs) {
  assertEquals(row.getBytes("i"), bb);
 }
}

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

ByteBuffer rawInitCond = row.getBytes("initcond");
if (rawInitCond == null) {
 initCond = null;

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

@Override
protected BiConsumer<Row, List<Span>> accumulator() {
 return (row, result) -> {
  V1ThriftSpanReader reader = V1ThriftSpanReader.create();
  V1SpanConverter converter = V1SpanConverter.create();
  V1Span read = reader.read(row.getBytes("span"));
  converter.convert(read, result);
 };
}

代码示例来源:origin: com.moz.fiji.schema/fiji-schema-cassandra

/** {@inheritDoc} */
 @Override
 public FijiCell<T> apply(final Row row) {
  try {
   final DecodedCell<T> decodedCell =
     mCellDecoder.decodeCell(ByteUtils.toBytes(row.getBytes(CQLUtils.VALUE_COL)));
   return FijiCell.create(mColumnName, row.getLong(CQLUtils.VERSION_COL), decodedCell);
  } catch (IOException e) {
   throw new FijiIOException(e);
  }
 }
}

相关文章