本文整理了Java中com.datastax.driver.core.Row.getUUID
方法的一些代码示例,展示了Row.getUUID
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Row.getUUID
方法的具体详情如下:
包路径:com.datastax.driver.core.Row
类名称:Row
方法名:getUUID
[英]Returns the ith value of this row as a UUID.
[中]将此行的第i个值作为UUID返回。
代码示例来源:origin: Netflix/conductor
@VisibleForTesting
String lookupWorkflowIdFromTaskId(String taskId) {
try {
ResultSet resultSet = session.execute(selectTaskLookupStatement.bind(UUID.fromString(taskId)));
return Optional.ofNullable(resultSet.one())
.map(row -> row.getUUID(WORKFLOW_ID_KEY).toString())
.orElse(null);
} catch (Exception e) {
Monitors.error(CLASS_NAME, "lookupWorkflowIdFromTaskId");
String errorMsg = String.format("Failed to lookup workflowId from taskId: %s", taskId);
LOGGER.error(errorMsg, e);
throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, errorMsg, e);
}
}
}
代码示例来源:origin: apache/usergrid
private Iterator<Shard> getIteratorFromRows( List<Row> rows){
List<Shard> shards = new ArrayList<>(rows.size());
rows.forEach(row -> {
final String queueName = row.getString( ShardSerializationImpl.COLUMN_QUEUE_NAME);
final String region = row.getString( ShardSerializationImpl.COLUMN_REGION);
final long shardId = row.getLong( ShardSerializationImpl.COLUMN_SHARD_ID);
final UUID pointer = row.getUUID( ShardSerializationImpl.COLUMN_POINTER);
shards.add(new Shard(queueName, region, shardType, shardId, pointer));
nextStart = shardId;
});
return shards.iterator();
}
代码示例来源:origin: apache/usergrid
private Iterator<DatabaseQueueMessage> getIteratorFromRows(List<Row> rows){
List<DatabaseQueueMessage> messages = new ArrayList<>(rows.size());
rows.forEach(row -> {
final String queueName = row.getString( COLUMN_QUEUE_NAME);
final String region = row.getString( COLUMN_REGION);
final long shardId = row.getLong( COLUMN_SHARD_ID);
final UUID queueMessageId = row.getUUID( COLUMN_QUEUE_MESSAGE_ID);
final UUID messageId = row.getUUID( COLUMN_MESSAGE_ID);
final long queuedAt = row.getLong( COLUMN_QUEUED_AT);
final long inflightAt = row.getLong( COLUMN_INFLIGHT_AT);
messages.add(new DatabaseQueueMessage(
messageId, messageType, queueName, region, shardId, queuedAt, inflightAt, queueMessageId));
//queueMessageId is internal to the messages_available and messages_inflight tables
nextStart = queueMessageId;
});
return messages.iterator();
}
代码示例来源:origin: apache/usergrid
@Override
public List<UUID> getTokensForPrincipal(ByteBuffer principalKeyBuffer){
Preconditions.checkNotNull(principalKeyBuffer, "principal key bytebuffer cannot be null");
Clause inPrincipal = QueryBuilder.eq("key", principalKeyBuffer);
Statement statement = QueryBuilder
.select()
.column("column1")
.from(PRINCIPAL_TOKENS_TABLE)
.where(inPrincipal);
final List<Row> rows = session.execute(statement).all();
final List<UUID> tokenUUIDs = new ArrayList<>(rows.size());
rows.forEach(row -> tokenUUIDs.add(row.getUUID("column1")));
logger.trace("getTokensForPrincipal, token UUIDs: {}", tokenUUIDs);
return tokenUUIDs;
}
代码示例来源:origin: kairosdb/kairosdb
@Override
public Date getServiceKeyLastModifiedTime(String service, String serviceKey) throws DatastoreException
{
BoundStatement statement = new BoundStatement(m_metaCluster.psServiceIndexModificationTime);
statement.setString(0, service);
statement.setString(1, serviceKey);
ResultSet resultSet = m_metaCluster.execute(statement);
Row row = resultSet.one();
if (row != null)
return new Date(UUIDs.unixTimestamp(row.getUUID(0)));
return new Date(0L);
}
代码示例来源:origin: prestodb/presto
case UUID:
case TIMEUUID:
return row.getUUID(i).toString();
case TIMESTAMP:
return Long.toString(row.getTimestamp(i).getTime());
代码示例来源:origin: prestodb/presto
public static NullableValue getColumnValueForPartitionKey(Row row, int i, CassandraType cassandraType, List<CassandraType> typeArguments)
{
Type nativeType = cassandraType.getNativeType();
if (row.isNull(i)) {
return NullableValue.asNull(nativeType);
}
switch (cassandraType) {
case ASCII:
case TEXT:
case VARCHAR:
return NullableValue.of(nativeType, utf8Slice(row.getString(i)));
case UUID:
case TIMEUUID:
return NullableValue.of(nativeType, utf8Slice(row.getUUID(i).toString()));
default:
return getColumnValue(row, i, cassandraType, typeArguments);
}
}
代码示例来源:origin: apache/usergrid
@Override
public Result<AuditLog> getAuditLogs( UUID messageId ) {
Statement query = QueryBuilder.select().all().from(TABLE_AUDIT_LOG)
.where( QueryBuilder.eq( COLUMN_MESSAGE_ID, messageId ) );
ResultSet rs = cassandraClient.getApplicationSession().execute( query );
final List<AuditLog> auditLogs = rs.all().stream().map( row ->
new AuditLog(
AuditLog.Action.valueOf( row.getString( COLUMN_ACTION )),
AuditLog.Status.valueOf( row.getString( COLUMN_STATUS )),
row.getString( COLUMN_QUEUE_NAME ),
row.getString( COLUMN_REGION ),
row.getUUID( COLUMN_MESSAGE_ID ),
row.getUUID( COLUMN_QUEUE_MESSAGE_ID ),
row.getLong( COLUMN_TRANSFER_TIME ) )
).collect( Collectors.toList() );
return new Result<AuditLog>() {
@Override
public PagingState getPagingState() {
return null; // no paging
}
@Override
public List<AuditLog> getEntities() {
return auditLogs;
}
};
}
代码示例来源:origin: apache/ignite
return row.getUUID(col);
代码示例来源:origin: prestodb/presto
case UUID:
case TIMEUUID:
return NullableValue.of(nativeType, utf8Slice(row.getUUID(i).toString()));
case TIMESTAMP:
return NullableValue.of(nativeType, row.getTimestamp(i).getTime());
代码示例来源:origin: apache/usergrid
row.getString( COLUMN_SOURCE_REGION ),
row.getString( COLUMN_DEST_REGION ),
row.getUUID( COLUMN_MESSAGE_ID ),
row.getLong( COLUMN_TRANSFER_TIME ));
transferLogs.add( tlog );
代码示例来源:origin: apache/usergrid
row.getUUID( COLUMN_MESSAGE_ID),
type,
row.getString( COLUMN_QUEUE_NAME),
row.getLong( COLUMN_QUEUED_AT),
row.getLong( COLUMN_INFLIGHT_AT),
row.getUUID( COLUMN_QUEUE_MESSAGE_ID)
);
代码示例来源:origin: apache/usergrid
public Shard loadShard(final Shard shard){
Clause queueNameClause = QueryBuilder.eq(COLUMN_QUEUE_NAME, shard.getQueueName());
Clause regionClause = QueryBuilder.eq(COLUMN_REGION, shard.getRegion());
Clause activeClause = QueryBuilder.eq(COLUMN_ACTIVE, 1);
Clause shardIdClause = QueryBuilder.eq(COLUMN_SHARD_ID, shard.getShardId());
Statement select = QueryBuilder.select().from(getTableName(shard.getType()))
.where(queueNameClause)
.and(regionClause)
.and(activeClause)
.and(shardIdClause);
Row row = cassandraClient.getQueueMessageSession().execute(select).one();
if (row == null){
return null;
}
final String queueName = row.getString(COLUMN_QUEUE_NAME);
final String region = row.getString(COLUMN_REGION);
final long shardId = row.getLong(COLUMN_SHARD_ID);
final UUID pointer = row.getUUID(COLUMN_POINTER);
return new Shard(queueName, region, shard.getType(), shardId, pointer);
}
代码示例来源:origin: Impetus/Kundera
@Override
public Object generate(Client<?> client, String dataType)
{
final String generatedId = "Select now() from system_schema.columns";
ResultSet rSet = ((DSClient) client).execute(generatedId, null);
UUID uuid = rSet.iterator().next().getUUID(0);
return uuid;
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private void assertRow(Row row) {
assertThat(row.getUUID(0)).isEqualTo(uuid);
assertThat(row.getObject(0)).isEqualTo(uuid);
assertThat(row.get(0, UUID.class)).isEqualTo(uuid);
assertThat(row.getString(1)).isEqualTo("John Doe");
assertThat(row.getObject(1)).isEqualTo("John Doe");
assertThat(row.get(1, String.class)).isEqualTo("John Doe");
assertThat(row.getTupleValue(2)).isEqualTo(locationValue);
assertThat(row.getObject(2)).isEqualTo(locationValue);
assertThat(row.get(2, TupleValue.class)).isEqualTo(locationValue);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private void assertPartialRow(Row row) {
assertThat(row.getUUID(0)).isEqualTo(uuid);
assertThat(row.getObject(0)).isEqualTo(uuid);
assertThat(row.get(0, UUID.class)).isEqualTo(uuid);
assertThat(row.getString(1)).isEqualTo("John Doe");
assertThat(row.getObject(1)).isEqualTo("John Doe");
assertThat(row.get(1, String.class)).isEqualTo("John Doe");
assertThat(row.getTupleValue(2)).isEqualTo(partialLocationValueRetrieved);
assertThat(row.getObject(2)).isEqualTo(partialLocationValueRetrieved);
assertThat(row.get(2, TupleValue.class)).isEqualTo(partialLocationValueRetrieved);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private void assertRow(Row row) {
assertThat(row.getUUID(0)).isEqualTo(uuid);
assertThat(row.getObject(0)).isEqualTo(uuid);
assertThat(row.get(0, UUID.class)).isEqualTo(uuid);
assertThat(row.getString(1)).isEqualTo("John Doe");
assertThat(row.getObject(1)).isEqualTo("John Doe");
assertThat(row.get(1, String.class)).isEqualTo("John Doe");
assertThat(row.getUDTValue(2)).isEqualTo(addressValue);
assertThat(row.getObject(2)).isEqualTo(addressValue);
assertThat(row.get(2, UDTValue.class)).isEqualTo(addressValue);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private static boolean checkSchemaAgreement(Connection connection, Cluster.Manager cluster)
throws InterruptedException, ExecutionException {
DefaultResultSetFuture peersFuture =
new DefaultResultSetFuture(
null, cluster.protocolVersion(), new Requests.Query(SELECT_SCHEMA_PEERS));
DefaultResultSetFuture localFuture =
new DefaultResultSetFuture(
null, cluster.protocolVersion(), new Requests.Query(SELECT_SCHEMA_LOCAL));
connection.write(peersFuture);
connection.write(localFuture);
Set<UUID> versions = new HashSet<UUID>();
Row localRow = localFuture.get().one();
if (localRow != null && !localRow.isNull("schema_version"))
versions.add(localRow.getUUID("schema_version"));
for (Row row : peersFuture.get()) {
InetSocketAddress addr = nativeAddressForPeerHost(row, connection.address, cluster);
if (addr == null || row.isNull("schema_version")) continue;
Host peer = cluster.metadata.getHost(addr);
if (peer != null && peer.isUp()) versions.add(row.getUUID("schema_version"));
}
logger.debug("Checking for schema agreement: versions are {}", versions);
return versions.size() <= 1;
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_check_agreement_through_cluster_metadata() {
Cluster controlCluster = register(TestUtils.buildControlCluster(cluster(), ccm()));
Session controlSession = controlCluster.connect();
Row localRow = controlSession.execute("SELECT schema_version FROM system.local").one();
UUID localVersion = localRow.getUUID("schema_version");
Row peerRow = controlSession.execute("SELECT peer, schema_version FROM system.peers").one();
InetAddress peerAddress = peerRow.getInet("peer");
UUID peerVersion = peerRow.getUUID("schema_version");
// The two nodes should be in agreement at this point, but check just in case:
assertThat(localVersion).isEqualTo(peerVersion);
// Now check the method under test:
assertThat(cluster().getMetadata().checkSchemaAgreement()).isTrue();
// Insert a fake version to simulate a disagreement:
forceSchemaVersion(controlSession, peerAddress, UUIDs.random());
assertThat(cluster().getMetadata().checkSchemaAgreement()).isFalse();
forceSchemaVersion(controlSession, peerAddress, peerVersion);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
ResultSet rows = session.execute(selectQuery, uuid);
Row row = rows.one();
assertThat(row.getUUID(0)).isEqualTo(uuid);
assertThat(row.getObject(0)).isEqualTo(uuid);
assertThat(row.get(0, UUID.class)).isEqualTo(uuid);
内容来源于网络,如有侵权,请联系作者删除!