use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class ConsensusCommitUtilsTest method isBeforeImageColumn_PartitionKeyAndClusteringKeyWithBeforePrefixGiven_shouldReturnProperResult.
@Test
public void isBeforeImageColumn_PartitionKeyAndClusteringKeyWithBeforePrefixGiven_shouldReturnProperResult() {
// Arrange
TableMetadata metadata = TableMetadata.newBuilder().addColumn("partitionKey", DataType.INT).addColumn("before_partitionKey", DataType.INT).addColumn("clusteringKey", DataType.INT).addColumn("before_clusteringKey", DataType.INT).addColumn("col", DataType.INT).addColumn(Attribute.ID, DataType.TEXT).addColumn(Attribute.STATE, DataType.INT).addColumn(Attribute.VERSION, DataType.INT).addColumn(Attribute.PREPARED_AT, DataType.BIGINT).addColumn(Attribute.COMMITTED_AT, DataType.BIGINT).addColumn(Attribute.BEFORE_PREFIX + "col", DataType.INT).addColumn(Attribute.BEFORE_ID, DataType.TEXT).addColumn(Attribute.BEFORE_STATE, DataType.INT).addColumn(Attribute.BEFORE_VERSION, DataType.INT).addColumn(Attribute.BEFORE_PREPARED_AT, DataType.BIGINT).addColumn(Attribute.BEFORE_COMMITTED_AT, DataType.BIGINT).addPartitionKey("partitionKey").addPartitionKey("before_partitionKey").addClusteringKey("clusteringKey").addClusteringKey("before_clusteringKey").build();
// Act Assert
assertThat(ConsensusCommitUtils.isBeforeImageColumn("partitionKey", metadata)).isFalse();
assertThat(ConsensusCommitUtils.isBeforeImageColumn("before_partitionKey", metadata)).isFalse();
assertThat(ConsensusCommitUtils.isBeforeImageColumn("clusteringKey", metadata)).isFalse();
assertThat(ConsensusCommitUtils.isBeforeImageColumn("before_clusteringKey", metadata)).isFalse();
assertThat(ConsensusCommitUtils.isBeforeImageColumn("col", metadata)).isFalse();
assertThat(ConsensusCommitUtils.isBeforeImageColumn(Attribute.ID, metadata)).isFalse();
assertThat(ConsensusCommitUtils.isBeforeImageColumn(Attribute.STATE, metadata)).isFalse();
assertThat(ConsensusCommitUtils.isBeforeImageColumn(Attribute.VERSION, metadata)).isFalse();
assertThat(ConsensusCommitUtils.isBeforeImageColumn(Attribute.PREPARED_AT, metadata)).isFalse();
assertThat(ConsensusCommitUtils.isBeforeImageColumn(Attribute.COMMITTED_AT, metadata)).isFalse();
assertThat(ConsensusCommitUtils.isBeforeImageColumn(Attribute.BEFORE_PREFIX + "col", metadata)).isTrue();
assertThat(ConsensusCommitUtils.isBeforeImageColumn(Attribute.BEFORE_ID, metadata)).isTrue();
assertThat(ConsensusCommitUtils.isBeforeImageColumn(Attribute.BEFORE_STATE, metadata)).isTrue();
assertThat(ConsensusCommitUtils.isBeforeImageColumn(Attribute.BEFORE_VERSION, metadata)).isTrue();
assertThat(ConsensusCommitUtils.isBeforeImageColumn(Attribute.BEFORE_PREPARED_AT, metadata)).isTrue();
assertThat(ConsensusCommitUtils.isBeforeImageColumn(Attribute.BEFORE_COMMITTED_AT, metadata)).isTrue();
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class TwoPhaseConsensusCommitSpecificIntegrationTestBase method createTables.
private void createTables() throws ExecutionException {
Map<String, String> options = getCreateOptions();
TableMetadata tableMetadata = TableMetadata.newBuilder().addColumn(ACCOUNT_ID, DataType.INT).addColumn(ACCOUNT_TYPE, DataType.INT).addColumn(BALANCE, DataType.INT).addPartitionKey(ACCOUNT_ID).addClusteringKey(ACCOUNT_TYPE).build();
admin.createNamespace(namespace, true, options);
consensusCommitAdmin.createTable(namespace, TABLE_1, tableMetadata, true, options);
consensusCommitAdmin.createTable(namespace, TABLE_2, tableMetadata, true, options);
consensusCommitAdmin.createCoordinatorTables(true, options);
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class MultiStorageAdminIntegrationTest method getTableMetadata_ForWrongTable_ShouldReturnNull.
@Test
public void getTableMetadata_ForWrongTable_ShouldReturnNull() throws ExecutionException {
// Arrange
String namespace = "wrong_ns";
String table = "wrong_table";
// Act
TableMetadata tableMetadata = multiStorageAdmin.getTableMetadata(namespace, table);
// Assert
assertThat(tableMetadata).isNull();
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class MultiStorageAdminIntegrationTest method initAdmin1.
private void initAdmin1() throws ExecutionException {
StorageFactory factory = StorageFactory.create(MultiStorageEnv.getPropertiesForStorage1());
admin1 = factory.getAdmin();
// create tables
admin1.createNamespace(NAMESPACE1, true);
TableMetadata tableMetadata = TableMetadata.newBuilder().addPartitionKey(COL_NAME1).addClusteringKey(COL_NAME4).addColumn(COL_NAME1, DataType.INT).addColumn(COL_NAME2, DataType.TEXT).addColumn(COL_NAME3, DataType.INT).addColumn(COL_NAME4, DataType.INT).addColumn(COL_NAME5, DataType.BOOLEAN).build();
for (String table : Arrays.asList(TABLE1, TABLE2, TABLE3)) {
admin1.createTable(NAMESPACE1, table, tableMetadata, true);
}
admin1.createNamespace(NAMESPACE2, true);
admin1.createTable(NAMESPACE2, TABLE1, tableMetadata, true);
}
use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.
the class MultiStorageAdminIntegrationTest method initAdmin2.
private void initAdmin2() throws ExecutionException {
StorageFactory factory = StorageFactory.create(MultiStorageEnv.getPropertiesForStorage2());
admin2 = factory.getAdmin();
// create tables
admin2.createNamespace(NAMESPACE1, true);
TableMetadata tableMetadata = TableMetadata.newBuilder().addColumn(COL_NAME1, DataType.TEXT).addColumn(COL_NAME2, DataType.INT).addColumn(COL_NAME3, DataType.BOOLEAN).addPartitionKey(COL_NAME1).build();
for (String table : Arrays.asList(TABLE1, TABLE2, TABLE3)) {
admin2.createTable(NAMESPACE1, table, tableMetadata, true);
}
admin2.createNamespace(NAMESPACE2, true);
admin2.createTable(NAMESPACE2, TABLE1, tableMetadata, true);
}
Aggregations