use of com.jimmysun.algorithms.chapter2_1.Transaction in project google-cloud-java by GoogleCloudPlatform.
the class SessionImplTest method multiUseReadOnlyTransactionReturnsMissingTransactionId.
@Test
public void multiUseReadOnlyTransactionReturnsMissingTransactionId() throws ParseException {
com.google.protobuf.Timestamp t = Timestamps.parse("2015-10-01T10:54:20.021Z");
Transaction txnMetadata = Transaction.newBuilder().setReadTimestamp(t).build();
PartialResultSet resultSet = PartialResultSet.newBuilder().setMetadata(newMetadata(Type.struct(Type.StructField.of("C", Type.string())))).build();
Mockito.when(rpc.beginTransaction(Mockito.<BeginTransactionRequest>any(), Mockito.eq(options))).thenReturn(txnMetadata);
mockRead(resultSet);
ReadOnlyTransaction txn = session.readOnlyTransaction(TimestampBound.strong());
expectedException.expect(SpannerMatchers.isSpannerException(ErrorCode.INTERNAL));
txn.readRow("Dummy", Key.of(), Arrays.asList("C"));
}
use of com.jimmysun.algorithms.chapter2_1.Transaction in project google-cloud-java by GoogleCloudPlatform.
the class SessionImplTest method multiUseReadOnlyTransactionReturnsMissingTimestamp.
@Test
public void multiUseReadOnlyTransactionReturnsMissingTimestamp() {
Transaction txnMetadata = Transaction.newBuilder().setId(ByteString.copyFromUtf8("x")).build();
PartialResultSet resultSet = PartialResultSet.newBuilder().setMetadata(newMetadata(Type.struct(Type.StructField.of("C", Type.string())))).build();
Mockito.when(rpc.beginTransaction(Mockito.<BeginTransactionRequest>any(), Mockito.eq(options))).thenReturn(txnMetadata);
mockRead(resultSet);
ReadOnlyTransaction txn = session.readOnlyTransaction(TimestampBound.strong());
expectedException.expect(SpannerMatchers.isSpannerException(ErrorCode.INTERNAL));
txn.readRow("Dummy", Key.of(), Arrays.asList("C"));
}
use of com.jimmysun.algorithms.chapter2_1.Transaction in project algorithms-sedgewick-wayne by reneargento.
the class Exercise22_TransactionSortTest method main.
public static void main(String[] args) {
String transactionFilePath = args[0];
Transaction[] transactions = readAllTransactions(transactionFilePath);
Arrays.sort(transactions);
for (Transaction transaction : transactions) {
StdOut.println(transaction);
}
}
use of com.jimmysun.algorithms.chapter2_1.Transaction in project algorithms-sedgewick-wayne by reneargento.
the class Exercise22_TransactionSortTest method readAllTransactions.
public static Transaction[] readAllTransactions(String fileName) {
In in = new In(fileName);
Queue<Transaction> queue = new Queue<>();
while (!in.isEmpty()) {
queue.enqueue(new Transaction(in.readLine()));
}
int queueSize = queue.size();
Transaction[] transactions = new Transaction[queueSize];
for (int i = 0; i < queueSize; i++) {
transactions[i] = queue.dequeue();
}
return transactions;
}
use of com.jimmysun.algorithms.chapter2_1.Transaction in project algorithms-sedgewick-wayne by reneargento.
the class Exercise17 method main.
public static void main(String[] args) {
String transactionFilePath = args[0];
Transaction[] transactions = readAllTransactions(transactionFilePath);
for (Transaction transaction : transactions) {
StdOut.println(transaction);
}
}
Aggregations