Search in sources :

Example 6 with NestedObjectExpression

use of io.crate.operation.reference.NestedObjectExpression in project crate by crate.

the class SysObjectArrayReference method getChildImplementation.

@Override
public ReferenceImplementation<Object[]> getChildImplementation(String name) {
    List<NestedObjectExpression> childImplementations = getChildImplementations();
    final Object[] values = new Object[childImplementations.size()];
    int i = 0;
    for (NestedObjectExpression sysObjectReference : childImplementations) {
        ReferenceImplementation<?> child = sysObjectReference.getChildImplementation(name);
        if (child != null) {
            Object value = child.value();
            values[i++] = value;
        } else {
            values[i++] = null;
        }
    }
    return () -> values;
}
Also used : NestedObjectExpression(io.crate.operation.reference.NestedObjectExpression)

Example 7 with NestedObjectExpression

use of io.crate.operation.reference.NestedObjectExpression in project crate by crate.

the class SysObjectArrayReference method value.

@Override
public Object[] value() {
    List<NestedObjectExpression> childImplementations = getChildImplementations();
    Object[] values = new Object[childImplementations.size()];
    int i = 0;
    for (NestedObjectExpression expression : childImplementations) {
        Map<String, Object> map = Maps.transformValues(expression.getChildImplementations(), new Function<ReferenceImplementation, Object>() {

            @Nullable
            @Override
            public Object apply(@Nullable ReferenceImplementation input) {
                Object value = input.value();
                if (value != null && value instanceof BytesRef) {
                    return ((BytesRef) value).utf8ToString();
                } else {
                    return value;
                }
            }
        });
        values[i++] = map;
    }
    return values;
}
Also used : NestedObjectExpression(io.crate.operation.reference.NestedObjectExpression) Nullable(javax.annotation.Nullable) BytesRef(org.apache.lucene.util.BytesRef) ReferenceImplementation(io.crate.metadata.ReferenceImplementation)

Aggregations

NestedObjectExpression (io.crate.operation.reference.NestedObjectExpression)7 CrateUnitTest (io.crate.test.integration.CrateUnitTest)5 Test (org.junit.Test)5 Reference (io.crate.metadata.Reference)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ColumnIdent (io.crate.metadata.ColumnIdent)2 TestingHelpers.mapToSortedString (io.crate.testing.TestingHelpers.mapToSortedString)2 BytesRef (org.apache.lucene.util.BytesRef)2 ReferenceImplementation (io.crate.metadata.ReferenceImplementation)1 TestingHelpers.resolveCanonicalString (io.crate.testing.TestingHelpers.resolveCanonicalString)1 Nullable (javax.annotation.Nullable)1