Example usage for java.util Spliterator CONCURRENT

List of usage examples for java.util Spliterator CONCURRENT

Introduction

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

Prototype

int CONCURRENT

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

Click Source Link

Document

Characteristic value signifying that the element source may be safely concurrently modified (allowing additions, replacements, and/or removals) by multiple threads without external synchronization.

Usage

From source file:nl.rivm.cib.episim.cbs.CBSConnectorTest.java

@Test
public void testOlingo() throws IOException {
    final String serviceUrl = "http://opendata.cbs.nl/ODataApi/odata/83225ned";//"http://opendata.cbs.nl/ODataApi/odata/81435ned";
    final Edm edm = ODataUtil.readEdm(serviceUrl);
    edm.getSchemas().forEach(s -> {//ww w  .  j  a  va 2s  . c o  m
        s.getEntityTypes().forEach(t -> {
            t.getPropertyNames().forEach(p -> {
                if (p.equals("Key"))
                    System.err.println(ODataUtil.readEntities(edm, serviceUrl, t.getName() + "$select="));
                LOG.trace("{}.{} :: {} ({})", t.getNamespace(), t.getName(), p, t.getProperty(p).getType());
            });
        });
        //         final Map<Object, Object> dims = s.getEntityTypes().stream().filter( e->e.getPropertyNames().contains( "Key" ) )
        //               .collect( Collectors.toMap(
        //                     e -> e.getProperty( "Key" ),
        //                     e -> e.getProperty( "Title" ) ) );
        //         LOG.trace( "{} dims: {}", s.getNamespace(), dims );

        final String dim = "Geslacht";
        final Map<Object, Object> keys = StreamSupport
                .stream(Spliterators.spliteratorUnknownSize(ODataUtil.readEntities(edm, serviceUrl, dim),
                        Spliterator.CONCURRENT), false)
                .collect(Collectors.toMap(e -> e.getProperty("Key").getPrimitiveValue().toValue(),
                        e -> e.getProperty("Title").getPrimitiveValue().toValue()));
        LOG.trace("{} keys: {}", dim, keys);
    });

}

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. j a v a  2 s  .c o m*/
}

From source file:io.syndesis.dao.DeploymentDescriptorTest.java

private static void assertActionProperties(final String connectorId, final JsonNode action,
        final String actionName, final JsonNode catalogedJsonSchema) {
    final JsonNode actionDefinition = action.get("definition");

    final JsonNode propertiesFromCatalog = catalogedJsonSchema.get("properties");

    // make sure that all action properties are as defined in
    // the connector
    StreamSupport.stream(actionDefinition.get("propertyDefinitionSteps").spliterator(), true)
            .flatMap(step -> StreamSupport.stream(Spliterators
                    .spliteratorUnknownSize(step.get("properties").fields(), Spliterator.CONCURRENT), true))
            .forEach(property -> {/*from   w  ww. j  a  va 2  s.  c om*/
                final String propertyName = property.getKey();
                final JsonNode propertyDefinition = property.getValue();

                final JsonNode catalogedPropertyDefinition = propertiesFromCatalog.get(propertyName);

                assertThat(catalogedPropertyDefinition).as(
                        "Definition of `%s` connector's action `%s` defines a property `%s` that is not defined in the Camel connector",
                        connectorId, actionName, propertyName).isNotNull();

                assertThat(propertyDefinition.get("componentProperty"))
                        .as("`componentProperty` field is missing for connector's %s %s action property %s",
                                connectorId, actionName, propertyName)
                        .isNotNull();
                assertThat(propertyDefinition.get("componentProperty").asBoolean()).as(
                        "Definition of `%s` connector's action `%s` property `%s` should be marked as `componentProperty`",
                        connectorId, actionName, propertyName).isFalse();
                // remove Syndesis specifics
                final ObjectNode propertyDefinitionForComparisson = propertyNodeForComparisson(
                        propertyDefinition);

                // remove properties that we would like to customize
                removeCustomizedProperties(propertyDefinitionForComparisson, catalogedPropertyDefinition);

                assertThat(propertyDefinitionForComparisson).as(
                        "Definition of `%s` connector's action's `%s` property `%s` differs from the one in Camel connector",
                        connectorId, actionName, propertyName).isEqualTo(catalogedPropertyDefinition);
            });
}

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
 *//*from w  w  w.  ja va 2  s  . co 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;
}