Search in sources :

Example 1 with StreamStoreDefinitionBuilder

use of com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder in project atlasdb by palantir.

the class BlobSchema method generateSchema.

private static Schema generateSchema() {
    Schema schema = new Schema(BlobSchema.class.getSimpleName(), BlobSchema.class.getPackage().getName() + ".generated", BLOB_NAMESPACE);
    schema.addStreamStoreDefinition(new StreamStoreDefinitionBuilder("data", "Data", ValueType.VAR_LONG).hashRowComponents().tableNameLogSafety(TableMetadataPersistence.LogSafety.SAFE).build());
    schema.addStreamStoreDefinition(new StreamStoreDefinitionBuilder("hotspottyData", "HotspottyData", ValueType.VAR_SIGNED_LONG).build());
    schema.addTableDefinition("auditedData", new TableDefinition() {

        {
            allSafeForLoggingByDefault();
            rowName();
            rowComponent("id", ValueType.FIXED_LONG);
            columns();
            column("data", "d", ValueType.BLOB);
        }
    });
    schema.addCleanupTask("auditedData", () -> (tx, cells) -> {
        log.info("Deleted data items: [{}]", UnsafeArg.of("cells", cells));
        return false;
    });
    schema.validate();
    return schema;
}
Also used : 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)

Example 2 with StreamStoreDefinitionBuilder

use of com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder in project atlasdb by palantir.

the class SchemaTest method streamStoreMetadataGeneratedCorrectlyForSimpleStreamStore.

@Test
public void streamStoreMetadataGeneratedCorrectlyForSimpleStreamStore() {
    Schema schema = new Schema("Table", TEST_PACKAGE, Namespace.EMPTY_NAMESPACE);
    String shortName = "f";
    String longName = "Floccinaucinihilipilification";
    schema.addStreamStoreDefinition(new StreamStoreDefinitionBuilder(shortName, longName, ValueType.VAR_LONG).build());
    assertCleanupMetadataCorrectForStreamStore(schema, shortName, 0, ValueType.VAR_LONG);
}
Also used : StreamStoreDefinitionBuilder(com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 3 with StreamStoreDefinitionBuilder

use of com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder in project atlasdb by palantir.

the class SchemaTest method streamStoreTablesSupportAdditionalCleanupTasks.

@Test
public void streamStoreTablesSupportAdditionalCleanupTasks() {
    Schema schema = new Schema("Table", TEST_PACKAGE, Namespace.EMPTY_NAMESPACE);
    String shortName = "l";
    String longName = "Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch";
    schema.addStreamStoreDefinition(new StreamStoreDefinitionBuilder(shortName, longName, ValueType.VAR_SIGNED_LONG).hashRowComponents().build());
    schema.addCleanupTask(StreamTableType.HASH.getTableName(shortName), () -> (cells, tx) -> false);
    schema.addCleanupTask(StreamTableType.INDEX.getTableName(shortName), () -> (cells, tx) -> false);
    assertCleanupMetadataInSchemaSatisfies(schema, StreamTableType.VALUE.getTableName(shortName), NULL_CLEANUP_METADATA_ASSERTION);
    assertCleanupMetadataInSchemaSatisfies(schema, StreamTableType.HASH.getTableName(shortName), ARBITRARY_CLEANUP_METADATA_ASSERTION);
    assertCleanupMetadataInSchemaSatisfies(schema, StreamTableType.METADATA.getTableName(shortName), getStreamStoreMetadataAssertion(2, ValueType.VAR_SIGNED_LONG));
    assertCleanupMetadataInSchemaSatisfies(schema, StreamTableType.INDEX.getTableName(shortName), ARBITRARY_CLEANUP_METADATA_ASSERTION);
}
Also used : StreamStoreDefinitionBuilder(com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 4 with StreamStoreDefinitionBuilder

use of com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder in project atlasdb by palantir.

the class SchemaTest method streamStoreMetadataGeneratedCorrectlyForStreamStoreWithHashRowComponents.

@Test
public void streamStoreMetadataGeneratedCorrectlyForStreamStoreWithHashRowComponents() {
    Schema schema = new Schema("Table", TEST_PACKAGE, Namespace.EMPTY_NAMESPACE);
    String shortName = "p";
    String longName = "Pneumonoultramicroscopicsilicovolcanoconiosis";
    schema.addStreamStoreDefinition(new StreamStoreDefinitionBuilder(shortName, longName, ValueType.FIXED_LONG_LITTLE_ENDIAN).hashRowComponents().build());
    assertCleanupMetadataCorrectForStreamStore(schema, shortName, 2, ValueType.FIXED_LONG_LITTLE_ENDIAN);
}
Also used : StreamStoreDefinitionBuilder(com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 5 with StreamStoreDefinitionBuilder

use of com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder in project atlasdb by palantir.

the class SchemaTest method streamStoreMetadataGeneratedCorrectlyForStreamStoreWithHashFirstRowComponent.

@Test
public void streamStoreMetadataGeneratedCorrectlyForStreamStoreWithHashFirstRowComponent() {
    Schema schema = new Schema("Table", TEST_PACKAGE, Namespace.EMPTY_NAMESPACE);
    String shortName = "a";
    String longName = "Antidisestablishmentarianism";
    schema.addStreamStoreDefinition(new StreamStoreDefinitionBuilder(shortName, longName, ValueType.FIXED_LONG).hashFirstRowComponent().build());
    assertCleanupMetadataCorrectForStreamStore(schema, shortName, 1, ValueType.FIXED_LONG);
}
Also used : StreamStoreDefinitionBuilder(com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

StreamStoreDefinitionBuilder (com.palantir.atlasdb.schema.stream.StreamStoreDefinitionBuilder)8 Matchers.containsString (org.hamcrest.Matchers.containsString)4 Test (org.junit.Test)4 AtlasSchema (com.palantir.atlasdb.schema.AtlasSchema)3 Schema (com.palantir.atlasdb.table.description.Schema)3 TableDefinition (com.palantir.atlasdb.table.description.TableDefinition)3 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)1 JsonNodePersister (com.palantir.atlasdb.persister.JsonNodePersister)1 StreamStoreDefinition (com.palantir.atlasdb.schema.stream.StreamStoreDefinition)1 IndexDefinition (com.palantir.atlasdb.table.description.IndexDefinition)1