Examples of ExpressionBuilder


Examples of com.asakusafw.utils.java.model.util.ExpressionBuilder

            SimpleName attributes = factory.newSimpleName("attributes");
            List<Statement> statements = Lists.create();
            statements.add(new TypeBuilder(factory, t(ArrayList.class, t(StageInput.class)))
                .newObject()
                .toLocalVariableDeclaration(t(List.class, t(StageInput.class)), list));
            statements.add(new ExpressionBuilder(factory, Models.toNullLiteral(factory))
                .toLocalVariableDeclaration(t(Map.class, t(String.class), t(String.class)), attributes));

            for (ResolvedSlot slot : slots) {
                Type mapperType = generateMapper(slot);
                statements.add(new ExpressionBuilder(factory, attributes)
                    .assignFrom(new TypeBuilder(factory, t(HashMap.class, t(String.class), t(String.class)))
                        .newObject()
                        .toExpression())
                    .toStatement());
                for (SourceInfo input : slot.getSource().getInputs()) {
                    for (Map.Entry<String, String> entry : input.getAttributes().entrySet()) {
                        statements.add(new ExpressionBuilder(factory, attributes)
                            .method("put",
                                    Models.toLiteral(factory, entry.getKey()),
                                    Models.toLiteral(factory, entry.getValue()))
                            .toStatement());
                    }
                    for (Location location : input.getLocations()) {
                        statements.add(new ExpressionBuilder(factory, list)
                            .method("add", new TypeBuilder(factory, t(StageInput.class))
                                .newObject(
                                        Models.toLiteral(factory, location.toPath(PATH_SEPARATOR)),
                                        factory.newClassLiteral(t(input.getFormat())),
                                        factory.newClassLiteral(mapperType),
                                        attributes)
                                .toExpression())
                            .toStatement());
                    }
                }
            }
            statements.add(new ExpressionBuilder(factory, list)
                .toReturnStatement());

            return factory.newMethodDeclaration(
                    null,
                    new AttributeBuilder(factory)
View Full Code Here

Examples of com.asakusafw.utils.java.model.util.ExpressionBuilder

                .newObject()
                .toLocalVariableDeclaration(t(List.class, t(StageOutput.class)), list));
            for (ResolvedSlot slot : slots) {
                Expression valueType = factory.newClassLiteral(t(slot.getValueClass().getType()));
                Class<?> outputFormatType = slot.getSource().getOutputFormatType();
                statements.add(new ExpressionBuilder(factory, list)
                    .method("add", new TypeBuilder(factory, t(StageOutput.class))
                        .newObject(
                                Models.toLiteral(factory, slot.getSource().getOutputName()),
                                factory.newClassLiteral(t(NullWritable.class)),
                                valueType,
                                factory.newClassLiteral(t(outputFormatType)))
                        .toExpression())
                    .toStatement());
            }
            statements.add(new ExpressionBuilder(factory, list)
                .toReturnStatement());

            return factory.newMethodDeclaration(
                    null,
                    new AttributeBuilder(factory)
View Full Code Here

Examples of com.asakusafw.utils.java.model.util.ExpressionBuilder

            // shuffle outputs
            for (Map.Entry<ShuffleModel.Segment, SimpleName> entry : shuffleNames.entrySet()) {
                ShuffleModel.Segment segment = entry.getKey();
                SimpleName name = entry.getValue();
                Name shuffleTypeName = segment.getCompiled().getCombineOutputType().getQualifiedName();
                statements.add(new ExpressionBuilder(factory, factory.newThis())
                    .field(name)
                    .assignFrom(new TypeBuilder(factory, importer.toType(shuffleTypeName))
                        .newObject(context)
                        .toExpression())
                    .toStatement());
                segments.put(segment.getPort(), segment);
            }

            // rendezvous
            for (Map.Entry<Fragment, SimpleName> entry : rendezvousNames.entrySet()) {
                Fragment fragment = entry.getKey();
                Type rendezvousType = importer.toType(fragment.getCompiled().getQualifiedName());
                List<Expression> arguments = Lists.create();
                for (FlowElementInput input : fragment.getInputPorts()) {
                    Segment segment = segments.get(input);
                    assert segment != null;
                    SimpleName shuffleName = shuffleNames.get(segment);
                    assert shuffleName != null;
                    arguments.add(new ExpressionBuilder(factory, factory.newThis())
                        .field(shuffleName)
                        .toExpression());
                }
                SimpleName name = entry.getValue();
                statements.add(new ExpressionBuilder(factory, factory.newThis())
                    .field(name)
                    .assignFrom(new TypeBuilder(factory, rendezvousType)
                        .newObject(arguments)
                        .toExpression())
                    .toStatement());
View Full Code Here

Examples of com.asakusafw.utils.java.model.util.ExpressionBuilder

        }

        private MethodDeclaration createCleanup() {
            List<Statement> statements = Lists.create();
            for (SimpleName name : shuffleNames.values()) {
                statements.add(new ExpressionBuilder(factory, factory.newThis())
                    .field(name)
                    .assignFrom(Models.toNullLiteral(factory))
                    .toStatement());
            }
            for (SimpleName name : rendezvousNames.values()) {
                statements.add(new ExpressionBuilder(factory, factory.newThis())
                    .field(name)
                    .assignFrom(Models.toNullLiteral(factory))
                    .toStatement());
            }
            return factory.newMethodDeclaration(
View Full Code Here

Examples of com.asakusafw.utils.java.model.util.ExpressionBuilder

        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }

        Expression impl = context.createImplementation();
        context.addEnd(new ExpressionBuilder(f, impl)
            .method(desc.getDeclaration().getName(), arguments)
            .toStatement());

        for (ListBufferMirror list : buffers) {
            context.addEnd(list.createShrink());
View Full Code Here

Examples of com.asakusafw.utils.java.model.util.ExpressionBuilder

                    cases.add(factory.newSwitchCaseLabel(v(segment.getPortId())));
                }
                FlowElement element = group.get(0).getPort().getOwner();
                SimpleName rendezvousName = fragments.get(element);
                if (rendezvousName == null) {
                    cases.add(new ExpressionBuilder(factory, Models.toNullLiteral(factory))
                        .toReturnStatement());
                } else {
                    cases.add(new ExpressionBuilder(factory, factory.newThis())
                        .field(rendezvousName)
                        .toReturnStatement());
                }
            }
            cases.add(factory.newSwitchDefaultLabel());
            cases.add(new TypeBuilder(factory, t(AssertionError.class))
                .newObject()
                .toThrowStatement());

            SimpleName argument = names.create("nextKey");
            List<Statement> statements = Lists.create();
            statements.add(factory.newSwitchStatement(
                    new ExpressionBuilder(factory, argument)
                        .method(SegmentedWritable.ID_GETTER)
                        .toExpression(),
                    cases));

            return factory.newMethodDeclaration(
View Full Code Here

Examples of com.asakusafw.utils.java.model.util.ExpressionBuilder

        }

        context.addProcess(tx, f.newIfStatement(
                masterAnalyzer.getHasMasterExpresion(),
                f.newBlock(new Statement[] {
                        new ExpressionBuilder(f, impl)
                            .method(desc.getDeclaration().getName(), arguments)
                            .toStatement(),
                        updated.createAdd(context.getProcessInput(tx))
                }),
                f.newBlock(missed.createAdd(context.getProcessInput(tx)))));
View Full Code Here

Examples of com.asakusafw.utils.java.model.util.ExpressionBuilder

            return results;
        }

        private MethodDeclaration createOutputName() {
            List<Statement> statements = Lists.create();
            statements.add(new ExpressionBuilder(factory, Models.toLiteral(factory, slot.getName()))
                .toReturnStatement());
            return factory.newMethodDeclaration(
                    null,
                    new AttributeBuilder(factory)
                        .annotation(importer.toType(Override.class))
View Full Code Here

Examples of com.asakusafw.utils.java.model.util.ExpressionBuilder

                if (slot.getSortProperties().isEmpty() && ParallelSortClientEmitter.legacy(environment) == false) {
                    outputName = Models.toNullLiteral(factory);
                } else {
                    outputName = Models.toLiteral(factory, slot.getSource().getOutputName());
                }
                statements.add(new ExpressionBuilder(factory, resultName)
                    .array(slot.getSlotNumber())
                    .assignFrom(outputName)
                    .toStatement());
            }
            statements.add(new ExpressionBuilder(factory, resultName)
                .toReturnStatement());
            return factory.newMethodDeclaration(
                    null,
                    new AttributeBuilder(factory)
                        .annotation(importer.toType(Override.class))
View Full Code Here

Examples of com.asakusafw.utils.java.model.util.ExpressionBuilder

                    object = Models.toNullLiteral(factory);
                } else {
                    DataClass slotClass = slot.getValueClass();
                    object = slotClass.createNewInstance(importer.toType(slotClass.getType()));
                }
                statements.add(new ExpressionBuilder(factory, resultName)
                    .array(slot.getSlotNumber())
                    .assignFrom(object)
                    .toStatement());
            }
            statements.add(new ExpressionBuilder(factory, resultName)
                .toReturnStatement());
            return factory.newMethodDeclaration(
                    null,
                    new AttributeBuilder(factory)
                        .annotation(importer.toType(Override.class))
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.