Search in sources :

Example 1 with ROW_NAME

use of com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.ROW_NAME in project atlasdb by palantir.

the class JdbcKeyValueService method addGarbageCollectionSentinelValues.

@Override
public void addGarbageCollectionSentinelValues(final TableReference tableRef, Iterable<Cell> cells) {
    int numCells = Iterables.size(cells);
    if (numCells == 0) {
        return;
    }
    for (List<Cell> partCells : Iterables.partition(cells, batchSizeForMutations)) {
        Long timestamp = Value.INVALID_VALUE_TIMESTAMP;
        byte[] value = new byte[0];
        final RowN[] rows = new RowN[numCells];
        int i = 0;
        for (Cell cell : partCells) {
            rows[i++] = row(new Object[] { cell.getRowName(), cell.getColumnName(), timestamp, value });
        }
        run((Function<DSLContext, Void>) ctx -> {
            ctx.insertInto(table(tableName(tableRef)), field(ROW_NAME, byte[].class), field(COL_NAME, byte[].class), field(TIMESTAMP, Long.class), field(VALUE, byte[].class)).select(ctx.select(T1_ROW_NAME, T1_COL_NAME, T1_TIMESTAMP, T1_VALUE).from(values(ctx, rows, TEMP_TABLE_1, ROW_NAME, COL_NAME, TIMESTAMP, VALUE)).whereNotExists(ctx.selectOne().from(atlasTable(tableRef).as(ATLAS_TABLE)).where(A_ROW_NAME.eq(T1_ROW_NAME).and(A_COL_NAME.eq(T1_COL_NAME)).and(A_TIMESTAMP.eq(T1_TIMESTAMP))))).execute();
            return null;
        });
    }
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) DSL(org.jooq.impl.DSL) DSL.field(org.jooq.impl.DSL.field) CheckAndSetRequest(com.palantir.atlasdb.keyvalue.api.CheckAndSetRequest) Condition(org.jooq.Condition) Record1(org.jooq.Record1) SelectField(org.jooq.SelectField) Map(java.util.Map) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) SQLDialect(org.jooq.SQLDialect) CandidateCellForSweeping(com.palantir.atlasdb.keyvalue.api.CandidateCellForSweeping) Select(org.jooq.Select) AtlasDbConstants(com.palantir.atlasdb.AtlasDbConstants) Cell(com.palantir.atlasdb.keyvalue.api.Cell) T1_TIMESTAMP(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.T1_TIMESTAMP) Set(java.util.Set) PutBatch(com.palantir.atlasdb.keyvalue.jdbc.impl.PutBatch) T1_COL_NAME(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.T1_COL_NAME) Result(org.jooq.Result) StandardCharsets(java.nio.charset.StandardCharsets) InsufficientConsistencyException(com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException) KeyAlreadyExistsException(com.palantir.atlasdb.keyvalue.api.KeyAlreadyExistsException) AbstractKeyValueService(com.palantir.atlasdb.keyvalue.impl.AbstractKeyValueService) ColumnRangeSelection(com.palantir.atlasdb.keyvalue.api.ColumnRangeSelection) Iterables(com.google.common.collect.Iterables) METADATA(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.METADATA) DSL.row(org.jooq.impl.DSL.row) ClusterAvailabilityStatus(com.palantir.atlasdb.keyvalue.api.ClusterAvailabilityStatus) R_TIMESTAMP(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.R_TIMESTAMP) SQLException(java.sql.SQLException) T2_MAX_TIMESTAMP(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.T2_MAX_TIMESTAMP) Lists(com.google.common.collect.Lists) VARBINARY(org.jooq.impl.SQLDataType.VARBINARY) RANGE_TABLE(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.RANGE_TABLE) VARCHAR(org.jooq.impl.SQLDataType.VARCHAR) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) Record(org.jooq.Record) UnsignedBytes(com.google.common.primitives.UnsignedBytes) JdbcDataSourceConfiguration(com.palantir.atlasdb.jdbc.config.JdbcDataSourceConfiguration) T1_ROW_NAME(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.T1_ROW_NAME) BaseEncoding(com.google.common.io.BaseEncoding) COL_NAME(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.COL_NAME) MoreObjects(com.google.common.base.MoreObjects) Throwables(com.google.common.base.Throwables) IOException(java.io.IOException) BLOB(org.jooq.impl.SQLDataType.BLOB) MultiTimestampPutBatch(com.palantir.atlasdb.keyvalue.jdbc.impl.MultiTimestampPutBatch) RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) DSL.table(org.jooq.impl.DSL.table) VALUE(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.VALUE) GetCandidateCellsForSweepingShim(com.palantir.atlasdb.keyvalue.impl.GetCandidateCellsForSweepingShim) TEMP_TABLE_1(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.TEMP_TABLE_1) RowN(org.jooq.RowN) RangeRequests(com.palantir.atlasdb.keyvalue.api.RangeRequests) TEMP_TABLE_2(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.TEMP_TABLE_2) Row(org.jooq.Row) Connection(java.sql.Connection) TABLE_VALUES(org.jooq.Clause.TABLE_VALUES) ATLAS_TABLE(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.ATLAS_TABLE) BatchColumnRangeSelection(com.palantir.atlasdb.keyvalue.api.BatchColumnRangeSelection) ClosableIterator(com.palantir.common.base.ClosableIterator) Table(org.jooq.Table) TABLE_NAME(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.TABLE_NAME) SelectOffsetStep(org.jooq.SelectOffsetStep) RowColumnRangeIterator(com.palantir.atlasdb.keyvalue.api.RowColumnRangeIterator) KeyValueServices(com.palantir.atlasdb.keyvalue.impl.KeyValueServices) A_TIMESTAMP(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.A_TIMESTAMP) RenderContext(org.jooq.RenderContext) HashMultimap(com.google.common.collect.HashMultimap) DSLContext(org.jooq.DSLContext) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) AbstractPagingIterable(com.palantir.util.paging.AbstractPagingIterable) Row3(org.jooq.Row3) Collection(java.util.Collection) SingleTimestampPutBatch(com.palantir.atlasdb.keyvalue.jdbc.impl.SingleTimestampPutBatch) ROW_NAME(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.ROW_NAME) T1_VALUE(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.T1_VALUE) NavigableMap(java.util.NavigableMap) Sets(com.google.common.collect.Sets) ColumnSelection(com.palantir.atlasdb.keyvalue.api.ColumnSelection) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) List(java.util.List) InsertValuesStep4(org.jooq.InsertValuesStep4) CandidateCellForSweepingRequest(com.palantir.atlasdb.keyvalue.api.CandidateCellForSweepingRequest) Entry(java.util.Map.Entry) Query(org.jooq.Query) SortedMap(java.util.SortedMap) T2_COL_NAME(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.T2_COL_NAME) A_COL_NAME(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.A_COL_NAME) HashMap(java.util.HashMap) Hashing(com.google.common.hash.Hashing) Multimap(com.google.common.collect.Multimap) BIGINT(org.jooq.impl.SQLDataType.BIGINT) TableLike(org.jooq.TableLike) ImmutableList(com.google.common.collect.ImmutableList) A_VALUE(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.A_VALUE) DataSource(javax.sql.DataSource) R_ROW_NAME(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.R_ROW_NAME) ClosableIterators(com.palantir.common.base.ClosableIterators) DataAccessException(org.jooq.exception.DataAccessException) Value(com.palantir.atlasdb.keyvalue.api.Value) Settings(org.jooq.conf.Settings) MAX_TIMESTAMP(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.MAX_TIMESTAMP) TIMESTAMP(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.TIMESTAMP) A_ROW_NAME(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.A_ROW_NAME) TokenBackedBasicResultsPage(com.palantir.util.paging.TokenBackedBasicResultsPage) Maps(com.google.common.collect.Maps) T2_ROW_NAME(com.palantir.atlasdb.keyvalue.jdbc.impl.JdbcConstants.T2_ROW_NAME) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) Closeable(java.io.Closeable) SimpleTokenBackedResultsPage(com.palantir.util.paging.SimpleTokenBackedResultsPage) BatchBindStep(org.jooq.BatchBindStep) RenderNameStyle(org.jooq.conf.RenderNameStyle) RowN(org.jooq.RowN) DSLContext(org.jooq.DSLContext) Cell(com.palantir.atlasdb.keyvalue.api.Cell)

Aggregations

Function (com.google.common.base.Function)1 MoreObjects (com.google.common.base.MoreObjects)1 Throwables (com.google.common.base.Throwables)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 HashMultimap (com.google.common.collect.HashMultimap)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Multimap (com.google.common.collect.Multimap)1 Sets (com.google.common.collect.Sets)1 Hashing (com.google.common.hash.Hashing)1 BaseEncoding (com.google.common.io.BaseEncoding)1 UnsignedBytes (com.google.common.primitives.UnsignedBytes)1 AtlasDbConstants (com.palantir.atlasdb.AtlasDbConstants)1 JdbcDataSourceConfiguration (com.palantir.atlasdb.jdbc.config.JdbcDataSourceConfiguration)1 BatchColumnRangeSelection (com.palantir.atlasdb.keyvalue.api.BatchColumnRangeSelection)1