use of com.scalar.db.api.Scan.Ordering.Order in project scalardb by scalar-labs.
the class DistributedStorageSingleClusteringKeyScanIntegrationTestBase method scan_WithClusteringKeyRangeWithSameValues_ShouldReturnProperResult.
@Test
public void scan_WithClusteringKeyRangeWithSameValues_ShouldReturnProperResult() throws ExecutionException, IOException {
for (DataType clusteringKeyType : clusteringKeyTypes) {
for (Order clusteringOrder : Order.values()) {
truncateTable(clusteringKeyType, clusteringOrder);
List<Value<?>> clusteringKeyValues = prepareRecords(clusteringKeyType, clusteringOrder);
for (boolean startInclusive : Arrays.asList(true, false)) {
for (boolean endInclusive : Arrays.asList(true, false)) {
for (OrderingType orderingType : OrderingType.values()) {
for (boolean withLimit : Arrays.asList(false, true)) {
scan_WithClusteringKeyRangeWithSameValues_ShouldReturnProperResult(clusteringKeyValues, clusteringKeyType, clusteringOrder, startInclusive, endInclusive, orderingType, withLimit);
}
}
}
}
}
}
}
use of com.scalar.db.api.Scan.Ordering.Order in project scalardb by scalar-labs.
the class DistributedStorageSingleClusteringKeyScanIntegrationTestBase method scan_WithClusteringKeyRangeWithMinAndMaxValue_ShouldReturnProperResult.
@Test
public void scan_WithClusteringKeyRangeWithMinAndMaxValue_ShouldReturnProperResult() throws ExecutionException, IOException {
for (DataType clusteringKeyType : clusteringKeyTypes) {
for (Order clusteringOrder : Order.values()) {
truncateTable(clusteringKeyType, clusteringOrder);
List<Value<?>> clusteringKeyValues = prepareRecords(clusteringKeyType, clusteringOrder);
for (boolean startInclusive : Arrays.asList(true, false)) {
for (boolean endInclusive : Arrays.asList(true, false)) {
for (OrderingType orderingType : OrderingType.values()) {
for (boolean withLimit : Arrays.asList(false, true)) {
scan_WithClusteringKeyRangeWithMinAndMaxValue_ShouldReturnProperResult(clusteringKeyValues, clusteringKeyType, clusteringOrder, startInclusive, endInclusive, orderingType, withLimit);
}
}
}
}
}
}
}
use of com.scalar.db.api.Scan.Ordering.Order in project scalardb by scalar-labs.
the class KeyBytesEncoderTest method encode_SingleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder.
private void encode_SingleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder(DataType col1Type, Order col1Order) {
// Arrange
// Add min and max values and random values
List<Key> target = new ArrayList<>(KEY_ELEMENT_COUNT);
target.add(new Key(getMinValue(COL1, col1Type)));
target.add(new Key(getMaxValue(COL1, col1Type)));
for (int i = 0; i < KEY_ELEMENT_COUNT - 2; i++) {
target.add(new Key(getRandomValue(COL1, col1Type, col1Order)));
}
Map<String, Order> keyOrders = new HashMap<>();
keyOrders.put(COL1, col1Order);
// 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 KeyBytesEncoderTest method encode_TripleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder.
private void encode_TripleKeysGiven_ShouldEncodeProperlyWithPreservingSortOrder(DataType col1Type, DataType col2Type, DataType col3Type, Order col1Order, Order col2Order, Order col3Order) {
// 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), getMinValue(COL3, col3Type)));
target.add(new Key(getMaxValue(COL1, col1Type), getMaxValue(COL2, col2Type), getMaxValue(COL3, col3Type)));
for (int i = 0; i < KEY_ELEMENT_COUNT - 2; i++) {
target.add(new Key(getRandomValue(COL1, col1Type, col1Order), getRandomValue(COL2, col2Type, col2Order), getRandomValue(COL3, col3Type, col3Order)));
}
Map<String, Order> keyOrders = new HashMap<>();
keyOrders.put(COL1, col1Order);
keyOrders.put(COL2, col2Order);
keyOrders.put(COL3, col3Order);
// 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 KeyBytesEncoderTest method sortWithKeyBytesEncoder.
private static List<Key> sortWithKeyBytesEncoder(List<Key> target, Map<String, Order> keyOrders) {
List<Element> list = new ArrayList<>();
for (Key key : target) {
ByteBuffer byteBuffer = new KeyBytesEncoder().encode(key, keyOrders);
list.add(new Element(byteBuffer, key));
}
return list.stream().sorted().map(e -> e.key).collect(Collectors.toList());
}
Aggregations