Examples of SummarizeTrait


Examples of com.asakusafw.dmdl.semantics.trait.SummarizeTrait

    @Override
    public List<Annotation> getTypeAnnotations(EmitContext context, ModelDeclaration model) {
        if (model.getOriginalAst().kind != ModelDefinitionKind.SUMMARIZED) {
            return Collections.emptyList();
        }
        SummarizeTrait trait = model.getTrait(SummarizeTrait.class);
        if (trait == null) {
            throw new IllegalStateException(MessageFormat.format(
                    "Internal Error: summarized model {0} has no SummarizeTrait", //$NON-NLS-1$
                    model.getName()));
        }

        ModelFactory f = context.getModelFactory();
        List<Annotation> eTerms = Lists.create();
        for (ReduceTerm<?> term : trait.getTerms()) {
            ClassLiteral source = f.newClassLiteral(context.resolve(term.getSource()));
            ArrayInitializer mappings = toMappings(context, term.getMappings());
            Annotation shuffle = toKey(context, term);
            eTerms.addAll(new AttributeBuilder(f)
                .annotation(context.resolve(Summarized.Term.class),
View Full Code Here

Examples of com.asakusafw.dmdl.semantics.trait.SummarizeTrait

        PropertyDeclaration min = simple.findPropertyDeclaration("min");
        assertThat(min, not(nullValue()));
        assertThat(min.getType(), is(type(BasicTypeKind.DATE)));

        SummarizeTrait trait = simple.getTrait(SummarizeTrait.class);
        assertThat(trait, not(nullValue()));
        assertThat(trait.getTerms().size(), is(1));

        ReduceTerm<AstSummarize> aTerm = trait.getTerms().get(0);
        assertThat(aTerm.getSource(), is(model("a")));
        assertThat(aTerm.getGrouping(), has(property("key")));
        assertThat(aTerm.getMappings(), has(mapping(PropertyMappingKind.ANY, "value_a", "key")));
        assertThat(aTerm.getMappings(), has(mapping(PropertyMappingKind.SUM, "value_b", "sum")));
        assertThat(aTerm.getMappings(), has(mapping(PropertyMappingKind.COUNT, "value_a", "count")));
View Full Code Here

Examples of com.asakusafw.dmdl.semantics.trait.SummarizeTrait

        PropertyDeclaration count = counter.findPropertyDeclaration("count");
        assertThat(count, not(nullValue()));
        assertThat(count.getType(), is(type(BasicTypeKind.LONG)));

        SummarizeTrait trait = counter.getTrait(SummarizeTrait.class);
        assertThat(trait, not(nullValue()));
        assertThat(trait.getTerms().size(), is(1));

        ReduceTerm<AstSummarize> aTerm = trait.getTerms().get(0);
        assertThat(aTerm.getSource(), is(model("simple")));
        assertThat(aTerm.getGrouping().size(), is(0));
        assertThat(aTerm.getMappings(), has(mapping(PropertyMappingKind.COUNT, "sid", "count")));
    }
View Full Code Here

Examples of com.asakusafw.dmdl.semantics.trait.SummarizeTrait

            List<MappingFactor> foldings = resolveFolding(model, source, term.folding);
            List<PropertySymbol> grouping = resolveGrouping(model, properties, term.grouping);
            results.add(new ReduceTerm<AstSummarize>(term, source, foldings, grouping));
        }
        if (checkSummarizeTerms(model, results)) {
            model.putTrait(SummarizeTrait.class, new SummarizeTrait(expression, results));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.