Search in sources :

Example 6 with TableDefinition

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

the class IndexTestSchema method generateSchema.

// Table/IndexDefinition syntax
@SuppressWarnings({ "checkstyle:Indentation", "checkstyle:RightCurly" })
private static Schema generateSchema() {
    Schema schema = new Schema("IndexTest", IndexTest.class.getPackage().getName() + ".generated", Namespace.DEFAULT_NAMESPACE, OptionalType.JAVA8);
    schema.addTableDefinition("data", new TableDefinition() {

        {
            rowName();
            rowComponent("id", ValueType.FIXED_LONG);
            columns();
            column("value", "v", ValueType.FIXED_LONG);
        }
    });
    schema.addIndexDefinition("index1", new IndexDefinition(IndexType.CELL_REFERENCING) {

        {
            onTable("data");
            rowName();
            componentFromColumn("value", ValueType.FIXED_LONG, "value", "_value");
            dynamicColumns();
            componentFromRow("id", ValueType.FIXED_LONG);
            rangeScanAllowed();
        }
    });
    schema.addIndexDefinition("index2", new IndexDefinition(IndexType.CELL_REFERENCING) {

        {
            onTable("data");
            rowName();
            componentFromColumn("value", ValueType.FIXED_LONG, "value", "_value");
            componentFromRow("id", ValueType.FIXED_LONG);
            rangeScanAllowed();
        }
    });
    schema.addIndexDefinition("index3", new IndexDefinition(IndexType.CELL_REFERENCING) {

        {
            onTable("data");
            rowName();
            componentFromIterableColumn("value", ValueType.FIXED_LONG, ValueByteOrder.ASCENDING, "value", "ImmutableList.of(_value)");
            rangeScanAllowed();
        }
    });
    schema.addIndexDefinition("index4", new IndexDefinition(IndexType.CELL_REFERENCING) {

        {
            onTable("data");
            rowName();
            componentFromIterableColumn("value1", ValueType.FIXED_LONG, ValueByteOrder.ASCENDING, "value", "ImmutableList.of(_value)");
            componentFromIterableColumn("value2", ValueType.FIXED_LONG, ValueByteOrder.ASCENDING, "value", "ImmutableList.of(_value)");
            rangeScanAllowed();
        }
    });
    schema.addTableDefinition("two_columns", new TableDefinition() {

        {
            rowName();
            rowComponent("id", ValueType.FIXED_LONG);
            columns();
            column("foo", "f", ValueType.FIXED_LONG);
            column("bar", "b", ValueType.FIXED_LONG);
        }
    });
    schema.addIndexDefinition("foo_to_id", new IndexDefinition(IndexType.CELL_REFERENCING) {

        {
            onTable("two_columns");
            rowName();
            hashFirstRowComponent();
            componentFromColumn("foo", ValueType.FIXED_LONG, "foo", "_value");
            dynamicColumns();
            componentFromRow("id", ValueType.FIXED_LONG);
        }
    });
    schema.addIndexDefinition("foo_to_id_cond", new IndexDefinition(IndexType.CELL_REFERENCING) {

        {
            onTable("two_columns");
            onCondition("foo", "_value > 1");
            rowName();
            componentFromColumn("foo", ValueType.FIXED_LONG, "foo", "_value");
            dynamicColumns();
            componentFromRow("id", ValueType.FIXED_LONG);
        }
    });
    return schema;
}
Also used : IndexDefinition(com.palantir.atlasdb.table.description.IndexDefinition) AtlasSchema(com.palantir.atlasdb.schema.AtlasSchema) Schema(com.palantir.atlasdb.table.description.Schema) TableDefinition(com.palantir.atlasdb.table.description.TableDefinition)

Example 7 with TableDefinition

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

the class GeneralTaskCheckpointer method getSchema.

@SuppressWarnings({ "checkstyle:Indentation", "checkstyle:RightCurly" })
private Schema getSchema() {
    Schema schema = new Schema(checkpointTable.getNamespace());
    schema.addTableDefinition(checkpointTable.getTablename(), new TableDefinition() {

        {
            rowName();
            rowComponent("table_name", ValueType.VAR_STRING);
            rowComponent("range_id", ValueType.VAR_LONG);
            columns();
            column("start", SHORT_COLUMN_NAME, ValueType.BLOB);
            rangeScanAllowed();
            conflictHandler(ConflictHandler.IGNORE_ALL);
        }
    });
    return schema;
}
Also used : Schema(com.palantir.atlasdb.table.description.Schema) TableDefinition(com.palantir.atlasdb.table.description.TableDefinition)

Example 8 with TableDefinition

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

the class Benchmarks method createTableWithDynamicColumns.

public static TableReference createTableWithDynamicColumns(KeyValueService kvs, TableReference tableRef, String rowComponent, String columnComponent) {
    TableDefinition tableDef = new TableDefinition() {

        {
            rowName();
            rowComponent(rowComponent, ValueType.STRING);
            dynamicColumns();
            columnComponent(columnComponent, ValueType.FIXED_LONG);
            value(ValueType.FIXED_LONG);
            conflictHandler(ConflictHandler.IGNORE_ALL);
            sweepStrategy(TableMetadataPersistence.SweepStrategy.NOTHING);
        }
    };
    kvs.createTable(tableRef, tableDef.toTableMetadata().persistToBytes());
    return tableRef;
}
Also used : TableDefinition(com.palantir.atlasdb.table.description.TableDefinition)

Example 9 with TableDefinition

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

the class Benchmarks method createTable.

public static void createTable(KeyValueService kvs, TableReference tableRef, String rowComponent, String columnName, TableMetadataPersistence.SweepStrategy sweepStrategy) {
    TableDefinition tableDef = new TableDefinition() {

        {
            rowName();
            rowComponent(rowComponent, ValueType.STRING);
            columns();
            column(columnName, columnName, ValueType.BLOB);
            conflictHandler(ConflictHandler.IGNORE_ALL);
            sweepStrategy(sweepStrategy);
        }
    };
    kvs.createTable(tableRef, tableDef.toTableMetadata().persistToBytes());
}
Also used : TableDefinition(com.palantir.atlasdb.table.description.TableDefinition)

Example 10 with TableDefinition

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

the class TodoSchema method generateSchema.

private static Schema generateSchema() {
    Schema schema = new Schema(TodoSchema.class.getSimpleName(), TodoSchema.class.getPackage().getName() + ".generated", Namespace.DEFAULT_NAMESPACE, OptionalType.JAVA8);
    schema.addTableDefinition(TODO_TABLE, new TableDefinition() {

        {
            rowName();
            rowComponent("id", ValueType.FIXED_LONG);
            columns();
            column(TEXT_COLUMN, "t", ValueType.STRING);
        }
    });
    return schema;
}
Also used : AtlasSchema(com.palantir.atlasdb.schema.AtlasSchema) Schema(com.palantir.atlasdb.table.description.Schema) TableDefinition(com.palantir.atlasdb.table.description.TableDefinition)

Aggregations

TableDefinition (com.palantir.atlasdb.table.description.TableDefinition)17 Schema (com.palantir.atlasdb.table.description.Schema)8 AtlasSchema (com.palantir.atlasdb.schema.AtlasSchema)7 Test (org.junit.Test)4 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)3 StreamStoreDefinitionBuilder (com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder)3 Cell (com.palantir.atlasdb.keyvalue.api.Cell)2 IndexDefinition (com.palantir.atlasdb.table.description.IndexDefinition)2 ClassName (com.squareup.javapoet.ClassName)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 AtlasDbTestCase (com.palantir.atlasdb.AtlasDbTestCase)1 PtBytes (com.palantir.atlasdb.encoding.PtBytes)1 Namespace (com.palantir.atlasdb.keyvalue.api.Namespace)1 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)1 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)1 Value (com.palantir.atlasdb.keyvalue.api.Value)1 InMemoryKeyValueService (com.palantir.atlasdb.keyvalue.impl.InMemoryKeyValueService)1 TableMappingNotFoundException (com.palantir.atlasdb.keyvalue.impl.TableMappingNotFoundException)1