default <U> ClosableIterator<U> flatMap(Function<T, Collection<U>> mapper) { return ClosableIterators.wrap(stream().flatMap(obj -> mapper.apply(obj).stream()).iterator(), this); }
private Set<Cell> getAllCells(TableReference tableRef) { try (ClosableIterator<RowResult<Value>> iterator = kvs.get() .getRange(tableRef, RangeRequest.all(), Long.MAX_VALUE)) { return iterator.stream() .map(RowResult::getCells) .flatMap(Streams::stream) .map(Map.Entry::getKey) .collect(Collectors.toSet()); } }
void deleteAllMetadataRowsForTable(TableReference tableRef) { try (ClosableIterator<RowResult<Value>> range = rangeLoader.getRange( AtlasDbConstants.DEFAULT_METADATA_TABLE, CassandraKeyValueServices.metadataRangeRequestForTable(tableRef), Long.MAX_VALUE)) { Map<Cell, Long> cellsToDelete = range.stream() .map(RowResult::getCells) .map(Iterables::getOnlyElement) .map(Map.Entry::getKey) .map(Cell::getRowName) .map(CassandraKeyValueServices::tableReferenceFromBytes) .filter(candidate -> nonNullMatchingIgnoreCase(candidate, tableRef)) .collect(Collectors.toMap(CassandraKeyValueServices::getOldMetadataCell, ignore -> Long.MAX_VALUE)); new CellRangeDeleter(clientPool, wrappingQueryRunner, CassandraKeyValueServiceImpl.DELETE_CONSISTENCY, no -> System.currentTimeMillis()) .deleteAllTimestamps(AtlasDbConstants.DEFAULT_METADATA_TABLE, cellsToDelete, true); } catch (AtlasDbDependencyException e) { log.info("Failed to delete old table metadata for table {} because not all Cassandra nodes are up.", LoggingArgs.tableRef(tableRef), e); } }
CassandraKeyValueServices.metadataRangeRequest(), Long.MAX_VALUE)) { tableToMetadataContents = range.stream() .map(RowResult::getCells) .map(Iterables::getOnlyElement)
private void assertSweepableCellsHasNoDedicatedRowsForShard(int shard) { TableReference sweepableCellsTable = TargetedSweepTableFactory.of().getSweepableCellsTable(null).getTableRef(); try (ClosableIterator<RowResult<Value>> iterator = spiedKvs.getRange(sweepableCellsTable, RangeRequest.all(), Long.MAX_VALUE)) { assertThat(iterator.stream() .map(RowResult::getRowName) .map(SweepableCellsTable.SweepableCellsRow.BYTES_HYDRATOR::hydrateFromBytes) .map(SweepableCellsTable.SweepableCellsRow::getMetadata) .map(TargetedSweepMetadata.BYTES_HYDRATOR::hydrateFromBytes) .filter(TargetedSweepMetadata::dedicatedRow) .filter(metadata -> metadata.shard() == shard) .collect(Collectors.toList())) .isEmpty(); } }
default <U> ClosableIterator<U> flatMap(Function<T, Collection<U>> mapper) { return ClosableIterators.wrap(stream().flatMap(obj -> mapper.apply(obj).stream()).iterator(), this); }
void deleteAllMetadataRowsForTable(TableReference tableRef) { try (ClosableIterator<RowResult<Value>> range = rangeLoader.getRange( AtlasDbConstants.DEFAULT_METADATA_TABLE, CassandraKeyValueServices.metadataRangeRequestForTable(tableRef), Long.MAX_VALUE)) { Map<Cell, Long> cellsToDelete = range.stream() .map(RowResult::getCells) .map(Iterables::getOnlyElement) .map(Map.Entry::getKey) .map(Cell::getRowName) .map(CassandraKeyValueServices::tableReferenceFromBytes) .filter(candidate -> nonNullMatchingIgnoreCase(candidate, tableRef)) .collect(Collectors.toMap(CassandraKeyValueServices::getOldMetadataCell, ignore -> Long.MAX_VALUE)); new CellRangeDeleter(clientPool, wrappingQueryRunner, CassandraKeyValueServiceImpl.DELETE_CONSISTENCY, no -> System.currentTimeMillis()) .deleteAllTimestamps(AtlasDbConstants.DEFAULT_METADATA_TABLE, cellsToDelete, true); } catch (AtlasDbDependencyException e) { log.info("Failed to delete old table metadata for table {} because not all Cassandra nodes are up.", LoggingArgs.tableRef(tableRef), e); } }
CassandraKeyValueServices.metadataRangeRequest(), Long.MAX_VALUE)) { tableToMetadataContents = range.stream() .map(RowResult::getCells) .map(Iterables::getOnlyElement)