• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java IoRegistry类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.io.IoRegistry的典型用法代码示例。如果您正苦于以下问题:Java IoRegistry类的具体用法?Java IoRegistry怎么用?Java IoRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

IoRegistry类属于org.apache.tinkerpop.gremlin.structure.io包,在下文中一共展示了IoRegistry类的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addIoRegistries

点赞 3

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
/**
 * Reads a list of fully qualified class names from the value of the {@link #TOKEN_IO_REGISTRIES} configuration
 * key. These classes should equate to {@link IoRegistry} implementations that will be assigned to the
 * {@link org.apache.tinkerpop.gremlin.structure.io.Mapper.Builder}.  The assumption is that the
 * {@link IoRegistry} either has a static {@code getInstance()} method or has a zero-arg constructor from which
 * it can be instantiated.
 */
protected void addIoRegistries(final Map<String, Object> config, final Mapper.Builder builder) {
    final List<String> classNameList = getListStringFromConfig(TOKEN_IO_REGISTRIES, config);

    classNameList.stream().forEach(className -> {
        try {
            final Class<?> clazz = Class.forName(className);
            try {
                final Method instanceMethod = clazz.getDeclaredMethod("getInstance");
                if (IoRegistry.class.isAssignableFrom(instanceMethod.getReturnType()))
                    builder.addRegistry((IoRegistry) instanceMethod.invoke(null));
                else
                    throw new Exception();
            } catch (Exception methodex) {
                // tried getInstance() and that failed so try newInstance() no-arg constructor
                builder.addRegistry((IoRegistry) clazz.newInstance());
            }
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
    });
}
 

开发者ID:PKUSilvester,
项目名称:LiteGraph,
代码行数:29,
代码来源:AbstractMessageSerializer.java

示例2: tryCreateIoRegistry

点赞 3

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
private static List<IoRegistry> tryCreateIoRegistry(final List<Object> classNames) {
    if (classNames.isEmpty()) return Collections.emptyList();

    final List<IoRegistry> registries = new ArrayList<>();
    classNames.forEach(c -> {
        try {
            final String className = c.toString();
            final Class<?> clazz = Class.forName(className);
            try {
                final Method instanceMethod = clazz.getDeclaredMethod("getInstance");
                if (IoRegistry.class.isAssignableFrom(instanceMethod.getReturnType()))
                    registries.add((IoRegistry) instanceMethod.invoke(null));
                else
                    throw new Exception();
            } catch (Exception methodex) {
                // tried getInstance() and that failed so try newInstance() no-arg constructor
                registries.add((IoRegistry) clazz.newInstance());
            }
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
    });
    return registries;
}
 

开发者ID:PKUSilvester,
项目名称:LiteGraph,
代码行数:25,
代码来源:GryoPool.java

示例3: addIoRegistries

点赞 3

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
/**
 * Reads a list of fully qualified class names from the value of the {@link #TOKEN_IO_REGISTRIES} configuration
 * key. These classes should equate to {@link IoRegistry} implementations that will be assigned to the
 * {@link org.apache.tinkerpop.gremlin.structure.io.Mapper.Builder}.  The assumption is that the
 * {@link IoRegistry} either has a static {@code instance()} method or has a zero-arg constructor from which
 * it can be instantiated.
 */
protected void addIoRegistries(final Map<String, Object> config, final Mapper.Builder builder) {
    final List<String> classNameList = getListStringFromConfig(TOKEN_IO_REGISTRIES, config);

    classNameList.stream().forEach(className -> {
        try {
            final Class<?> clazz = Class.forName(className);
            try {
                // try instance() first and then instance() which was deprecated in 3.2.4
                final Method instanceMethod = tryInstanceMethod(clazz);
                if (IoRegistry.class.isAssignableFrom(instanceMethod.getReturnType()))
                    builder.addRegistry((IoRegistry) instanceMethod.invoke(null));
                else
                    throw new Exception();
            } catch (Exception methodex) {
                // tried instance() and that failed so try newInstance() no-arg constructor
                builder.addRegistry((IoRegistry) clazz.newInstance());
            }
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
    });
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:30,
代码来源:AbstractMessageSerializer.java

示例4: shouldConfigPoolOnConstructionWithPoolSizeOneAndNoIoRegistry

点赞 3

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
@Test
public void shouldConfigPoolOnConstructionWithPoolSizeOneAndNoIoRegistry() throws Exception {
    final Configuration conf = new BaseConfiguration();
    final GryoPool pool = GryoPool.build().poolSize(1).ioRegistries(conf.getList(IoRegistry.IO_REGISTRY, Collections.emptyList())).create();
    final GryoReader reader = pool.takeReader();
    final GryoWriter writer = pool.takeWriter();

    pool.offerReader(reader);
    pool.offerWriter(writer);

    for (int ix = 0; ix < 100; ix++) {
        final GryoReader r = pool.takeReader();
        final GryoWriter w = pool.takeWriter();
        assertReaderWriter(w, r, 1, Integer.class);

        // should always return the same original instance
        assertEquals(reader, r);
        assertEquals(writer, w);

        pool.offerReader(r);
        pool.offerWriter(w);
    }
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:24,
代码来源:GryoPoolTest.java

示例5: addRegistry

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Builder addRegistry(final IoRegistry registry) {
    if (null == registry) throw new IllegalArgumentException("The registry cannot be null");
    this.registries.add(registry);
    return this;
}
 

开发者ID:PKUSilvester,
项目名称:LiteGraph,
代码行数:10,
代码来源:GryoMapper.java

示例6: initialize

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
public synchronized static void initialize(final Configuration configuration) {
    if (!INITIALIZED) {
        INITIALIZED = true;
        GRYO_POOL = GryoPool.build().
                poolSize(configuration.getInt(GryoPool.CONFIG_IO_GRYO_POOL_SIZE, 256)).
                version(GryoVersion.valueOf(configuration.getString(GryoPool.CONFIG_IO_GRYO_VERSION, GryoPool.CONFIG_IO_GRYO_POOL_VERSION_DEFAULT.name()))).
                ioRegistries(configuration.getList(IoRegistry.IO_REGISTRY, Collections.emptyList())).
                initializeMapper(m -> m.registrationRequired(false)).
                create();
    }
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:12,
代码来源:HadoopPools.java

示例7: checkGryoV1d0IoRegistryCompliance

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
public void checkGryoV1d0IoRegistryCompliance(final HadoopGraph graph, final Class<? extends GraphComputer> graphComputerClass) throws Exception {
    final File input = TestHelper.generateTempFile(this.getClass(), "gryo-io-registry", ".kryo");
    graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, GryoInputFormat.class.getCanonicalName());
    graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, GryoOutputFormat.class.getCanonicalName());
    graph.configuration().setProperty(GryoPool.CONFIG_IO_GRYO_VERSION, GryoVersion.V1_0.name());
    graph.configuration().setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, input.getAbsolutePath());
    graph.configuration().setProperty(IoRegistry.IO_REGISTRY, ToyIoRegistry.class.getCanonicalName());
    final GryoRecordWriter writer = new GryoRecordWriter(new DataOutputStream(new FileOutputStream(input)), ConfUtil.makeHadoopConfiguration(graph.configuration()));
    validateIoRegistryGraph(graph, graphComputerClass, writer);
    assertTrue(input.delete());
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:12,
代码来源:AbstractIoRegistryCheck.java

示例8: checkGryoV3d0IoRegistryCompliance

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
public void checkGryoV3d0IoRegistryCompliance(final HadoopGraph graph, final Class<? extends GraphComputer> graphComputerClass) throws Exception {
    final File input = TestHelper.generateTempFile(this.getClass(), "gryo-io-registry", ".kryo");
    graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, GryoInputFormat.class.getCanonicalName());
    graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, GryoOutputFormat.class.getCanonicalName());
    graph.configuration().setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, input.getAbsolutePath());
    graph.configuration().setProperty(GryoPool.CONFIG_IO_GRYO_VERSION, GryoVersion.V3_0.name());
    graph.configuration().setProperty(IoRegistry.IO_REGISTRY, ToyIoRegistry.class.getCanonicalName());
    final GryoRecordWriter writer = new GryoRecordWriter(new DataOutputStream(new FileOutputStream(input)), ConfUtil.makeHadoopConfiguration(graph.configuration()));
    validateIoRegistryGraph(graph, graphComputerClass, writer);
    assertTrue(input.delete());
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:12,
代码来源:AbstractIoRegistryCheck.java

示例9: checkGraphSONIoRegistryCompliance

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
public void checkGraphSONIoRegistryCompliance(final HadoopGraph graph, final Class<? extends GraphComputer> graphComputerClass) throws Exception {
    final File input = TestHelper.generateTempFile(this.getClass(), "graphson-io-registry", ".json");
    graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, GraphSONInputFormat.class.getCanonicalName());
    graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, GraphSONOutputFormat.class.getCanonicalName());
    graph.configuration().setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, input.getAbsolutePath());
    graph.configuration().setProperty(IoRegistry.IO_REGISTRY, ToyIoRegistry.class.getCanonicalName());
    final GraphSONRecordWriter writer = new GraphSONRecordWriter(new DataOutputStream(new FileOutputStream(input)), ConfUtil.makeHadoopConfiguration(graph.configuration()));
    validateIoRegistryGraph(graph, graphComputerClass, writer);
    assertTrue(input.delete());
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:11,
代码来源:AbstractIoRegistryCheck.java

示例10: createRegistries

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
public static List<IoRegistry> createRegistries(final Configuration configuration) {
    if (configuration.containsKey(IoRegistry.IO_REGISTRY)) {
        final Object property = configuration.getProperty(IoRegistry.IO_REGISTRY);
        if (property instanceof IoRegistry)
            return Collections.singletonList((IoRegistry) property);
        else if (property instanceof List)
            return createRegistries((List) property);
        else if (property instanceof String)
            return createRegistries(Arrays.asList(((String) property).split(",")));
        else
            throw new IllegalArgumentException("The provided registry object can not be resolved to an instance: " + property);
    } else
        return Collections.emptyList();
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:15,
代码来源:IoRegistryHelper.java

示例11: shouldDoWithReaderWriterMethods

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
@Test
public void shouldDoWithReaderWriterMethods() throws Exception {
    final Configuration conf = new BaseConfiguration();
    final GryoPool pool = GryoPool.build().ioRegistries(conf.getList(IoRegistry.IO_REGISTRY, Collections.emptyList())).create();
    try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
        pool.doWithWriter(writer -> writer.writeObject(os, 1));
        os.flush();
        try (final ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray())) {
            assertEquals(1, pool.<Integer>doWithReader(FunctionUtils.wrapFunction(reader -> reader.readObject(is, Integer.class))).intValue());
        }
    }
    assertReaderWriter(pool.takeWriter(), pool.takeReader(), 1, Integer.class);
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:14,
代码来源:GryoPoolTest.java

示例12: shouldConfigPoolOnConstructionWithCustomIoRegistryConstructor

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
@Test
public void shouldConfigPoolOnConstructionWithCustomIoRegistryConstructor() throws Exception {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty(IoRegistry.IO_REGISTRY, IoXIoRegistry.ConstructorBased.class.getName());
    final GryoPool pool = GryoPool.build().ioRegistries(conf.getList(IoRegistry.IO_REGISTRY, Collections.emptyList())).create();
    assertReaderWriter(pool.takeWriter(), pool.takeReader(), new IoX("test"), IoX.class);
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:8,
代码来源:GryoPoolTest.java

示例13: shouldConfigPoolOnConstructionWithCustomIoRegistryInstance

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
@Test
public void shouldConfigPoolOnConstructionWithCustomIoRegistryInstance() throws Exception {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty(IoRegistry.IO_REGISTRY, IoXIoRegistry.InstanceBased.class.getName());
    final GryoPool pool = GryoPool.build().ioRegistries(conf.getList(IoRegistry.IO_REGISTRY, Collections.emptyList())).create();
    assertReaderWriter(pool.takeWriter(), pool.takeReader(), new IoX("test"), IoX.class);
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:8,
代码来源:GryoPoolTest.java

示例14: shouldConfigPoolOnConstructionWithMultipleCustomIoRegistries

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
@Test
public void shouldConfigPoolOnConstructionWithMultipleCustomIoRegistries() throws Exception {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty(IoRegistry.IO_REGISTRY,
            IoXIoRegistry.InstanceBased.class.getName() + "," + IoYIoRegistry.InstanceBased.class.getName());
    final GryoPool pool = GryoPool.build().ioRegistries(conf.getList(IoRegistry.IO_REGISTRY, Collections.emptyList())).create();
    assertReaderWriter(pool.takeWriter(), pool.takeReader(), new IoX("test"), IoX.class);
    assertReaderWriter(pool.takeWriter(), pool.takeReader(), new IoY(100, 200), IoY.class);
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:10,
代码来源:GryoPoolTest.java

示例15: GryoSerializer

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
public GryoSerializer(final SparkConf sparkConfiguration) {
    final long bufferSizeKb = sparkConfiguration.getSizeAsKb("spark.kryoserializer.buffer", "64k");
    final long maxBufferSizeMb = sparkConfiguration.getSizeAsMb("spark.kryoserializer.buffer.max", "64m");
    this.referenceTracking = sparkConfiguration.getBoolean("spark.kryo.referenceTracking", true);
    this.registrationRequired = sparkConfiguration.getBoolean(Constants.SPARK_KRYO_REGISTRATION_REQUIRED, false);
    if (bufferSizeKb >= ByteUnit.GiB.toKiB(2L)) {
        throw new IllegalArgumentException("spark.kryoserializer.buffer must be less than 2048 mb, got: " + bufferSizeKb + " mb.");
    } else {
        this.bufferSize = (int) ByteUnit.KiB.toBytes(bufferSizeKb);
        if (maxBufferSizeMb >= ByteUnit.GiB.toMiB(2L)) {
            throw new IllegalArgumentException("spark.kryoserializer.buffer.max must be less than 2048 mb, got: " + maxBufferSizeMb + " mb.");
        } else {
            this.maxBufferSize = (int) ByteUnit.MiB.toBytes(maxBufferSizeMb);
            //this.userRegistrator = sparkConfiguration.getOption("spark.kryo.registrator");
        }
    }
    // create a GryoPool and store it in static HadoopPools
    final List<Object> ioRegistries = new ArrayList<>();
    ioRegistries.addAll(makeApacheConfiguration(sparkConfiguration).getList(IoRegistry.IO_REGISTRY, Collections.emptyList()));
    ioRegistries.add(SparkIoRegistry.class.getCanonicalName().replace("." + SparkIoRegistry.class.getSimpleName(), "$" + SparkIoRegistry.class.getSimpleName()));
    HadoopPools.initialize(GryoPool.build().
            version(GryoVersion.valueOf(sparkConfiguration.get(GryoPool.CONFIG_IO_GRYO_VERSION, GryoPool.CONFIG_IO_GRYO_POOL_VERSION_DEFAULT.name()))).
            poolSize(sparkConfiguration.getInt(GryoPool.CONFIG_IO_GRYO_POOL_SIZE, GryoPool.CONFIG_IO_GRYO_POOL_SIZE_DEFAULT)).
            ioRegistries(ioRegistries).
            initializeMapper(builder ->
                    builder.referenceTracking(this.referenceTracking).
                            registrationRequired(this.registrationRequired)).
            create());
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:30,
代码来源:GryoSerializer.java

示例16: addRegistry

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Builder addRegistry(IoRegistry registry) {
    registries.add(Objects.requireNonNull(registry));
    return this;
}
 

开发者ID:blackducksoftware,
项目名称:bdio,
代码行数:9,
代码来源:BlackDuckIoMapper.java

示例17: GryoIo

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
private GryoIo(final IoRegistry registry, final Graph graph) {
    this.registry = registry;
    this.graph = graph;
}
 

开发者ID:PKUSilvester,
项目名称:LiteGraph,
代码行数:5,
代码来源:GryoIo.java

示例18: GraphSONIo

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
private GraphSONIo(final IoRegistry registry, final Graph graph) {
    this.registry = registry;
    this.graph = graph;
}
 

开发者ID:PKUSilvester,
项目名称:LiteGraph,
代码行数:5,
代码来源:GraphSONIo.java

示例19: addRegistry

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Builder addRegistry(final IoRegistry registry) {
    registries.add(registry);
    return this;
}
 

开发者ID:PKUSilvester,
项目名称:LiteGraph,
代码行数:9,
代码来源:GraphSONMapper.java

示例20: addRegistry

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
@Override
public Builder addRegistry(final IoRegistry registry) {
    throw new UnsupportedOperationException("GraphML does not accept custom serializers - it is a format for full Graph serialization");
}
 

开发者ID:PKUSilvester,
项目名称:LiteGraph,
代码行数:5,
代码来源:GraphMLMapper.java

示例21: shouldConfigPoolOnConstructionWithDefaults

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
@Test
public void shouldConfigPoolOnConstructionWithDefaults() throws Exception {
    final Configuration conf = new BaseConfiguration();
    final GryoPool pool = GryoPool.build().ioRegistries(conf.getList(IoRegistry.IO_REGISTRY, Collections.emptyList())).create();
    assertReaderWriter(pool.takeWriter(), pool.takeReader(), 1, Integer.class);
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:7,
代码来源:GryoPoolTest.java

示例22: shouldConfigPoolOnConstructionWithoutCustomIoRegistryAndFail

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void shouldConfigPoolOnConstructionWithoutCustomIoRegistryAndFail() throws Exception {
    final Configuration conf = new BaseConfiguration();
    final GryoPool pool = GryoPool.build().ioRegistries(conf.getList(IoRegistry.IO_REGISTRY, Collections.emptyList())).create();
    assertReaderWriter(pool.takeWriter(), pool.takeReader(), new IoX("test"), IoX.class);
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:7,
代码来源:GryoPoolTest.java

示例23: shouldConfigPoolOnConstructionWithoutBadIoRegistryAndFail

点赞 2

import org.apache.tinkerpop.gremlin.structure.io.IoRegistry; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void shouldConfigPoolOnConstructionWithoutBadIoRegistryAndFail() throws Exception {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty(IoRegistry.IO_REGISTRY, "some.class.that.does.not.exist");
    GryoPool.build().ioRegistries(conf.getList(IoRegistry.IO_REGISTRY, Collections.emptyList())).create();
}
 

开发者ID:apache,
项目名称:tinkerpop,
代码行数:7,
代码来源:GryoPoolTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)