Java Code Examples for org.apache.commons.collections.IteratorUtils#toList()
The following examples show how to use
org.apache.commons.collections.IteratorUtils#toList() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobContextAdapterStore.java From geowave with Apache License 2.0 | 6 votes |
public List<String> getTypeNames() { final DataTypeAdapter<?>[] userAdapters = GeoWaveConfiguratorBase.getDataAdapters(CLASS, context); if ((userAdapters == null) || (userAdapters.length <= 0)) { return IteratorUtils.toList( IteratorUtils.transformedIterator(getAdapters(), new Transformer() { @Override public Object transform(final Object input) { if (input instanceof DataTypeAdapter) { return ((DataTypeAdapter) input).getTypeName(); } return input; } })); } else { final List<String> retVal = new ArrayList<>(userAdapters.length); for (final DataTypeAdapter<?> adapter : userAdapters) { retVal.add(adapter.getTypeName()); } return retVal; } }
Example 2
Source File: ReflectionUtilTest.java From hugegraph-common with Apache License 2.0 | 6 votes |
@Test public void testClasses() throws IOException { @SuppressWarnings("unchecked") List<ClassInfo> classes = IteratorUtils.toList(ReflectionUtil.classes( "com.baidu.hugegraph.util")); Assert.assertEquals(16, classes.size()); classes.sort((c1, c2) -> c1.getName().compareTo(c2.getName())); Assert.assertEquals("com.baidu.hugegraph.util.Bytes", classes.get(0).getName()); Assert.assertEquals("com.baidu.hugegraph.util.CheckSocket", classes.get(1).getName()); Assert.assertEquals("com.baidu.hugegraph.util.CollectionUtil", classes.get(2).getName()); Assert.assertEquals("com.baidu.hugegraph.util.VersionUtil", classes.get(15).getName()); }
Example 3
Source File: LaborLedgerBalanceServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
@Override @NonTransactional @Deprecated public Integer getBalanceRecordCount(Map fieldValues, boolean isConsolidated, List<String> encumbranceBalanceTypes) { LOG.debug("getBalanceRecordCount() started"); Integer recordCount = null; if (!isConsolidated) { recordCount = OJBUtility.getResultSizeFromMap(fieldValues, new LedgerBalance()).intValue(); } else { Iterator recordCountIterator = laborLedgerBalanceDao.getConsolidatedBalanceRecordCount(fieldValues, encumbranceBalanceTypes); List recordCountList = IteratorUtils.toList(recordCountIterator); recordCount = recordCountList.size(); } return recordCount; }
Example 4
Source File: LaborLedgerBalanceServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * @see org.kuali.kfs.module.ld.service.LaborLedgerBalanceService#getBalanceRecordCount(Map, boolean, List) */ @Override @NonTransactional public Integer getBalanceRecordCount(Map fieldValues, boolean isConsolidated, List<String> encumbranceBalanceTypes, boolean noZeroAmounts) { LOG.debug("getBalanceRecordCount() started"); Integer recordCount = null; if (!isConsolidated) { recordCount = OJBUtility.getResultSizeFromMap(fieldValues, new LedgerBalance()).intValue(); } else { Iterator recordCountIterator = laborLedgerBalanceDao.getConsolidatedBalanceRecordCount(fieldValues, encumbranceBalanceTypes, noZeroAmounts); List recordCountList = IteratorUtils.toList(recordCountIterator); recordCount = recordCountList.size(); } return recordCount; }
Example 5
Source File: SqlScriptTest.java From jpa-unit with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testRemovalOfCommentsProperSplittingOfStatementsAndTrimmingOfEachOfIt() { // GIVEN final SqlScript script = new SqlScript(TEST_SCRIPT); // WHEN final List<String> list = IteratorUtils.toList(script.iterator()); // THEN assertThat(list.size(), equalTo(12)); assertThat(list, everyItem(not(containsString("comment")))); assertThat(list, everyItem(not(startsWith(" ")))); assertThat(list, everyItem(not(startsWith("\t")))); assertThat(list, everyItem(not(endsWith(" ")))); assertThat(list, everyItem(not(endsWith("\t")))); }
Example 6
Source File: DailySnapshot.java From soundwave with Apache License 2.0 | 5 votes |
@GET @Path("/dailysnapshot/{day}") public Response getDailySnapshot(@PathParam("day") @NotNull String day) { OperationStats opStats = new OperationStats("cmdb_api", "get_dailysnapshot", new HashMap<>()); Map<String, String> tags = new HashMap<>(); try { DateTime time = DateTime.parse(day, DateTimeFormat.forPattern("yyyy-MM-dd")); DailySnapshotStore dailySnapshot = factory.getDailyStore(time); Iterator<EsDailySnapshotInstance> iter = dailySnapshot.getSnapshotInstances(); List<EsDailySnapshotInstance> ret = IteratorUtils.toList(iter); logger.info("Success: getDailySnapshot - {}", day); return Response.status(Response.Status.OK) .type(MediaType.APPLICATION_JSON) .entity(ret) .build(); } catch (Exception e) { return Utils.responseException(e, logger, opStats, tags); } }
Example 7
Source File: AccountBalanceServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 5 votes |
/** * This method gets the number of the available account balances according to input fields and values * * @param fieldValues the input fields and values * @param isConsolidated determine whether the search results are consolidated * @return the number of the available account balances * @see org.kuali.kfs.gl.service.AccountBalanceService#getAvailableAccountBalanceCount(java.util.Map, boolean) */ public Integer getAvailableAccountBalanceCount(Map fieldValues, boolean isConsolidated) { Integer recordCount = null; if (!isConsolidated) { recordCount = OJBUtility.getResultSizeFromMap(fieldValues, new AccountBalance()).intValue(); } else { Iterator recordCountIterator = accountBalanceDao.findConsolidatedAvailableAccountBalance(fieldValues); // TODO: WL: why build a list and waste time/memory when we can just iterate through the iterator and do a count? List recordCountList = IteratorUtils.toList(recordCountIterator); recordCount = recordCountList.size(); } return recordCount; }
Example 8
Source File: TestSimpleXJoinResultsFactory.java From BioSolr with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) private void testResultsFile(NamedList args, boolean globalValues, boolean resultValues) throws IOException { SimpleXJoinResultsFactory factory = new SimpleXJoinResultsFactory(); factory.init(args); SolrParams params = new ModifiableSolrParams(); XJoinResults<String> results = factory.getResults(params); Map<String, String> values = (Map<String, String>)results; if (globalValues) { assertEquals(312, values.get("total")); } else { assertEquals(0, values.size()); } Set<String> joinIds = new HashSet<>(IteratorUtils.toList(results.getJoinIds().iterator())); assertEquals(new HashSet<>(Arrays.asList(new String[] { "a3e5bd", "252ae1", "912151" })), joinIds); Map<String, String> result1 = (Map<String, String>)results.getResult("a3e5bd"); Map<String, String> result2 = (Map<String, String>)results.getResult("252ae1"); if (resultValues) { assertEquals("blue", result1.get("colour")); assertEquals(10.5, result2.get("value")); } else { assertEquals(0, result1.size()); assertEquals(0, result2.size()); } }
Example 9
Source File: CsvReaderDataSource.java From obevo with Apache License 2.0 | 5 votes |
@Override protected CatoDataObject nextDataObject() throws Exception { final List<String> data; if (csvVersion == CsvStaticDataReader.CSV_V2) { if (!this.iteratorV2.hasNext()) { return null; } data = IteratorUtils.toList(iteratorV2.next().iterator()); } else { String[] csvRow = this.csvreaderV1.readNext(); data = csvRow != null ? Arrays.asList(csvRow) : Lists.mutable.<String>empty(); } if (data == null || data.size() == 0 || (data.size() == 1 && data.get(0).isEmpty())) { return null; } else if (data.size() != this.fields.size()) { throw new IllegalArgumentException("This row does not have the right # of columns: expecting " + this.fields.size() + " columns, but the row was: " + Lists.mutable.with(data)); } CatoDataObject dataObject = this.createDataObject(); for (int i = 0; i < data.size(); i++) { dataObject.setValue(this.fields.get(i), data.get(i)); } // needed to preserve the order of rows in the difference calculation dataObject.setValue(ROW_NUMBER_FIELD, rowNumber++); return dataObject; }
Example 10
Source File: WriteNewInventoryReportFunc.java From s3-inventory-usage-examples with Apache License 2.0 | 5 votes |
@Override public Iterator<InventoryManifest.Locator> call(Iterator<InventoryReportLine> inventoryReport) throws IOException { // Exclude the empty iterators which are caused by the mapPartitions // when one partition only owns empty InventoryReportLine iterator after the filtering if (!inventoryReport.hasNext()){ return Collections.emptyIterator(); } List<InventoryReportLine> inventoryReportLineList = IteratorUtils.toList(inventoryReport); InventoryReportLineWriter scvWriter = new InventoryReportLineWriter(s3ClientFactory.getValue().get(), destBucket, destPrefix, srcBucket, manifestStorage); return Collections.singletonList(scvWriter.writeCsvFile(inventoryReportLineList)).iterator(); }
Example 11
Source File: TestSimpleXJoinResultsFactory.java From BioSolr with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) private void testResultsFile(NamedList args, boolean globalValues, boolean resultValues) throws IOException { SimpleXJoinResultsFactory factory = new SimpleXJoinResultsFactory(); factory.init(args); SolrParams params = new ModifiableSolrParams(); XJoinResults<String> results = factory.getResults(params); Map<String, String> values = (Map<String, String>)results; if (globalValues) { assertEquals(312, values.get("total")); } else { assertEquals(0, values.size()); } Set<String> joinIds = new HashSet<>(IteratorUtils.toList(results.getJoinIds().iterator())); assertEquals(new HashSet<>(Arrays.asList(new String[] { "a3e5bd", "252ae1", "912151" })), joinIds); Map<String, String> result1 = (Map<String, String>)results.getResult("a3e5bd"); Map<String, String> result2 = (Map<String, String>)results.getResult("252ae1"); if (resultValues) { assertEquals("blue", result1.get("colour")); assertEquals(10.5, result2.get("value")); } else { assertEquals(0, result1.size()); assertEquals(0, result2.size()); } }
Example 12
Source File: GraphHelper.java From atlas with Apache License 2.0 | 5 votes |
public static List<AtlasEdge> getMapValuesUsingRelationship(AtlasVertex vertex, AtlasAttribute attribute) { String edgeLabel = attribute.getRelationshipEdgeLabel(); AtlasRelationshipEdgeDirection edgeDirection = attribute.getRelationshipEdgeDirection(); Iterator<AtlasEdge> edgesForLabel = getEdgesForLabel(vertex, edgeLabel, edgeDirection); return (List<AtlasEdge>) IteratorUtils.toList(edgesForLabel); }
Example 13
Source File: SnapshotFunctionalityTest.java From iceberg with Apache License 2.0 | 5 votes |
/** * Expires anything older than a given timestamp, NOT including that timestamp. */ @Test public void retireAllSnapshotsOlderThanTimestamp() { long secondLatestTimestamp = table.history().get(2).timestampMillis(); Iterator<Snapshot> beforeIterator = table.snapshots().iterator(); List<Snapshot> beforeSnapshots = IteratorUtils.toList(beforeIterator); //Delete the 2 oldest snapshots table.expireSnapshots().expireOlderThan(secondLatestTimestamp).commit(); table.refresh(); Iterator<Snapshot> afterIterator = table.snapshots().iterator(); List<Snapshot> afterSnapshots = IteratorUtils.toList(afterIterator); }
Example 14
Source File: TestSimpleXJoinResultsFactory.java From BioSolr with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) private void testResultsFile(NamedList args, boolean globalValues, boolean resultValues) throws IOException { SimpleXJoinResultsFactory factory = new SimpleXJoinResultsFactory(); factory.init(args); SolrParams params = new ModifiableSolrParams(); XJoinResults<String> results = factory.getResults(params); Map<String, String> values = (Map<String, String>)results; if (globalValues) { assertEquals(312, values.get("total")); } else { assertEquals(0, values.size()); } Set<String> joinIds = new HashSet<>(IteratorUtils.toList(results.getJoinIds().iterator())); assertEquals(new HashSet<>(Arrays.asList(new String[] { "a3e5bd", "252ae1", "912151" })), joinIds); Map<String, String> result1 = (Map<String, String>)results.getResult("a3e5bd"); Map<String, String> result2 = (Map<String, String>)results.getResult("252ae1"); if (resultValues) { assertEquals("blue", result1.get("colour")); assertEquals(10.5, result2.get("value")); } else { assertEquals(0, result1.size()); assertEquals(0, result2.size()); } }
Example 15
Source File: SystemOptionManager.java From Bats with Apache License 2.0 | 4 votes |
@Override public OptionList getOptionList() { return (OptionList) IteratorUtils.toList(iterator()); }
Example 16
Source File: Counters.java From hadoop with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public synchronized Collection<String> getGroupNames() { return IteratorUtils.toList(super.getGroupNames().iterator()); }
Example 17
Source File: Counters.java From big-c with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public synchronized Collection<String> getGroupNames() { return IteratorUtils.toList(super.getGroupNames().iterator()); }
Example 18
Source File: RITSupport.java From nexus-repository-r with Eclipse Public License 1.0 | 4 votes |
protected List<Asset> findAssetsByComponent(final Repository repository, final Component component) { try (StorageTx tx = getStorageTx(repository)) { tx.begin(); return IteratorUtils.toList(tx.browseAssets(component).iterator()); } }
Example 19
Source File: XJoinQParserPlugin.java From BioSolr with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("unchecked") Query makeQuery(String fname, Iterator<BytesRef> it) { return new TermInSetQuery(fname, IteratorUtils.toList(it)); }
Example 20
Source File: VariantContextTestUtils.java From gatk with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Returns a list of VariantContext records from a VCF file * * @param vcfFile VCF file * @return list of VariantContext records * @throws IOException if the file does not exist or can not be opened */ @SuppressWarnings({"unchecked"}) public static List<VariantContext> getVariantContexts(final File vcfFile) { try (final FeatureDataSource<VariantContext> variantContextFeatureDataSource = new FeatureDataSource<>(vcfFile)) { return IteratorUtils.toList(variantContextFeatureDataSource.iterator()); } }