当前位置: 首页>>代码示例>>Java>>正文


Java Mutable类代码示例

本文整理汇总了Java中org.apache.commons.lang3.mutable.Mutable的典型用法代码示例。如果您正苦于以下问题:Java Mutable类的具体用法?Java Mutable怎么用?Java Mutable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Mutable类属于org.apache.commons.lang3.mutable包,在下文中一共展示了Mutable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGetVariable

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
/**
 * Result {@code null} means that there is no variable. Result other than {@code null} means that there is a variable (that may possibly
 * be {@code null}).
 *
 * @param name the name of the variable.
 * @return a holder for a variable.
 */
protected Mutable<Object> doGetVariable(String name) {
    List<Object> variables =
            scripts.stream().filter(script -> script.getMetaClass().hasProperty(script.getMetaClass().getTheClass(), name) != null)
                    .map(script -> script.getProperty(name)).collect(Collectors.toList());

    if (variables.isEmpty()) {
        try {
            return new MutableObject<>(binding.getProperty(name));
        } catch (MissingPropertyException e) {
            return null; // This means that no variable has been found!
        }
    }

    return new MutableObject<>(variables.get(0));
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:23,代码来源:GroovyKnowledgeBaseInterpreter.java

示例2: computeLocalProperties

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
public void computeLocalProperties(ILogicalOperator op) {
    OrderOperator ord = (OrderOperator) op;
    List<OrderColumn> orderColumns = new ArrayList<OrderColumn>();
    for (Pair<IOrder, Mutable<ILogicalExpression>> p : ord.getOrderExpressions()) {
        ILogicalExpression expr = p.second.getValue();
        if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
            VariableReferenceExpression varRef = (VariableReferenceExpression) expr;
            LogicalVariable var = varRef.getVariableReference();
            orderColumns.add(new OrderColumn(var, p.first.getKind()));
        } else {
            throw new IllegalStateException();
        }
    }
    sortColumns = orderColumns.toArray(new OrderColumn[orderColumns.size()]);
    orderProp = new LocalOrderProperty(orderColumns);
}
 
开发者ID:apache,项目名称:incubator-asterixdb-hyracks,代码行数:17,代码来源:AbstractStableSortPOperator.java

示例3: printLogicalPlan

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
public static void printLogicalPlan(ILogicalPlan plan) throws AlgebricksException {
    int indent = 5;
    StringBuilder out = new StringBuilder();
    int randomInt = 10000 + randomGenerator.nextInt(100);
    appendln(out, "digraph G {");
    for (Mutable<ILogicalOperator> root : plan.getRoots()) {
        printVisualizationGraph((AbstractLogicalOperator) root.getValue(), indent, out, "", randomInt);
    }
    appendln(out, "\n}\n}");
    try {
        File file = File.createTempFile("logicalPlan", ".txt");
        FileUtils.writeStringToFile(file, out.toString());
        file.deleteOnExit();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:apache,项目名称:incubator-asterixdb-hyracks,代码行数:18,代码来源:PlanPlotter.java

示例4: rewriteWithRuleCollection

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
@Override
public boolean rewriteWithRuleCollection(Mutable<ILogicalOperator> root, Collection<IAlgebraicRewriteRule> rules)
        throws AlgebricksException {
    boolean anyRuleFired = false;
    boolean anyChange = false;
    do {
        anyChange = false;
        for (IAlgebraicRewriteRule r : rules) {
            while (true) {
                boolean ruleFired = rewriteOperatorRef(root, r);
                if (ruleFired) {
                    anyChange = true;
                    anyRuleFired = true;
                } else {
                    break; // go to next rule
                }
            }
        }
    } while (anyChange);
    return anyRuleFired;
}
 
开发者ID:apache,项目名称:incubator-asterixdb-hyracks,代码行数:22,代码来源:PrioritizedRuleController.java

示例5: visitTokenizeOperator

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
@Override
public ILogicalOperator visitTokenizeOperator(TokenizeOperator op, Void arg) throws AlgebricksException {
    List<Mutable<ILogicalExpression>> newPrimaryKeyExpressions = new ArrayList<Mutable<ILogicalExpression>>();
    deepCopyExpressionRefs(newPrimaryKeyExpressions, op.getPrimaryKeyExpressions());
    List<Mutable<ILogicalExpression>> newSecondaryKeyExpressions = new ArrayList<Mutable<ILogicalExpression>>();
    deepCopyExpressionRefs(newSecondaryKeyExpressions, op.getSecondaryKeyExpressions());
    List<LogicalVariable> newTokenizeVars = new ArrayList<LogicalVariable>();
    deepCopyVars(newTokenizeVars, op.getTokenizeVars());
    Mutable<ILogicalExpression> newFilterExpression = new MutableObject<ILogicalExpression>(
            ((AbstractLogicalExpression) op.getFilterExpression()).cloneExpression());
    List<Object> newTokenizeVarTypes = new ArrayList<Object>();
    deepCopyObjects(newTokenizeVarTypes, op.getTokenizeVarTypes());

    TokenizeOperator tokenizeOp = new TokenizeOperator(op.getDataSourceIndex(), newPrimaryKeyExpressions,
            newSecondaryKeyExpressions, newTokenizeVars, newFilterExpression, op.getOperation(), op.isBulkload(),
            op.isPartitioned(), newTokenizeVarTypes);
    return tokenizeOp;
}
 
开发者ID:apache,项目名称:incubator-asterixdb-hyracks,代码行数:19,代码来源:OperatorDeepCopyVisitor.java

示例6: substituteVarRec

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
public static void substituteVarRec(AbstractLogicalOperator op, LogicalVariable v1, LogicalVariable v2,
        boolean goThroughNts, ITypingContext ctx) throws AlgebricksException {
    VariableUtilities.substituteVariables(op, v1, v2, goThroughNts, ctx);
    for (Mutable<ILogicalOperator> opRef2 : op.getInputs()) {
        substituteVarRec((AbstractLogicalOperator) opRef2.getValue(), v1, v2, goThroughNts, ctx);
    }
    if (op.getOperatorTag() == LogicalOperatorTag.NESTEDTUPLESOURCE && goThroughNts) {
        NestedTupleSourceOperator nts = (NestedTupleSourceOperator) op;
        if (nts.getDataSourceReference() != null) {
            AbstractLogicalOperator op2 = (AbstractLogicalOperator) nts.getDataSourceReference().getValue()
                    .getInputs().get(0).getValue();
            substituteVarRec(op2, v1, v2, goThroughNts, ctx);
        }
    }
    if (op.hasNestedPlans()) {
        AbstractOperatorWithNestedPlans aonp = (AbstractOperatorWithNestedPlans) op;
        for (ILogicalPlan p : aonp.getNestedPlans()) {
            for (Mutable<ILogicalOperator> ref : p.getRoots()) {
                AbstractLogicalOperator aop = (AbstractLogicalOperator) ref.getValue();
                substituteVarRec(aop, v1, v2, goThroughNts, ctx);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-asterixdb-hyracks,代码行数:25,代码来源:OperatorManipulationUtil.java

示例7: rewritePre

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
@Override
public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
        throws AlgebricksException {
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getOperatorTag() != LogicalOperatorTag.PROJECT) {
        return false;
    }
    ProjectOperator pi = (ProjectOperator) op;
    Mutable<ILogicalOperator> opRef2 = pi.getInputs().get(0);

    HashSet<LogicalVariable> toPush = new HashSet<LogicalVariable>();
    toPush.addAll(pi.getVariables());

    Pair<Boolean, Boolean> p = pushThroughOp(toPush, opRef2, op, context);
    boolean smthWasPushed = p.first;
    if (p.second) { // the original projection is redundant
        opRef.setValue(op.getInputs().get(0).getValue());
        smthWasPushed = true;
    }

    return smthWasPushed;
}
 
开发者ID:apache,项目名称:incubator-asterixdb-hyracks,代码行数:23,代码来源:PushProjectDownRule.java

示例8: pushNeededProjections

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
private static boolean pushNeededProjections(HashSet<LogicalVariable> toPush, Mutable<ILogicalOperator> opRef,
        IOptimizationContext context, ILogicalOperator initialOp) throws AlgebricksException {
    HashSet<LogicalVariable> allP = new HashSet<LogicalVariable>();
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    VariableUtilities.getSubplanLocalLiveVariables(op, allP);

    HashSet<LogicalVariable> toProject = new HashSet<LogicalVariable>();
    for (LogicalVariable v : toPush) {
        if (allP.contains(v)) {
            toProject.add(v);
        }
    }
    if (toProject.equals(allP)) {
        // projection would be redundant, since we would project everything
        // but we can try with the children
        boolean push = false;
        if (pushThroughOp(toProject, opRef, initialOp, context).first) {
            push = true;
        }
        return push;
    } else {
        return pushAllProjectionsOnTopOf(toProject, opRef, context, initialOp);
    }
}
 
开发者ID:apache,项目名称:incubator-asterixdb-hyracks,代码行数:25,代码来源:PushProjectDownRule.java

示例9: rewritePost

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
@Override
public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
        throws AlgebricksException {
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getInputs().size() <= 0)
        return false;
    AbstractLogicalOperator project = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
    if (project.getOperatorTag() != LogicalOperatorTag.PROJECT)
        return false;
    AbstractLogicalOperator exchange = (AbstractLogicalOperator) project.getInputs().get(0).getValue();
    if (exchange.getOperatorTag() != LogicalOperatorTag.EXCHANGE)
        return false;
    AbstractLogicalOperator inputOp = (AbstractLogicalOperator) exchange.getInputs().get(0).getValue();
    if (inputOp.getOperatorTag() != LogicalOperatorTag.DATASOURCESCAN)
        return false;
    DataSourceScanOperator scanOp = (DataSourceScanOperator) inputOp;
    ProjectOperator projectOp = (ProjectOperator) project;
    scanOp.addProjectVariables(projectOp.getVariables());
    if (op.getOperatorTag() != LogicalOperatorTag.EXCHANGE) {
        op.getInputs().set(0, project.getInputs().get(0));
    } else {
        op.getInputs().set(0, exchange.getInputs().get(0));
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-asterixdb-hyracks,代码行数:26,代码来源:PushProjectIntoDataSourceScanRule.java

示例10: rewriteWithRuleCollection

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
@Override
public boolean rewriteWithRuleCollection(Mutable<ILogicalOperator> root,
        Collection<IAlgebraicRewriteRule> ruleCollection) throws AlgebricksException {
    boolean anyRuleFired = false;
    boolean anyChange = false;
    do {
        anyChange = false;
        for (IAlgebraicRewriteRule rule : ruleCollection) {
            boolean ruleFired = rewriteOperatorRef(root, rule, true, fullDfs);
            if (ruleFired) {
                anyChange = true;
                anyRuleFired = true;
            }
        }
    } while (anyChange);
    return anyRuleFired;
}
 
开发者ID:apache,项目名称:incubator-asterixdb-hyracks,代码行数:18,代码来源:SequentialFixpointRuleController.java

示例11: visitIndexInsertDeleteUpsertOperator

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
@Override
public ILogicalOperator visitIndexInsertDeleteUpsertOperator(IndexInsertDeleteUpsertOperator op, Void arg)
        throws AlgebricksException {
    List<Mutable<ILogicalExpression>> newPrimaryKeyExpressions = new ArrayList<Mutable<ILogicalExpression>>();
    deepCopyExpressionRefs(newPrimaryKeyExpressions, op.getPrimaryKeyExpressions());
    List<Mutable<ILogicalExpression>> newSecondaryKeyExpressions = new ArrayList<Mutable<ILogicalExpression>>();
    deepCopyExpressionRefs(newSecondaryKeyExpressions, op.getSecondaryKeyExpressions());
    Mutable<ILogicalExpression> newFilterExpression = new MutableObject<ILogicalExpression>(
            ((AbstractLogicalExpression) op.getFilterExpression()).cloneExpression());
    List<Mutable<ILogicalExpression>> newLSMComponentFilterExpressions = new ArrayList<Mutable<ILogicalExpression>>();
    deepCopyExpressionRefs(newLSMComponentFilterExpressions, op.getAdditionalFilteringExpressions());
    IndexInsertDeleteUpsertOperator indexInsertDeleteOp = new IndexInsertDeleteUpsertOperator(
            op.getDataSourceIndex(), newPrimaryKeyExpressions, newSecondaryKeyExpressions, newFilterExpression,
            op.getOperation(), op.isBulkload());
    indexInsertDeleteOp.setAdditionalFilteringExpressions(newLSMComponentFilterExpressions);
    return indexInsertDeleteOp;
}
 
开发者ID:apache,项目名称:incubator-asterixdb-hyracks,代码行数:18,代码来源:OperatorDeepCopyVisitor.java

示例12: mapVariablesInNestedPlans

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
private void mapVariablesInNestedPlans(ILogicalOperator opOrigin, ILogicalOperator arg) throws AlgebricksException {
    AbstractOperatorWithNestedPlans op = (AbstractOperatorWithNestedPlans) opOrigin;
    AbstractOperatorWithNestedPlans argOp = (AbstractOperatorWithNestedPlans) arg;
    List<ILogicalPlan> plans = op.getNestedPlans();
    List<ILogicalPlan> plansArg = argOp.getNestedPlans();
    if (plans.size() != plansArg.size())
        return;
    for (int i = 0; i < plans.size(); i++) {
        List<Mutable<ILogicalOperator>> roots = plans.get(i).getRoots();
        List<Mutable<ILogicalOperator>> rootsArg = plansArg.get(i).getRoots();
        if (roots.size() != rootsArg.size())
            return;
        for (int j = 0; j < roots.size(); j++) {
            ILogicalOperator topOp1 = roots.get(j).getValue();
            ILogicalOperator topOp2 = rootsArg.get(j).getValue();
            topOp1.accept(this, topOp2);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-asterixdb-hyracks,代码行数:20,代码来源:IsomorphismVariableMappingVisitor.java

示例13: getVariable

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
@Override
public Object getVariable(String name) {
    try {
        Mutable<Object> variable = doGetVariable(name);
        if (variable == null) {
            throw new SpongeException("Variable '" + name + "' not found in any of the scripts");
        }

        return variable.getValue();
    } catch (Throwable e) {
        throw SpongeUtils.wrapException("getVariable", e);
    }
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:14,代码来源:GroovyKnowledgeBaseInterpreter.java

示例14: shouldAddToEventTreeForNMode

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
@Override
protected boolean shouldAddToEventTreeForNMode(TreeNode<NodeValue> parentNode, Mutable<TreeNode<NodeValue>> newNodeHolder,
        Event event) {
    handleNoneEventHappenedButShouldNot(parentNode, newNodeHolder.getValue(), event);

    return false;
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:8,代码来源:UnorderedRuleAdapterRuntime.java

示例15: shouldAddToEventTreeForNMode

import org.apache.commons.lang3.mutable.Mutable; //导入依赖的package包/类
@Override
protected boolean shouldAddToEventTreeForNMode(TreeNode<NodeValue> parentNode, Mutable<TreeNode<NodeValue>> newNodeHolder,
        Event event) {
    boolean result = false;

    if (handleNoneEventHappenedButShouldNot(parentNode, newNodeHolder.getValue(), event)) {
        return false;
    }

    // We need only one node marking NONE event that has not happened, so others are removed.
    parentNode.getChildren().subList(1, parentNode.getChildren().size()).clear();

    // Because an event hasn't happened, the value of the node will be set to null.
    TreeNode<NodeValue> emptyNode = parentNode.getChildren().get(0);
    if (emptyNode.getValue().getEvent() != null) {
        emptyNode.getValue().setEvent(null);
    }

    // Recursively build event tree because the event may match one of the following expected events for this rule.
    buildEventTree(emptyNode, event);

    // Add to event tree only when the event does match one of the following expected events.
    if (emptyNode.hasChildren()) {
        result = true;
    }

    // Change newNode in the holder for further processing.
    newNodeHolder.setValue(emptyNode);

    return result;
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:32,代码来源:OrderedRuleAdapterRuntime.java


注:本文中的org.apache.commons.lang3.mutable.Mutable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。