Example usage for java.util Spliterator NONNULL

List of usage examples for java.util Spliterator NONNULL

Introduction

In this page you can find the example usage for java.util Spliterator NONNULL.

Prototype

int NONNULL

To view the source code for java.util Spliterator NONNULL.

Click Source Link

Document

Characteristic value signifying that the source guarantees that encountered elements will not be null .

Usage

From source file:com.steelbridgelabs.oss.neo4j.Neo4JTestGraphProvider.java

@Override
public Map<String, Object> getBaseConfiguration(String graphName, Class<?> test, String testMethodName,
        LoadGraphWith.GraphData graphData) {
    // build configuration
    Configuration configuration = Neo4JGraphConfigurationBuilder.connect("localhost", "neo4j", "123")
            .withName(graphName).withElementIdProvider(ElementIdProvider.class).build();
    // create property map from configuration
    Map<String, Object> map = StreamSupport
            .stream(Spliterators.spliteratorUnknownSize(configuration.getKeys(),
                    Spliterator.NONNULL | Spliterator.IMMUTABLE), false)
            .collect(Collectors.toMap(key -> key, configuration::getProperty));
    // append class name
    map.put(Graph.GRAPH, Neo4JGraph.class.getName());
    // return configuration map
    return map;/*from  www  .  ja v a 2 s  .com*/
}

From source file:com.wrmsr.kleist.util.Itertools.java

public static <T> Spliterator<EnumeratedElement<T>> enumerate(Spliterator<T> spliterator) {
    int characteristics = spliterator.characteristics() | Spliterator.NONNULL & ~Spliterator.CONCURRENT;
    return Spliterators.spliterator(enumerate(Spliterators.iterator(spliterator)), spliterator.estimateSize(),
            characteristics);/*ww w.  ja v a 2  s  .c o m*/
}

From source file:com.yevster.spdxtra.Read.java

public static Stream<SpdxPackage> getAllPackages(Dataset dataset) {

    try (DatasetAutoAbortTransaction transaction = DatasetAutoAbortTransaction.begin(dataset, ReadWrite.READ)) {

        String sparql = createSparqlQueryByType(SpdxUris.SPDX_PACKAGE);
        QueryExecution qe = QueryExecutionFactory.create(sparql, dataset);
        ResultSet results = qe.execSelect();
        Stream<QuerySolution> querySolutionStream = StreamSupport.stream(
                Spliterators.spliteratorUnknownSize(results, Spliterator.ORDERED | Spliterator.NONNULL), false);

        return querySolutionStream.map((QuerySolution qs) -> {
            RDFNode subject = qs.get("s");
            return new SpdxPackage(subject.asResource());
        });//w w w.j  a v  a  2 s. com
    }
}

From source file:com.uber.hoodie.utilities.sources.KafkaSource.java

public KafkaSource(PropertiesConfiguration config, JavaSparkContext sparkContext, SourceDataFormat dataFormat,
        SchemaProvider schemaProvider) {
    super(config, sparkContext, dataFormat, schemaProvider);

    kafkaParams = new HashMap<>();
    Stream<String> keys = StreamSupport
            .stream(Spliterators.spliteratorUnknownSize(config.getKeys(), Spliterator.NONNULL), false);
    keys.forEach(k -> kafkaParams.put(k, config.getString(k)));

    UtilHelpers.checkRequiredProperties(config, Arrays.asList(Config.KAFKA_TOPIC_NAME));
    topicName = config.getString(Config.KAFKA_TOPIC_NAME);
}

From source file:com.yevster.spdxtra.Read.java

private static Stream<Relationship> getRelationshipsWithSparql(Dataset dataset, String sparql) {
    try (DatasetAutoAbortTransaction transaction = DatasetAutoAbortTransaction.begin(dataset, ReadWrite.READ)) {
        QueryExecution qe = QueryExecutionFactory.create(sparql, dataset);
        ResultSet results = qe.execSelect();
        Stream<QuerySolution> solutionStream = StreamSupport.stream(
                Spliterators.spliteratorUnknownSize(results, Spliterator.ORDERED | Spliterator.NONNULL), false);

        return solutionStream.map((QuerySolution qs) -> {
            RDFNode relationshipNode = qs.get("o");
            assert (relationshipNode.isResource());
            return new Relationship(relationshipNode.asResource());
        });//from   w  w  w .ja v  a  2  s.  c  o m

    }
}

From source file:com.joyent.manta.client.MantaClient.java

/**
 * Return a stream of the contents of a directory in Manta.
 *
 * @param path The fully qualified path of the directory.
 * @return A {@link Stream} of {@link MantaObjectResponse} listing the contents of the directory.
 * @throws IOException thrown when there is a problem getting the listing over the network
 */// w  w  w. j a v  a 2 s  .c o  m
public Stream<MantaObject> listObjects(final String path) throws IOException {
    final MantaDirectoryListingIterator itr = streamingIterator(path);

    /* We preemptively check the iterator for a next value because that will
     * trigger an error if the path doesn't exist or is otherwise inaccessible.
     * This error typically takes the form of an UncheckedIOException, so we
     * unwind that exception if the cause is a MantaClientHttpResponseException
     * and rethrow another MantaClientHttpResponseException, so that the
     * stacktrace will point to this running method.
     */
    try {
        if (!itr.hasNext()) {
            itr.close();
            return Stream.empty();
        }
    } catch (UncheckedIOException e) {
        if (e.getCause() instanceof MantaClientHttpResponseException) {
            throw e.getCause();
        } else {
            throw e;
        }
    }

    final int additionalCharacteristics = Spliterator.CONCURRENT | Spliterator.ORDERED | Spliterator.NONNULL
            | Spliterator.DISTINCT;

    Stream<Map<String, Object>> backingStream = StreamSupport
            .stream(Spliterators.spliteratorUnknownSize(itr, additionalCharacteristics), false);

    Stream<MantaObject> stream = backingStream.map(MantaObjectConversionFunction.INSTANCE).onClose(itr::close);

    danglingStreams.add(stream);

    return stream;
}

From source file:com.joyent.manta.client.MantaClient.java

/**
 * Gets all of the Manta jobs' IDs as a real-time {@link Stream} from
 * the Manta API. <strong>Make sure to close this stream when you are done with
 * otherwise the HTTP socket will remain open.</strong>
 *
 * @return a stream with all of the job IDs (actually all that Manta will give us)
 *///from   ww w  . j  av a  2 s . c om
public Stream<UUID> getAllJobIds() {
    final String path = String.format("%s/jobs", config.getMantaHomeDirectory());

    final MantaDirectoryListingIterator itr = new MantaDirectoryListingIterator(path, httpHelper, MAX_RESULTS);

    danglingStreams.add(itr);

    Stream<Map<String, Object>> backingStream = StreamSupport
            .stream(Spliterators.spliteratorUnknownSize(itr, Spliterator.ORDERED | Spliterator.NONNULL), false);

    return backingStream.map(item -> {
        final String id = Objects.toString(item.get("name"));
        return UUID.fromString(id);
    });
}

From source file:objective.taskboard.utils.ZipUtils.java

public static Stream<ZipStreamEntry> stream(InputStream inputStream) {
    ZipEntryIterator it = new ZipEntryIterator(new ZipInputStream(inputStream));
    return StreamSupport
            .stream(Spliterators.spliteratorUnknownSize(it, Spliterator.ORDERED | Spliterator.NONNULL), false);
}

From source file:org.codice.alliance.libs.mpegts.TSStream.java

/**
 * Create a stream of PESPackets from a byte source.
 *
 * @param byteSource must be non-null//www. j a  va2s.c om
 * @return stream of PESPackets
 * @throws IOException
 */
public static Stream<PESPacket> from(ByteSource byteSource) throws IOException {
    notNull(byteSource, "byteSource must be non-null");
    return StreamSupport.stream(Spliterators.spliteratorUnknownSize(new PESPacketIterator(byteSource),
            Spliterator.ORDERED | Spliterator.NONNULL), false);
}