List of usage examples for java.util LinkedList addAll
public boolean addAll(Collection<? extends E> c)
From source file:pt.ist.vaadinframework.data.AbstractBufferedItem.java
private void applyWriter() { if (writer != null) { try {/* w w w. jav a 2s . c om*/ if (fieldDiffer(writer.getOrderedArguments())) { LinkedList<Class<?>> argumentTypes = new LinkedList<Class<?>>(); argumentTypes.add(getType()); argumentTypes.addAll(Arrays.asList(getArgumentTypes(writer.getOrderedArguments()))); Method method = findMethod(writer.getClass(), argumentTypes.toArray(new Class<?>[0])); LinkedList<Object> argumentValues = new LinkedList<Object>(); argumentValues.add(cache); argumentValues.addAll(Arrays.asList(readArguments(writer.getOrderedArguments()))); // VaadinFrameworkLogger.getLogger().debug( // "persisting item with writer with properties: [" // + StringUtils.join(writer.getOrderedArguments(), ", ") + // "] with values: [" // + StringUtils.join(argumentValues.subList(1, // argumentValues.size()), ", ") + "]"); method.invoke(writer, argumentValues.toArray(new Object[0])); for (Id id : writer.getOrderedArguments()) { if (getItemProperty(id) instanceof Buffered) { ((Buffered) getItemProperty(id)).discard(); } } } } catch (Throwable e) { ServiceUtils.handleException(e); throw new SourceException(this, e); } } }
From source file:com.asakusafw.runtime.directio.DirectDataSourceRepository.java
/** * Returns all {@link DirectDataSource}s registered in this repository. * @return all {@link DirectDataSource}s * @throws IOException if failed to initialize data sources * @throws InterruptedException if interrupted *//* ww w . j av a 2 s . c o m*/ public Collection<String> getContainerPaths() throws IOException, InterruptedException { Collection<String> results = new ArrayList<>(); LinkedList<Node> work = new LinkedList<>(); work.add(root); while (work.isEmpty() == false) { Node node = work.removeFirst(); if (node.hasContent()) { results.add(node.path.getPathString()); } work.addAll(node.children.values()); } return results; }
From source file:org.apache.pig.pen.ExampleGenerator.java
public Collection<IdentityHashSet<Tuple>> getEqClasses() { Map<LogicalRelationalOperator, Collection<IdentityHashSet<Tuple>>> logToEqclassesMap = getLoToEqClassMap(); LinkedList<IdentityHashSet<Tuple>> ret = new LinkedList<IdentityHashSet<Tuple>>(); for (Map.Entry<LogicalRelationalOperator, Collection<IdentityHashSet<Tuple>>> entry : logToEqclassesMap .entrySet()) {/*from w w w . j a v a2 s.c o m*/ if (entry.getValue() != null) ret.addAll(entry.getValue()); } return ret; }
From source file:org.apache.hyracks.algebricks.rewriter.rules.PushSelectIntoJoinRule.java
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { Collection<LogicalVariable> joinLiveVarsLeft = new HashSet<LogicalVariable>(); Collection<LogicalVariable> joinLiveVarsRight = new HashSet<LogicalVariable>(); Collection<LogicalVariable> liveInOpsToPushLeft = new HashSet<LogicalVariable>(); Collection<LogicalVariable> liveInOpsToPushRight = new HashSet<LogicalVariable>(); List<ILogicalOperator> pushedOnLeft = new ArrayList<ILogicalOperator>(); List<ILogicalOperator> pushedOnRight = new ArrayList<ILogicalOperator>(); List<ILogicalOperator> pushedOnEither = new ArrayList<ILogicalOperator>(); LinkedList<ILogicalOperator> notPushedStack = new LinkedList<ILogicalOperator>(); Collection<LogicalVariable> usedVars = new HashSet<LogicalVariable>(); Collection<LogicalVariable> producedVars = new HashSet<LogicalVariable>(); AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (op.getOperatorTag() != LogicalOperatorTag.SELECT) { return false; }//from ww w.j av a 2s . c o m SelectOperator select = (SelectOperator) op; Mutable<ILogicalOperator> opRef2 = op.getInputs().get(0); AbstractLogicalOperator son = (AbstractLogicalOperator) opRef2.getValue(); AbstractLogicalOperator op2 = son; boolean needToPushOps = false; while (son.isMap()) { needToPushOps = true; Mutable<ILogicalOperator> opRefLink = son.getInputs().get(0); son = (AbstractLogicalOperator) opRefLink.getValue(); } if (son.getOperatorTag() != LogicalOperatorTag.INNERJOIN && son.getOperatorTag() != LogicalOperatorTag.LEFTOUTERJOIN) { return false; } boolean isLoj = son.getOperatorTag() == LogicalOperatorTag.LEFTOUTERJOIN; AbstractBinaryJoinOperator join = (AbstractBinaryJoinOperator) son; Mutable<ILogicalOperator> joinBranchLeftRef = join.getInputs().get(0); Mutable<ILogicalOperator> joinBranchRightRef = join.getInputs().get(1); if (needToPushOps) { ILogicalOperator joinBranchLeft = joinBranchLeftRef.getValue(); ILogicalOperator joinBranchRight = joinBranchRightRef.getValue(); VariableUtilities.getLiveVariables(joinBranchLeft, joinLiveVarsLeft); VariableUtilities.getLiveVariables(joinBranchRight, joinLiveVarsRight); Mutable<ILogicalOperator> opIterRef = opRef2; ILogicalOperator opIter = op2; while (opIter != join) { LogicalOperatorTag tag = ((AbstractLogicalOperator) opIter).getOperatorTag(); if (tag == LogicalOperatorTag.PROJECT) { notPushedStack.addFirst(opIter); } else { VariableUtilities.getUsedVariables(opIter, usedVars); VariableUtilities.getProducedVariables(opIter, producedVars); if (usedVars.size() == 0) { pushedOnEither.add(opIter); } else if (joinLiveVarsLeft.containsAll(usedVars)) { pushedOnLeft.add(opIter); liveInOpsToPushLeft.addAll(producedVars); } else if (joinLiveVarsRight.containsAll(usedVars)) { pushedOnRight.add(opIter); liveInOpsToPushRight.addAll(producedVars); } else { return false; } } opIterRef = opIter.getInputs().get(0); opIter = opIterRef.getValue(); } if (isLoj && pushedOnLeft.isEmpty()) { return false; } } boolean intersectsAllBranches = true; boolean[] intersectsBranch = new boolean[join.getInputs().size()]; LinkedList<LogicalVariable> selectVars = new LinkedList<LogicalVariable>(); select.getCondition().getValue().getUsedVariables(selectVars); int i = 0; for (Mutable<ILogicalOperator> branch : join.getInputs()) { LinkedList<LogicalVariable> branchVars = new LinkedList<LogicalVariable>(); VariableUtilities.getLiveVariables(branch.getValue(), branchVars); if (i == 0) { branchVars.addAll(liveInOpsToPushLeft); } else { branchVars.addAll(liveInOpsToPushRight); } if (OperatorPropertiesUtil.disjoint(selectVars, branchVars)) { intersectsAllBranches = false; } else { intersectsBranch[i] = true; } i++; } if (!intersectsBranch[0] && !intersectsBranch[1]) { return false; } if (needToPushOps) { //We should push independent ops into the first branch that the selection depends on if (intersectsBranch[0]) { pushOps(pushedOnEither, joinBranchLeftRef, context); } else { pushOps(pushedOnEither, joinBranchRightRef, context); } pushOps(pushedOnLeft, joinBranchLeftRef, context); pushOps(pushedOnRight, joinBranchRightRef, context); } if (intersectsAllBranches) { addCondToJoin(select, join, context); } else { // push down Iterator<Mutable<ILogicalOperator>> branchIter = join.getInputs().iterator(); ILogicalExpression selectCondition = select.getCondition().getValue(); boolean lojToInner = false; for (int j = 0; j < intersectsBranch.length; j++) { Mutable<ILogicalOperator> branch = branchIter.next(); boolean inter = intersectsBranch[j]; if (!inter) { continue; } // if a left outer join, if the select condition is not-missing filtering, // we rewrite left outer join // to inner join for this case. if (j > 0 && isLoj && containsNotMissingFiltering(selectCondition)) { lojToInner = true; } if ((j > 0 && isLoj) && containsMissingFiltering(selectCondition)) { // Select "is-not-missing($$var)" cannot be pushed in the right branch of a LOJ; notPushedStack.addFirst(select); } else { // Conditions for the left branch can always be pushed. // Other conditions can be pushed to the right branch of a LOJ. copySelectToBranch(select, branch, context); } } if (lojToInner) { // Rewrites left outer join to inner join. InnerJoinOperator innerJoin = new InnerJoinOperator(join.getCondition()); innerJoin.getInputs().addAll(join.getInputs()); join = innerJoin; context.computeAndSetTypeEnvironmentForOperator(join); } } ILogicalOperator top = join; for (ILogicalOperator npOp : notPushedStack) { List<Mutable<ILogicalOperator>> npInpList = npOp.getInputs(); npInpList.clear(); npInpList.add(new MutableObject<ILogicalOperator>(top)); context.computeAndSetTypeEnvironmentForOperator(npOp); top = npOp; } opRef.setValue(top); return true; }
From source file:se.sics.kompics.p2p.experiment.dsl.SimulationScenario.java
/** * Gets the all classes.// w w w . ja va2s . com * * @param cp * the cp * * @return the all classes * * @throws IOException * Signals that an I/O exception has occurred. */ private static LinkedList<String> getAllClasses(String cp) throws IOException { LinkedList<String> list = new LinkedList<String>(); for (String location : getAllLocations(cp)) { list.addAll(getClassesFromLocation(location)); } return list; }
From source file:se.sics.kompics.p2p.experiment.dsl.SimulationScenario.java
/** * Gets the all resources.//from w w w . java 2 s . c o m * * @param cp * the cp * * @return the all resources * * @throws IOException * Signals that an I/O exception has occurred. */ private static LinkedList<String> getAllResources(String cp) throws IOException { LinkedList<String> list = new LinkedList<String>(); for (String location : getAllLocations(cp)) { list.addAll(getResourcesFromLocation(location)); } return list; }
From source file:org.opencastproject.loadtest.impl.LoadTest.java
/** * Begins the load testing as its own thread. *//*w w w. j a v a 2s . c om*/ @Override public void run() { try { updateImportantProperties(properties); } catch (InvalidConfigurationException e1) { logger.error(e1.getMessage()); } catch (URISyntaxException e1) { logger.error(e1.getMessage()); } logger.info("Starting load test on core " + coreAddress + " with distribution " + getPrettyPackageDistribution() + "@" + getPrettyPackageDistributionTimings()); logger.info("Creating Workspace"); try { FileUtils.forceMkdir(new File(workspaceLocation)); } catch (IOException e) { logger.error("Had trouble creating workspace at " + workspaceLocation + " because " + e.getMessage()); } if (this.packageDistribution.length != this.packageDistributionTiming.length) { logger.warn( "The length of the distribution must be 1 greater than the number of package distribution timings. "); return; } long delay = 0; LinkedList<IngestionGroup> ingestGroups = new LinkedList<IngestionGroup>(); logger.info("Creating " + this.packageDistribution.length + " ingestion groups. " + getPrettyPackageDistribution()); for (int i = 0; i < this.packageDistribution.length; i++) { delay += this.packageDistributionTiming[i]; IngestionGroup ingestionGroup = new IngestionGroup(this.packageDistribution[i], delay, this, client); ingestGroups.add(ingestionGroup); } LinkedList<IngestJob> ingestJobs = new LinkedList<IngestJob>(); for (IngestionGroup ingestionGroup : ingestGroups) { ingestJobs.addAll(ingestionGroup.getJobs()); } while (!ThreadCounter.allDone()) { try { Thread.sleep(15 * MILLISECONDS_IN_SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } logger.info("There are still " + ThreadCounter.getCount() + " threads that are executing."); } logger.info("Load Testing script is finished now just to wait for processing."); }
From source file:com.safi.workshop.sqlexplorer.sqlpanel.AbstractSQLExecution.java
/** * Checks the database server for messages *///from www.j a v a 2 s . c om protected boolean checkForMessages(Query query) throws SQLException { LinkedList<Message> messages = new LinkedList<Message>(); Collection<Message> messagesTmp; if (query != null) { messagesTmp = _session.getDatabaseProduct().getErrorMessages(_connection, query); if (messagesTmp != null) messages.addAll(messagesTmp); } messagesTmp = _session.getDatabaseProduct().getServerMessages(_connection); if (messagesTmp != null) messages.addAll(messagesTmp); boolean hasMessages = false; for (Message msg : messages) { msg.setLineNo(getQueryParser().adjustLineNo(msg.getLineNo())); if (msg.getStatus() != Message.Status.SUCCESS) hasMessages = true; } addMessages(messages); return hasMessages; }
From source file:com.github.nitrico.mapviewpager.MapViewPager.java
private void initDefaultPositions(final MultiAdapter adapter) { // each page//from ww w . j av a 2 s.c o m defaultPositions = new LinkedList<>(); for (int i = 0; i < adapter.getCount(); i++) { defaultPositions.add(getDefaultPagePosition(adapter, i)); } // global LinkedList<Marker> all = new LinkedList<>(); for (List<Marker> list : allMarkers) if (list != null) all.addAll(list); LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (Marker marker : all) if (marker != null) builder.include(marker.getPosition()); LatLngBounds bounds = builder.build(); defaultPosition = CameraUpdateFactory.newLatLngBounds(bounds, mapOffset); }
From source file:ubic.gemma.core.datastructure.matrix.ExpressionDataMatrixColumnSort.java
/** * @return list of factors, sorted from simplest (fewest number of values from the biomaterials passed in) to least * simple. Continuous factors will always be first, and batch factors last. *//*from w w w.j av a 2 s .co m*/ private static List<ExperimentalFactor> orderFactorsByExperimentalDesign(List<BioMaterial> start, Collection<ExperimentalFactor> factors) { if (factors == null || factors.isEmpty()) { ExpressionDataMatrixColumnSort.log.warn("No factors supplied for sorting"); return new LinkedList<>(); } LinkedList<ExperimentalFactor> sortedFactors = new LinkedList<>(); Collection<ExperimentalFactor> factorsToTake = new HashSet<>(factors); while (!factorsToTake.isEmpty()) { ExperimentalFactor simplest = ExpressionDataMatrixColumnSort.chooseSimplestFactor(start, factorsToTake); if (simplest == null) { // none of the factors have more than one factor value. One-sided t-tests ... /* * This assertion isn't right -- we now allow this, though we can only have ONE such constant factor. * See bug 2390. Unless we are dealing with a subset, in which case there can be any number of constant * factors within the subset. */ // assert factors.size() == 1 : // "It's possible to have just one factor value, but only if there is only one factor."; sortedFactors.addAll(factors); return sortedFactors; } sortedFactors.addLast(simplest); factorsToTake.remove(simplest); } return sortedFactors; }