类org.apache.commons.lang3.mutable.Mutable源码实例Demo

下面列出了怎么用org.apache.commons.lang3.mutable.Mutable的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: vxquery   文件: PushChildIntoDataScanRule.java
@Override
boolean updateDataSource(IVXQueryDataSource datasource, Mutable<ILogicalExpression> expression) {
    List<Mutable<ILogicalExpression>> finds = new ArrayList<Mutable<ILogicalExpression>>();
    boolean added = false;

    ExpressionToolbox.findAllFunctionExpressions(expression, BuiltinOperators.CHILD.getFunctionIdentifier(), finds);
    for (int i = finds.size(); i > 0; --i) {
        int typeId = ExpressionToolbox.getTypeExpressionTypeArgument(finds.get(i - 1));
        if (typeId > 0) {
            ElementType it = (ElementType) dCtx.lookupSequenceType(typeId).getItemType();
            ElementType et = ElementType.ANYELEMENT;

            if (it.getContentType().equals(et.getContentType())) {
                datasource.addChildSeq(typeId);
                added = true;
            }
        }
    }
    return added;
}
 
源代码2 项目: commons-configuration   文件: InMemoryNodeModel.java
/**
 * Creates tracked node entries for the specified nodes and creates the
 * corresponding selectors.
 *
 * @param refSelectors the reference where to store the selectors
 * @param nodes the nodes to be tracked
 * @param current the current {@code TreeData} object
 * @param resolver the {@code NodeKeyResolver}
 * @return the updated {@code TreeData} object
 */
private static TreeData createSelectorsForTrackedNodes(
        final Mutable<Collection<NodeSelector>> refSelectors,
        final List<ImmutableNode> nodes, final TreeData current,
        final NodeKeyResolver<ImmutableNode> resolver)
{
    final List<NodeSelector> selectors =
            new ArrayList<>(nodes.size());
    final Map<ImmutableNode, String> cache = new HashMap<>();
    for (final ImmutableNode node : nodes)
    {
        selectors.add(new NodeSelector(resolver.nodeKey(node, cache,
                current)));
    }
    refSelectors.setValue(selectors);
    final NodeTracker newTracker =
            current.getNodeTracker().trackNodes(selectors, nodes);
    return current.updateNodeTracker(newTracker);
}
 
源代码3 项目: vxquery   文件: PushGroupByThroughProduct.java
private void push(Mutable<ILogicalOperator> opRefGby, Mutable<ILogicalOperator> opRefJoin, int branch,
        List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> decorToPush,
        List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> decorNotToPush, IOptimizationContext context)
                throws AlgebricksException {
    GroupByOperator gby = (GroupByOperator) opRefGby.getValue();
    AbstractBinaryJoinOperator join = (AbstractBinaryJoinOperator) opRefJoin.getValue();
    gby.getDecorList().clear();
    gby.getDecorList().addAll(decorToPush);
    for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : decorNotToPush) {
        LogicalVariable v1 = p.first;
        if (v1 != null) {
            VariableReferenceExpression varRef = (VariableReferenceExpression) p.second.getValue();
            LogicalVariable v2 = varRef.getVariableReference();
            OperatorManipulationUtil.substituteVarRec(join, v2, v1, true, context);
        }
    }
    Mutable<ILogicalOperator> branchRef = join.getInputs().get(branch);
    ILogicalOperator opBranch = branchRef.getValue();
    opRefJoin.setValue(opBranch);
    branchRef.setValue(gby);
    opRefGby.setValue(join);
}
 
源代码4 项目: vxquery   文件: PushIndexingIntoDatascanRule.java
public void findChildren(VXQueryIndexingDataSource ids, Mutable<ILogicalExpression> expression) {
    List<Mutable<ILogicalExpression>> children = new ArrayList<>();
    List<Mutable<ILogicalExpression>> valueEqch = new ArrayList<>();
    ExpressionToolbox.findAllFunctionExpressions(expression, BuiltinOperators.GENERAL_EQ.getFunctionIdentifier(),
            valueEqch);
    if (valueEqch.isEmpty()) {
        ExpressionToolbox.findAllFunctionExpressions(expression, AlgebricksBuiltinFunctions.EQ, valueEqch);
        if (valueEqch.isEmpty()) {
            return;
        }
    }
    ExpressionToolbox.findAllFunctionExpressions(valueEqch.get(valueEqch.size() - 1),
            BuiltinOperators.CHILD.getFunctionIdentifier(), children);
    for (int i = children.size(); i > 0; --i) {
        int typeId = ExpressionToolbox.getTypeExpressionTypeArgument(children.get(i - 1));
        if (typeId > 0) {
            ElementType it = (ElementType) dCtx.lookupSequenceType(typeId).getItemType();
            ElementType et = ElementType.ANYELEMENT;

            if (it.getContentType().equals(et.getContentType())) {
                ids.addIndexChildSeq(typeId);
            }
        }
    }
    findAttributes(ids, valueEqch.get(valueEqch.size() - 1));
}
 
源代码5 项目: vxquery   文件: OperatorToolbox.java
public static Mutable<ILogicalExpression> getExpressionOf(Mutable<ILogicalOperator> opRef, LogicalVariable lv) {
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    switch (op.getOperatorTag()) {
        case AGGREGATE:
        case ASSIGN:
        case RUNNINGAGGREGATE:
            AbstractAssignOperator aao = (AbstractAssignOperator) op;
            if (!aao.getVariables().contains(lv)) {
                return null;
            }
            return aao.getExpressions().get(aao.getVariables().indexOf(lv));
        case UNNEST:
        case UNNEST_MAP:
            AbstractUnnestOperator ano = (AbstractUnnestOperator) op;
            return ano.getExpressionRef();
        default:
            // TODO Not yet implemented.
            break;
    }
    return null;
}
 
源代码6 项目: vxquery   文件: IntroduceIndexingRule.java
@Override
public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
        throws AlgebricksException {
    VXQueryOptimizationContext vxqueryContext = (VXQueryOptimizationContext) context;
    String args[] = getFunctionalArguments(opRef, VXQueryCommons.indexingFunctions);

    if (args != null) {

        String collection = args[0];
        // Build the new operator and update the query plan.
        int collectionId = vxqueryContext.newCollectionId();
        VXQueryIndexingDataSource ids = VXQueryIndexingDataSource.create(collectionId, collection,
                SequenceType.create(AnyItemType.INSTANCE, Quantifier.QUANT_STAR),
                functionCall.getFunctionIdentifier().getName());
        if (ids != null) {
            ids.setTotalDataSources(vxqueryContext.getTotalDataSources());

            // Known to be true because of collection name.
            return setDataSourceScan(ids, opRef);
        }
    }
    return false;
}
 
@Override
public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
    if (hasRun && !firstOpRef.equals(opRef)) {
        return false;
    } else {
        firstOpRef = opRef;
    }
    boolean modified = false;
    boolean modified_last_pass;
    do {
        usedVariables.clear();
        modified_last_pass = rewritePreTrackingUsedVariables(opRef, context);
        if (modified_last_pass) {
            modified = modified_last_pass;
        }
    } while (modified_last_pass);
    hasRun = true;
    return modified;
}
 
源代码8 项目: vxquery   文件: PushAggregateIntoGroupbyRule.java
private void rewriteGroupByAggregate(LogicalVariable oldAggVar, GroupByOperator gbyOp,
        AggregateFunctionCallExpression aggFun, LogicalVariable newAggVar, IOptimizationContext context)
                throws AlgebricksException {
    for (int j = 0; j < gbyOp.getNestedPlans().size(); j++) {
        AggregateOperator aggOp = (AggregateOperator) gbyOp.getNestedPlans().get(j).getRoots().get(0).getValue();
        int n = aggOp.getVariables().size();
        for (int i = 0; i < n; i++) {
            LogicalVariable v = aggOp.getVariables().get(i);
            if (v.equals(oldAggVar)) {
                AbstractFunctionCallExpression oldAggExpr = (AbstractFunctionCallExpression) aggOp.getExpressions()
                        .get(i).getValue();
                AggregateFunctionCallExpression newAggFun = new AggregateFunctionCallExpression(
                        aggFun.getFunctionInfo(), false, new ArrayList<Mutable<ILogicalExpression>>());
                for (Mutable<ILogicalExpression> arg : oldAggExpr.getArguments()) {
                    ILogicalExpression cloned = ((AbstractLogicalExpression) arg.getValue()).cloneExpression();
                    newAggFun.getArguments().add(new MutableObject<ILogicalExpression>(cloned));
                }
                aggOp.getVariables().add(newAggVar);
                aggOp.getExpressions().add(new MutableObject<ILogicalExpression>(newAggFun));
                context.computeAndSetTypeEnvironmentForOperator(aggOp);
                break;
            }
        }
    }
}
 
源代码9 项目: commons-configuration   文件: InMemoryNodeModel.java
/**
 * Allows tracking all nodes selected by a key. This method evaluates the
 * specified key on the current nodes structure. For all selected nodes
 * corresponding {@code NodeSelector} objects are created, and they are
 * tracked. The returned collection of {@code NodeSelector} objects can be
 * used for interacting with the selected nodes.
 *
 * @param key the key for selecting the nodes to track
 * @param resolver the {@code NodeKeyResolver}
 * @return a collection with the {@code NodeSelector} objects for the new
 *         tracked nodes
 */
public Collection<NodeSelector> selectAndTrackNodes(final String key,
        final NodeKeyResolver<ImmutableNode> resolver)
{
    final Mutable<Collection<NodeSelector>> refSelectors =
            new MutableObject<>();
    boolean done;
    do
    {
        final TreeData current = structure.get();
        final List<ImmutableNode> nodes =
                resolver.resolveNodeKey(current.getRootNode(), key, current);
        if (nodes.isEmpty())
        {
            return Collections.emptyList();
        }
        done =
                structure.compareAndSet(
                        current,
                        createSelectorsForTrackedNodes(refSelectors, nodes,
                                current, resolver));
    } while (!done);
    return refSelectors.getValue();
}
 
源代码10 项目: vxquery   文件: ExpressionToolbox.java
public static Mutable<ILogicalExpression> findVariableExpression(Mutable<ILogicalExpression> mutableLe,
        LogicalVariable lv) {
    ILogicalExpression le = mutableLe.getValue();
    if (le.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
        VariableReferenceExpression vre = (VariableReferenceExpression) le;
        if (vre.getVariableReference() == lv) {
            return mutableLe;
        }
    } else if (le.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
        AbstractFunctionCallExpression afce = (AbstractFunctionCallExpression) le;
        for (Mutable<ILogicalExpression> argExp : afce.getArguments()) {
            Mutable<ILogicalExpression> resultLe = findVariableExpression(argExp, lv);
            if (resultLe != null) {
                return resultLe;
            }
        }
    }
    return null;
}
 
public boolean convertFunctionToAlgebricksExpression(Mutable<ILogicalExpression> searchM,
        AbstractFunctionCallExpression functionCall, IOptimizationContext context,
        Map<FunctionIdentifier, FunctionIdentifier> map) {

    if (map.containsKey(functionCall.getFunctionIdentifier())) {
        IExpressionAnnotation annotate = new ExpressionAnnotationNoCopyImpl();
        annotate.setObject(functionCall.getFunctionIdentifier());
        FunctionIdentifier algebricksFid = map.get(functionCall.getFunctionIdentifier());
        IFunctionInfo algebricksFunction = context.getMetadataProvider().lookupFunction(algebricksFid);
        functionCall.setFunctionInfo(algebricksFunction);
        functionCall.getAnnotations().put(ALGEBRICKS_CONVERSION_ANNOTATION, annotate);
        searchM.setValue(functionCall);
        return true;
    }
    return false;
}
 
源代码12 项目: SkyblockAddons   文件: ConfigValues.java
private <N extends Number> void deserializeNumber(Mutable<Number> number, String path, Class<N> numberClass) {
    try {
        if (settingsConfig.has(path)) {
            number.setValue(getNumber(settingsConfig.get(path), numberClass));
        }
    } catch (Exception ex) {
        SkyblockAddons.getInstance().getLogger().error("Failed to deserialize path: "+ path);
        ex.printStackTrace();
    }
}
 
源代码13 项目: vxquery   文件: XMLQueryTranslator.java
private static ILogicalExpression afce(Function fn, boolean isTwoStep, ILogicalExpression... argExprs) {
    List<Mutable<ILogicalExpression>> args = new ArrayList<Mutable<ILogicalExpression>>();
    for (ILogicalExpression e : argExprs) {
        args.add(mutable(e));
    }
    return new AggregateFunctionCallExpression(fn, isTwoStep, args);
}
 
源代码14 项目: vxquery   文件: XMLQueryTranslator.java
private static ILogicalExpression ufce(Function fn, ILogicalExpression... argExprs) {
    List<Mutable<ILogicalExpression>> args = new ArrayList<Mutable<ILogicalExpression>>();
    for (ILogicalExpression e : argExprs) {
        args.add(mutable(e));
    }
    return new UnnestingFunctionCallExpression(fn, args);
}
 
源代码15 项目: vxquery   文件: XMLQueryTranslator.java
private static ILogicalExpression sfce(Function fn, ILogicalExpression... argExprs) {
    List<Mutable<ILogicalExpression>> args = new ArrayList<Mutable<ILogicalExpression>>();
    for (ILogicalExpression e : argExprs) {
        args.add(mutable(e));
    }
    return new ScalarFunctionCallExpression(fn, args);
}
 
源代码16 项目: vxquery   文件: XMLQueryTranslator.java
private static ILogicalExpression createFunctionCall(Function fn, List<LogicalVariable> vars) {
    List<Mutable<ILogicalExpression>> args = new ArrayList<Mutable<ILogicalExpression>>();
    for (LogicalVariable var : vars) {
        args.add(mutable(new VariableReferenceExpression(var)));
    }
    return new ScalarFunctionCallExpression(fn, args);
}
 
protected StringBuilder appendArguments(StringBuilder sb, List<Mutable<ILogicalExpression>> args, Integer indent)
        throws AlgebricksException {
    sb.append("[\n");
    for (Mutable<ILogicalExpression> arg : args) {
        addIndent(sb, indent + 2).append(arg.getValue().accept(this, indent + 2)).append("\n");
    }
    return addIndent(sb, indent).append("]");
}
 
源代码18 项目: vxquery   文件: ExpressionToolbox.java
public static SequenceType getTypeExpressionTypeArgument(Mutable<ILogicalExpression> searchM, StaticContext dCtx) {
    int typeId = getTypeExpressionTypeArgument(searchM);
    if (typeId > 0) {
        return dCtx.lookupSequenceType(typeId);
    } else {
        return null;
    }
}
 
源代码19 项目: vxquery   文件: VXQueryExpressionRuntimeProvider.java
private IScalarEvaluatorFactory[] createArgumentEvaluatorFactories(IVariableTypeEnvironment env,
        IOperatorSchema[] inputSchemas, JobGenContext context, List<Mutable<ILogicalExpression>> args)
        throws AlgebricksException {
    IScalarEvaluatorFactory[] argFactories = new IScalarEvaluatorFactory[args.size()];
    for (int i = 0; i < argFactories.length; ++i) {
        Mutable<ILogicalExpression> arg = args.get(i);
        argFactories[i] = createEvaluatorFactory(arg.getValue(), env, inputSchemas, context);
    }
    return argFactories;
}
 
public List<Mutable<ILogicalOperator>> isNestedPlanOperator(Mutable<ILogicalOperator> opRef) {
    List<Mutable<ILogicalOperator>> nestedPlans = new ArrayList<Mutable<ILogicalOperator>>();
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue().getInputs().get(0).getValue();
    if (op.hasNestedPlans()) {
        AbstractOperatorWithNestedPlans aownp = (AbstractOperatorWithNestedPlans) op;
        for (Mutable<ILogicalOperator> input : aownp.getNestedPlans().get(0).getRoots()) {
            nestedPlans.add(input);
        }
    }
    return nestedPlans;
}
 
源代码21 项目: vxquery   文件: PushIndexingIntoDatascanRule.java
@Override
protected boolean processOperator(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
        throws AlgebricksException {
    if (context.checkIfInDontApplySet(this, opRef.getValue())) {
        return false;
    }
    AbstractLogicalOperator op2 = null;

    if (dCtx == null) {
        VXQueryOptimizationContext vxqueryCtx = (VXQueryOptimizationContext) context;
        dCtx = ((VXQueryMetadataProvider) vxqueryCtx.getMetadataProvider()).getStaticContext();
    }
    AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue();
    if (op1.getOperatorTag() != LogicalOperatorTag.SELECT) {
        return false;
    }
    SelectOperator select = (SelectOperator) op1;

    op2 = (AbstractLogicalOperator) select.getInputs().get(0).getValue();

    if (op2.getOperatorTag() != LogicalOperatorTag.DATASOURCESCAN) {
        return false;
    }

    DataSourceScanOperator datascan = (DataSourceScanOperator) op2;

    if (!usedVariables.contains(datascan.getVariables())) {

        Mutable<ILogicalExpression> expressionRef = select.getCondition();
        if (!(updateDataSource((IVXQueryDataSource) datascan.getDataSource(), expressionRef))) {
            return false;
        }
        context.addToDontApplySet(this, opRef.getValue());
        return true;
    }

    return false;

}
 
源代码22 项目: vxquery   文件: ExpressionToolbox.java
public static Mutable<ILogicalExpression> findVariableExpression(Mutable<ILogicalExpression> mutableLe) {
    ILogicalExpression le = mutableLe.getValue();
    if (le.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
        return mutableLe;
    } else if (le.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
        AbstractFunctionCallExpression afce = (AbstractFunctionCallExpression) le;
        for (Mutable<ILogicalExpression> argExp : afce.getArguments()) {
            Mutable<ILogicalExpression> resultLe = findVariableExpression(argExp);
            if (resultLe != null) {
                return resultLe;
            }
        }
    }
    return null;
}
 
源代码23 项目: vxquery   文件: PushIndexingIntoDatascanRule.java
public void findValues(VXQueryIndexingDataSource ids, Mutable<ILogicalExpression> expression) {
    Byte[] index = null;
    AbstractFunctionCallExpression valueEq = (AbstractFunctionCallExpression) expression.getValue();
    if (valueEq.getArguments().get(1).getValue().getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
        index = ExpressionToolbox.getConstantArgument(valueEq.getArguments().get(1), 0);
    } else {
        index = convertConstantToInteger(valueEq.getArguments().get(1));
    }
    ids.addIndexValueSeq(index);
}
 
源代码24 项目: vxquery   文件: SetCollectionDataSourceRule.java
@Override
public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
        throws AlgebricksException {
    if (context.checkIfInDontApplySet(this, opRef.getValue())) {
        return false;
    }
    VXQueryOptimizationContext vxqueryContext = (VXQueryOptimizationContext) context;
    vxqueryContext.incrementTotalDataSources();
    context.addToDontApplySet(this, opRef.getValue());
    return false;
}
 
@Override
public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
        throws AlgebricksException {
    boolean modified = false;
    List<Mutable<ILogicalExpression>> expressions = OperatorToolbox.getExpressions(opRef);
    for (Mutable<ILogicalExpression> expression : expressions) {
        if (processTypeExpression(opRef, expression)) {
            context.computeAndSetTypeEnvironmentForOperator(opRef.getValue());
            modified = true;
        }
    }
    return modified;
}
 
源代码26 项目: astor   文件: MethodUtilsTest.java
@Test
public void testGetAccessibleInterfaceMethod() throws Exception {
    Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
    for (Class<?>[] element : p) {
        Method method = TestMutable.class.getMethod("getValue", element);
        Method accessibleMethod = MethodUtils.getAccessibleMethod(method);
        assertNotSame(accessibleMethod, method);
        assertSame(Mutable.class, accessibleMethod.getDeclaringClass());
    }
}
 
源代码27 项目: astor   文件: MethodUtilsTest.java
@Test
public void testGetAccessibleInterfaceMethodFromDescription()
        throws Exception {
    final Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
    for (final Class<?>[] element : p) {
        final Method accessibleMethod = MethodUtils.getAccessibleMethod(
                TestMutable.class, "getValue", element);
        assertSame(Mutable.class, accessibleMethod.getDeclaringClass());
    }
}
 
private int getOperatorSortDistinctNodesAscOrAtomicsArgumentVariableId(Mutable<ILogicalOperator> opRef) {
    // Check if assign is for sort-distinct-nodes-asc-or-atomics.
    AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
    if (op.getOperatorTag() != LogicalOperatorTag.ASSIGN) {
        return 0;
    }
    AssignOperator assign = (AssignOperator) op;

    // Check to see if the expression is a function and
    // sort-distinct-nodes-asc-or-atomics.
    ILogicalExpression logicalExpression = (ILogicalExpression) assign.getExpressions().get(0).getValue();
    if (logicalExpression.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
        return 0;
    }
    AbstractFunctionCallExpression functionCall = (AbstractFunctionCallExpression) logicalExpression;
    if (!functionCall.getFunctionIdentifier()
            .equals(BuiltinOperators.SORT_DISTINCT_NODES_ASC_OR_ATOMICS.getFunctionIdentifier())) {
        return 0;
    }

    // Find the variable id used as the parameter.
    ILogicalExpression logicalExpression2 = (ILogicalExpression) functionCall.getArguments().get(0).getValue();
    if (logicalExpression2.getExpressionTag() != LogicalExpressionTag.VARIABLE) {
        return 0;
    }
    VariableReferenceExpression variableExpression = (VariableReferenceExpression) logicalExpression2;
    return variableExpression.getVariableReference().getId();
}
 
private UniqueNodes propagateUniqueNodes(ILogicalExpression expr, HashMap<Integer, UniqueNodes> variableMap) {
    UniqueNodes uniqueNodes = null;
    switch (expr.getExpressionTag()) {
        case FUNCTION_CALL:
            AbstractFunctionCallExpression functionCall = (AbstractFunctionCallExpression) expr;

            // Look up all arguments.
            List<UniqueNodes> argProperties = new ArrayList<UniqueNodes>();
            for (Mutable<ILogicalExpression> argExpr : functionCall.getArguments()) {
                argProperties.add(propagateUniqueNodes(argExpr.getValue(), variableMap));
            }

            // Propagate the property.
            Function func = (Function) functionCall.getFunctionInfo();
            uniqueNodes = func.getUniqueNodesPropagationPolicy().propagate(argProperties);
            break;
        case VARIABLE:
            VariableReferenceExpression variableReference = (VariableReferenceExpression) expr;
            int argVariableId = variableReference.getVariableReference().getId();
            uniqueNodes = variableMap.get(argVariableId);
            break;
        case CONSTANT:
        default:
            uniqueNodes = UniqueNodes.YES;
            break;
    }
    return uniqueNodes;
}
 
源代码30 项目: astor   文件: MethodUtilsTest.java
@Test
public void testGetAccessibleInterfaceMethodFromDescription()
        throws Exception {
    Class<?>[][] p = { ArrayUtils.EMPTY_CLASS_ARRAY, null };
    for (Class<?>[] element : p) {
        Method accessibleMethod = MethodUtils.getAccessibleMethod(
                TestMutable.class, "getValue", element);
        assertSame(Mutable.class, accessibleMethod.getDeclaringClass());
    }
}
 
 类所在包
 同包方法