List of usage examples for com.google.common.collect Lists newArrayListWithExpectedSize
@GwtCompatible(serializable = true) public static <E> ArrayList<E> newArrayListWithExpectedSize(int estimatedSize)
From source file:com.yahoo.yqlplus.engine.internal.plan.DynamicExpressionEvaluator.java
public List<OperatorNode<PhysicalExprOperator>> applyAll(List<OperatorNode<ExpressionOperator>> inputs) { List<OperatorNode<PhysicalExprOperator>> out = Lists.newArrayListWithExpectedSize(inputs.size()); for (OperatorNode<ExpressionOperator> arg : inputs) { out.add(apply(arg));/*from w ww . j av a 2 s . c o m*/ } return out; }
From source file:org.apache.shindig.social.core.model.IdSpec.java
/** * Only valid for IdSpecs of type USER_IDS. * @return A list of the user ids in the id spec * * @throws JSONException If the id spec isn't a valid json String array *//*from w w w. j a va2 s . com*/ public List<String> fetchUserIds() throws JSONException { JSONArray userIdArray; try { userIdArray = new JSONArray(jsonSpec); } catch (JSONException e) { // If it isn't an array, treat it as a simple string // TODO: This will go away with rest so we can remove this hack return Lists.newArrayList(jsonSpec); } List<String> userIds = Lists.newArrayListWithExpectedSize(userIdArray.length()); for (int i = 0; i < userIdArray.length(); i++) { userIds.add(userIdArray.getString(i)); } return userIds; }
From source file:co.cask.cdap.gateway.handlers.AppFabricDataHttpHandler.java
/** * Returns a list of streams in a namespace. *//*from w ww .ja v a2s . c o m*/ @GET @Path("/streams") public void getStreams(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespace) { Id.Namespace namespaceId = Id.Namespace.from(namespace); Collection<StreamSpecification> specs = store.getAllStreams(namespaceId); List<StreamDetail> result = Lists.newArrayListWithExpectedSize(specs.size()); for (StreamSpecification spec : specs) { result.add(new StreamDetail(spec.getName())); } if (result.isEmpty() && store.getNamespace(namespaceId) == null) { responder.sendString(HttpResponseStatus.NOT_FOUND, String.format("Namespace '%s' not found.", namespace)); return; } responder.sendJson(HttpResponseStatus.OK, result); }
From source file:com.google.gxp.compiler.fs.AbstractFileSystem.java
/** * {@inheritDoc}/*from w ww . ja v a 2 s . c o m*/ * * <p>This implementation splits {@code filenameList} using the result of * {@link #getFilenameListDelimiter()} and parses the resulting filenames * with {@link #parseFilename(String)}. */ public final List<FileRef> parseFilenameList(String filenameList) { String[] filenames = getFilenameListDelimiter().split(filenameList, -1); List<FileRef> result = Lists.newArrayListWithExpectedSize(filenames.length); for (int i = 0; i < filenames.length; i++) { result.add(parseFilename(filenames[i])); } return Collections.unmodifiableList(result); }
From source file:org.auraframework.impl.root.component.ComponentDefRefArrayImpl.java
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public List<Component> newInstance(BaseComponent<?, ?> fallbackValueProvider, Map<String, Object> extraProviders) throws QuickFixException { List<Component> components = Lists.newArrayListWithExpectedSize(cdrs.size()); BaseComponent<?, ?> valueProvider = this.vp != null ? this.vp : fallbackValueProvider; if (extraProviders != null) { // TODO: rename this thing valueProvider = new IterationValueProvider(valueProvider, extraProviders); }// w w w . j a v a2 s. co m AuraContext context = Aura.getContextService().getCurrentContext(); int idx = 0; for (ComponentDefRef cdr : this.cdrs) { context.getInstanceStack().setAttributeIndex(idx); components.add(cdr.newInstance(valueProvider)); context.getInstanceStack().clearAttributeIndex(idx); idx += 1; } return components; }
From source file:com.android.build.gradle.internal.dependency.ManifestDependencyImpl.java
public List<File> getAllManifests() { List<File> files = Lists.newArrayListWithExpectedSize(1 + dependencies.size() * 2); files.add(manifest);// w w w .jav a2s. c om for (ManifestDependencyImpl manifestDep : dependencies) { files.addAll(manifestDep.getAllManifests()); } return files; }
From source file:com.technophobia.substeps.runner.builder.FeatureNodeBuilder.java
private FeatureNode buildRunnableFeatureNode(FeatureFile featureFile) { List<ScenarioNode<?>> scenarioNodes = Lists.newArrayListWithExpectedSize(featureFile.getScenarios().size()); Set<String> tags = featureFile.getTags() != null ? featureFile.getTags() : Collections.<String>emptySet(); for (final Scenario scenario : featureFile.getScenarios()) { if (scenario != null) { ScenarioNode<?> scenarioNode = scenarioNodeBuilder.build(scenario, tags, _2); if (scenarioNode != null) { scenarioNodes.add(scenarioNode); }//from w w w .j av a2 s . c o m } } final Feature feature = new Feature(featureFile.getName(), featureFile.getSourceFile().getName()); final FeatureNode featureNode = new FeatureNode(feature, scenarioNodes, tags); featureNode.setFileUri(featureFile.getSourceFile().getAbsolutePath()); featureNode.setLineNumber(0); return featureNode; }
From source file:org.eclipse.xtext.formatting2.debug.TextRegionListToString.java
@Override public String toString() { int offsetDigits = 0; int lengthDigits = 0; for (Item item : items) { if (item.region != null) { int lengthD = String.valueOf(item.region.getLength()).length(); if (lengthDigits < lengthD) lengthDigits = lengthD;/* w ww .j a va 2 s . com*/ int lengthO = String.valueOf(item.region.getOffset()).length(); if (offsetDigits < lengthO) offsetDigits = lengthO; } } List<String> result = Lists.newArrayListWithExpectedSize(items.size()); String prefix = Strings.repeat(" ", offsetDigits + lengthDigits + 2); for (Item item : items) { String[] lines = item.text.split("\n"); if (item.region != null) { String offset = Strings.padStart(String.valueOf(item.region.getOffset()), offsetDigits, ' '); String length = Strings.padStart(String.valueOf(item.region.getLength()), lengthDigits, ' '); if (lines.length == 1) { result.add(offset + " " + length + " " + lines[0]); } else { String offsetSpace = Strings.repeat(" ", offsetDigits); String lengthSpace = Strings.repeat(" ", lengthDigits); for (int i = 0; i < lines.length; i++) { String first = i == 0 ? offset : offsetSpace; String second = i == lines.length - 1 ? length : lengthSpace; result.add(first + " " + second + " " + lines[i]); } } } else if (item.indented) { for (int i = 0; i < lines.length; i++) result.add(prefix + lines[i]); } else { for (int i = 0; i < lines.length; i++) result.add(lines[i]); } } return Joiner.on("\n").join(result); }
From source file:org.apache.bookkeeper.stream.storage.impl.sc.LocalStorageContainerManager.java
@Override protected void doStart() { List<CompletableFuture<StorageContainer>> futures = Lists .newArrayListWithExpectedSize(numStorageContainers); for (int scId = 0; scId < numStorageContainers; scId++) { futures.add(this.registry.startStorageContainer(scId)); }//from w ww. ja va 2 s. c om FutureUtils.collect(futures).join(); }
From source file:org.apache.phoenix.index.PhoenixIndexBuilder.java
@Override public void batchStarted(MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException { // The entire purpose of this method impl is to get the existing rows for the // table rows being indexed into the block cache, as the index maintenance code // does a point scan per row List<KeyRange> keys = Lists.newArrayListWithExpectedSize(miniBatchOp.size()); Map<ImmutableBytesWritable, IndexMaintainer> maintainers = new HashMap<ImmutableBytesWritable, IndexMaintainer>(); ImmutableBytesWritable indexTableName = new ImmutableBytesWritable(); for (int i = 0; i < miniBatchOp.size(); i++) { Mutation m = miniBatchOp.getOperation(i); keys.add(PVarbinary.INSTANCE.getKeyRange(m.getRow())); List<IndexMaintainer> indexMaintainers = getCodec().getIndexMaintainers(m.getAttributesMap()); for (IndexMaintainer indexMaintainer : indexMaintainers) { if (indexMaintainer.isImmutableRows() && indexMaintainer.isLocalIndex()) continue; indexTableName.set(indexMaintainer.getIndexTableName()); if (maintainers.get(indexTableName) != null) continue; maintainers.put(indexTableName, indexMaintainer); }/* ww w . j a v a 2s. c o m*/ } if (maintainers.isEmpty()) return; Scan scan = IndexManagementUtil.newLocalStateScan(new ArrayList<IndexMaintainer>(maintainers.values())); ScanRanges scanRanges = ScanRanges.createPointLookup(keys); scanRanges.initializeScan(scan); scan.setFilter(scanRanges.getSkipScanFilter()); Region region = this.env.getRegion(); RegionScanner scanner = region.getScanner(scan); // Run through the scanner using internal nextRaw method region.startRegionOperation(); try { synchronized (scanner) { boolean hasMore; do { List<Cell> results = Lists.newArrayList(); // Results are potentially returned even when the return value of s.next is // false since this is an indication of whether or not there are more values // after the ones returned hasMore = scanner.nextRaw(results); } while (hasMore); } } finally { try { scanner.close(); } finally { region.closeRegionOperation(); } } }