Search in sources :

Example 11 with Transaction

use of com.google.spanner.v1.Transaction in project neo4j by neo4j.

the class BoltCausalClusteringIT method executeReadQuery.

private void executeReadQuery(String bookmark, Session session) {
    try (Transaction tx = session.beginTransaction(bookmark)) {
        Record record = tx.run("MATCH (n:Person) RETURN COUNT(*) AS count").next();
        assertEquals(1, record.get("count").asInt());
    }
}
Also used : Transaction(org.neo4j.driver.v1.Transaction) Record(org.neo4j.driver.v1.Record)

Example 12 with Transaction

use of com.google.spanner.v1.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"));
}
Also used : Transaction(com.google.spanner.v1.Transaction) PartialResultSet(com.google.spanner.v1.PartialResultSet) Test(org.junit.Test)

Example 13 with Transaction

use of com.google.spanner.v1.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"));
}
Also used : Transaction(com.google.spanner.v1.Transaction) PartialResultSet(com.google.spanner.v1.PartialResultSet) Test(org.junit.Test)

Example 14 with Transaction

use of com.google.spanner.v1.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);
    }
}
Also used : Transaction(edu.princeton.cs.algs4.Transaction)

Example 15 with Transaction

use of com.google.spanner.v1.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;
}
Also used : Transaction(edu.princeton.cs.algs4.Transaction) In(edu.princeton.cs.algs4.In) Queue(edu.princeton.cs.algs4.Queue)

Aggregations

Test (org.junit.Test)9 Transaction (org.neo4j.driver.v1.Transaction)9 Session (org.neo4j.driver.v1.Session)8 Driver (org.neo4j.driver.v1.Driver)6 Record (org.neo4j.driver.v1.Record)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 CoreClusterMember (org.neo4j.causalclustering.discovery.CoreClusterMember)5 RoutingNetworkSession (org.neo4j.driver.internal.RoutingNetworkSession)5 Transaction (edu.princeton.cs.algs4.Transaction)4 PartialResultSet (com.google.spanner.v1.PartialResultSet)3 Transaction (com.google.spanner.v1.Transaction)3 In (edu.princeton.cs.algs4.In)2 Queue (edu.princeton.cs.algs4.Queue)2 ReadReplica (org.neo4j.causalclustering.discovery.ReadReplica)2 StatementResult (org.neo4j.driver.v1.StatementResult)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Stack (com.jimmysun.algorithms.chapter1_3.Stack)1 Transaction (com.jimmysun.algorithms.chapter2_1.Transaction)1 MinPQ (edu.princeton.cs.algs4.MinPQ)1 IOException (java.io.IOException)1