Search in sources :

Example 76 with KeyExpression

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));
}
Also used : ListKeyExpression(com.apple.foundationdb.record.metadata.expressions.ListKeyExpression) GroupingKeyExpression(com.apple.foundationdb.record.metadata.expressions.GroupingKeyExpression) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) QueryableKeyExpression(com.apple.foundationdb.record.metadata.expressions.QueryableKeyExpression) FunctionKeyExpression(com.apple.foundationdb.record.metadata.expressions.FunctionKeyExpression) FieldKeyExpression(com.apple.foundationdb.record.metadata.expressions.FieldKeyExpression) NestingKeyExpression(com.apple.foundationdb.record.metadata.expressions.NestingKeyExpression) SplitKeyExpression(com.apple.foundationdb.record.metadata.expressions.SplitKeyExpression) EmptyKeyExpression(com.apple.foundationdb.record.metadata.expressions.EmptyKeyExpression) ThenKeyExpression(com.apple.foundationdb.record.metadata.expressions.ThenKeyExpression) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 77 with KeyExpression

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));
}
Also used : ListKeyExpression(com.apple.foundationdb.record.metadata.expressions.ListKeyExpression) GroupingKeyExpression(com.apple.foundationdb.record.metadata.expressions.GroupingKeyExpression) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) QueryableKeyExpression(com.apple.foundationdb.record.metadata.expressions.QueryableKeyExpression) FunctionKeyExpression(com.apple.foundationdb.record.metadata.expressions.FunctionKeyExpression) FieldKeyExpression(com.apple.foundationdb.record.metadata.expressions.FieldKeyExpression) NestingKeyExpression(com.apple.foundationdb.record.metadata.expressions.NestingKeyExpression) SplitKeyExpression(com.apple.foundationdb.record.metadata.expressions.SplitKeyExpression) EmptyKeyExpression(com.apple.foundationdb.record.metadata.expressions.EmptyKeyExpression) ThenKeyExpression(com.apple.foundationdb.record.metadata.expressions.ThenKeyExpression) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 78 with KeyExpression

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));
}
Also used : ListKeyExpression(com.apple.foundationdb.record.metadata.expressions.ListKeyExpression) GroupingKeyExpression(com.apple.foundationdb.record.metadata.expressions.GroupingKeyExpression) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) QueryableKeyExpression(com.apple.foundationdb.record.metadata.expressions.QueryableKeyExpression) FunctionKeyExpression(com.apple.foundationdb.record.metadata.expressions.FunctionKeyExpression) FieldKeyExpression(com.apple.foundationdb.record.metadata.expressions.FieldKeyExpression) NestingKeyExpression(com.apple.foundationdb.record.metadata.expressions.NestingKeyExpression) SplitKeyExpression(com.apple.foundationdb.record.metadata.expressions.SplitKeyExpression) EmptyKeyExpression(com.apple.foundationdb.record.metadata.expressions.EmptyKeyExpression) ThenKeyExpression(com.apple.foundationdb.record.metadata.expressions.ThenKeyExpression) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 79 with KeyExpression

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));
}
Also used : ListKeyExpression(com.apple.foundationdb.record.metadata.expressions.ListKeyExpression) GroupingKeyExpression(com.apple.foundationdb.record.metadata.expressions.GroupingKeyExpression) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) QueryableKeyExpression(com.apple.foundationdb.record.metadata.expressions.QueryableKeyExpression) FunctionKeyExpression(com.apple.foundationdb.record.metadata.expressions.FunctionKeyExpression) FieldKeyExpression(com.apple.foundationdb.record.metadata.expressions.FieldKeyExpression) NestingKeyExpression(com.apple.foundationdb.record.metadata.expressions.NestingKeyExpression) SplitKeyExpression(com.apple.foundationdb.record.metadata.expressions.SplitKeyExpression) EmptyKeyExpression(com.apple.foundationdb.record.metadata.expressions.EmptyKeyExpression) ThenKeyExpression(com.apple.foundationdb.record.metadata.expressions.ThenKeyExpression) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 80 with KeyExpression

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));
}
Also used : ListKeyExpression(com.apple.foundationdb.record.metadata.expressions.ListKeyExpression) GroupingKeyExpression(com.apple.foundationdb.record.metadata.expressions.GroupingKeyExpression) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) QueryableKeyExpression(com.apple.foundationdb.record.metadata.expressions.QueryableKeyExpression) FunctionKeyExpression(com.apple.foundationdb.record.metadata.expressions.FunctionKeyExpression) FieldKeyExpression(com.apple.foundationdb.record.metadata.expressions.FieldKeyExpression) NestingKeyExpression(com.apple.foundationdb.record.metadata.expressions.NestingKeyExpression) SplitKeyExpression(com.apple.foundationdb.record.metadata.expressions.SplitKeyExpression) EmptyKeyExpression(com.apple.foundationdb.record.metadata.expressions.EmptyKeyExpression) ThenKeyExpression(com.apple.foundationdb.record.metadata.expressions.ThenKeyExpression) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

KeyExpression (com.apple.foundationdb.record.metadata.expressions.KeyExpression)152 GroupingKeyExpression (com.apple.foundationdb.record.metadata.expressions.GroupingKeyExpression)85 Test (org.junit.jupiter.api.Test)63 FieldKeyExpression (com.apple.foundationdb.record.metadata.expressions.FieldKeyExpression)60 EmptyKeyExpression (com.apple.foundationdb.record.metadata.expressions.EmptyKeyExpression)56 NestingKeyExpression (com.apple.foundationdb.record.metadata.expressions.NestingKeyExpression)56 ThenKeyExpression (com.apple.foundationdb.record.metadata.expressions.ThenKeyExpression)52 Nonnull (javax.annotation.Nonnull)52 Index (com.apple.foundationdb.record.metadata.Index)37 List (java.util.List)36 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)35 Nullable (javax.annotation.Nullable)33 RecordQueryPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan)30 FunctionKeyExpression (com.apple.foundationdb.record.metadata.expressions.FunctionKeyExpression)28 Message (com.google.protobuf.Message)26 ArrayList (java.util.ArrayList)26 RecordMetaData (com.apple.foundationdb.record.RecordMetaData)25 QueryableKeyExpression (com.apple.foundationdb.record.metadata.expressions.QueryableKeyExpression)25 RecordCoreException (com.apple.foundationdb.record.RecordCoreException)24 ListKeyExpression (com.apple.foundationdb.record.metadata.expressions.ListKeyExpression)23