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;
}
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;
}
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;
}
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());
}
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;
}
Aggregations