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.sosy_lab.cpachecker.util.predicates.interpolation.strategy.NestedInterpolation.java
@Override public List<BooleanFormula> getInterpolants(final InterpolationManager.Interpolator<T> interpolator, final List<Triple<BooleanFormula, AbstractState, T>> formulasWithStatesAndGroupdIds) throws InterruptedException, SolverException { List<BooleanFormula> interpolants = Lists .newArrayListWithExpectedSize(formulasWithStatesAndGroupdIds.size() - 1); BooleanFormula lastItp = bfmgr.makeBoolean(true); // PSI_0 = True final Deque<Triple<BooleanFormula, BooleanFormula, CFANode>> callstack = new ArrayDeque<>(); for (int positionOfA = 0; positionOfA < formulasWithStatesAndGroupdIds.size() - 1; positionOfA++) { // use a new prover, because we use several distinct queries lastItp = getNestedInterpolant(formulasWithStatesAndGroupdIds, interpolants, callstack, interpolator, positionOfA, lastItp);//from ww w . j a v a 2 s .c om } return interpolants; }
From source file:com.android.tools.idea.navigator.nodes.AndroidJniFolderNode.java
@NotNull @Override/*from w w w. j a v a 2 s . co m*/ public PsiDirectory[] getDirectories() { Collection<File> sourceFolders = getModel().getSelectedVariant().getSourceFolders(); List<PsiDirectory> psiDirectories = Lists.newArrayListWithExpectedSize(sourceFolders.size()); LocalFileSystem fileSystem = LocalFileSystem.getInstance(); assert myProject != null; PsiManager psiManager = PsiManager.getInstance(myProject); for (File folder : sourceFolders) { VirtualFile virtualFile = fileSystem.findFileByIoFile(folder); if (virtualFile != null) { PsiDirectory dir = psiManager.findDirectory(virtualFile); if (dir != null) { psiDirectories.add(dir); } } } return psiDirectories.toArray(new PsiDirectory[psiDirectories.size()]); }
From source file:edu.umich.robot.soar.LidarIL.java
LidarIL(SoarAgent agent) { super(agent, IOConstants.LIDAR, agent.getSoarAgent().GetInputLink()); this.agent = agent; ranges = Lists.newArrayListWithExpectedSize(5); update(); }
From source file:monasca.thresh.infrastructure.persistence.hibernate.AlarmDefinitionSqlImpl.java
@Override @SuppressWarnings("unchecked") public List<AlarmDefinition> listAll() { Session session = null;//from w ww. ja v a2 s . c o m List<AlarmDefinition> alarmDefinitions = null; try { session = sessionFactory.openSession(); List<AlarmDefinitionDb> alarmDefDbList = session.createCriteria(AlarmDefinitionDb.class) .add(Restrictions.isNull("deletedAt")).addOrder(Order.asc("createdAt")).setReadOnly(true) .list(); if (alarmDefDbList != null) { alarmDefinitions = Lists.newArrayListWithExpectedSize(alarmDefDbList.size()); for (final AlarmDefinitionDb alarmDefDb : alarmDefDbList) { final Collection<String> matchBy = alarmDefDb.getMatchByAsCollection(); final boolean actionEnable = alarmDefDb.isActionsEnabled(); alarmDefinitions.add(new AlarmDefinition(alarmDefDb.getId(), alarmDefDb.getTenantId(), alarmDefDb.getName(), alarmDefDb.getDescription(), AlarmExpression.of(alarmDefDb.getExpression()), alarmDefDb.getSeverity().name(), actionEnable, this.findSubExpressions(session, alarmDefDb.getId()), matchBy.isEmpty() ? Collections.<String>emptyList() : Lists.newArrayList(matchBy))); session.evict(alarmDefDb); } } return alarmDefinitions == null ? Collections.<AlarmDefinition>emptyList() : alarmDefinitions; } finally { if (session != null) { session.close(); } } }
From source file:org.apache.kylin.cube.util.KeyValueBuilder.java
public String[] buildValueOf(int idxOfMeasure, String[] row) { MeasureDesc measure = cubeDesc.getMeasures().get(idxOfMeasure); FunctionDesc function = measure.getFunction(); int[] colIdxOnFlatTable = flatDesc.getMeasureColumnIndexes()[idxOfMeasure]; int paramCount = function.getParameterCount(); List<String> inputToMeasure = Lists.newArrayListWithExpectedSize(paramCount); // pick up parameter values ParameterDesc param = function.getParameter(); int colParamIdx = 0; // index among parameters of column type for (int i = 0; i < paramCount; i++, param = param.getNextParameter()) { String value;/* ww w . j a v a 2 s . c o m*/ if (function.isCount()) { value = "1"; } else if (param.isColumnType()) { value = getCell(colIdxOnFlatTable[colParamIdx++], row); } else { value = param.getValue(); } inputToMeasure.add(value); } return inputToMeasure.toArray(new String[inputToMeasure.size()]); }
From source file:org.eclipse.xtext.validation.ResourceValidatorImpl.java
@Override public List<Issue> validate(Resource resource, final CheckMode mode, CancelIndicator mon) throws OperationCanceledError { StoppedTask task = Stopwatches.forTask("ResourceValidatorImpl.validation"); try {/* w w w. j a v a2 s.com*/ task.start(); final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon; resolveProxies(resource, monitor); operationCanceledManager.checkCanceled(monitor); final List<Issue> result = Lists .newArrayListWithExpectedSize(resource.getErrors().size() + resource.getWarnings().size()); try { IAcceptor<Issue> acceptor = createAcceptor(result); if (mode.shouldCheck(CheckType.FAST)) { collectResourceDiagnostics(resource, monitor, acceptor); } operationCanceledManager.checkCanceled(monitor); boolean syntaxDiagFail = !result.isEmpty(); logCheckStatus(resource, syntaxDiagFail, "Syntax"); validate(resource, mode, monitor, acceptor); operationCanceledManager.checkCanceled(monitor); } catch (RuntimeException e) { operationCanceledManager.propagateAsErrorIfCancelException(e); log.error(e.getMessage(), e); } return result; } finally { task.stop(); } }
From source file:io.ucoin.ucoinj.web.security.UcoinjUserDetailsImpl.java
protected Collection<? extends GrantedAuthority> createAuthorities(Set<String> roles) { List<SimpleGrantedAuthority> authorities = Lists.newArrayListWithExpectedSize(roles.size()); for (String role : roles) { authorities.add(new SimpleGrantedAuthority(role)); }//from w w w . j a va2 s . co m return authorities; }
From source file:org.apache.phoenix.compile.PostLocalIndexDDLCompiler.java
public MutationPlan compile(PTable index) throws SQLException { try (final PhoenixStatement statement = new PhoenixStatement(connection)) { String query = "SELECT count(*) FROM " + tableName; final QueryPlan plan = statement.compileQuery(query); TableRef tableRef = plan.getTableRef(); Scan scan = plan.getContext().getScan(); ImmutableBytesWritable ptr = new ImmutableBytesWritable(); final PTable dataTable = tableRef.getTable(); List<PTable> indexes = Lists.newArrayListWithExpectedSize(1); for (PTable indexTable : dataTable.getIndexes()) { if (indexTable.getKey().equals(index.getKey())) { index = indexTable;/*from w w w . ja v a2 s. c o m*/ break; } } // Only build newly created index. indexes.add(index); IndexMaintainer.serialize(dataTable, ptr, indexes, plan.getContext().getConnection()); // Set attribute on scan that UngroupedAggregateRegionObserver will switch on. // We'll detect that this attribute was set the server-side and write the index // rows per region as a result. The value of the attribute will be our persisted // index maintainers. // Define the LOCAL_INDEX_BUILD as a new static in BaseScannerRegionObserver scan.setAttribute(BaseScannerRegionObserver.LOCAL_INDEX_BUILD_PROTO, ByteUtil.copyKeyBytesIfNecessary(ptr)); // By default, we'd use a FirstKeyOnly filter as nothing else needs to be projected for count(*). // However, in this case, we need to project all of the data columns that contribute to the index. IndexMaintainer indexMaintainer = index.getIndexMaintainer(dataTable, connection); for (ColumnReference columnRef : indexMaintainer.getAllColumns()) { if (index.getImmutableStorageScheme() == ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS) { scan.addFamily(columnRef.getFamily()); } else { scan.addColumn(columnRef.getFamily(), columnRef.getQualifier()); } } // Go through MutationPlan abstraction so that we can create local indexes // with a connectionless connection (which makes testing easier). return new BaseMutationPlan(plan.getContext(), Operation.UPSERT) { @Override public MutationState execute() throws SQLException { connection.getMutationState().commitDDLFence(dataTable); Tuple tuple = plan.iterator().next(); long rowCount = 0; if (tuple != null) { Cell kv = tuple.getValue(0); ImmutableBytesWritable tmpPtr = new ImmutableBytesWritable(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()); // A single Cell will be returned with the count(*) - we decode that here rowCount = PLong.INSTANCE.getCodec().decodeLong(tmpPtr, SortOrder.getDefault()); } // The contract is to return a MutationState that contains the number of rows modified. In this // case, it's the number of rows in the data table which corresponds to the number of index // rows that were added. return new MutationState(0, connection, rowCount); } }; } }
From source file:org.sosy_lab.cpachecker.core.counterexample.CounterexampleInfo.java
private CounterexampleInfo(boolean pSpurious, ARGPath pTargetPath, CFAPathWithAssumptions pAssignments, boolean pIsPreciseCEX) { uniqueId = ID_GENERATOR.getFreshId(); spurious = pSpurious;// www .j a va 2s . com targetPath = pTargetPath; assignments = pAssignments; isPreciseCounterExample = pIsPreciseCEX; if (!spurious) { furtherInfo = Lists.newArrayListWithExpectedSize(1); } else { furtherInfo = null; } }
From source file:mods.nazu.ncraft.launcher.SubscriptionManager.java
private void loadSubscriptions() { File file = new File("subscriptions"); if (!file.exists() && !file.mkdir()) { System.err.println("Unable to create subscriptions folder."); return;/*from w w w .ja v a 2 s . c o m*/ } File[] files = file.listFiles(FILTER_JSON_FILES); subscriptions = Lists.newArrayListWithExpectedSize(files.length); Subscription sub; for (File f : files) { sub = Subscription.fromFile(f); if (null != sub) { subscriptions.add(sub); } } }