@Override public boolean cellsCleanedUp(Transaction t, Set<Cell> cells) { SnapshotsStreamIdxTable usersIndex = tables.getSnapshotsStreamIdxTable(t); Set<SnapshotsStreamIdxTable.SnapshotsStreamIdxRow> rows = Sets.newHashSetWithExpectedSize(cells.size()); for (Cell cell : cells) { rows.add(SnapshotsStreamIdxTable.SnapshotsStreamIdxRow.BYTES_HYDRATOR.hydrateFromBytes(cell.getRowName())); } BatchColumnRangeSelection oneColumn = BatchColumnRangeSelection.create( PtBytes.EMPTY_BYTE_ARRAY, PtBytes.EMPTY_BYTE_ARRAY, 1); Map<SnapshotsStreamIdxTable.SnapshotsStreamIdxRow, BatchingVisitable<SnapshotsStreamIdxTable.SnapshotsStreamIdxColumnValue>> existentRows = usersIndex.getRowsColumnRange(rows, oneColumn); Set<SnapshotsStreamIdxTable.SnapshotsStreamIdxRow> rowsInDb = Sets.newHashSetWithExpectedSize(cells.size()); for (Map.Entry<SnapshotsStreamIdxTable.SnapshotsStreamIdxRow, BatchingVisitable<SnapshotsStreamIdxTable.SnapshotsStreamIdxColumnValue>> rowVisitable : existentRows.entrySet()) { rowVisitable.getValue().batchAccept(1, columnValues -> { if (!columnValues.isEmpty()) { rowsInDb.add(rowVisitable.getKey()); } return false; }); } Set<Long> toDelete = Sets.newHashSetWithExpectedSize(rows.size() - rowsInDb.size()); for (SnapshotsStreamIdxTable.SnapshotsStreamIdxRow rowToDelete : Sets.difference(rows, rowsInDb)) { toDelete.add(rowToDelete.getId()); } SnapshotsStreamStore.of(tables).deleteStreams(t, toDelete); return false; } }
@Override public boolean cellsCleanedUp(Transaction t, Set<Cell> cells) { SnapshotsStreamIdxTable usersIndex = tables.getSnapshotsStreamIdxTable(t); Set<SnapshotsStreamIdxTable.SnapshotsStreamIdxRow> rows = Sets.newHashSetWithExpectedSize(cells.size()); for (Cell cell : cells) { rows.add(SnapshotsStreamIdxTable.SnapshotsStreamIdxRow.BYTES_HYDRATOR.hydrateFromBytes(cell.getRowName())); } BatchColumnRangeSelection oneColumn = BatchColumnRangeSelection.create( PtBytes.EMPTY_BYTE_ARRAY, PtBytes.EMPTY_BYTE_ARRAY, 1); Map<SnapshotsStreamIdxTable.SnapshotsStreamIdxRow, BatchingVisitable<SnapshotsStreamIdxTable.SnapshotsStreamIdxColumnValue>> existentRows = usersIndex.getRowsColumnRange(rows, oneColumn); Set<SnapshotsStreamIdxTable.SnapshotsStreamIdxRow> rowsInDb = Sets.newHashSetWithExpectedSize(cells.size()); for (Map.Entry<SnapshotsStreamIdxTable.SnapshotsStreamIdxRow, BatchingVisitable<SnapshotsStreamIdxTable.SnapshotsStreamIdxColumnValue>> rowVisitable : existentRows.entrySet()) { rowVisitable.getValue().batchAccept(1, columnValues -> { if (!columnValues.isEmpty()) { rowsInDb.add(rowVisitable.getKey()); } return false; }); } Set<Long> toDelete = Sets.newHashSetWithExpectedSize(rows.size() - rowsInDb.size()); for (SnapshotsStreamIdxTable.SnapshotsStreamIdxRow rowToDelete : Sets.difference(rows, rowsInDb)) { toDelete.add(rowToDelete.getId()); } SnapshotsStreamStore.of(tables).deleteStreams(t, toDelete); return false; } }