use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class TableRemappingKeyValueService method createTable.
@Override
public void createTable(TableReference tableRef, byte[] tableMetadata) {
TableReference shortName = tableMapper.addTable(tableRef);
delegate().createTable(shortName, tableMetadata);
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class TableSplittingKeyValueService method multiPut.
@Override
public void multiPut(Map<TableReference, ? extends Map<Cell, byte[]>> valuesByTable, long timestamp) {
Map<KeyValueService, Map<TableReference, Map<Cell, byte[]>>> mapByDelegate = Maps.newHashMap();
for (Entry<TableReference, ? extends Map<Cell, byte[]>> e : valuesByTable.entrySet()) {
KeyValueService delegate = getDelegate(e.getKey());
Map<TableReference, Map<Cell, byte[]>> map = mapByDelegate.computeIfAbsent(delegate, table -> Maps.newHashMap());
map.put(e.getKey(), e.getValue());
}
for (Entry<KeyValueService, Map<TableReference, Map<Cell, byte[]>>> e : mapByDelegate.entrySet()) {
e.getKey().multiPut(e.getValue(), timestamp);
}
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class TableSplittingKeyValueService method groupByDelegate.
private Map<KeyValueService, Map<TableReference, byte[]>> groupByDelegate(Map<TableReference, byte[]> tableRefsToTableMetadata) {
Map<KeyValueService, Map<TableReference, byte[]>> splitTableNamesToTableMetadata = Maps.newHashMap();
for (Entry<TableReference, byte[]> tableEntry : tableRefsToTableMetadata.entrySet()) {
TableReference tableRef = tableEntry.getKey();
byte[] tableMetadata = tableEntry.getValue();
KeyValueService delegate = getDelegate(tableRef);
if (splitTableNamesToTableMetadata.containsKey(delegate)) {
splitTableNamesToTableMetadata.get(delegate).put(tableRef, tableMetadata);
} else {
Map<TableReference, byte[]> mapTableToMaxValue = Maps.newHashMap();
mapTableToMaxValue.put(tableRef, tableMetadata);
splitTableNamesToTableMetadata.put(delegate, mapTableToMaxValue);
}
}
return splitTableNamesToTableMetadata;
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class SweepTaskRunner method runInternal.
private SweepResults runInternal(TableReference tableRef, SweepBatchConfig batchConfig, byte[] startRow, RunType runType) {
Preconditions.checkNotNull(tableRef, "tableRef cannot be null");
Preconditions.checkState(!AtlasDbConstants.hiddenTables.contains(tableRef));
if (tableRef.getQualifiedName().startsWith(AtlasDbConstants.NAMESPACE_PREFIX)) {
// this happens sometimes; I think it's because some places in the code can
// start this sweeper without doing the full normally ordered KVSModule startup.
// I did check and sweep.stats did contain the FQ table name for all of the tables,
// so it is at least broken in some way that still allows namespaced tables to eventually be swept.
log.warn("The sweeper should not be run on tables passed through namespace mapping.");
return SweepResults.createEmptySweepResultWithNoMoreToSweep();
}
if (keyValueService.getMetadataForTable(tableRef).length == 0) {
log.warn("The sweeper tried to sweep table '{}', but the table does not exist. Skipping table.", LoggingArgs.tableRef("tableRef", tableRef));
return SweepResults.createEmptySweepResultWithNoMoreToSweep();
}
SweepStrategy sweepStrategy = sweepStrategyManager.get().getOrDefault(tableRef, SweepStrategy.CONSERVATIVE);
Optional<Sweeper> maybeSweeper = Sweeper.of(sweepStrategy);
return maybeSweeper.map(sweeper -> doRun(tableRef, batchConfig, startRow, runType, sweeper)).orElseGet(SweepResults::createEmptySweepResultWithNoMoreToSweep);
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class SweeperServiceImpl method sweepTable.
@Override
public SweepTableResponse sweepTable(String tableName, Optional<String> startRow, Optional<Boolean> fullSweep, Optional<Integer> maxCellTsPairsToExamine, Optional<Integer> candidateBatchSize, Optional<Integer> deleteBatchSize) {
TableReference tableRef = getTableRef(tableName);
checkTableExists(tableName, tableRef);
byte[] decodedStartRow = startRow.map(PtBytes::decodeHexString).orElse(PtBytes.EMPTY_BYTE_ARRAY);
SweepBatchConfig config = buildConfigWithOverrides(maxCellTsPairsToExamine, candidateBatchSize, deleteBatchSize);
return SweepTableResponse.from(runSweep(fullSweep, tableRef, decodedStartRow, config));
}
Aggregations