Search in sources :

Example 11 with Schema

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

the class ProfileSchema method generateSchema.

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

        {
            allSafeForLoggingByDefault();
            rowName();
            rowComponent("id", ValueType.UUID);
            columns();
            column("metadata", "m", ProfilePersistence.UserProfile.class);
            column("create", "c", CreationData.Persister.class);
            column("json", "j", JsonNodePersister.class);
            column("photo_stream_id", "p", ValueType.FIXED_LONG);
        }
    });
    schema.addIndexDefinition("user_birthdays", new IndexDefinition(IndexType.CELL_REFERENCING) {

        {
            onTable("user_profile");
            allSafeForLoggingByDefault();
            rowName();
            componentFromColumn("birthday", ValueType.VAR_SIGNED_LONG, "metadata", "_value.getBirthEpochDay()");
            dynamicColumns();
            componentFromRow("id", ValueType.UUID);
            rangeScanAllowed();
            ignoreHotspottingChecks();
        }
    });
    schema.addIndexDefinition("created", new IndexDefinition(IndexType.CELL_REFERENCING) {

        {
            onTable("user_profile");
            allSafeForLoggingByDefault();
            rowName();
            componentFromColumn("time", ValueType.VAR_LONG, "create", "_value.getTimeCreated()");
            dynamicColumns();
            componentFromRow("id", ValueType.UUID);
            rangeScanAllowed();
            ignoreHotspottingChecks();
        }
    });
    schema.addIndexDefinition("cookies", new IndexDefinition(IndexType.CELL_REFERENCING) {

        {
            onTable("user_profile");
            allSafeForLoggingByDefault();
            rowName();
            componentFromIterableColumn("cookie", ValueType.STRING, ValueByteOrder.ASCENDING, "json", "com.palantir.example.profile.schema.ProfileSchema.getCookies(_value)");
            dynamicColumns();
            componentFromRow("id", ValueType.UUID);
            rangeScanAllowed();
        }
    });
    schema.addStreamStoreDefinition(new StreamStoreDefinitionBuilder("user_photos", "user_photos", ValueType.VAR_LONG).tableNameLogSafety(TableMetadataPersistence.LogSafety.SAFE).build());
    return schema;
}
Also used : IndexDefinition(com.palantir.atlasdb.table.description.IndexDefinition) StreamStoreDefinitionBuilder(com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder) AtlasSchema(com.palantir.atlasdb.schema.AtlasSchema) Schema(com.palantir.atlasdb.table.description.Schema) TableDefinition(com.palantir.atlasdb.table.description.TableDefinition) JsonNodePersister(com.palantir.atlasdb.persister.JsonNodePersister) JsonNodePersister(com.palantir.atlasdb.persister.JsonNodePersister)

Aggregations

Schema (com.palantir.atlasdb.table.description.Schema)11 AtlasSchema (com.palantir.atlasdb.schema.AtlasSchema)8 TableDefinition (com.palantir.atlasdb.table.description.TableDefinition)8 StreamStoreDefinitionBuilder (com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder)3 IndexDefinition (com.palantir.atlasdb.table.description.IndexDefinition)2 SweepConfig (com.palantir.atlasdb.config.SweepConfig)1 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)1 ProfilingKeyValueService (com.palantir.atlasdb.keyvalue.impl.ProfilingKeyValueService)1 SweepStatsKeyValueService (com.palantir.atlasdb.keyvalue.impl.SweepStatsKeyValueService)1 TracingKeyValueService (com.palantir.atlasdb.keyvalue.impl.TracingKeyValueService)1 ValidatingQueryRewritingKeyValueService (com.palantir.atlasdb.keyvalue.impl.ValidatingQueryRewritingKeyValueService)1 JsonNodePersister (com.palantir.atlasdb.persister.JsonNodePersister)1 CompactSchema (com.palantir.atlasdb.schema.CompactSchema)1 SweepSchema (com.palantir.atlasdb.schema.SweepSchema)1 Idempotent (com.palantir.common.annotation.Idempotent)1 Provides (dagger.Provides)1 Named (javax.inject.Named)1 Singleton (javax.inject.Singleton)1