use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITWriteTest method writeInt64.
@Test
public void writeInt64() {
write(baseInsert().set("Int64Value").to(1234).build());
Struct row = readLastRow("Int64Value");
assertThat(row.isNull(0)).isFalse();
assertThat(row.getLong(0)).isEqualTo(1234L);
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITWriteTest method writeFloat64.
@Test
public void writeFloat64() {
write(baseInsert().set("Float64Value").to(2.0).build());
Struct row = readLastRow("Float64Value");
assertThat(row.isNull(0)).isFalse();
assertThat(row.getDouble(0)).isWithin(0.0).of(2.0);
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITReadOnlyTxnTest method singleReadTimestamp.
@Test
public void singleReadTimestamp() {
History expected = history.get(2);
TimestampBound bound = TimestampBound.ofReadTimestamp(expected.timestamp);
ReadOnlyTransaction readContext = client.singleUseReadOnlyTransaction(bound);
Struct row = readRow(readContext);
assertThat(row).isNotNull();
assertThat(row.getString(0)).isEqualTo(expected.value);
assertThat(readContext.getReadTimestamp()).isEqualTo(expected.timestamp);
row = readRow(client.singleUse(bound));
assertThat(row).isNotNull();
assertThat(row.getString(0)).isEqualTo(expected.value);
}
use of com.google.cloud.spanner.Struct in project YCSB by brianfrankcooper.
the class CloudSpannerClient method read.
@Override
public Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
if (queriesForReads) {
return readUsingQuery(table, key, fields, result);
}
Iterable<String> columns = fields == null ? STANDARD_FIELDS : fields;
try {
Struct row = dbClient.singleUse(timestampBound).readRow(table, Key.of(key), columns);
decodeStruct(columns, row, result);
return Status.OK;
} catch (Exception e) {
LOGGER.log(Level.INFO, "read()", e);
return Status.ERROR;
}
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITReadOnlyTxnTest method multiStrong.
@Test
public void multiStrong() {
setUpPrivateDatabase();
History expected = history.get(history.size() - 1);
try (ReadOnlyTransaction readContext = client.readOnlyTransaction()) {
Struct row = readRow(readContext);
assertThat(row).isNotNull();
assertThat(row.getString(0)).isEqualTo(expected.value);
assertThat(readContext.getReadTimestamp()).isAtLeast(expected.timestamp);
insertAndReadAgain(readContext, readContext.getReadTimestamp(), expected.value);
}
}
Aggregations