List of usage examples for java.util List clear
void clear();
From source file:edu.uci.ics.asterix.optimizer.rules.PushFieldAccessRule.java
private void pushAccessDown(Mutable<ILogicalOperator> fldAccessOpRef, ILogicalOperator op2, Mutable<ILogicalOperator> inputOfOp2, IOptimizationContext context, String finalAnnot) throws AlgebricksException { ILogicalOperator fieldAccessOp = fldAccessOpRef.getValue(); fldAccessOpRef.setValue(op2);//from w w w .j a v a 2s. c o m List<Mutable<ILogicalOperator>> faInpList = fieldAccessOp.getInputs(); faInpList.clear(); faInpList.add(new MutableObject<ILogicalOperator>(inputOfOp2.getValue())); inputOfOp2.setValue(fieldAccessOp); // typing context.computeAndSetTypeEnvironmentForOperator(fieldAccessOp); context.computeAndSetTypeEnvironmentForOperator(op2); propagateFieldAccessRec(inputOfOp2, context, finalAnnot); }
From source file:com.evolveum.midpoint.wf.impl.jobs.JobCreationInstruction.java
private void setHandlers(List<UriStackEntry> list, List<UriStackEntry> uriStackEntry) { list.clear(); list.addAll(uriStackEntry); }
From source file:com.hp.autonomy.types.idol.marshalling.marshallers.jaxb2.QueueInfoResponseParser.java
@Override public Autnresponse parseResponse(final InputStream inputStream) throws AciErrorException { final Autnresponse autnresponse = responseDataMarshaller.parseResponse(inputStream); final QueueInfoGetStatusResponseData responseData = (QueueInfoGetStatusResponseData) autnresponse .getResponseData();// w w w.j av a 2s . c o m responseData.getActions().getAction().forEach(action -> { final List<Object> results = action.getResults(); final List<Object> mappedResults = results.stream().filter(o -> o instanceof Node).map(o -> (Node) o) .filter(n -> expectedResults.containsKey(n.getNodeName())) .map(n -> expectedResults.get(n.getNodeName()).unmarshal(new DOMSource(n))) .collect(Collectors.toList()); results.clear(); results.addAll(mappedResults); }); return autnresponse; }
From source file:com.xing.android.sdk.network.request.RequestUtilsTest.java
@Test public void appendParamsToBuilder() throws Exception { Uri uriBase = new Uri.Builder().scheme("test").authority("test").build(); Uri.Builder builder = uriBase.buildUpon(); // Check nothing happens RequestUtils.appendParamsToBuilder(builder, null); assertEquals(uriBase.toString(), builder.build().toString()); // Check param with empty key will not be added List<Pair<String, String>> pairs = new ArrayList<>(); pairs.add(new Pair<String, String>(null, null)); RequestUtils.appendParamsToBuilder(builder, pairs); assertEquals(uriBase.toString(), builder.build().toString()); // Check param with empty value will not be added pairs.clear(); pairs.add(new Pair<String, String>("test", null)); RequestUtils.appendParamsToBuilder(builder, pairs); assertEquals(uriBase.toString(), builder.build().toString()); // Check actual param is added pairs.clear();//from w w w . ja va 2 s. c o m pairs.add(new Pair<>("a", "a")); RequestUtils.appendParamsToBuilder(builder, pairs); assertEquals(uriBase + "?a=a", builder.build().toString()); // Check next 2 params will be appended pairs.clear(); pairs.add(new Pair<>("b", "b")); pairs.add(new Pair<String, String>(null, "d")); pairs.add(new Pair<String, String>("f", null)); pairs.add(new Pair<>("c", "c")); RequestUtils.appendParamsToBuilder(builder, pairs); assertEquals(uriBase + "?a=a&b=b&c=c", builder.build().toString()); }
From source file:net.shipilev.fjptrace.tasks.PrintSummaryTask.java
@Override public void doWork() throws Exception { // walk the trees PrintWriter pw = new PrintWriter(fileName); LayerStatistics global = new LayerStatistics(); SortedMap<Integer, LayerStatistics> layerStats = new TreeMap<>(); for (Task t : subgraphs.getParents()) { // compute transitive closure Set<Task> visited = new HashSet<>(); Set<Long> workers = new HashSet<>(); List<Task> prev = new ArrayList<>(); List<Task> cur = new ArrayList<>(); int depth = 0; cur.add(t);//from w ww.ja v a 2s .co m while (visited.addAll(cur)) { prev.clear(); prev.addAll(cur); cur.clear(); Set<Long> layerWorkers = new HashSet<>(); LayerStatistics layerStat = layerStats.get(depth); if (layerStat == null) { layerStat = new LayerStatistics(); layerStats.put(depth, layerStat); } for (Task c : prev) { Collection<Task> children = c.getChildren(); if (!children.isEmpty()) { cur.addAll(children); } layerStat.arities.addValue(children.size()); layerStat.selfTime.addValue(c.getSelfTime() / 1_000_000.0); layerStat.totalTime.addValue(c.getTotalTime() / 1_000_000.0); global.selfTime.addValue(c.getSelfTime() / 1_000_000.0); global.totalTime.addValue(c.getTotalTime() / 1_000_000.0); global.arities.addValue(children.size()); layerWorkers.add(c.getWorker()); } layerStat.counts.addValue(prev.size()); layerStat.threads.addValue(layerWorkers.size()); workers.addAll(layerWorkers); depth++; } global.depths.addValue(depth); global.counts.addValue(visited.size()); global.threads.addValue(workers.size()); } pw.println("Summary statistics:"); pw.printf(" total external tasks = %.0f\n", layerStats.get(0).counts.getSum()); pw.printf(" total subtasks = %.0f\n", global.counts.getSum()); pw.printf(" total threads = %.0f\n", global.threads.getMean()); pw.println(); pw.println("Per task statistics:"); pw.printf(" tasks: sum = %10.0f, min = %5.2f, avg = %5.2f, max = %5.2f\n", global.counts.getSum(), global.counts.getMin(), global.counts.getMean(), global.counts.getMax()); pw.printf(" depth: min = %5.2f, avg = %5.2f, max = %5.2f\n", global.depths.getMin(), global.depths.getMean(), global.depths.getMax()); pw.printf(" arity: min = %5.2f, avg = %5.2f, max = %5.2f\n", global.arities.getMin(), global.arities.getMean(), global.arities.getMax()); pw.printf(" threads: min = %5.2f, avg = %5.2f, max = %5.2f\n", global.threads.getMin(), global.threads.getMean(), global.threads.getMax()); pw.println(); pw.println("Per task + per depth statistics:"); for (Integer depth : layerStats.keySet()) { LayerStatistics s = layerStats.get(depth); pw.printf(" Depth = %d: \n", depth); pw.printf(" tasks: sum = %10.0f, min = %5.2f, avg = %5.2f, max = %5.2f\n", s.counts.getSum(), s.counts.getMin(), s.counts.getMean(), s.counts.getMax()); pw.printf(" self time (ms): sum = %10.0f, min = %5.2f, avg = %5.2f, max = %5.2f\n", s.selfTime.getSum(), s.selfTime.getMin(), s.selfTime.getMean(), s.selfTime.getMax()); pw.printf(" total time (ms): sum = %10.0f, min = %5.2f, avg = %5.2f, max = %5.2f\n", s.totalTime.getSum(), s.totalTime.getMin(), s.totalTime.getMean(), s.totalTime.getMax()); pw.printf(" arity: min = %5.2f, avg = %5.2f, max = %5.2f\n", s.arities.getMin(), s.arities.getMean(), s.arities.getMax()); pw.printf(" threads: min = %5.2f, avg = %5.2f, max = %5.2f\n", s.threads.getMin(), s.threads.getMean(), s.threads.getMax()); } summarizeEvents(pw, events); pw.flush(); pw.close(); }
From source file:com.google.dart.tools.ui.internal.refactoring.ChangeParametersControl_NEW.java
private static void moveUp(List<RefactoringMethodParameter> elements, List<RefactoringMethodParameter> move) { List<RefactoringMethodParameter> res = Lists.newArrayList(); RefactoringMethodParameter floating = null; for (Iterator<RefactoringMethodParameter> iter = elements.iterator(); iter.hasNext();) { RefactoringMethodParameter curr = iter.next(); if (move.contains(curr)) { res.add(curr);// w ww. java 2 s.c o m } else { if (floating != null) { res.add(floating); } floating = curr; } } if (floating != null) { res.add(floating); } elements.clear(); for (Iterator<RefactoringMethodParameter> iter = res.iterator(); iter.hasNext();) { elements.add(iter.next()); } }
From source file:libra.common.kmermatch.KmerJoiner.java
private List<Integer> findMinKeys() throws IOException { CompressedSequenceWritable minKey = null; List<Integer> minKeyIndice = new ArrayList<Integer>(); for (int i = 0; i < this.readers.length; i++) { if (this.stepKeys[i] != null) { if (minKey == null) { minKey = this.stepKeys[i]; minKeyIndice.clear(); minKeyIndice.add(i);/* w w w . j a v a 2 s . com*/ } else { int comp = minKey.compareTo(this.stepKeys[i]); if (comp == 0) { // found same min key minKeyIndice.add(i); } else if (comp > 0) { // found smaller one minKey = this.stepKeys[i]; minKeyIndice.clear(); minKeyIndice.add(i); } } } } return minKeyIndice; }
From source file:com.amazonaws.services.kinesis.log4j.helpers.AmazonKinesisPutRecordsHelper.java
public boolean sendRecordsAsync(String shardKey, List<PutRecordsRequestEntry> putRecordsRequestEntryList) { synchronized (putRecordsRequestEntryList) { // Only try to put records if there are some records already in cache. if (putRecordsRequestEntryList.size() > 0) { // Calculate the real number of records which will be put in the request. If the number of records in // the list is no less than 500, set it to 500; otherwise, set it as the list size. final int intendToSendRecordNumber = (putRecordsRequestEntryList .size() >= RECORDS_COUNT_LIMIT_FOR_ONE_BATCH) ? RECORDS_COUNT_LIMIT_FOR_ONE_BATCH : putRecordsRequestEntryList.size(); try { // Create PutRecords request and use kinesis client to send it. PutRecordsRequest putRecordsRequest = new PutRecordsRequest(); putRecordsRequest.setStreamName(streamName); // Set a sub list of the current records list with maximum of 500 records. List subList = putRecordsRequestEntryList.subList(0, intendToSendRecordNumber); putRecordsRequest.setRecords(new ArrayList(subList)); subList.clear(); if (LOG.isDebugEnabled()) { LOG.debug(String.format("SequenceNumberForOrdering : [%s]; NumberOfRecords : [%d]", sequenceNumberForOrdering, intendToSendRecordNumber)); }//w w w.j a v a 2 s .com amazonKinesisClient.putRecordsAsync(putRecordsRequest, asyncCallHander); shardToFlushTime.get(shardKey).set(System.currentTimeMillis()); } catch (AmazonClientException e) { LOG.error(e.getMessage()); } } } // Return true if the entries count hit the limit, otherwise, return false. return (putRecordsRequestEntryList.size() > 0); }
From source file:io.cloudslang.engine.queue.repositories.ExecutionQueueRepositoryTest.java
@Test public void testPollMessagesWithoutAckWithVersion() { List<ExecutionMessage> msg = new ArrayList<>(); msg.add(generateMessage(1, "group1", "msg1", 1)); executionQueueRepository.insertExecutionQueue(msg, 1L); msg.clear(); msg.add(generateMessage(2, "group2", "msg2", 1)); executionQueueRepository.insertExecutionQueue(msg, 4L); List<ExecutionMessage> result = executionQueueRepository.pollMessagesWithoutAck(100, 3); Assert.assertNotNull(result);//from ww w .j ava 2 s . c o m Assert.assertEquals(1, result.size()); ExecutionMessage resultMsg = result.get(0); Assert.assertEquals(ExecStatus.SENT, resultMsg.getStatus()); Assert.assertEquals("group1", resultMsg.getWorkerGroup()); }
From source file:org.energyos.espi.common.service.impl.ElectricPowerUsageSummaryServiceImpl.java
@Override public EntryType findEntryType(Long retailCustomerId, Long usagePointId, Long electricPowerUsageSummaryId) { EntryType result = null;//from ww w. ja v a 2 s . c om try { // TODO - this is sub-optimal (but defers the need to understan // creation of an EntryType List<Long> temp = new ArrayList<Long>(); temp = resourceService.findAllIdsByXPath(retailCustomerId, usagePointId, ElectricPowerUsageSummary.class); // temp.add(electricPowerUsageSummaryId); if (temp.contains(electricPowerUsageSummaryId)) { temp.clear(); temp.add(electricPowerUsageSummaryId); } else { temp.clear(); } result = (new EntryTypeIterator(resourceService, temp, ElectricPowerUsageSummary.class)) .nextEntry(ElectricPowerUsageSummary.class); } catch (Exception e) { // TODO need a log file entry as we are going to return a null if // it's not found result = null; } return result; }