use of com.scalar.db.api.Scan.Ordering.Order in project scalardb by scalar-labs.
the class KeyBytesEncoderTest method encode_DoubleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder.
@Test
public void encode_DoubleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder() {
RANDOM.setSeed(seed);
runTest(() -> {
for (DataType col1Type : KEY_TYPES) {
// the BLOB type is supported only for the last key
if (col1Type == DataType.BLOB) {
continue;
}
for (DataType col2Type : KEY_TYPES) {
for (Order col1Order : ORDERS) {
for (Order col2Order : ORDERS) {
encode_DoubleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder(col1Type, col2Type, col1Order, col2Order);
}
}
}
}
});
}
use of com.scalar.db.api.Scan.Ordering.Order in project scalardb by scalar-labs.
the class KeyBytesEncoderTest method encode_TripleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder.
@Test
public void encode_TripleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder() {
RANDOM.setSeed(seed);
runTest(() -> {
for (DataType col1Type : KEY_TYPES) {
// the BLOB type is supported only for the last key
if (col1Type == DataType.BLOB) {
continue;
}
for (DataType col2Type : KEY_TYPES) {
// the BLOB type is supported only for the last key
if (col2Type == DataType.BLOB) {
continue;
}
for (DataType col3Type : KEY_TYPES) {
for (Order col1Order : ORDERS) {
for (Order col2Order : ORDERS) {
for (Order col3Order : ORDERS) {
encode_TripleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder(col1Type, col2Type, col3Type, col1Order, col2Order, col3Order);
}
}
}
}
}
}
});
}
use of com.scalar.db.api.Scan.Ordering.Order in project scalardb by scalar-labs.
the class KeyBytesEncoderTest method encode_DoubleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder.
private void encode_DoubleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder(DataType col1Type, DataType col2Type, Order col1Order, Order col2Order) {
// Arrange
// Add min and max values and random values
List<Key> target = new ArrayList<>(KEY_ELEMENT_COUNT);
target.add(new Key(getMinValue(COL1, col1Type), getMinValue(COL2, col2Type)));
target.add(new Key(getMaxValue(COL1, col1Type), getMaxValue(COL2, col2Type)));
for (int i = 0; i < KEY_ELEMENT_COUNT - 2; i++) {
target.add(new Key(getRandomValue(COL1, col1Type, col1Order), getRandomValue(COL2, col2Type, col2Order)));
}
Map<String, Order> keyOrders = new HashMap<>();
keyOrders.put(COL1, col1Order);
keyOrders.put(COL2, col2Order);
// Act
List<Key> actual = sortWithKeyBytesEncoder(target, keyOrders);
List<Key> expected = target.stream().sorted(getComparator(keyOrders)).collect(Collectors.toList());
// Assert
assertThat(actual).isEqualTo(expected);
}
use of com.scalar.db.api.Scan.Ordering.Order in project scalardb by scalar-labs.
the class DistributedStorageMultipleClusteringKeyScanIntegrationTestBase method dropTables.
private void dropTables() throws java.util.concurrent.ExecutionException, InterruptedException {
List<Callable<Void>> testCallables = new ArrayList<>();
for (DataType firstClusteringKeyType : clusteringKeyTypes.keySet()) {
Callable<Void> testCallable = () -> {
for (DataType secondClusteringKeyType : clusteringKeyTypes.get(firstClusteringKeyType)) {
for (Order firstClusteringOrder : Order.values()) {
for (Order secondClusteringOrder : Order.values()) {
admin.dropTable(getNamespaceName(firstClusteringKeyType), getTableName(firstClusteringKeyType, firstClusteringOrder, secondClusteringKeyType, secondClusteringOrder));
}
}
}
admin.dropNamespace(getNamespaceName(firstClusteringKeyType));
return null;
};
testCallables.add(testCallable);
}
// We firstly execute the callables without the last one. And then we execute the last one. This
// is because the last table deletion deletes the metadata table, and this process can't be
// handled in multiple threads/processes at the same time.
executeInParallel(testCallables.subList(0, testCallables.size() - 1));
executeInParallel(testCallables.subList(testCallables.size() - 1, testCallables.size()));
}
use of com.scalar.db.api.Scan.Ordering.Order in project scalardb by scalar-labs.
the class DistributedStorageSingleClusteringKeyScanIntegrationTestBase method scan_WithoutClusteringKeyRange_ShouldReturnProperResult.
@Test
public void scan_WithoutClusteringKeyRange_ShouldReturnProperResult() throws ExecutionException, IOException {
for (DataType clusteringKeyType : clusteringKeyTypes) {
for (Order clusteringOrder : Order.values()) {
truncateTable(clusteringKeyType, clusteringOrder);
List<Value<?>> clusteringKeyValues = prepareRecords(clusteringKeyType, clusteringOrder);
for (OrderingType orderingType : OrderingType.values()) {
for (boolean withLimit : Arrays.asList(false, true)) {
scan_WithoutClusteringKeyRange_ShouldReturnProperResult(clusteringKeyValues, clusteringKeyType, clusteringOrder, orderingType, withLimit);
}
}
}
}
}
Aggregations