Search in sources :

Example 11 with NamedColumnDescription

use of com.palantir.atlasdb.table.description.NamedColumnDescription in project atlasdb by palantir.

the class TableClassRendererV2 method renderNamedDelete.

private List<MethodSpec> renderNamedDelete() {
    List<MethodSpec> deleteResults = new ArrayList<>();
    deleteResults.add(renderNamedDeleteRow());
    for (NamedColumnDescription col : ColumnRenderers.namedColumns(tableMetadata)) {
        deleteResults.add(renderNamedDeleteColumn(col));
    }
    return deleteResults;
}
Also used : MethodSpec(com.squareup.javapoet.MethodSpec) ArrayList(java.util.ArrayList) NamedColumnDescription(com.palantir.atlasdb.table.description.NamedColumnDescription)

Example 12 with NamedColumnDescription

use of com.palantir.atlasdb.table.description.NamedColumnDescription in project atlasdb by palantir.

the class TableClassRendererV2 method renderNamedDeleteRow.

private MethodSpec renderNamedDeleteRow() {
    MethodSpec.Builder deleteRowBuilder = MethodSpec.methodBuilder("deleteRow").addModifiers(Modifier.PUBLIC).addJavadoc("Delete all columns for specified row components.");
    deleteRowBuilder = addParametersFromRowComponents(deleteRowBuilder, tableMetadata);
    SortedSet<NamedColumnDescription> namedColumns = ColumnRenderers.namedColumns(tableMetadata);
    deleteRowBuilder.addStatement("$T row = $T.of($L)", rowType, rowType, getArgumentsFromRowComponents(tableMetadata)).addStatement("byte[] rowBytes = row.persistToBytes()", Persistables.class).addStatement("$T<$T> cells = $T.newHashSetWithExpectedSize($L)", Set.class, Cell.class, Sets.class, namedColumns.size());
    for (NamedColumnDescription col : namedColumns) {
        deleteRowBuilder.addStatement("cells.add($T.create(rowBytes, $T.toCachedBytes($L)))", Cell.class, PtBytes.class, ColumnRenderers.short_name(col));
    }
    deleteRowBuilder.addStatement("t.delete(tableRef, cells)");
    return deleteRowBuilder.build();
}
Also used : MethodSpec(com.squareup.javapoet.MethodSpec) Persistables(com.palantir.common.persist.Persistables) NamedColumnDescription(com.palantir.atlasdb.table.description.NamedColumnDescription)

Example 13 with NamedColumnDescription

use of com.palantir.atlasdb.table.description.NamedColumnDescription in project atlasdb by palantir.

the class TableClassRendererV2 method renderNamedGet.

private List<MethodSpec> renderNamedGet() {
    List<MethodSpec> getterResults = new ArrayList<>();
    for (NamedColumnDescription col : ColumnRenderers.namedColumns(tableMetadata)) {
        getterResults.add(renderNamedGetColumn(col));
        if (tableMetadata.getRowMetadata().getRowParts().size() == 1) {
            getterResults.add(renderNamedGetSeveralRows(col));
            if (tableMetadata.isRangeScanAllowed()) {
                getterResults.add(renderNamedGetRangeColumn(col));
                getterResults.add(renderNamedGetRangeStartEnd(col));
                getterResults.add(renderNamedGetRangeColumnLimit(col));
            }
        } else {
            getterResults.add(renderNamedGetSeveralRowObjects(col));
            if (tableMetadata.isRangeScanAllowed()) {
                getterResults.add(renderNamedGetRangeColumnRowObjects(col));
                getterResults.add(renderNamedGetRangeColumnRowObjectsLimit(col));
            }
        }
    }
    return getterResults;
}
Also used : MethodSpec(com.squareup.javapoet.MethodSpec) ArrayList(java.util.ArrayList) NamedColumnDescription(com.palantir.atlasdb.table.description.NamedColumnDescription)

Aggregations

NamedColumnDescription (com.palantir.atlasdb.table.description.NamedColumnDescription)13 ColumnMetadataDescription (com.palantir.atlasdb.table.description.ColumnMetadataDescription)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 DynamicColumnDescription (com.palantir.atlasdb.table.description.DynamicColumnDescription)4 MethodSpec (com.squareup.javapoet.MethodSpec)4 ArrayList (java.util.ArrayList)4 NameMetadataDescription (com.palantir.atlasdb.table.description.NameMetadataDescription)3 TableMetadata (com.palantir.atlasdb.table.description.TableMetadata)2 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 TableRowResult (com.palantir.atlasdb.api.TableRowResult)1 Cell (com.palantir.atlasdb.keyvalue.api.Cell)1 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)1 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)1 ColumnValueDescription (com.palantir.atlasdb.table.description.ColumnValueDescription)1 Persistables (com.palantir.common.persist.Persistables)1 Entry (java.util.Map.Entry)1