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:org.eclipse.viatra.query.runtime.localsearch.planner.LocalSearchPlanner.java
/** * Creates executable plans for the provided query. It is required to call one of the * <code>initializePlanner()</code> methods before calling this method. * //from w w w. j a v a 2 s . c o m * @param querySpec * @param boundVarIndices * a set of integers representing the variables that are bound * @return a mapping between ISearchOperation list and a mapping, that holds a PVariable-Integer mapping for the * list of ISearchOperations * @throws QueryProcessingException */ public Collection<SearchPlanForBody> plan(PQuery querySpec, Set<Integer> boundVarIndices) throws QueryProcessingException { // 1. Preparation Set<PBody> normalizedBodies = prepareNormalizedBodies(querySpec); plansForBodies = Lists.newArrayListWithExpectedSize(normalizedBodies.size()); for (PBody normalizedBody : normalizedBodies) { // 2. Plan creation // Context has matchers for the referred Queries (IQuerySpecifications) Set<PVariable> boundVariables = calculatePatternAdornmentForPlanner(boundVarIndices, normalizedBody); SubPlan plan = plannerStrategy.plan(normalizedBody, logger, boundVariables, metaContext, runtimeContext, hints); // 3. PConstraint -> POperation compilation step // TODO finish (revisit?) the implementation of the compile function // * Pay extra caution to extend operations, when more than one variables are unbound List<ISearchOperation> compiledOperations = operationCompiler.compile(plan, boundVarIndices); // Store the variable mappings for the plans for debug purposes (traceability information) SearchPlanForBody compiledPlan = new SearchPlanForBody(normalizedBody, operationCompiler.getVariableMappings(), plan, compiledOperations); plansForBodies.add(compiledPlan); } return plansForBodies; }
From source file:org.apache.kylin.query.relnode.visitor.TupleExpressionVisitor.java
private CaseTupleExpression getCaseTupleExpression(RexCall call) { List<Pair<TupleFilter, TupleExpression>> whenList = Lists .newArrayListWithExpectedSize(call.operands.size() / 2); TupleExpression elseExpr = null;//w w w .j a v a 2 s .com TupleFilterVisitor filterVistor = new TupleFilterVisitor(inputRowType); for (int i = 0; i < call.operands.size() - 1; i += 2) { if (call.operands.get(i) instanceof RexCall) { RexCall whenCall = (RexCall) call.operands.get(i); CompareTupleFilter.CompareResultType compareResultType = RexUtil.getCompareResultType(whenCall); if (compareResultType == CompareTupleFilter.CompareResultType.AlwaysTrue) { elseExpr = call.operands.get(i + 1).accept(this); break; } else if (compareResultType == CompareTupleFilter.CompareResultType.AlwaysFalse) { continue; } TupleFilter whenFilter = whenCall.accept(filterVistor); whenFilter = new FilterOptimizeTransformer().transform(whenFilter); TupleExpression thenExpr = call.operands.get(i + 1).accept(this); whenList.add(new Pair<>(whenFilter, thenExpr)); } } if (elseExpr == null && call.operands.size() % 2 == 1) { RexNode elseNode = call.operands.get(call.operands.size() - 1); if (!(elseNode instanceof RexLiteral && ((RexLiteral) elseNode).getValue() == null)) { elseExpr = elseNode.accept(this); } } CaseTupleExpression tuple = new CaseTupleExpression(whenList, elseExpr); tuple.setDigest(call.toString()); return tuple; }
From source file:de.chaosfisch.google.youtube.playlist.AbstractPlaylistService.java
List<Playlist> parsePlaylistListResponse(final Account account, final PlaylistListResponse response) { final List<Playlist> list = Lists.newArrayListWithExpectedSize(response.getItems().size()); for (final com.google.api.services.youtube.model.Playlist entry : response.getItems()) { final Playlist playlist = findByPkey(entry.getId()); if (null == playlist) { list.add(_createNewPlaylist(account, entry)); } else {/*from www . j a va 2 s . c om*/ list.add(_updateExistingPlaylist(account, entry, playlist)); } } return list; }
From source file:org.agatom.springatom.data.model.person.NPerson.java
private List<NPersonContact> _getContacts() { if (this.contacts == null) { this.contacts = Lists.newArrayListWithExpectedSize(5); }/*from ww w . j a v a 2s.c o m*/ return this.contacts; }
From source file:com.android.builder.dependency.DependencyContainerImpl.java
@NonNull @Override//from ww w .j a v a2s. c o m public DependencyContainer flatten(@Nullable AndroidLibrary testedLibrary, @Nullable DependencyContainer testedDependencyContainer) { /* The handling of test for aars is a bit special due to how the dependencies are setup. Because we cannot have the test app depend directly on the generated aar, we have a weird setup: - The configuration for the test extends the configuration of the aar - The VariantConfiguration manually adds the AndroidLibrary representing the aar. So instead of having: test +- espresso +- aar +- guava We have: test +- espresso +- guava +- aar We also have a problem with local jars. Because of the configuration extension, they show up in both configuration objects so we have to remove the duplicated ones, and use the ones coming through the aar. We could more easily take the one from the configuration and drop the one inside the aar but it wouldn't work. The ones in the aar are slightly different (during java res merging, the res move from the local jars to the main classes.jar), so we really need those rather than the original ones. */ List<AndroidLibrary> flatAndroidLibs = Lists.newArrayList(); Set<JavaLibrary> flatJavaLibs = Sets.newLinkedHashSet(); computeFlatLibraryList(mLibraryDependencies, flatAndroidLibs, flatJavaLibs); // add the tested libs after since it'll be added at the beginning of the list. if (testedLibrary != null) { computeFlatLibraryList(testedLibrary, flatAndroidLibs, flatJavaLibs); } computeFlatJarList(mJavaDependencies, flatJavaLibs); // handle the local jars. Remove the duplicated ones from mLocalJars. // They will actually show up through the testedLibrary's local jars. List<JavaLibrary> localJars = mLocalJars; if (testedDependencyContainer != null && testedLibrary != null) { Collection<JavaLibrary> testedLocalJars = testedDependencyContainer.getLocalDependencies(); localJars = Lists.newArrayListWithExpectedSize(mLocalJars.size()); for (JavaLibrary javaLibrary : mLocalJars) { if (!testedLocalJars.contains(javaLibrary)) { localJars.add(javaLibrary); } } } return new DependencyContainerImpl(flatAndroidLibs, flatJavaLibs, localJars); }
From source file:org.apache.drill.exec.physical.impl.aggregate.HashAggBatch.java
public HashAggBatch(HashAggregate popConfig, RecordBatch incoming, FragmentContext context) throws ExecutionSetupException { super(popConfig, context); this.incoming = incoming; final int numGrpByExprs = popConfig.getGroupByExprs().size(); comparators = Lists.newArrayListWithExpectedSize(numGrpByExprs); for (int i = 0; i < numGrpByExprs; i++) { // nulls are equal in group by case comparators.add(Comparator.IS_NOT_DISTINCT_FROM); }// w w w .ja va2s . c o m }
From source file:eu.interedition.web.index.IndexController.java
@RequestMapping(produces = "application/json") @ResponseBody/*from w w w. j a va2 s . co m*/ public List<IndexQueryResult> query(@ModelAttribute("query") IndexQuery query) throws IOException, ParseException { if (Strings.isNullOrEmpty(query.getQuery())) { return Collections.emptyList(); } final Query parsed = new QueryParser(Version.LUCENE_30, "content", analyzer).parse(query.getQuery()); final int pageSize = query.getPageSize(); final int offset = query.getPage() * pageSize; final Map<Long, Integer> scores = Maps.newLinkedHashMap(); final IndexSearcher searcher = indexSearcher(); final TopDocs searchResult = searcher.search(parsed, offset + pageSize); for (int rc = offset; rc < searchResult.scoreDocs.length; rc++) { final ScoreDoc scoreDocument = searchResult.scoreDocs[rc]; final Document document = searcher.doc(scoreDocument.doc); scores.put(Long.parseLong(document.get("id")), Math.round(scoreDocument.score * 100)); } final List<IndexQueryResult> results = Lists.newArrayListWithExpectedSize(scores.size()); for (DublinCoreMetadata metadata : metadataController.read(scores.keySet())) { results.add(new IndexQueryResult(metadata, scores.get(metadata.getText()))); } return results; }
From source file:com.attribyte.essem.model.Application.java
private void addPrefix(final Map<String, List<Metric>> prefixMap, final Metric metric) { for (int i = 0; i < MAX_PREFIX_RESOLUTION; i++) { for (String matchName : nameSplitter.split(metric.name)) { if (matchName.length() > i) { String prefix = matchName.substring(0, i + 1).toLowerCase(); List<Metric> currList = prefixMap.get(prefix); if (currList == null) { currList = Lists.newArrayListWithExpectedSize(4); prefixMap.put(prefix, currList); }/* ww w . j av a 2s .com*/ currList.add(metric); } } } }
From source file:eu.project.ttc.utils.TermSuiteUtils.java
public static String getGroupingKey(Collection<TermWord> words) { StringBuilder patternSb = new StringBuilder(); List<String> lemmas = Lists.newArrayListWithExpectedSize(words.size()); for (TermWord tw : words) { patternSb.append(tw.getSyntacticLabel().toLowerCase()); lemmas.add(tw.getWord().getLemma()); }// w w w.j av a 2 s. com return toGroupingKey(patternSb, lemmas); }
From source file:com.android.tools.lint.psi.EcjPsiBinaryField.java
@NonNull @Override/*from www. j ava 2 s. co m*/ public PsiAnnotation[] getApplicableAnnotations() { List<PsiAnnotation> all = Lists.newArrayListWithExpectedSize(4); ExternalAnnotationRepository manager = mManager.getAnnotationRepository(); AnnotationBinding[] annotations = mBinding.getAnnotations(); int count = annotations.length; if (count > 0) { for (AnnotationBinding annotation : annotations) { if (annotation != null) { all.add(new EcjPsiBinaryAnnotation(mManager, this, annotation)); } } } // Look for external annotations if (manager != null) { Collection<PsiAnnotation> external = manager.getAnnotations(mBinding); if (external != null) { all.addAll(external); } } return EcjPsiManager.ensureUnique(all); }