use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class DistributedStorageIntegrationTestBase method scan_ScanWithLimitGiven_ShouldReturnGivenNumberOfResults.
@Test
public void scan_ScanWithLimitGiven_ShouldReturnGivenNumberOfResults() throws IOException, ExecutionException {
// setup
List<Put> puts = preparePuts();
storage.mutate(Arrays.asList(puts.get(0), puts.get(1), puts.get(2)));
Scan scan = new Scan(new Key(COL_NAME1, 0)).withOrdering(new Scan.Ordering(COL_NAME4, Scan.Ordering.Order.DESC)).withLimit(1);
// exercise
List<Result> actual = scanAll(scan);
// verify
assertThat(actual.size()).isEqualTo(1);
assertThat(actual.get(0).getValue(COL_NAME4)).isEqualTo(Optional.of(new IntValue(COL_NAME4, 2)));
}
use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class DistributedStorageIntegrationTestBase method scan_ScanWithOrderAscGiven_ShouldReturnAscendingOrderedResults.
@Test
public void scan_ScanWithOrderAscGiven_ShouldReturnAscendingOrderedResults() throws IOException, ExecutionException {
// Arrange
List<Put> puts = preparePuts();
storage.mutate(Arrays.asList(puts.get(0), puts.get(1), puts.get(2)));
Scan scan = new Scan(new Key(COL_NAME1, 0)).withOrdering(new Scan.Ordering(COL_NAME4, Scan.Ordering.Order.ASC));
// Act
List<Result> actual = scanAll(scan);
// Assert
assertThat(actual.size()).isEqualTo(3);
assertThat(actual.get(0).getValue(COL_NAME4)).isEqualTo(Optional.of(new IntValue(COL_NAME4, 0)));
assertThat(actual.get(1).getValue(COL_NAME4)).isEqualTo(Optional.of(new IntValue(COL_NAME4, 1)));
assertThat(actual.get(2).getValue(COL_NAME4)).isEqualTo(Optional.of(new IntValue(COL_NAME4, 2)));
}
use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class DistributedStorageWithReservedKeywordIntegrationTestBase method get_WithReservedKeywordAndGetGivenForIndexedColumn_ShouldGet.
@Test
public void get_WithReservedKeywordAndGetGivenForIndexedColumn_ShouldGet() throws ExecutionException {
// Arrange
// (0,0)
storage.put(preparePuts().get(0));
int c3 = 0;
Get get = new Get(new Key(columnName3, c3));
// Act
Optional<Result> actual = storage.get(get);
// Assert
assertThat(actual.isPresent()).isTrue();
assertThat(actual.get().getValue(columnName1)).isEqualTo(Optional.of(new IntValue(columnName1, 0)));
assertThat(actual.get().getValue(columnName4)).isEqualTo(Optional.of(new IntValue(columnName4, 0)));
}
use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class DistributedStorageWithReservedKeywordIntegrationTestBase method put_PutWithReservedKeywordAndIfGivenWhenSuchRecordExists_ShouldUpdateRecord.
@Test
public void put_PutWithReservedKeywordAndIfGivenWhenSuchRecordExists_ShouldUpdateRecord() throws ExecutionException {
// Arrange
int pKey = 0;
int cKey = 0;
List<Put> puts = preparePuts();
Get get = prepareGet(pKey, cKey);
// Act Assert
storage.put(puts.get(0));
puts.get(0).withCondition(new PutIf(new ConditionalExpression(columnName3, new IntValue(pKey + cKey), ConditionalExpression.Operator.EQ)));
puts.get(0).withValue(columnName3, Integer.MAX_VALUE);
assertThatCode(() -> storage.put(puts.get(0))).doesNotThrowAnyException();
// Assert
Optional<Result> actual = storage.get(get);
assertThat(actual.isPresent()).isTrue();
Result result = actual.get();
assertThat(result.getValue(columnName1)).isEqualTo(Optional.of(new IntValue(columnName1, pKey)));
assertThat(result.getValue(columnName4)).isEqualTo(Optional.of(new IntValue(columnName4, cKey)));
assertThat(result.getValue(columnName3)).isEqualTo(Optional.of(new IntValue(columnName3, Integer.MAX_VALUE)));
}
use of com.scalar.db.io.IntValue in project scalardb by scalar-labs.
the class DistributedStorageWithReservedKeywordIntegrationTestBase method put_WithReservedKeywordAndSinglePutGiven_ShouldStoreProperly.
@Test
public void put_WithReservedKeywordAndSinglePutGiven_ShouldStoreProperly() throws ExecutionException {
// Arrange
int pKey = 0;
int cKey = 0;
List<Put> puts = preparePuts();
Key partitionKey = new Key(columnName1, pKey);
Key clusteringKey = new Key(columnName4, cKey);
Get get = new Get(partitionKey, clusteringKey);
// Act
storage.put(puts.get(pKey * 2 + cKey));
// Assert
Optional<Result> actual = storage.get(get);
assertThat(actual.isPresent()).isTrue();
assertThat(actual.get().getValue(columnName1)).isEqualTo(Optional.of(new IntValue(columnName1, pKey)));
assertThat(actual.get().getValue(columnName2)).isEqualTo(Optional.of(new TextValue(columnName2, Integer.toString(pKey + cKey))));
assertThat(actual.get().getValue(columnName3)).isEqualTo(Optional.of(new IntValue(columnName3, pKey + cKey)));
assertThat(actual.get().getValue(columnName4)).isEqualTo(Optional.of(new IntValue(columnName4, cKey)));
assertThat(actual.get().getValue(columnName5)).isEqualTo(Optional.of(new BooleanValue(columnName5, cKey % 2 == 0)));
}
Aggregations