public static ColumnSelection getColumnSelection(Collection<DataStreamHashAidxColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, Persistables.persistToBytesFunction())); }
public static ColumnSelection getColumnSelection(Collection<SweepIdToNameColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, Persistables.persistToBytesFunction())); }
public static ColumnSelection getColumnSelection(Collection<BlobsNamedColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, BlobsNamedColumn.toShortName())); }
public static ColumnSelection getColumnSelection(Collection<UserBirthdaysIdxColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, Persistables.persistToBytesFunction())); }
public static ColumnSelection extractColumnSelection(RangeRequest rangeRequest) { if (rangeRequest.getColumnNames().isEmpty()) { return ColumnSelection.all(); } return ColumnSelection.create(rangeRequest.getColumnNames()); }
protected String get(Transaction txn, TableReference tableRef, String rowName, String columnName) { byte[] row = PtBytes.toBytes(rowName); byte[] column = PtBytes.toBytes(columnName); Cell cell = Cell.create(row, column); byte[] valueBytes = Cells.convertRowResultsToCells( txn.getRows(tableRef, ImmutableSet.of(row), ColumnSelection.create(ImmutableSet.of(column))).values()).get(cell); return valueBytes != null ? PtBytes.toString(valueBytes) : null; }
public static ColumnSelection getColumnSelection(Collection<StreamTestMaxMemStreamMetadataNamedColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, StreamTestMaxMemStreamMetadataNamedColumn.toShortName())); }
public static ColumnSelection getColumnSelection(Collection<TestHashComponentsStreamHashAidxColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, Persistables.persistToBytesFunction())); }
public static ColumnSelection getColumnSelection(Collection<StreamTestStreamHashAidxColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, Persistables.persistToBytesFunction())); }
public static ColumnSelection getColumnSelection(Collection<TestHashComponentsStreamIdxColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, Persistables.persistToBytesFunction())); }
public static ColumnSelection getColumnSelection(Collection<StreamTestMaxMemStreamHashAidxColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, Persistables.persistToBytesFunction())); }
public static ColumnSelection getColumnSelection(Collection<TwoColumnsNamedColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, TwoColumnsNamedColumn.toShortName())); }
public static ColumnSelection getColumnSelection(Collection<FooToIdCondIdxColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, Persistables.persistToBytesFunction())); }
public static ColumnSelection getColumnSelection(Collection<StreamTestWithHashStreamIdxColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, Persistables.persistToBytesFunction())); }
public static ColumnSelection getColumnSelection(Collection<Index3IdxColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, Persistables.persistToBytesFunction())); }
public static ColumnSelection getColumnSelection(Collection<StreamTestWithHashStreamMetadataNamedColumn> cols) { return ColumnSelection.create(Collections2.transform(cols, StreamTestWithHashStreamMetadataNamedColumn.toShortName())); }
@Test public void testGetRowsWithSelectedColumns() { putTestDataForSingleTimestamp(); ColumnSelection columns1and2 = ColumnSelection.create(Arrays.asList(column(1), column(2))); Map<Cell, Value> values = keyValueService.getRows(TEST_TABLE, Arrays.asList(row(1), row(2)), columns1and2, TEST_TIMESTAMP + 1); assertEquals(3, values.size()); assertNull(values.get(Cell.create(row(1), column(0)))); assertArrayEquals(val(1, 2), values.get(Cell.create(row(1), column(2))).getContents()); assertArrayEquals(val(2, 1), values.get(Cell.create(row(2), column(1))).getContents()); assertArrayEquals(val(2, 2), values.get(Cell.create(row(2), column(2))).getContents()); }
@Test public void whereClausesOneColumn() { RangeRequest request = RangeRequest.builder().startRowInclusive(START).endRowExclusive(END).retainColumns( ColumnSelection.create(ImmutableList.of(COL1))).build(); WhereClauses whereClauses = WhereClauses.create("i", request); List<String> expectedClauses = ImmutableList.of("i.row_name >= ?", "i.row_name < ?", "i.col_name IN (?)"); assertEquals(whereClauses.getClauses(), expectedClauses); checkWhereArguments(whereClauses, ImmutableList.of(START, END, COL1)); }
@Test public void whereClausesMultiColumn() { RangeRequest request = RangeRequest.builder().startRowInclusive(START).endRowExclusive(END).retainColumns( ColumnSelection.create(ImmutableList.of(COL1, COL2, COL3))).build(); WhereClauses whereClauses = WhereClauses.create("i", request); List<String> expectedClauses = ImmutableList.of("i.row_name >= ?", "i.row_name < ?", "i.col_name IN (?,?,?)"); assertEquals(whereClauses.getClauses(), expectedClauses); checkWhereArguments(whereClauses, ImmutableList.of(START, END, COL1, COL2, COL3)); }
@Test public void usesDifferentTableIdentifier() { RangeRequest request = RangeRequest.builder().startRowInclusive(START).endRowExclusive(END).retainColumns( ColumnSelection.create(ImmutableList.of(COL1))).build(); WhereClauses whereClauses = WhereClauses.create("other", request); List<String> expectedClauses = ImmutableList.of( "other.row_name >= ?", "other.row_name < ?", "other.col_name IN (?)"); assertEquals(whereClauses.getClauses(), expectedClauses); checkWhereArguments(whereClauses, ImmutableList.of(START, END, COL1)); }