List of usage examples for com.google.common.collect Lists newLinkedList
@GwtCompatible(serializable = true) public static <E> LinkedList<E> newLinkedList()
From source file:models.feeds.UserNodeChildren.java
@Override public void getData(Map<String, String> params, Request request, Session session, User user, RenderArgs renderArgs) {/*from ww w .ja va2s.c o m*/ Integer start = 0; Integer count = 30; int pageNum = 0; try { pageNum = Integer.parseInt(params.get("pageNum")); } catch (Exception e) { } start = count * pageNum; List<NodeContent> ll = new LinkedList<NodeContent>(); BasicDBObject query = new BasicDBObject("parid", user.getId()); DBCursor iobj = Activity.dbcol.find(query).sort(sort).skip(start).limit(count); List<ObjectId> nodeIds = Lists.newLinkedList(); while (iobj.hasNext()) nodeIds.add(MongoDB.fromDBObject(Activity.class, iobj.next()).getOid()); renderArgs.put(dataName, Lists.reverse(NodeContent.load(nodeIds, user))); }
From source file:org.plista.kornakapi.core.training.FromFileVectorizer.java
/** * Generates SequenceFile//from ww w . j a va 2s. c o m * @throws Exception */ private void generateSequneceFiles() throws Exception { List<String> argList = Lists.newLinkedList(); argList.add("-i"); argList.add(DocumentFilesPath.toString()); argList.add("-o"); argList.add(sequenceFilesPath.toString()); argList.add("-ow"); String[] args = argList.toArray(new String[argList.size()]); ToolRunner.run(new SequenceFilesFromDirectory(), args); }
From source file:com.cloudera.livy.client.local.JobHandleImpl.java
JobHandleImpl(LocalClient client, Promise<T> promise, String jobId) { this.client = client; this.jobId = jobId; this.promise = promise; this.listeners = Lists.newLinkedList(); this.metrics = new MetricsCollection(); this.sparkJobIds = new CopyOnWriteArrayList<Integer>(); this.state = State.SENT; }
From source file:com.yahoo.yqlplus.engine.rules.MergeFilters.java
private OperatorNode<SequenceOperator> visitChain(OperatorNode<SequenceOperator> top, OperatorNode<SequenceOperator> current) { if (MERGE_THROUGH.contains(current.getOperator())) { return visitChain(top, (OperatorNode<SequenceOperator>) current.getArgument(0)); } else if (top == current) { return top; } else {/*from w w w .j a v a 2s. co m*/ // if there's any sorting, we'd like to do it AFTER we filter // 'current' contains what will be the target of the new filter (as it is neither FILTER or SORT) // we know 'top' is a FILTER because it started as such // so, walk between top and current, accumulating filters and sorting Deque<OperatorNode<SequenceOperator>> sorts = Lists.newLinkedList(); List<OperatorNode<ExpressionOperator>> filters = Lists.newArrayList(); Map<String, Object> annotations = Maps.newLinkedHashMap(); OperatorNode<SequenceOperator> n = top; while (n != current) { if (n.getOperator() == SequenceOperator.FILTER) { annotations.putAll(n.getAnnotations()); filters.add(super.visitExpr((OperatorNode<ExpressionOperator>) n.getArgument(1))); n = n.getArgument(0); } else if (n.getOperator() == SequenceOperator.SORT) { sorts.addFirst(n); } } current = super.visitSequenceOperator(current); OperatorNode<ExpressionOperator> filter = createFilter(filters); OperatorNode<SequenceOperator> filtered = OperatorNode.create(top.getLocation(), annotations, SequenceOperator.FILTER, current, filter); while (!sorts.isEmpty()) { OperatorNode<SequenceOperator> sort = sorts.removeLast(); filtered = OperatorNode.create(sort.getLocation(), sort.getAnnotations(), sort.getOperator(), filtered, sort.getArgument(1)); } return filtered; } }
From source file:com.dogecoin.dogecoinj.wallet.KeyTimeCoinSelector.java
@Override public CoinSelection select(Coin target, List<TransactionOutput> candidates) { try {//w w w . j a v a2 s. c om LinkedList<TransactionOutput> gathered = Lists.newLinkedList(); Coin valueGathered = Coin.ZERO; for (TransactionOutput output : candidates) { if (ignorePending && !isConfirmed(output)) continue; // Find the key that controls output, assuming it's a regular pay-to-pubkey or pay-to-address output. // We ignore any other kind of exotic output on the assumption we can't spend it ourselves. final Script scriptPubKey = output.getScriptPubKey(); ECKey controllingKey; if (scriptPubKey.isSentToRawPubKey()) { controllingKey = wallet.findKeyFromPubKey(scriptPubKey.getPubKey()); } else if (scriptPubKey.isSentToAddress()) { controllingKey = wallet.findKeyFromPubHash(scriptPubKey.getPubKeyHash()); } else { log.info("Skipping tx output {} because it's not of simple form.", output); continue; } checkNotNull(controllingKey, "Coin selector given output as candidate for which we lack the key"); if (controllingKey.getCreationTimeSeconds() >= unixTimeSeconds) continue; // It's older than the cutoff time so select. valueGathered = valueGathered.add(output.getValue()); gathered.push(output); if (gathered.size() >= MAX_SIMULTANEOUS_INPUTS) { log.warn("Reached {} inputs, going further would yield a tx that is too large, stopping here.", gathered.size()); break; } } return new CoinSelection(valueGathered, gathered); } catch (ScriptException e) { throw new RuntimeException(e); // We should never have problems understanding scripts in our wallet. } }
From source file:org.impressivecode.depress.mr.pmd.PMDEntriesParser.java
public List<PMDEntry> parseEntries(final String path) throws IOException, ParserConfigurationException, SAXException { Preconditions.checkArgument(!isNullOrEmpty(path), "Path has to be set."); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(path); NodeList nList = getSourceFileNodes(doc); int size = nList.getLength(); List<PMDEntry> pmdEntries = Lists.newLinkedList(); for (int i = 0; i < size; i++) { Node item = nList.item(i); NodeList cNodes = item.getChildNodes(); for (int j = 0; j < cNodes.getLength(); j++) { Node item2 = cNodes.item(j); if (!isError(item2)) { continue; }/* ww w .ja v a2s . c o m*/ PMDEntry entry = parse(item2); pmdEntries.add(entry); } } return pmdEntries; }
From source file:com.google.bitcoin.wallet.KeyTimeCoinSelector.java
@Override public CoinSelection select(BigInteger target, LinkedList<TransactionOutput> candidates) { try {/*from w ww . j a v a 2 s . co m*/ LinkedList<TransactionOutput> gathered = Lists.newLinkedList(); BigInteger valueGathered = BigInteger.ZERO; for (TransactionOutput output : candidates) { if (ignorePending && !isConfirmed(output)) continue; // Find the key that controls output, assuming it's a regular pay-to-pubkey or pay-to-address output. // We ignore any other kind of exotic output on the assumption we can't spend it ourselves. final Script scriptPubKey = output.getScriptPubKey(); ECKey controllingKey; if (scriptPubKey.isSentToRawPubKey()) { controllingKey = wallet.findKeyFromPubKey(scriptPubKey.getPubKey()); } else if (scriptPubKey.isSentToAddress()) { controllingKey = wallet.findKeyFromPubHash(scriptPubKey.getPubKeyHash()); } else { log.info("Skipping tx output {} because it's not of simple form.", output); continue; } checkNotNull(controllingKey, "Coin selector given output as candidate for which we lack the key"); if (controllingKey.getCreationTimeSeconds() >= unixTimeSeconds) continue; // It's older than the cutoff time so select. valueGathered = valueGathered.add(output.getValue()); gathered.push(output); if (gathered.size() >= MAX_SIMULTANEOUS_INPUTS) { log.warn("Reached {} inputs, going further would yield a tx that is too large, stopping here.", gathered.size()); break; } } return new CoinSelection(valueGathered, gathered); } catch (ScriptException e) { throw new RuntimeException(e); // We should never have problems understanding scripts in our wallet. } }
From source file:cc.kave.commons.utils.exec.ReadAllContextsRunner.java
private List<File> findAllZips(String dir) { List<File> zips = Lists.newLinkedList(); for (File f : FileUtils.listFiles(new File(dir), new String[] { "zip" }, true)) { zips.add(f);//ww w. j a va 2 s.c om } return zips; }
From source file:org.sonar.core.components.CacheMetricFinder.java
@Override public Collection<Metric> findAll(List<String> metricKeys) { List<Metric> result = Lists.newLinkedList(); for (String metricKey : metricKeys) { Metric metric = findByKey(metricKey); if (metric != null) { result.add(metric);//from w w w . j a v a 2s . c o m } } return result; }
From source file:org.eclipse.sirius.business.internal.metamodel.description.tool.spec.PasteDescriptionSpec.java
/** * {@inheritDoc}//from w w w . j a v a 2 s . c o m * * @see org.eclipse.sirius.viewpoint.description.tool.impl.PasteDescriptionImpl#getContainers() */ @Override public EList<PasteTargetDescription> getContainers() { Resource r = this.eResource(); if (r == null) { throw new UnsupportedOperationException(); } ECrossReferenceAdapter crossReferencer = ECrossReferenceAdapter.getCrossReferenceAdapter(r); if (crossReferencer == null) { throw new UnsupportedOperationException(); } final List<PasteTargetDescription> pasteTargetDescriptions = Lists.newLinkedList(); final Collection<Setting> settings = crossReferencer.getInverseReferences(this, true); for (final Setting setting : settings) { final EObject eReferencer = setting.getEObject(); final EStructuralFeature eFeature = setting.getEStructuralFeature(); if (eReferencer instanceof PasteTargetDescription && eFeature .equals(DescriptionPackage.eINSTANCE.getPasteTargetDescription_PasteDescriptions())) { pasteTargetDescriptions.add((PasteTargetDescription) eReferencer); } } return new BasicEList<PasteTargetDescription>(pasteTargetDescriptions); }