use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class SnapshotTransaction method getCellsToScrubByTable.
private Multimap<TableReference, Cell> getCellsToScrubByTable(State expectedState) {
Multimap<TableReference, Cell> tableRefToCells = HashMultimap.create();
State actualState = state.get();
if (expectedState == actualState) {
for (Entry<TableReference, ConcurrentNavigableMap<Cell, byte[]>> entry : writesByTable.entrySet()) {
TableReference table = entry.getKey();
Set<Cell> cells = entry.getValue().keySet();
tableRefToCells.putAll(table, cells);
}
} else {
AssertUtils.assertAndLog(log, false, "Expected state: " + expectedState + "; actual state: " + actualState);
}
return tableRefToCells;
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class SnapshotTransaction method getLocksForWrites.
protected Set<LockDescriptor> getLocksForWrites() {
Set<LockDescriptor> result = Sets.newHashSet();
Iterable<TableReference> allTables = IterableUtils.append(writesByTable.keySet(), TransactionConstants.TRANSACTION_TABLE);
for (TableReference tableRef : allTables) {
if (tableRef.equals(TransactionConstants.TRANSACTION_TABLE)) {
result.add(AtlasRowLockDescriptor.of(TransactionConstants.TRANSACTION_TABLE.getQualifiedName(), TransactionConstants.getValueForTimestamp(getStartTimestamp())));
continue;
}
ConflictHandler conflictHandler = getConflictHandlerForTable(tableRef);
if (conflictHandler == ConflictHandler.RETRY_ON_WRITE_WRITE_CELL) {
for (Cell cell : getLocalWrites(tableRef).keySet()) {
result.add(AtlasCellLockDescriptor.of(tableRef.getQualifiedName(), cell.getRowName(), cell.getColumnName()));
}
} else if (conflictHandler != ConflictHandler.IGNORE_ALL) {
Cell lastCell = null;
for (Cell cell : getLocalWrites(tableRef).keySet()) {
if (lastCell == null || !Arrays.equals(lastCell.getRowName(), cell.getRowName())) {
result.add(AtlasRowLockDescriptor.of(tableRef.getQualifiedName(), cell.getRowName()));
}
lastCell = cell;
}
}
}
return result;
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class SnapshotTransaction method getCellsToScrubByCell.
private Multimap<Cell, TableReference> getCellsToScrubByCell(State expectedState) {
Multimap<Cell, TableReference> cellToTableName = HashMultimap.create();
State actualState = state.get();
if (expectedState == actualState) {
for (Entry<TableReference, ConcurrentNavigableMap<Cell, byte[]>> entry : writesByTable.entrySet()) {
TableReference table = entry.getKey();
Set<Cell> cells = entry.getValue().keySet();
for (Cell c : cells) {
cellToTableName.put(c, table);
}
}
} else {
AssertUtils.assertAndLog(log, false, "Expected state: " + expectedState + "; actual state: " + actualState);
}
return cellToTableName;
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class AbstractTableMappingService method getMappedTableName.
@Override
public TableReference getMappedTableName(TableReference tableRef) throws TableMappingNotFoundException {
if (tableRef.getNamespace().isEmptyNamespace()) {
return tableRef;
}
if (tableMap.get().containsKey(tableRef)) {
TableReference shortName = tableMap.get().get(tableRef);
validateShortName(tableRef, shortName);
return tableMap.get().get(tableRef);
} else {
updateTableMap();
TableReference shortTableName = tableMap.get().get(tableRef);
if (shortTableName != null) {
return shortTableName;
}
throw new TableMappingNotFoundException("Unable to resolve full name for table reference " + tableRef);
}
}
use of com.palantir.atlasdb.keyvalue.api.TableReference in project atlasdb by palantir.
the class KvTableMappingService method readTableMap.
@Override
protected BiMap<TableReference, TableReference> readTableMap() {
BiMap<TableReference, TableReference> ret = HashBiMap.create();
ClosableIterator<RowResult<Value>> range = kv.getRange(AtlasDbConstants.NAMESPACE_TABLE, RangeRequest.builder().build(), Long.MAX_VALUE);
try {
while (range.hasNext()) {
RowResult<Value> row = range.next();
String shortName = PtBytes.toString(row.getColumns().get(AtlasDbConstants.NAMESPACE_SHORT_COLUMN_BYTES).getContents());
TableReference ref = getTableRefFromBytes(row.getRowName());
ret.put(ref, TableReference.createWithEmptyNamespace(shortName));
}
} finally {
range.close();
}
return ret;
}
Aggregations