use of com.scalar.db.api.Result in project scalardb by scalar-labs.
the class AbstractResult method equals.
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Result)) {
return false;
}
Result other = (Result) o;
if (!getContainedColumnNames().equals(other.getContainedColumnNames())) {
return false;
}
for (String containedColumnName : getContainedColumnNames()) {
Object value = getAsObject(containedColumnName);
Object otherValue = other.getAsObject(containedColumnName);
if (value == null && otherValue == null) {
continue;
}
if (value == null || otherValue == null) {
return false;
}
if (!value.equals(otherValue)) {
return false;
}
}
return true;
}
use of com.scalar.db.api.Result in project scalardb by scalar-labs.
the class StorageMultipleClusteringKeyScanIntegrationTestBase method scan_WithSecondClusteringKeyRangeWithSameValues_ShouldReturnProperResult.
private void scan_WithSecondClusteringKeyRangeWithSameValues_ShouldReturnProperResult(List<ClusteringKey> clusteringKeys, DataType firstClusteringKeyType, Order firstClusteringOrder, DataType secondClusteringKeyType, Order secondClusteringOrder, boolean startInclusive, boolean endInclusive, OrderingType orderingType, boolean withLimit) throws ExecutionException, IOException {
// Arrange
if (firstClusteringKeyType == DataType.BOOLEAN) {
Value<?> firstClusteringKeyValue = clusteringKeys.get(0).first;
clusteringKeys = clusteringKeys.stream().filter(c -> c.first.equals(firstClusteringKeyValue)).collect(Collectors.toList());
} else {
Value<?> firstClusteringKeyValue = clusteringKeys.get(getFirstClusteringKeyIndex(2, secondClusteringKeyType)).first;
clusteringKeys = clusteringKeys.stream().filter(c -> c.first.equals(firstClusteringKeyValue)).collect(Collectors.toList());
}
ClusteringKey startAndEndClusteringKey;
if (secondClusteringKeyType == DataType.BOOLEAN) {
startAndEndClusteringKey = new ClusteringKey(clusteringKeys.get(0).first, clusteringKeys.get(0).second);
} else {
startAndEndClusteringKey = new ClusteringKey(clusteringKeys.get(9).first, clusteringKeys.get(9).second);
}
List<ClusteringKey> expected = getExpected(clusteringKeys, startAndEndClusteringKey, startInclusive, startAndEndClusteringKey, endInclusive, orderingType);
int limit = getLimit(withLimit, expected);
if (limit > 0) {
expected = expected.subList(0, limit);
}
Scan scan = getScan(firstClusteringKeyType, firstClusteringOrder, secondClusteringKeyType, secondClusteringOrder, startAndEndClusteringKey, startInclusive, startAndEndClusteringKey, endInclusive, orderingType, limit);
// Act
List<Result> actual = scanAll(scan);
// Assert
assertScanResult(actual, expected, description(firstClusteringKeyType, firstClusteringOrder, secondClusteringKeyType, secondClusteringOrder, startInclusive, endInclusive, orderingType, withLimit));
}
use of com.scalar.db.api.Result in project scalardb by scalar-labs.
the class StorageMultipleClusteringKeyScanIntegrationTestBase method scan_WithFirstClusteringKeyEndRange_ShouldReturnProperResult.
private void scan_WithFirstClusteringKeyEndRange_ShouldReturnProperResult(List<ClusteringKey> clusteringKeys, DataType firstClusteringKeyType, Order firstClusteringOrder, boolean endInclusive, OrderingType orderingType, boolean withLimit) throws ExecutionException, IOException {
// Arrange
ClusteringKey endClusteringKey;
if (firstClusteringKeyType == DataType.BOOLEAN) {
endClusteringKey = new ClusteringKey(clusteringKeys.get(getFirstClusteringKeyIndex(1, DataType.INT)).first);
} else {
endClusteringKey = new ClusteringKey(clusteringKeys.get(getFirstClusteringKeyIndex(3, DataType.INT)).first);
}
List<ClusteringKey> expected = getExpected(clusteringKeys, null, null, endClusteringKey, endInclusive, orderingType);
int limit = getLimit(withLimit, expected);
if (limit > 0) {
expected = expected.subList(0, limit);
}
Scan scan = getScan(firstClusteringKeyType, firstClusteringOrder, DataType.INT, Order.ASC, null, null, endClusteringKey, endInclusive, orderingType, limit);
// Act
List<Result> actual = scanAll(scan);
// Assert
assertScanResult(actual, expected, description(firstClusteringKeyType, firstClusteringOrder, null, null, null, endInclusive, orderingType, withLimit));
}
use of com.scalar.db.api.Result in project scalardb by scalar-labs.
the class StorageMultipleClusteringKeyScanIntegrationTestBase method scan_WithFirstClusteringKeyRangeWithSameValues_ShouldReturnProperResult.
private void scan_WithFirstClusteringKeyRangeWithSameValues_ShouldReturnProperResult(List<ClusteringKey> clusteringKeys, DataType firstClusteringKeyType, Order firstClusteringOrder, boolean startInclusive, boolean endInclusive, OrderingType orderingType, boolean withLimit) throws ExecutionException, IOException {
// Arrange
ClusteringKey startAndEndClusteringKey;
if (firstClusteringKeyType == DataType.BOOLEAN) {
startAndEndClusteringKey = new ClusteringKey(clusteringKeys.get(getFirstClusteringKeyIndex(0, DataType.INT)).first);
} else {
startAndEndClusteringKey = new ClusteringKey(clusteringKeys.get(getFirstClusteringKeyIndex(2, DataType.INT)).first);
}
List<ClusteringKey> expected = getExpected(clusteringKeys, startAndEndClusteringKey, startInclusive, startAndEndClusteringKey, endInclusive, orderingType);
int limit = getLimit(withLimit, expected);
if (limit > 0) {
expected = expected.subList(0, limit);
}
Scan scan = getScan(firstClusteringKeyType, firstClusteringOrder, DataType.INT, Order.ASC, startAndEndClusteringKey, startInclusive, startAndEndClusteringKey, endInclusive, orderingType, limit);
// Act
List<Result> actual = scanAll(scan);
// Assert
assertScanResult(actual, expected, description(firstClusteringKeyType, firstClusteringOrder, null, null, startInclusive, endInclusive, orderingType, withLimit));
}
use of com.scalar.db.api.Result in project scalardb by scalar-labs.
the class StorageMultipleClusteringKeyScanIntegrationTestBase method scan_WithSecondClusteringKeyStartRangeWithMinValue_ShouldReturnProperResult.
private void scan_WithSecondClusteringKeyStartRangeWithMinValue_ShouldReturnProperResult(List<ClusteringKey> clusteringKeys, DataType firstClusteringKeyType, Order firstClusteringOrder, DataType secondClusteringKeyType, Order secondClusteringOrder, boolean startInclusive, OrderingType orderingType, boolean withLimit) throws ExecutionException, IOException {
// Arrange
Value<?> firstClusteringKeyValue = getMinValue(FIRST_CLUSTERING_KEY, firstClusteringKeyType);
clusteringKeys = clusteringKeys.stream().filter(c -> c.first.equals(firstClusteringKeyValue)).collect(Collectors.toList());
ClusteringKey startClusteringKey = new ClusteringKey(firstClusteringKeyValue, getMinValue(SECOND_CLUSTERING_KEY, secondClusteringKeyType));
List<ClusteringKey> expected = getExpected(clusteringKeys, startClusteringKey, startInclusive, null, null, orderingType);
int limit = getLimit(withLimit, expected);
if (limit > 0) {
expected = expected.subList(0, limit);
}
Scan scan = getScan(firstClusteringKeyType, firstClusteringOrder, secondClusteringKeyType, secondClusteringOrder, startClusteringKey, startInclusive, null, null, orderingType, limit);
// Act
List<Result> actual = scanAll(scan);
// Assert
assertScanResult(actual, expected, description(firstClusteringKeyType, firstClusteringOrder, secondClusteringKeyType, secondClusteringOrder, startInclusive, null, orderingType, withLimit));
}
Aggregations