List of usage examples for com.google.common.collect Lists newArrayListWithCapacity
@GwtCompatible(serializable = true) public static <E> ArrayList<E> newArrayListWithCapacity(int initialArraySize)
From source file:com.atlassian.jira.rest.client.test.matchers.IssueMatchers.java
public static Matcher<Iterable<? extends BasicIssue>> issuesWithKeys(String... keys) { final Collection<Matcher<? super BasicIssue>> matchers = Lists.newArrayListWithCapacity(keys.length); for (String key : keys) { matchers.add(withIssueKey(key)); }//from w w w . j ava2 s.c o m return IsIterableContainingInAnyOrder.containsInAnyOrder(matchers); }
From source file:com.atlassian.jira.rest.client.test.matchers.NamedEntityMatchers.java
public static Matcher<Iterable<? extends NamedEntity>> entitiesWithNames(String... names) { final Collection<Matcher<? super NamedEntity>> matchers = Lists.newArrayListWithCapacity(names.length); for (String key : names) { matchers.add(withName(key));//from w w w. ja v a 2 s .c o m } return IsIterableContainingInAnyOrder.containsInAnyOrder(matchers); }
From source file:com.ebay.pulsar.analytics.metricstore.druid.query.model.QueryCacheHelper.java
public static byte[] computePostAggregatorBytes(List<BasePostAggregator> postaggregators) { List<byte[]> cacheKeySet = Lists.newArrayListWithCapacity(postaggregators.size()); int totalSize = 0; for (BasePostAggregator agg : postaggregators) { final byte[] cacheKey = agg.cacheKey(); cacheKeySet.add(cacheKey);//from w w w.j a v a 2s . c o m totalSize += cacheKey.length; } ByteBuffer retVal = ByteBuffer.allocate(totalSize); for (byte[] bytes : cacheKeySet) { retVal.put(bytes); } return retVal.array(); }
From source file:io.druid.sql.calcite.table.DruidTables.java
/** * Returns the "natural" rowOrder for a Druid table. This is the order that a scan without projection would return. * * @param druidTable druid table// w ww . j a va 2s .c o m * * @return natural row order */ public static List<String> rowOrder(final DruidTable druidTable) { final List<String> rowOrder = Lists.newArrayListWithCapacity(druidTable.getColumnCount()); for (int i = 0; i < druidTable.getColumnCount(); i++) { rowOrder.add(druidTable.getColumnName(i)); } return rowOrder; }
From source file:com.atlassian.jira.rest.client.test.matchers.AddressableEntityMatchers.java
public static Matcher<Iterable<? extends AddressableEntity>> entitiesWithSelf(URI... uris) { final Collection<Matcher<? super AddressableEntity>> matchers = Lists.newArrayListWithCapacity(uris.length); for (URI uri : uris) { matchers.add(withSelf(uri));//from ww w . j a v a 2 s . c om } return IsIterableContainingInAnyOrder.containsInAnyOrder(matchers); }
From source file:tachyon.io.Utils.java
/** * Converts a list of byte buffers to a list of base64-encoded Strings. *///from w w w . j av a 2 s . c o m public static List<String> byteBufferListToBase64(List<ByteBuffer> bufs) { if (bufs == null) { return null; } List<String> bytes = Lists.newArrayListWithCapacity(bufs.size()); for (ByteBuffer buf : bufs) { bytes.add(byteBufferToBase64(buf)); } return bytes; }
From source file:org.apache.drill.exec.planner.sql.parser.DrillCompoundIdentifier.java
private static List<String> getNames(List<IdentifierHolder> identifiers) { List<String> names = Lists.newArrayListWithCapacity(identifiers.size()); for (IdentifierHolder h : identifiers) { names.add(h.value);//from www .j av a2 s .c o m } return names; }
From source file:com.torodb.torod.db.backends.query.processors.NotProcessor.java
public static List<ProcessedQueryCriteria> process(NotQueryCriteria criteria, QueryCriteriaVisitor<List<ProcessedQueryCriteria>, Void> visitor) { List<ProcessedQueryCriteria> childResults = criteria.getSubQueryCriteria().accept(visitor, null); List<ProcessedQueryCriteria> result = Lists.newArrayListWithCapacity(childResults.size() * 2); for (ProcessedQueryCriteria cr : childResults) { //if the structure query is not a tautology (=always true) //then we add the negation of the given expression with no data query if (cr.getStructureQuery() != null && !TrueQueryCriteria.getInstance().equals(cr.getStructureQuery())) { result.add(new ProcessedQueryCriteria(new NotQueryCriteria(cr.getStructureQuery()), null)); }//from w ww . jav a 2 s. c o m if (cr.getDataQuery() != null && !TrueQueryCriteria.getInstance().equals(cr.getDataQuery())) { result.add(new ProcessedQueryCriteria(cr.getStructureQuery(), new NotQueryCriteria(cr.getDataQuery()))); } } return result; }
From source file:com.torodb.torod.db.postgresql.query.processors.OrProcessor.java
public static List<ProcessedQueryCriteria> process(OrQueryCriteria criteria, QueryCriteriaVisitor<List<ProcessedQueryCriteria>, Void> visitor) { List<ProcessedQueryCriteria> child1Result = criteria.getSubQueryCriteria1().accept(visitor, null); List<ProcessedQueryCriteria> child2Result = criteria.getSubQueryCriteria2().accept(visitor, null); List<ProcessedQueryCriteria> result = Lists .newArrayListWithCapacity(child1Result.size() + child2Result.size()); result.addAll(child1Result);// ww w. ja va 2 s . com result.addAll(child2Result); return result; }
From source file:co.cask.tephra.util.TransactionEditUtil.java
/** * Generates a number of semi-random {@link TransactionEdit} instances. * These are just randomly selected from the possible states, so would not necessarily reflect a real-world * distribution.//w w w . jav a 2 s. c om * * @param numEntries how many entries to generate in the returned list. * @return a list of randomly generated transaction log edits. */ public static List<TransactionEdit> createRandomEdits(int numEntries) { List<TransactionEdit> edits = Lists.newArrayListWithCapacity(numEntries); for (int i = 0; i < numEntries; i++) { TransactionEdit.State nextType = TransactionEdit.State.values()[random.nextInt(6)]; long writePointer = Math.abs(random.nextLong()); switch (nextType) { case INPROGRESS: edits.add(TransactionEdit.createStarted(writePointer, writePointer - 1, System.currentTimeMillis() + 300000L, TransactionType.SHORT)); break; case COMMITTING: edits.add(TransactionEdit.createCommitting(writePointer, generateChangeSet(10))); break; case COMMITTED: edits.add(TransactionEdit.createCommitted(writePointer, generateChangeSet(10), writePointer + 1, random.nextBoolean())); break; case INVALID: edits.add(TransactionEdit.createInvalid(writePointer)); break; case ABORTED: edits.add(TransactionEdit.createAborted(writePointer, TransactionType.SHORT, null)); break; case MOVE_WATERMARK: edits.add(TransactionEdit.createMoveWatermark(writePointer)); break; } } return edits; }