Package com.asakusafw.compiler.operator.ExecutableAnalyzer

Examples of com.asakusafw.compiler.operator.ExecutableAnalyzer.TypeConstraint


        }
        if (a.hasError()) {
            return null;
        }

        TypeConstraint joined = a.getParameterType(0);
        TypeConstraint from = a.getParameterType(1).getTypeArgument();
        TypeConstraint join = a.getParameterType(2).getTypeArgument();
        if (joined.isJoinedModel(from.getType(), join.getType()) == false) {
            a.error(0, "分割演算子の最初の引数は結果の2つの型を結合した型である必要があります");
            return null;
        }

        Builder builder = new Builder(getTargetAnnotationType(), context);
View Full Code Here


        if (a.getReturnType().isVoid() == false) {
            a.error("グループ結合演算子は戻り値にvoidを指定する必要があります");
        }
        int startResults = 0;
        for (int i = 0, n = a.countParameters(); i < n; i++) {
            TypeConstraint type = a.getParameterType(i);
            if (type.isResult()) {
                break;
            }
            if (type.isList() == false) {
                a.error(i, "グループ結合演算子の先頭の引数はリスト型(java.util.List)である必要があります");
            } else if (type.getTypeArgument().isModel() == false) {
                a.error(i, "グループ結合演算子の先頭の引数はリストのモデルオブジェクト型である必要があります");
            }
            startResults++;
        }
        if (startResults == 0) { // リスト型がない
            a.error("グループ結合演算子の引数には一つ以上のリスト型(java.util.List)を指定する必要があります");
        }

        int startParameters = startResults;
        for (int i = startResults, n = a.countParameters(); i < n; i++) {
            TypeConstraint param = a.getParameterType(i);
            if (param.isResult() == false) {
                break;
            } else if (param.getTypeArgument().isModel() == false) {
                a.error(i, "グループ結合演算子の結果は結果のモデルオブジェクト型である必要があります");
            } else {
                startParameters++;
            }
        }
        if (startParameters == startResults) { // 結果型がない
            a.error("グループ結合演算子の引数には一つ以上の結果(Result)型を指定する必要があります");
        }
        for (int i = startParameters, n = a.countParameters(); i < n; i++) {
            TypeConstraint param = a.getParameterType(i);
            if (param.isResult()) {
                a.error(i, "ユーザー引数の後には結果型を含められません");
            } else if (param.isBasic() == false) {
                a.error(i, "ユーザー引数は文字列またはプリミティブ型である必要があります");
            }
        }
        if (a.hasError()) {
            return null;
        }

        List<ShuffleKey> keys = Lists.create();
        for (int i = 0; i < startResults; i++) {
            ShuffleKey key = a.getParameterKey(i);
            if (key == null) {
                a.error(i, "グループ結合演算子の引数には@Key注釈によってグループ化項目を指定する必要があります");
            } else {
                keys.add(key);
            }
        }
        if (keys.isEmpty() == false) {
            ShuffleKey first = keys.get(0);
            for (int i = 1, n = keys.size(); i < n; i++) {
                if (first.getGroupProperties().size() != keys.get(i).getGroupProperties().size()) {
                    a.error(0, "グループ結合演算子の@Key注釈ではグループ化項目の個数を全て一致させる必要があります");
                }
            }
        }
        if (a.hasError()) {
            return null;
        }
        CoGroup annotation = context.element.getAnnotation(CoGroup.class);
        if (annotation == null) {
            a.error("注釈の解釈に失敗しました");
            return null;
        }

        Builder builder = new Builder(getTargetAnnotationType(), context);
        builder.addAttribute(FlowBoundary.SHUFFLE);
        builder.addAttribute(a.getObservationCount());
        builder.addAttribute(annotation.inputBuffer());
        builder.setDocumentation(a.getExecutableDocument());
        for (int i = 0; i < startResults; i++) {
            builder.addInput(
                    a.getParameterDocument(i),
                    a.getParameterName(i),
                    a.getParameterType(i).getTypeArgument().getType(),
                    i,
                    keys.get(i));
        }
        for (int i = startResults; i < startParameters; i++) {
            TypeConstraint outputType = a.getParameterType(i).getTypeArgument();
            TypeMirror outputTypeMirror = outputType.getType();
            String found = builder.findInput(outputTypeMirror);
            if (found == null && outputType.isProjectiveModel()) {
                a.error("出力型{0}に対する入力が見つかりません", outputTypeMirror);
            }
            builder.addOutput(
                    a.getParameterDocument(i),
                    a.getParameterName(i),
View Full Code Here

TOP

Related Classes of com.asakusafw.compiler.operator.ExecutableAnalyzer.TypeConstraint

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.