Package io.crate.planner.symbol

Examples of io.crate.planner.symbol.Reference


        Set shardIds = routing.locations().get(clusterService().localNode().id()).get(TEST_TABLE_NAME);

        CollectNode collectNode = new CollectNode("docCollect", routing);
        collectNode.toCollect(Arrays.<Symbol>asList(
                testDocLevelReference,
                new Reference(SysNodesTableInfo.INFOS.get(new ColumnIdent("name"))),
                new Reference(SysShardsTableInfo.INFOS.get(new ColumnIdent("id"))),
                new Reference(SysClusterTableInfo.INFOS.get(new ColumnIdent("name")))
        ));
        collectNode.maxRowGranularity(RowGranularity.DOC);

        Object[][] result = operation.collect(collectNode).get();
View Full Code Here


    public void testCollectWithPartitionedColumns() throws Exception {
        Routing routing = docSchemaInfo.getTableInfo(PARTITIONED_TABLE_NAME).getRouting(WhereClause.MATCH_ALL);
        TableIdent tableIdent = new TableIdent(DocSchemaInfo.NAME, PARTITIONED_TABLE_NAME);
        CollectNode collectNode = new CollectNode("docCollect", routing);
        collectNode.toCollect(Arrays.<Symbol>asList(
                new Reference(new ReferenceInfo(
                        new ReferenceIdent(tableIdent, "id"),
                        RowGranularity.DOC, DataTypes.INTEGER)),
                new Reference(new ReferenceInfo(
                        new ReferenceIdent(tableIdent, "date"),
                        RowGranularity.SHARD, DataTypes.TIMESTAMP))
        ));
        collectNode.maxRowGranularity(RowGranularity.DOC);
        collectNode.isPartitioned(true);
View Full Code Here

        assertThat(getFunction(LogFunction.LnFunction.NAME, DataTypes.STRING), Matchers.nullValue());
    }

    @Test
    public void testNormalizeReference() throws Exception {
        Reference dB = TestingHelpers.createReference("dB", DataTypes.DOUBLE);

        LogFunction log10 = getFunction(LogFunction.NAME, DataTypes.DOUBLE);
        Function function = new Function(log10.info(), Arrays.<Symbol>asList(dB));
        Function normalized = (Function) log10.normalizeSymbol(function);
        assertThat(normalized, Matchers.sameInstance(function));

        LogFunction ln = getFunction(LogFunction.LnFunction.NAME, DataTypes.DOUBLE);
        function = new Function(ln.info(), Arrays.<Symbol>asList(dB));
        normalized = (Function) ln.normalizeSymbol(function);
        assertThat(normalized, Matchers.sameInstance(function));

        LogFunction logBase = getFunction(LogFunction.NAME, DataTypes.DOUBLE, DataTypes.LONG);
        function = new Function(logBase.info(), Arrays.<Symbol>asList(dB, Literal.newLiteral(10L)));
        normalized = (Function) logBase.normalizeSymbol(function);
        assertThat(normalized, Matchers.sameInstance(function));

        Reference base = TestingHelpers.createReference("base", DataTypes.INTEGER);
        function = new Function(logBase.info(), Arrays.<Symbol>asList(dB, base));
        normalized = (Function) logBase.normalizeSymbol(function);
        assertThat(normalized, Matchers.sameInstance(function));
    }
View Full Code Here

        if (routing != null && (routing.equals(columnIdent) || routing.isChildOf(columnIdent))) {
            context.routingColumnIndex(i);
        }

        // ensure that every column is only listed once
        Reference columnReference = context.allocateUniqueReference(ident, true);
        context.columns().add(columnReference);
        return columnReference;
    }
View Full Code Here

        for (int i = 0, valuesSize = values.size(); i < valuesSize; i++) {
            Expression expression = values.get(i);
            Symbol valuesSymbol = process(expression, context);

            // implicit type conversion
            Reference column = context.columns().get(i);
            final ColumnIdent columnIdent = column.info().ident().columnIdent();
            try {
                valuesSymbol = context.normalizeInputForReference(valuesSymbol, column, true);
            } catch (IllegalArgumentException | UnsupportedOperationException e) {
                throw new ColumnValidationException(column.info().ident().columnIdent().fqn(), e);
            }
            try {
                Object value = ((Input) valuesSymbol).value();
                if (context.primaryKeyColumnIndices().contains(i)) {
                    int idx = primaryKey.indexOf(columnIdent);
View Full Code Here

    private ESFieldExtractor[] buildExtractor(final List<Symbol> outputs) {
        ESFieldExtractor[] extractors = new ESFieldExtractor[outputs.size()];
        int i = 0;
        for (Symbol output : outputs) {
            assert output instanceof Reference;
            Reference reference = ((Reference) output);
            final ColumnIdent columnIdent = reference.info().ident().columnIdent();
            if (DocSysColumns.VERSION.equals(columnIdent)) {
                extractors[i] = new ESFieldExtractor() {
                    @Override
                    public Object extract(SearchHit hit) {
                        return hit.getVersion();
                    }
                };
            } else if (DocSysColumns.ID.equals(columnIdent)) {
                extractors[i] = new ESFieldExtractor() {
                    @Override
                    public Object extract(SearchHit hit) {
                        return new BytesRef(hit.getId());
                    }
                };
            } else if (DocSysColumns.DOC.equals(columnIdent)) {
                extractors[i] = new ESFieldExtractor() {
                    @Override
                    public Object extract(SearchHit hit) {
                        return hit.getSource();
                    }
                };
            } else if (DocSysColumns.RAW.equals(columnIdent)) {
                extractors[i] = new ESFieldExtractor() {
                    @Override
                    public Object extract(SearchHit hit) {
                        return hit.getSourceRef().toBytesRef();
                    }
                };
            } else if (DocSysColumns.SCORE.equals(columnIdent)) {
                extractors[i] = new ESFieldExtractor() {
                    @Override
                    public Object extract(SearchHit hit) {
                        return hit.getScore();
                    }
                };
            } else if (searchNode.partitionBy().contains(reference.info())) {
                extractors[i] = new ESFieldExtractor.PartitionedByColumnExtractor(
                        reference, searchNode.partitionBy()
                );
            } else {
                extractors[i] = new ESFieldExtractor.Source(columnIdent);
View Full Code Here

TOP

Related Classes of io.crate.planner.symbol.Reference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.