@Test public void testIndexGet() throws IOException { Result result = null; nextTsAndCreateTransaction(); transaction.put(MAIN_TABLE, new ThemisPut(ROW).add(FAMILY, QUALIFIER, VALUE)); mockTsAndCommitTransaction(); nextTsAndCreateTransaction(); ResultScanner scanner = transaction.getScanner(MAIN_TABLE, new ThemisScan().addColumn(FAMILY, QUALIFIER)); Assert.assertFalse(scanner instanceof IndexScanner); checkReadResult(VALUE, COLUMN, scanner.next()); scanner.close(); IndexGet indexGet = new IndexGet(INDEX_COLUMN, VALUE, new DataGet().addColumn(FAMILY, QUALIFIER)); scanner = transaction.getScanner(MAIN_TABLE, indexGet); Assert.assertTrue(scanner instanceof IndexScanner); checkReadResult(VALUE, COLUMN, scanner.next()); checkAndCloseScanner(scanner); nextTsAndCreateTransaction(); transaction.delete(MAIN_TABLE, new ThemisDelete(ROW).deleteColumn(FAMILY, ANOTHER_QUALIFIER)); transaction.put(MAIN_TABLE, new ThemisPut(ROW).add(ANOTHER_FAMILY, QUALIFIER, ANOTHER_VALUE)); mockTsAndCommitTransaction(); nextTsAndCreateTransaction(); indexGet = new IndexGet(INDEX_COLUMN, VALUE, new DataGet().addColumn(FAMILY, QUALIFIER).addFamily(ANOTHER_FAMILY)); scanner = transaction.getScanner(MAIN_TABLE, indexGet); checkReadResults(new byte[][] { VALUE, ANOTHER_VALUE }, new ColumnCoordinate[] { COLUMN, COLUMN_WITH_ANOTHER_FAMILY }, scanner.next()); checkAndCloseScanner(scanner); indexGet = new IndexGet(INDEX_COLUMN, VALUE, new DataGet()); scanner = transaction.getScanner(MAIN_TABLE, indexGet); checkReadResults(new byte[][] { VALUE, ANOTHER_VALUE }, new ColumnCoordinate[] { COLUMN, COLUMN_WITH_ANOTHER_FAMILY }, scanner.next()); checkAndCloseScanner(scanner); transaction.put(MAIN_TABLE, new ThemisPut(ROW).add(FAMILY, QUALIFIER, ANOTHER_VALUE)); mockTsAndCommitTransaction(); indexGet = new IndexGet(INDEX_COLUMN, VALUE, new DataGet().addColumn(FAMILY, QUALIFIER)); scanner = transaction.getScanner(MAIN_TABLE, indexGet); Assert.assertTrue(scanner instanceof IndexScanner); checkReadResult(VALUE, COLUMN, scanner.next()); checkAndCloseScanner(scanner); nextTransactionTs(); createTransactionWithMock(); indexGet = new IndexGet(INDEX_COLUMN, VALUE, new DataGet().addColumn(FAMILY, QUALIFIER)); scanner = transaction.getScanner(MAIN_TABLE, indexGet); Assert.assertTrue(scanner instanceof IndexScanner); checkAndCloseScanner(scanner); nextTsAndCreateTransaction(); indexGet = new IndexGet(INDEX_COLUMN, ANOTHER_VALUE, new DataGet().addColumn(FAMILY, QUALIFIER) .addFamily(ANOTHER_FAMILY)); scanner = transaction.getScanner(MAIN_TABLE, indexGet); Assert.assertTrue(scanner instanceof IndexScanner); checkReadResults(new byte[][] { ANOTHER_VALUE, ANOTHER_VALUE }, new ColumnCoordinate[] { COLUMN, COLUMN_WITH_ANOTHER_FAMILY }, scanner.next()); checkAndCloseScanner(scanner); transaction.delete(MAIN_TABLE, new ThemisDelete(ROW).deleteColumn(FAMILY, QUALIFIER)); mockTsAndCommitTransaction(); indexGet = new IndexGet(INDEX_COLUMN, ANOTHER_VALUE, new DataGet().addColumn(FAMILY, QUALIFIER)); scanner = transaction.getScanner(MAIN_TABLE, indexGet); Assert.assertTrue(scanner instanceof IndexScanner); checkReadResult(ANOTHER_VALUE, COLUMN, scanner.next()); checkAndCloseScanner(scanner); nextTsAndCreateTransaction(); indexGet = new IndexGet(INDEX_COLUMN, ANOTHER_VALUE, new DataGet().addColumn(FAMILY, QUALIFIER)); scanner = transaction.getScanner(MAIN_TABLE, indexGet); Assert.assertTrue(scanner instanceof IndexScanner); checkAndCloseScanner(scanner); nextTsAndCreateTransaction(); transaction.put(MAIN_TABLE, new ThemisPut(ANOTHER_ROW).add(FAMILY, QUALIFIER, VALUE)); transaction.put(MAIN_TABLE, new ThemisPut(ROW).add(FAMILY, QUALIFIER, VALUE)); mockTsAndCommitTransaction(); nextTsAndCreateTransaction(); indexGet = new IndexGet(INDEX_COLUMN, VALUE, new DataGet().addColumn(FAMILY, QUALIFIER)); scanner = transaction.getScanner(MAIN_TABLE, indexGet); Assert.assertTrue(scanner instanceof IndexScanner); result = scanner.next(); Assert.assertArrayEquals(ANOTHER_ROW, result.getRow()); checkReadResult(VALUE, COLUMN, result); result = scanner.next(); Assert.assertArrayEquals(ROW, result.getRow()); checkReadResult(VALUE, COLUMN, result); checkAndCloseScanner(scanner); }
@Override public IndexScanner getScanner(byte[] tableName, ThemisScan scan, Transaction transaction) throws IOException { if (!(scan instanceof IndexRead)) { return null; } IndexRead indexRead = (IndexRead)scan; if (!Bytes.equals(tableName, indexRead.getIndexColumn().getTableName())) { throw new IOException("tableName not match, tableName=" + Bytes.toString(tableName) + ", indexColumn=" + indexRead.getIndexColumn()); } String indexTableName = columnIndexes.get(indexRead.getIndexColumn()); if (indexTableName == null) { throw new IOException("not find index definition for indexColumn=" + indexRead.getIndexColumn()); } return new IndexScanner(indexTableName, indexRead, transaction); }
DefaultIndexer extends Indexer { @Override public IndexScanner getScanner(byte[] tableName, ThemisScan scan, Transaction transaction) throws IOException { if (!(scan instanceof IndexRead)) { return null; } IndexRead indexRead = (IndexRead)scan; if (!Bytes.equals(tableName, indexRead.getIndexColumn().getTableName())) { throw new IOException("tableName not match, tableName=" + Bytes.toString(tableName) + ", indexColumn=" + indexRead.getIndexColumn()); } String indexTableName = columnIndexes.get(indexRead.getIndexColumn()); if (indexTableName == null) { throw new IOException("not find index definition for indexColumn=" + indexRead.getIndexColumn()); } return new IndexScanner(indexTableName, indexRead, transaction); } }
DefaultIndexer extends Indexer { @Override public IndexScanner getScanner(byte[] tableName, ThemisScan scan, Transaction transaction) throws IOException { if (!(scan instanceof IndexRead)) { return null; } IndexRead indexRead = (IndexRead)scan; if (!Bytes.equals(tableName, indexRead.getIndexColumn().getTableName())) { throw new IOException("tableName not match, tableName=" + Bytes.toString(tableName) + ", indexColumn=" + indexRead.getIndexColumn()); } String indexTableName = columnIndexes.get(indexRead.getIndexColumn()); if (indexTableName == null) { throw new IOException("not find index definition for indexColumn=" + indexRead.getIndexColumn()); } return new IndexScanner(indexTableName, indexRead, transaction); } DefaultIndexer(Configuration conf); }
DefaultIndexer extends Indexer { @Override public IndexScanner getScanner(byte[] tableName, ThemisScan scan, Transaction transaction) throws IOException { if (!(scan instanceof IndexRead)) { return null; } IndexRead indexRead = (IndexRead)scan; if (!Bytes.equals(tableName, indexRead.getIndexColumn().getTableName())) { throw new IOException("tableName not match, tableName=" + Bytes.toString(tableName) + ", indexColumn=" + indexRead.getIndexColumn()); } String indexTableName = columnIndexes.get(indexRead.getIndexColumn()); if (indexTableName == null) { throw new IOException("not find index definition for indexColumn=" + indexRead.getIndexColumn()); } return new IndexScanner(indexTableName, indexRead, transaction); } DefaultIndexer(Configuration conf); Map<IndexColumn, String> getColumnIndexes(); @Override IndexScanner getScanner(byte[] tableName, ThemisScan scan, Transaction transaction); @Override void addIndexMutations(ColumnMutationCache mutationCache); }
DefaultIndexer extends Indexer { @Override public IndexScanner getScanner(byte[] tableName, ThemisScan scan, Transaction transaction) throws IOException { if (!(scan instanceof IndexRead)) { return null; } IndexRead indexRead = (IndexRead)scan; if (!Bytes.equals(tableName, indexRead.getIndexColumn().getTableName())) { throw new IOException("tableName not match, tableName=" + Bytes.toString(tableName) + ", indexColumn=" + indexRead.getIndexColumn()); } String indexTableName = columnIndexes.get(indexRead.getIndexColumn()); if (indexTableName == null) { throw new IOException("not find index definition for indexColumn=" + indexRead.getIndexColumn()); } return new IndexScanner(indexTableName, indexRead, transaction); } DefaultIndexer(Configuration conf); Map<IndexColumn, String> getColumnIndexes(); @Override IndexScanner getScanner(byte[] tableName, ThemisScan scan, Transaction transaction); @Override void addIndexMutations(ColumnMutationCache mutationCache);  }