Search in sources :

Example 86 with TableMetadata

use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.

the class MultiStorageAdminIntegrationTest method getTableMetadata_ForTable2InNamespace1_ShouldReturnMetadataFromStorage2.

@Test
public void getTableMetadata_ForTable2InNamespace1_ShouldReturnMetadataFromStorage2() throws ExecutionException {
    // Arrange
    String namespace = NAMESPACE1;
    String table = TABLE2;
    // Act
    TableMetadata tableMetadata = multiStorageAdmin.getTableMetadata(namespace, table);
    // Assert
    assertThat(tableMetadata).isNotNull();
    assertThat(tableMetadata.getPartitionKeyNames().size()).isEqualTo(1);
    assertThat(tableMetadata.getPartitionKeyNames().iterator().next()).isEqualTo(COL_NAME1);
    assertThat(tableMetadata.getClusteringKeyNames()).isEmpty();
    assertThat(tableMetadata.getColumnNames().size()).isEqualTo(3);
    assertThat(tableMetadata.getColumnNames().contains(COL_NAME1)).isTrue();
    assertThat(tableMetadata.getColumnNames().contains(COL_NAME2)).isTrue();
    assertThat(tableMetadata.getColumnNames().contains(COL_NAME3)).isTrue();
    assertThat(tableMetadata.getColumnDataType(COL_NAME1)).isEqualTo(DataType.TEXT);
    assertThat(tableMetadata.getColumnDataType(COL_NAME2)).isEqualTo(DataType.INT);
    assertThat(tableMetadata.getColumnDataType(COL_NAME3)).isEqualTo(DataType.BOOLEAN);
    assertThat(tableMetadata.getClusteringOrder(COL_NAME1)).isNull();
    assertThat(tableMetadata.getClusteringOrder(COL_NAME2)).isNull();
    assertThat(tableMetadata.getClusteringOrder(COL_NAME3)).isNull();
    assertThat(tableMetadata.getSecondaryIndexNames()).isEmpty();
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata) Test(org.junit.jupiter.api.Test)

Example 87 with TableMetadata

use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.

the class MultiStorageAdminIntegrationTest method getTableMetadata_ForTable1InNamespace2_ShouldReturnMetadataFromStorage2.

@Test
public void getTableMetadata_ForTable1InNamespace2_ShouldReturnMetadataFromStorage2() throws ExecutionException {
    // Arrange
    String namespace = NAMESPACE2;
    String table = TABLE1;
    // Act
    TableMetadata tableMetadata = multiStorageAdmin.getTableMetadata(namespace, table);
    // Assert
    assertThat(tableMetadata).isNotNull();
    assertThat(tableMetadata.getPartitionKeyNames().size()).isEqualTo(1);
    assertThat(tableMetadata.getPartitionKeyNames().iterator().next()).isEqualTo(COL_NAME1);
    assertThat(tableMetadata.getClusteringKeyNames()).isEmpty();
    assertThat(tableMetadata.getColumnNames().size()).isEqualTo(3);
    assertThat(tableMetadata.getColumnNames().contains(COL_NAME1)).isTrue();
    assertThat(tableMetadata.getColumnNames().contains(COL_NAME2)).isTrue();
    assertThat(tableMetadata.getColumnNames().contains(COL_NAME3)).isTrue();
    assertThat(tableMetadata.getColumnDataType(COL_NAME1)).isEqualTo(DataType.TEXT);
    assertThat(tableMetadata.getColumnDataType(COL_NAME2)).isEqualTo(DataType.INT);
    assertThat(tableMetadata.getColumnDataType(COL_NAME3)).isEqualTo(DataType.BOOLEAN);
    assertThat(tableMetadata.getClusteringOrder(COL_NAME1)).isNull();
    assertThat(tableMetadata.getClusteringOrder(COL_NAME2)).isNull();
    assertThat(tableMetadata.getClusteringOrder(COL_NAME3)).isNull();
    assertThat(tableMetadata.getSecondaryIndexNames()).isEmpty();
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata) Test(org.junit.jupiter.api.Test)

Example 88 with TableMetadata

use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.

the class CosmosAdmin method dropIndex.

@Override
public void dropIndex(String namespace, String table, String columnName) throws ExecutionException {
    TableMetadata tableMetadata = getTableMetadata(namespace, table);
    TableMetadata newTableMetadata = TableMetadata.newBuilder(tableMetadata).removeSecondaryIndex(columnName).build();
    updateIndexingPolicy(namespace, table, newTableMetadata);
    // update metadata
    putTableMetadata(namespace, table, newTableMetadata);
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata)

Example 89 with TableMetadata

use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.

the class OperationChecker method check.

public void check(Put put) throws ExecutionException {
    TableMetadata metadata = getMetadata(put);
    checkPrimaryKey(put, metadata);
    checkColumnsInPut(put, metadata);
    checkCondition(put, metadata);
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata)

Example 90 with TableMetadata

use of com.scalar.db.api.TableMetadata in project scalardb by scalar-labs.

the class OperationChecker method check.

public void check(ScanAll scanAll) throws ExecutionException {
    TableMetadata metadata = getMetadata(scanAll);
    checkProjections(scanAll, metadata);
    if (scanAll.getLimit() < 0) {
        throw new IllegalArgumentException("The limit cannot be negative. Operation: " + scanAll);
    }
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata)

Aggregations

TableMetadata (com.scalar.db.api.TableMetadata)101 Test (org.junit.jupiter.api.Test)39 Get (com.scalar.db.api.Get)11 PreparedStatement (java.sql.PreparedStatement)10 ExecutionException (com.scalar.db.exception.storage.ExecutionException)9 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 Key (com.scalar.db.io.Key)6 DynamoDbException (software.amazon.awssdk.services.dynamodb.model.DynamoDbException)6 Mutation (com.scalar.db.api.Mutation)5 Result (com.scalar.db.api.Result)5 GetTableMetadataResponse (com.scalar.db.rpc.GetTableMetadataResponse)5 ResultSet (java.sql.ResultSet)5 Nonnull (javax.annotation.Nonnull)5 HashMap (java.util.HashMap)4 Options (com.datastax.driver.core.schemabuilder.Create.Options)3 KeyspaceOptions (com.datastax.driver.core.schemabuilder.KeyspaceOptions)3 TableOptions (com.datastax.driver.core.schemabuilder.TableOptions)3 ScanAll (com.scalar.db.api.ScanAll)3 NoMutationException (com.scalar.db.exception.storage.NoMutationException)3