@Test public void query() { BitSet seenRows = new BitSet(numRows); TimestampBound bound = getRandomBound(); PartitionOptions partitionParams = getRandomPartitionOptions(); batchTxn = client.batchReadOnlyTransaction(bound); List<Partition> partitions = batchTxn.partitionQuery( partitionParams, Statement.of("SELECT Key, Data, Fingerprint, Size FROM " + TABLE_NAME)); BatchTransactionId txnID = batchTxn.getBatchTransactionId(); fetchAndValidateRows(partitions, txnID, seenRows); }
private void fetchAndValidateRows( List<Partition> partitions, BatchTransactionId txnID, BitSet seenRows) { for (Partition p : partitions) { BatchReadOnlyTransaction batchTxnOnEachWorker = client.batchReadOnlyTransaction(txnID); try (ResultSet result = batchTxnOnEachWorker.execute(p)) { // validate no duplicate rows; verify all columns read. validate(result, seenRows); } } // verify all rows were read from the database. assertThat(seenRows.nextClearBit(0)).isEqualTo(numRows); }
@Test public void readUsingIndex() { TimestampBound bound = getRandomBound(); PartitionOptions partitionParams = getRandomPartitionOptions(); batchTxn = client.batchReadOnlyTransaction(bound); List<Partition> partitions = batchTxn.partitionReadUsingIndex( partitionParams, TABLE_NAME, INDEX_NAME, KeySet.all(), Arrays.asList("Fingerprint")); BatchTransactionId txnID = batchTxn.getBatchTransactionId(); int numRowsRead = 0; for (Partition p : partitions) { BatchReadOnlyTransaction batchTxnOnEachWorker = client.batchReadOnlyTransaction(txnID); try (ResultSet result = batchTxnOnEachWorker.execute(p)) { while (result.next()) { numRowsRead++; } } } assertThat(numRowsRead).isEqualTo(numRows); }
int totalSize = 0; int i = 0; for (int row : manyRows()) { numRows++; byte[] data = new byte[row];
@Test public void read() { BitSet seenRows = new BitSet(numRows); TimestampBound bound = getRandomBound(); PartitionOptions partitionParams = getRandomPartitionOptions(); batchTxn = client.batchReadOnlyTransaction(bound); List<Partition> partitions = batchTxn.partitionRead( partitionParams, TABLE_NAME, KeySet.all(), Arrays.asList("Key", "Data", "Fingerprint", "Size")); BatchTransactionId txnID = batchTxn.getBatchTransactionId(); fetchAndValidateRows(partitions, txnID, seenRows); }