Package com.asakusafw.vocabulary.model

Examples of com.asakusafw.vocabulary.model.Summarized


    }

    private ShuffleKey rebuildShuffleKey(FlowElementPortDescription output, FlowElementPortDescription input) {
        assert output != null;
        assert input != null;
        Summarized summarized = TypeUtil.erase(output.getDataType()).getAnnotation(Summarized.class);
        if (summarized == null) {
            throw new IllegalStateException(MessageFormat.format(
                    "Internal Error: {0} does not declared in {1} ({2})",
                    Summarized.class.getSimpleName(),
                    output.getDataType(),
                    output));
        }

        Map<String, String> mapping = Maps.create();
        for (Summarized.Folding folding : summarized.term().foldings()) {
            if (folding.aggregator() == Aggregator.ANY) {
                mapping.put(folding.source(), folding.destination());
            }
        }
        List<String> remapped = Lists.create();
View Full Code Here


        DataObjectMirror cache = context.createModelCache(output.getDataType());

        List<Statement> combine = Lists.create();
        DataClass outputType = getEnvironment().getDataClasses().load(output.getDataType());
        Summarized summarized = TypeUtil.erase(output.getDataType()).getAnnotation(Summarized.class);
        for (Summarized.Folding folding : summarized.term().foldings()) {
            if (folding.aggregator() == Aggregator.ANY) {
                continue;
            }
            combine.add(createAddSummarizeFor(context, folding, outputType, cache.get()));
        }
View Full Code Here

            this.outputType = outputType;
        }

        @Override
        public void emitLinePart(Context context) {
            Summarized summarized = TypeUtil.erase(outputType).getAnnotation(Summarized.class);
            DataObjectMirror cache = context.createModelCache(outputType);
            DataClass inputData = getEnvironment().getDataClasses().load(inputType);
            DataClass outputData = getEnvironment().getDataClasses().load(outputType);
            for (Summarized.Folding folding : summarized.term().foldings()) {
                context.add(createStartSummarizeFor(context, folding, inputData, outputData, cache.get()));
            }
            context.setOutput(cache.get());
        }
View Full Code Here

     * simple summarize.
     */
    @Test
    public void simple_summarize() {
        ModelLoader loader = generate();
        Summarized annotation = loader.modelType("Simple").getAnnotation(Summarized.class);
        assertThat(annotation, not(nullValue()));

        Term term = annotation.term();
        assertThat(term.source(), eq(loader.modelType("A")));
        assertThat(term.foldings().length, is(5));
        assertThat(term.foldings(), hasItemInArray(mapping(ANY, "valueA", "key")));
        assertThat(term.foldings(), hasItemInArray(mapping(SUM, "valueB", "sum")));
        assertThat(term.foldings(), hasItemInArray(mapping(COUNT, "valueA", "count")));
View Full Code Here

     * simple record.
     */
    @Test
    public void simple_record() {
        ModelLoader loader = generate();
        Summarized annotation = loader.modelType("Simple").getAnnotation(Summarized.class);
        assertThat(annotation, nullValue());
    }
View Full Code Here

        object.set("max", new Date(2011, 12, 31));
        assertThat(object.get("max"), eq(new Date(2011, 12, 31)));
        object.set("min", new Date(2011, 4, 1));
        assertThat(object.get("min"), eq(new Date(2011, 4, 1)));

        Summarized annotation = object.unwrap().getClass().getAnnotation(Summarized.class);
        assertThat(annotation, not(nullValue()));

        loader.setNamespace(Constants.SOURCE_TABLE);

        Term term = annotation.term();
        assertThat(term.source(), eq(loader.modelType("Target")));
        assertThat(term.foldings().length, is(5));
        assertThat(term.foldings(), hasItemInArray(mapping(ANY, "valueA", "key")));
        assertThat(term.foldings(), hasItemInArray(mapping(SUM, "valueB", "sum")));
        assertThat(term.foldings(), hasItemInArray(mapping(COUNT, "sid", "count")));
View Full Code Here

        ModelLoader loader = generateJava();
        loader.setNamespace(Constants.SOURCE_VIEW);

        ModelWrapper object = loader.newModel("Simple");
        Summarized annotation = object.unwrap().getClass().getAnnotation(Summarized.class);
        assertThat(annotation, not(nullValue()));

        loader.setNamespace(Constants.SOURCE_TABLE);

        Term term = annotation.term();
        assertThat(term.source(), eq(loader.modelType("Target")));
        assertThat(term.foldings().length, is(2));
        assertThat(term.foldings(), hasItemInArray(mapping(ANY, "grouping", "key")));
        assertThat(term.foldings(), hasItemInArray(mapping(COUNT, "grouping", "count")));
        assertThat(term.shuffle(), is(grouping("grouping")));
View Full Code Here

TOP

Related Classes of com.asakusafw.vocabulary.model.Summarized

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.