Package io.crate.planner.projection

Examples of io.crate.planner.projection.TopNProjection


    }

    @Test
    public void testLocalMerge() throws Exception {
        for (int run = 0; run < 100; run++) {
            TopNProjection topNProjection = new TopNProjection(3,
                    TopN.NO_OFFSET,
                    Arrays.<Symbol>asList(new InputColumn(0), new InputColumn(1)),
                    new boolean[]{true, true},
                    new Boolean[] { null, null });
            topNProjection.outputs(Arrays.<Symbol>asList(new InputColumn(0), new InputColumn(1)));

            MergeNode mergeNode = new MergeNode("merge", 2);
            mergeNode.projections(Arrays.<Projection>asList(
                    groupProjection,
                    topNProjection
View Full Code Here


                null
        );
        MergeNode mergeNode = new MergeNode("merge", 1);
        mergeNode.inputTypes(Arrays.<DataType>asList(DataTypes.INTEGER, DataTypes.TIMESTAMP));
        mergeNode.outputTypes(Arrays.<DataType>asList(DataTypes.INTEGER, DataTypes.TIMESTAMP));
        TopNProjection topN = new TopNProjection(2, TopN.NO_OFFSET);
        topN.outputs(Arrays.<Symbol>asList(new InputColumn(0), function));
        mergeNode.projections(Arrays.<Projection>asList(topN));
        Plan plan = new Plan();
        plan.add(node);
        plan.add(mergeNode);
        Job job = executor.newJob(plan);
View Full Code Here

    public void testSerializationWithContext() throws Exception {
        UUID contextId = UUID.randomUUID();
        MergeNode dummyMergeNode = new MergeNode();
        dummyMergeNode.contextId(contextId);
        dummyMergeNode.inputTypes(Arrays.<DataType>asList(DataTypes.INTEGER, DataTypes.STRING));
        TopNProjection topNProjection = new TopNProjection(10, 0);
        topNProjection.outputs(Arrays.<Symbol>asList(
                new InputColumn(0, DataTypes.INTEGER),
                new InputColumn(1, DataTypes.INTEGER)));
        dummyMergeNode.projections(Arrays.<Projection>asList(topNProjection));

        DistributedRequestContextManager contextManager =
View Full Code Here

                        ImmutableList.<Symbol>of(new InputColumn(0)),
                        Aggregation.Step.PARTIAL,
                        Aggregation.Step.FINAL
                )
        ));
        TopNProjection topNProjection = new TopNProjection(
                10, 0, Arrays.<Symbol>asList(new InputColumn(1)), new boolean[] { false }, new Boolean[] { null });
        topNProjection.outputs(Arrays.<Symbol>asList(new InputColumn(0), new InputColumn(1)));

        mergeNode.projections(Arrays.asList(groupProjection, topNProjection));
        mergeNode.outputTypes(Arrays.<DataType>asList(DataTypes.STRING, DataTypes.LONG));

        Streamer<?>[] mapperOutputStreamer = new Streamer[] {
View Full Code Here

                        countInfo,
                        ImmutableList.<Symbol>of(),
                        Aggregation.Step.PARTIAL, Aggregation.Step.FINAL))
        );

        TopNProjection topNProjection = new TopNProjection(2, 0);
        topNProjection.outputs(Arrays.<Symbol>asList(
                new InputColumn(1),
                new InputColumn(0)
        ));

        mergeNode.projections(Arrays.asList(groupProjection, topNProjection));
View Full Code Here

                        ImmutableList.<Symbol>of(),
                        Aggregation.Step.PARTIAL,
                        Aggregation.Step.FINAL
                )
        ));
        TopNProjection topNProjection = new TopNProjection(10, 0);

        node.projections(Arrays.asList(groupProjection, topNProjection));

        BytesStreamOutput output = new BytesStreamOutput();
        node.writeTo(output);
View Full Code Here

        ));
    }

    @Test
    public void testMergeSingleResult() throws Exception {
        TopNProjection topNProjection = new TopNProjection(3, TopN.NO_OFFSET,
                Arrays.<Symbol>asList(new InputColumn(0)), new boolean[]{false}, new Boolean[] { null });
        topNProjection.outputs(Arrays.<Symbol>asList(new InputColumn(0), new InputColumn(1)));

        MergeNode mergeNode = new MergeNode("merge", 2); // no need for inputTypes here
        mergeNode.projections(Arrays.asList(
                groupProjection,
                topNProjection
View Full Code Here

        avgInfo = new FunctionInfo(new FunctionIdent(AverageAggregation.NAME, Arrays.<DataType>asList(DataTypes.INTEGER)), DataTypes.DOUBLE);
    }

    @Test
    public void testSimpleTopNProjection() throws ExecutionException, InterruptedException {
        TopNProjection projection = new TopNProjection(10, 2);
        projection.outputs(Arrays.<Symbol>asList(Literal.newLiteral("foo"), new InputColumn(0)));

        CollectingProjector collectingProjector = new CollectingProjector();
        Projector projector = visitor.process(projection);
        projector.registerUpstream(null);
        projector.downstream(collectingProjector);
View Full Code Here

        assertThat((Integer)rows[0][1], is(42));
    }

    @Test
    public void testSortingTopNProjection() throws ExecutionException, InterruptedException {
        TopNProjection projection = new TopNProjection(10, 0,
                Arrays.<Symbol>asList(new InputColumn(0), new InputColumn(1)),
                new boolean[]{false, false},
                new Boolean[] { null, null }
        );
        projection.outputs(Arrays.<Symbol>asList(Literal.newLiteral("foo"), new InputColumn(0), new InputColumn(1)));
        Projector projector = visitor.process(projection);
        projector.registerUpstream(null);
        assertThat(projector, instanceOf(SortingTopNProjector.class));

        projector.startProjection();
View Full Code Here

                Aggregation.Step.PARTIAL);
    }

    @Test
    public void testWithShardProjections() throws Exception {
        TopNProjection topN = new TopNProjection(0, 1);
        GroupProjection groupProjection = new GroupProjection(
                Arrays.<DataTypeSymbol>asList(Literal.newLiteral(true)),
                Arrays.asList(countAggregation()));
        groupProjection.setRequiredGranularity(RowGranularity.SHARD);
        ShardProjectorChain chain = new ShardProjectorChain(2, ImmutableList.of(groupProjection, topN), projectionToProjectorVisitor);
View Full Code Here

TOP

Related Classes of io.crate.planner.projection.TopNProjection

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.