Java Code Examples for java.util.Collections#emptyIterator()
The following examples show how to use
java.util.Collections#emptyIterator() .
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: ScriptRuntime.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Returns an iterator over property values used in the {@code for each...in} statement. Aside from built-in JS * objects, it also operates on Java arrays, any {@link Iterable}, as well as on {@link Map} objects, iterating over * map values. * @param obj object to iterate on. * @return iterator over the object's property values. */ public static Iterator<?> toValueIterator(final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).valueIterator(); } if (obj instanceof JSObject) { return ((JSObject)obj).values().iterator(); } final Iterator<?> itr = iteratorForJavaArrayOrList(obj); if (itr != null) { return itr; } if (obj instanceof Map) { return ((Map<?,?>)obj).values().iterator(); } final Object wrapped = Global.instance().wrapAsObject(obj); if (wrapped instanceof ScriptObject) { return ((ScriptObject)wrapped).valueIterator(); } return Collections.emptyIterator(); }
Example 2
Source File: SharedFlatMapMultiDataSet.java From deeplearning4j with Apache License 2.0 | 6 votes |
@Override public Iterator<R> call(Iterator<MultiDataSet> dataSetIterator) throws Exception { //Under some limited circumstances, we might have an empty partition. In this case, we should return immediately if(!dataSetIterator.hasNext()){ return Collections.emptyIterator(); } /* That's the place where we do our stuff. Here's the plan: 1) we pass given iterator to VirtualDataSetIterator, which acts as holder for them 2) Virtual iterator will provide load balancing between available devices 3) we'll lock out here */ // iterator should be silently attached to VirtualDataSetIterator, and used appropriately SharedTrainingWrapper.getInstance(worker.getInstanceId()).attachMDS(dataSetIterator); // first callee will become master, others will obey and die // all threads in this executor will be blocked here until training finished SharedTrainingResult result = SharedTrainingWrapper.getInstance(worker.getInstanceId()).run(worker); return Collections.singletonList((R) result).iterator(); }
Example 3
Source File: ImageIO.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Returns an <code>Iterator</code> containing all currently * registered <code>ImageTranscoder</code>s that claim to be * able to transcode between the metadata of the given * <code>ImageReader</code> and <code>ImageWriter</code>. * * @param reader an <code>ImageReader</code>. * @param writer an <code>ImageWriter</code>. * * @return an <code>Iterator</code> containing * <code>ImageTranscoder</code>s. * * @exception IllegalArgumentException if <code>reader</code> or * <code>writer</code> is <code>null</code>. */ public static Iterator<ImageTranscoder> getImageTranscoders(ImageReader reader, ImageWriter writer) { if (reader == null) { throw new IllegalArgumentException("reader == null!"); } if (writer == null) { throw new IllegalArgumentException("writer == null!"); } ImageReaderSpi readerSpi = reader.getOriginatingProvider(); ImageWriterSpi writerSpi = writer.getOriginatingProvider(); ServiceRegistry.Filter filter = new TranscoderFilter(readerSpi, writerSpi); Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class, filter, true); } catch (IllegalArgumentException e) { return Collections.emptyIterator(); } return new ImageTranscoderIterator(iter); }
Example 4
Source File: ImageIO.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Returns an <code>Iterator</code> containing all currently * registered <code>ImageWriter</code>s that claim to be able to * encode the named format. * * @param formatName a <code>String</code> containing the informal * name of a format (<i>e.g.</i>, "jpeg" or "tiff". * * @return an <code>Iterator</code> containing * <code>ImageWriter</code>s. * * @exception IllegalArgumentException if <code>formatName</code> is * <code>null</code>. * * @see javax.imageio.spi.ImageWriterSpi#getFormatNames */ public static Iterator<ImageWriter> getImageWritersByFormatName(String formatName) { if (formatName == null) { throw new IllegalArgumentException("formatName == null!"); } Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new ContainsFilter(writerFormatNamesMethod, formatName), true); } catch (IllegalArgumentException e) { return Collections.emptyIterator(); } return new ImageWriterIterator(iter); }
Example 5
Source File: JanusGraphPropertiesStep.java From grakn with GNU Affero General Public License v3.0 | 6 votes |
@Override protected Iterator<E> flatMap(Traverser.Admin<Element> traverser) { if (useMultiQuery) { //it is guaranteed that all elements are vertices if (multiQueryResults == null || !multiQueryResults.containsKey(traverser.get())) { initializeMultiQuery(Arrays.asList(traverser)); } return convertIterator(multiQueryResults.get(traverser.get())); } else if (traverser.get() instanceof JanusGraphVertex || traverser.get() instanceof WrappedVertex) { JanusGraphVertexQuery query = makeQuery((JanusGraphTraversalUtil.getJanusGraphVertex(traverser)).query()); return convertIterator(query.properties()); } else { //It is some other element (edge or vertex property) Iterator<E> iterator; if (getReturnType().forValues()) { iterator = traverser.get().values(getPropertyKeys()); } else { //HasContainers don't apply => empty result set if (!hasContainers.isEmpty()) return Collections.emptyIterator(); iterator = (Iterator<E>) traverser.get().properties(getPropertyKeys()); } if (limit != Query.NO_LIMIT) iterator = Iterators.limit(iterator, limit); return iterator; } }
Example 6
Source File: ImageIO.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Returns an <code>Iterator</code> containing all currently * registered <code>ImageWriter</code>s that claim to be able to * encode files with the given suffix. * * @param fileSuffix a <code>String</code> containing a file * suffix (<i>e.g.</i>, "jpg" or "tiff"). * * @return an <code>Iterator</code> containing <code>ImageWriter</code>s. * * @exception IllegalArgumentException if <code>fileSuffix</code> is * <code>null</code>. * * @see javax.imageio.spi.ImageWriterSpi#getFileSuffixes */ public static Iterator<ImageWriter> getImageWritersBySuffix(String fileSuffix) { if (fileSuffix == null) { throw new IllegalArgumentException("fileSuffix == null!"); } Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new ContainsFilter(writerFileSuffixesMethod, fileSuffix), true); } catch (IllegalArgumentException e) { return Collections.emptyIterator(); } return new ImageWriterIterator(iter); }
Example 7
Source File: ImageIO.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Returns an <code>Iterator</code> containing all currently * registered <code>ImageWriter</code>s that claim to be able to * encode the named format. * * @param formatName a <code>String</code> containing the informal * name of a format (<i>e.g.</i>, "jpeg" or "tiff". * * @return an <code>Iterator</code> containing * <code>ImageWriter</code>s. * * @exception IllegalArgumentException if <code>formatName</code> is * <code>null</code>. * * @see javax.imageio.spi.ImageWriterSpi#getFormatNames */ public static Iterator<ImageWriter> getImageWritersByFormatName(String formatName) { if (formatName == null) { throw new IllegalArgumentException("formatName == null!"); } Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new ContainsFilter(writerFormatNamesMethod, formatName), true); } catch (IllegalArgumentException e) { return Collections.emptyIterator(); } return new ImageWriterIterator(iter); }
Example 8
Source File: ImageIO.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Returns an <code>Iterator</code> containing all currently * registered <code>ImageWriter</code>s that claim to be able to * encode the named format. * * @param formatName a <code>String</code> containing the informal * name of a format (<i>e.g.</i>, "jpeg" or "tiff". * * @return an <code>Iterator</code> containing * <code>ImageWriter</code>s. * * @exception IllegalArgumentException if <code>formatName</code> is * <code>null</code>. * * @see javax.imageio.spi.ImageWriterSpi#getFormatNames */ public static Iterator<ImageWriter> getImageWritersByFormatName(String formatName) { if (formatName == null) { throw new IllegalArgumentException("formatName == null!"); } Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new ContainsFilter(writerFormatNamesMethod, formatName), true); } catch (IllegalArgumentException e) { return Collections.emptyIterator(); } return new ImageWriterIterator(iter); }
Example 9
Source File: ImageIO.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Returns an {@code Iterator} containing all currently * registered {@code ImageTranscoder}s that claim to be * able to transcode between the metadata of the given * {@code ImageReader} and {@code ImageWriter}. * * @param reader an {@code ImageReader}. * @param writer an {@code ImageWriter}. * * @return an {@code Iterator} containing * {@code ImageTranscoder}s. * * @exception IllegalArgumentException if {@code reader} or * {@code writer} is {@code null}. */ public static Iterator<ImageTranscoder> getImageTranscoders(ImageReader reader, ImageWriter writer) { if (reader == null) { throw new IllegalArgumentException("reader == null!"); } if (writer == null) { throw new IllegalArgumentException("writer == null!"); } ImageReaderSpi readerSpi = reader.getOriginatingProvider(); ImageWriterSpi writerSpi = writer.getOriginatingProvider(); ServiceRegistry.Filter filter = new TranscoderFilter(readerSpi, writerSpi); Iterator<ImageTranscoderSpi> iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class, filter, true); } catch (IllegalArgumentException e) { return Collections.emptyIterator(); } return new ImageTranscoderIterator(iter); }
Example 10
Source File: LocalPersistentStore.java From Bats with Apache License 2.0 | 5 votes |
@Override public Iterator<Map.Entry<String, V>> getRange(int skip, int take) { try { // list only files with sys file suffix PathFilter sysFileSuffixFilter = new PathFilter() { @Override public boolean accept(Path path) { return path.getName().endsWith(DRILL_SYS_FILE_SUFFIX); } }; List<FileStatus> fileStatuses = DrillFileSystemUtil.listFiles(fs, basePath, false, sysFileSuffixFilter); if (fileStatuses.isEmpty()) { return Collections.emptyIterator(); } List<String> files = Lists.newArrayList(); for (FileStatus stat : fileStatuses) { String s = stat.getPath().getName(); files.add(s.substring(0, s.length() - DRILL_SYS_FILE_SUFFIX.length())); } Collections.sort(files); return Iterables.transform(Iterables.limit(Iterables.skip(files, skip), take), new Function<String, Entry<String, V>>() { @Nullable @Override public Entry<String, V> apply(String key) { return new ImmutableEntry<>(key, get(key)); } }).iterator(); } catch (IOException e) { throw new RuntimeException(e); } }
Example 11
Source File: ScanWithDremioReader.java From dremio-oss with Apache License 2.0 | 5 votes |
static Iterator<RecordReader> createReaders( final HiveConf hiveConf, final BaseHiveStoragePlugin hiveStoragePlugin, final FragmentExecutionContext fragmentExecContext, final OperatorContext context, final HiveProxyingSubScan config, final HiveTableXattr tableXattr, final CompositeReaderConfig compositeReader, final UserGroupInformation readerUGI, List<SplitAndPartitionInfo> splits) { try (ContextClassLoaderSwapper ccls = ContextClassLoaderSwapper.newInstance()) { if(splits.isEmpty()) { return Collections.emptyIterator(); } final JobConf jobConf = new JobConf(hiveConf); final List<HiveParquetSplit> sortedSplits = Lists.newArrayList(); for (SplitAndPartitionInfo split : splits) { sortedSplits.add(new HiveParquetSplit(split)); } Collections.sort(sortedSplits); return new HiveParquetSplitReaderIterator( jobConf, context, config, sortedSplits, readerUGI, compositeReader, hiveStoragePlugin, tableXattr); } catch (final Exception e) { throw Throwables.propagate(e); } }
Example 12
Source File: ValueRowMappedJoinTable.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public Iterator<ExecRow> fetchInner(ExecRow outer) throws IOException, StandardException{ for (int i = 0; i < numKeys; i++) { keyRow.setColumn(i+1, outer.getColumn(outerHashKeys[i] + 1)); } List<ExecRow> rows = table.get(keyRow); if(rows==null) return Collections.emptyIterator(); else return rows.iterator(); }
Example 13
Source File: SelectionResult.java From quarkus with Apache License 2.0 | 5 votes |
@Override public Iterator<Extension> iterator() { if (matches) { return extensions.iterator(); } return Collections.emptyIterator(); }
Example 14
Source File: CloseableIterable.java From iceberg with Apache License 2.0 | 5 votes |
static <E> CloseableIterable<E> empty() { return new CloseableIterable<E>() { @Override public void close() { } @Override public Iterator<E> iterator() { return Collections.emptyIterator(); } }; }
Example 15
Source File: TaskSlotTableImpl.java From flink with Apache License 2.0 | 5 votes |
private TaskSlotIterator(JobID jobId, TaskSlotState state) { Set<AllocationID> allocationIds = slotsPerJob.get(jobId); if (allocationIds == null || allocationIds.isEmpty()) { allSlots = Collections.emptyIterator(); } else { allSlots = allocationIds.iterator(); } this.state = Preconditions.checkNotNull(state); this.currentSlot = null; }
Example 16
Source File: ScriptRuntime.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Returns an iterator over property values used in the {@code for each...in} statement. Aside from built-in JS * objects, it also operates on Java arrays, any {@link Iterable}, as well as on {@link Map} objects, iterating over * map values. * @param obj object to iterate on. * @return iterator over the object's property values. */ public static Iterator<?> toValueIterator(final Object obj) { if (obj instanceof ScriptObject) { return ((ScriptObject)obj).valueIterator(); } if (obj != null && obj.getClass().isArray()) { final Object array = obj; final int length = Array.getLength(obj); return new Iterator<Object>() { private int index = 0; @Override public boolean hasNext() { return index < length; } @Override public Object next() { if (index >= length) { throw new NoSuchElementException(); } return Array.get(array, index++); } @Override public void remove() { throw new UnsupportedOperationException("remove"); } }; } if (obj instanceof JSObject) { return ((JSObject)obj).values().iterator(); } if (obj instanceof Map) { return ((Map<?,?>)obj).values().iterator(); } if (obj instanceof Iterable) { return ((Iterable<?>)obj).iterator(); } final Object wrapped = Global.instance().wrapAsObject(obj); if (wrapped instanceof ScriptObject) { return ((ScriptObject)wrapped).valueIterator(); } return Collections.emptyIterator(); }
Example 17
Source File: EmptyGraph.java From tinkerpop with Apache License 2.0 | 4 votes |
@Override public Iterator<Edge> edges(final Object... edgeIds) { return Collections.emptyIterator(); }
Example 18
Source File: ValueExpressions.java From Bats with Apache License 2.0 | 4 votes |
@Override public Iterator<LogicalExpression> iterator() { return Collections.emptyIterator(); }
Example 19
Source File: HResult.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
@Override public Iterator<DataCell> iterator(){ if(result==null||result.isEmpty()) return Collections.emptyIterator(); return Iterators.transform(result.listCells().iterator(),transform); }
Example 20
Source File: LL.java From ReactFX with BSD 2-Clause "Simplified" License | votes |
@Override public Iterator<T> iterator() { return Collections.emptyIterator(); }