use of com.apple.foundationdb.record.metadata.expressions.KeyExpression in project fdb-record-layer by FoundationDB.
the class KeyExpressionTest method testList.
@Test
public void testList() throws Exception {
final KeyExpression list = list(field("field"), field("repeat_me", FanType.Concatenate));
list.validate(TestScalarFieldAccess.getDescriptor());
assertEquals(Collections.singletonList(concatenate(scalar("Plants").values(), scalar(concatenate("Boxes", "Bowls").values()).values())), evaluate(list, plantsBoxesAndBowls));
}
use of com.apple.foundationdb.record.metadata.expressions.KeyExpression in project fdb-record-layer by FoundationDB.
the class KeyExpressionTest method testNestedRepeats.
@Test
public void testNestedRepeats() throws Exception {
final KeyExpression expression = field("repeated_nesty", FanType.FanOut).nest("regular_old_field");
expression.validate(NestedField.getDescriptor());
assertTrue(expression.createsDuplicates());
assertEquals(Arrays.asList(scalar("Daughter"), scalar("Sister")), evaluate(expression, matryoshkaDolls));
assertEquals(Collections.emptyList(), evaluate(expression, emptyNested));
assertEquals(Arrays.asList(Key.Evaluated.NULL, Key.Evaluated.NULL), evaluate(expression, lonelyDoll));
assertEquals(Collections.emptyList(), evaluate(expression, null));
}
use of com.apple.foundationdb.record.metadata.expressions.KeyExpression in project fdb-record-layer by FoundationDB.
the class KeyExpressionTest method testFanSingleRepeatedField.
@Test
public void testFanSingleRepeatedField() throws Exception {
final KeyExpression expression = field("repeat_me", FanType.FanOut);
expression.validate(TestScalarFieldAccess.getDescriptor());
assertTrue(expression.createsDuplicates());
assertEquals(Arrays.asList(scalar("Boxes"), scalar("Bowls")), evaluate(expression, plantsBoxesAndBowls));
assertEquals(Collections.emptyList(), evaluate(expression, emptyScalar));
assertEquals(Collections.emptyList(), evaluate(expression, null));
}
use of com.apple.foundationdb.record.metadata.expressions.KeyExpression in project fdb-record-layer by FoundationDB.
the class KeyExpressionTest method testFunctions.
@Test
public void testFunctions() throws Exception {
final KeyExpression expression = function("substr", concat(field("field"), value(0), value(2)));
expression.validate(TestScalarFieldAccess.getDescriptor());
assertEquals(Collections.singletonList(scalar("Pl")), evaluate(expression, plantsBoxesAndBowls));
assertEquals(Collections.singletonList(Key.Evaluated.NULL), evaluate(expression, emptyScalar));
assertEquals(Collections.singletonList(Key.Evaluated.NULL), evaluate(expression, null));
}
use of com.apple.foundationdb.record.metadata.expressions.KeyExpression in project fdb-record-layer by FoundationDB.
the class KeyExpressionTest method testNestedScalars.
@Test
public void testNestedScalars() throws Exception {
final KeyExpression expression = field("nesty").nest("regular_old_field");
expression.validate(NestedField.getDescriptor());
assertFalse(expression.createsDuplicates());
assertEquals(Collections.singletonList(scalar("Mother")), evaluate(expression, matryoshkaDolls));
assertEquals(Collections.singletonList(Key.Evaluated.NULL), evaluate(expression, emptyNested));
assertEquals(Collections.singletonList(Key.Evaluated.NULL), evaluate(expression, lonelyDoll));
assertEquals(Collections.singletonList(Key.Evaluated.NULL), evaluate(expression, null));
}
Aggregations