unify the answers by applying multiunifier to variable set
@param multiUnifier multiunifier to be applied to the query answers
@return unified query answers
556084
public QueryAnswers unify(MultiUnifier multiUnifier){
        QueryAnswers unifiedAnswers = new QueryAnswers();
        this.stream()
                .flatMap(multiUnifier::apply)
                .filter(ans -> !ans.isEmpty())
                .forEach(unifiedAnswers::add);
        return unifiedAnswers;
    }
415578
public static UnifiedorderResult payUnifiedorder(Unifiedorder unifiedorder,String key){
		Map<String,String> map = MapUtil.objectToMap(unifiedorder, "detail", "scene_info");
		//@since 2.8.8 detail 字段签名处理
		if(unifiedorder.getDetail() != null){
			map.put("detail",JsonUtil.toJSONString(unifiedorder.getDetail()));
		}
		//@since 2.8.21 scene_info 字段签名处理
		if(unifiedorder.getScene_info() != null){
			map.put("scene_info",JsonUtil.toJSONString(unifiedorder.getScene_info()));
		}
		if(key != null){
			String sign = SignatureUtil.generateSign(map,unifiedorder.getSign_type(),key);
			unifiedorder.setSign(sign);
		}
		String unifiedorderXML = XMLConverUtil.convertToXML(unifiedorder);
		HttpUriRequest httpUriRequest = RequestBuilder.post()
										.setHeader(xmlHeader)
										.setUri(baseURI()+ "/pay/unifiedorder")
										.setEntity(new StringEntity(unifiedorderXML,Charset.forName("utf-8")))
										.build();
		return LocalHttpClient.executeXmlResult(httpUriRequest,UnifiedorderResult.class,unifiedorder.getSign_type(),key);
	}
736414
private Optional<IQ> mergeDefinitions(Collection<IQ> predicateDefinitions,
                                          Optional<ImmutableQueryModifiers> optionalTopModifiers) {
        if (predicateDefinitions.isEmpty())
            return Optional.empty();

        IQ firstDefinition = predicateDefinitions.iterator().next();
        if (predicateDefinitions.size() == 1) {
            return Optional.of(firstDefinition);
        }

        DistinctVariableOnlyDataAtom projectionAtom = firstDefinition.getProjectionAtom();

        VariableGenerator variableGenerator =  coreUtilsFactory.createVariableGenerator(firstDefinition.getTree().getKnownVariables());

        Stream<IQTree> renamedDefinitions = predicateDefinitions.stream()
                .skip(1)
                .map(def -> {
                    // Updates the variable generator
                    InjectiveVar2VarSubstitution disjointVariableSetRenaming = substitutionFactory.generateNotConflictingRenaming(
                            variableGenerator, def.getTree().getKnownVariables());

                    ImmutableSet<Variable> freshVariables = ImmutableSet.copyOf(
                            disjointVariableSetRenaming.getImmutableMap().values());

                    InjectiveVar2VarSubstitution headSubstitution = computeRenamingSubstitution(
                            disjointVariableSetRenaming.applyToDistinctVariableOnlyDataAtom(def.getProjectionAtom()),
                            projectionAtom)
                            .orElseThrow(() -> new IllegalStateException("Bug: unexpected incompatible atoms"));

                    InjectiveVar2VarSubstitution renamingSubstitution =
                            /*
                              fresh variables are excluded from the domain of the renaming substitution
                               since they are in use in the sub-query.

                               NB: this guarantees that the renaming substitution is injective
                             */
                            headSubstitution.composeWithAndPreserveInjectivity(disjointVariableSetRenaming, freshVariables)
                                    .orElseThrow(() -> new IllegalStateException("Bug: the renaming substitution is not injective"));

                    QueryRenamer queryRenamer = transformerFactory.createRenamer(renamingSubstitution);
                    return queryRenamer.transform(def).getTree();
                });

        ImmutableList<IQTree> unionChildren = Stream.concat(Stream.of(firstDefinition.getTree()), renamedDefinitions)
                .collect(ImmutableCollectors.toList());

        IQTree unionTree = iqFactory.createNaryIQTree(iqFactory.createUnionNode(projectionAtom.getVariables()),
                unionChildren);

        IQTree tree = optionalTopModifiers
                .map(m -> m.insertAbove(unionTree, iqFactory))
                .orElse(unionTree);

        return Optional.of(iqFactory.createIQ(projectionAtom, tree));
    }
803031
public CombineOutput combine(final List<ShareInfo> usetheseshares)
    {
        CombineOutput ret = null;

        sanityCheckPublicInfos(publicInfo, usetheseshares);

        if (true)
        {
            println(" SOLVING USING THESE SHARES, mod=" + publicInfo.getPrimeModulus());
            for (ShareInfo si : usetheseshares)
            {
                println("   " + si.share);
            }
            println("end SOLVING USING THESE SHARES");
        }
        if (publicInfo.getK() > usetheseshares.size())
        {
            throw new SecretShareException("Must have " + publicInfo.getK() +
                                           " shares to solve.  Only provided " +
                                           usetheseshares.size());
        }

        checkForDuplicatesOrThrow(usetheseshares);


        final int size = publicInfo.getK();
        BigInteger[] xarray = new BigInteger[size];
        BigInteger[] fofxarray = new BigInteger[size];
        for (int i = 0, n = size; i < n; i++)
        {
            xarray[i] = usetheseshares.get(i).getXasBigInteger();
            fofxarray[i] = usetheseshares.get(i).getShare();
        }
        EasyLinearEquation ele =
            EasyLinearEquation.createForPolynomial(xarray, fofxarray);
        if (publicInfo.getPrimeModulus() != null)
        {
            ele = ele.createWithPrimeModulus(publicInfo.getPrimeModulus());
        }

        BigInteger solveSecret = null;

        if (false)
        {
            EasyLinearEquation.EasySolve solve = ele.solve();

            solveSecret = solve.getAnswer(1);
        }
        else
        {
            BigInteger[][] matrix = ele.getMatrix();
            NumberMatrix.print("SS.java", matrix, out);
            println("CVT matrix.height=" + matrix.length + " width=" + matrix[0].length);
            BigRationalMatrix brm = BigRationalMatrix.create(matrix);
            NumberMatrix.print("SS.java brm", brm.getArray(), out);

            NumberSimplex<BigRational> simplex = new NumberSimplex<BigRational>(brm, 0);
            simplex.initForSolve(out);
            simplex.solve(out);

            BigRational answer = simplex.getAnswer(0);
            if (publicInfo.getPrimeModulus() != null)
            {
                solveSecret = answer.computeBigIntegerMod(publicInfo.getPrimeModulus());
            }
            else
            {
                solveSecret = answer.bigIntegerValue();
            }
        }

        if (publicInfo.getPrimeModulus() != null)
        {
            solveSecret = solveSecret.mod(publicInfo.getPrimeModulus());
        }
        ret = new CombineOutput(solveSecret);


        return ret;
    }
491179
public JTSGeometryExpression<Geometry> union(Expression<? extends Geometry> geometry) {
        return JTSGeometryExpressions.geometryOperation(SpatialOps.UNION, mixin, geometry);
    }
284129
public JCExpression getUnderlyingBinding(Unifier unifier) {
    return (unifier == null) ? null : unifier.getBinding(new UFreeIdent.Key(identifier()));
  }
706821
@javax.annotation.Nonnull
  public com.simiacryptus.util.data.DoubleStatistics combine(@javax.annotation.Nonnull final com.simiacryptus.util.data.DoubleStatistics other) {
    super.combine(other);
    simpleSumOfSquare += other.simpleSumOfSquare;
    sumOfSquareWithCompensation(other.sumOfSquare);
    sumOfSquareWithCompensation(other.sumOfSquareCompensation);
    return this;
  }
1323933
public Multiset<O> difference(Multiset<O> multiset) throws ParameterException {
		Validate.notNull(multiset);
		Multiset<O> result = new Multiset<>();
		for (O o : support()) {
			if (multiset.multiplicity(o) > 0) {
				result.setMultiplicity(o, Math.max(0, multiplicity(o) - multiset.multiplicity(o)));
			} else {
				result.setMultiplicity(o, multiplicity(o));
			}
		}
		return result;
	}
849353
public static <T, U extends Unifiable<? super T>> Choice<Unifier> unifyList(
      Unifier unifier, @Nullable List<U> toUnify, @Nullable final List<? extends T> targets) {
    return unifyList(unifier, toUnify, targets, /* allowVarargs= */ false);
  }
1358569
@SuppressWarnings("unchecked")
	public <OUT extends Tuple> SingleOutputStreamOperator<OUT> projectTupleX() {
		SingleOutputStreamOperator<OUT> projOperator = null;

		switch (fieldIndexes.length) {
			case 1: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple1(); break;
			case 2: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple2(); break;
			case 3: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple3(); break;
			case 4: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple4(); break;
			case 5: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple5(); break;
			case 6: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple6(); break;
			case 7: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple7(); break;
			case 8: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple8(); break;
			case 9: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple9(); break;
			case 10: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple10(); break;
			case 11: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple11(); break;
			case 12: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple12(); break;
			case 13: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple13(); break;
			case 14: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple14(); break;
			case 15: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple15(); break;
			case 16: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple16(); break;
			case 17: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple17(); break;
			case 18: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple18(); break;
			case 19: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple19(); break;
			case 20: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple20(); break;
			case 21: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple21(); break;
			case 22: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple22(); break;
			case 23: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple23(); break;
			case 24: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple24(); break;
			case 25: projOperator = (SingleOutputStreamOperator<OUT>) projectTuple25(); break;
			default:
				throw new IllegalStateException("Excessive arity in tuple.");
		}

		return projOperator;
	}
183391
private IQ mergeDefinitions(Collection<IQ> queries) {
        return queryMerger.mergeDefinitions(queries)
                .orElseThrow(() -> new MappingMergingException("The query should be present"));
    }
1188650
protected List<WorkUnit> squeezeMultiWorkUnits(List<MultiWorkUnit> multiWorkUnits) {
    List<WorkUnit> workUnits = Lists.newArrayList();
    for (MultiWorkUnit multiWorkUnit : multiWorkUnits) {
      workUnits.add(squeezeMultiWorkUnit(multiWorkUnit));
    }
    return workUnits;
  }
1016594
protected MultiStringWrapper asMultiStringWrapper(StringWrapper w) {
		if (w instanceof MultiStringWrapper) return (MultiStringWrapper)w;
		else return (MultiStringWrapper)prepare(w.unwrap());
	}
328019
protected MultiMap resolveHeaders()
    {
        MultiMap resolved = null;
        if(headerFactory != null)
            resolved = headerFactory.getHeaders();

        if(resolved != null)
            resolved = resolved.merge(headers);
        else
            resolved = headers;

        return resolved;
    }
894294
public UnifiedOrderResponse unifiedOrder(UnifiedOrderRequest unifiedOrderRequest) {
        UnifiedOrderRequestWrapper wrapper = new UnifiedOrderRequestWrapper();
        wrapper.setRequest(unifiedOrderRequest);
        setBaseSettings(wrapper);
        SortedMap<String, Object> unifiedOrderRequestMap = JsonMapper.nonEmptyMapper().getMapper().convertValue(wrapper, SortedMap.class);
        sign(wrapper, unifiedOrderRequestMap);

        String url = WxEndpoint.get("url.pay.payment.order.unified");
        try {
            String xml = XmlObjectMapper.nonEmptyMapper().toXml(wrapper);
            logger.info("支付 unified order request: {}", xml);
            String response = wxSslClient.post(url, xml);
            logger.info("支付 unified order response: {}", response);

            UnifiedOrderResponseWrapper responseWrapper = XmlObjectMapper.defaultMapper().fromXml(response, UnifiedOrderResponseWrapper.class);
            return responseWrapper.getResponse();
        } catch (Exception e) {
            throw new WxRuntimeException(999, "pre order failed:" + e.getMessage());
        }

    }
322664
public static Assignment unionAll(Collection<Assignment> assignments) {
    int numVars = 0;
    for (Assignment assignment : assignments) {
      numVars += assignment.size();
    }

    int[] vars = new int[numVars];
    Object[] values = new Object[numVars];
    int numFilled = 0;
    for (Assignment assignment : assignments) {
      int[] assignmentVars = assignment.vars;
      Object[] assignmentValues = assignment.values;
      int numAssignmentVars = assignment.vars.length;
      for (int i = 0; i < numAssignmentVars; i++) {
        vars[numFilled] = assignmentVars[i];
        values[numFilled] = assignmentValues[i];
        numFilled++;
      }
    }
    Preconditions.checkState(numFilled == numVars);
    return Assignment.fromUnsortedArrays(vars, values);
  }
1078174
@SuppressWarnings("unchecked")
    public static List<LineString> mergeLinestrings( List<LineString> multiLines ) {
        LineMerger lineMerger = new LineMerger();
        for( int i = 0; i < multiLines.size(); i++ ) {
            Geometry line = multiLines.get(i);
            lineMerger.add(line);
        }
        Collection<Geometry> merged = lineMerger.getMergedLineStrings();
        List<LineString> mergedList = new ArrayList<>();
        for( Geometry geom : merged ) {
            mergedList.add((LineString) geom);
        }
        return mergedList;
    }