/** * 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 getInstance() 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); } }); }
/** * Adds a vendor supplied {@link IoRegistry} to the {@code Mapper.Builder} which enables it to check for * vendor custom serializers to add to the {@link Mapper}. All {@link Io} implementations should expose * this method via this {@link Builder} so that it is compatible with {@link Graph#io}. Successive calls * to this method will add multiple registries. Registry order must be respected when doing so. In * other words, data written with {@link IoRegistry} {@code A} added first and {@code B} second must be read * by a {@code Mapper} with that same registry ordering. Attempting to add {@code B} before {@code A} will * result in errors. */ public default B addRegistries(final List<IoRegistry> registries) { B b = (B) this; for (final IoRegistry registry : registries) { b = this.addRegistry(registry); } return b; } }
@Override public <I extends Io> I io(Io.Builder<I> builder) { return (I) OGraph.super.io(builder.onMapper(mb -> mb.addRegistry(OrientIoRegistry.getInstance()))); }
@SuppressWarnings("unchecked") @Override public <I extends Io> I io(final Io.Builder<I> builder) { if (builder.requiresVersion(GryoVersion.V1_0) || builder.requiresVersion(GraphSONVersion.V1_0)) return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(SqlgIoRegistryV1.instance())).create(); else if (builder.requiresVersion(GraphSONVersion.V2_0)) // there is no gryo v2 return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(SqlgIoRegistryV2.instance())).create(); else return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(SqlgIoRegistryV3.instance())).create(); }
@Override public <I extends Io> I io(final Io.Builder<I> builder) { return (I) builder.graph(this).onMapper(m -> m.addRegistry(BitsyIoRegistryV3d0.instance())).create(); }
@Override public <I extends Io> I io(Io.Builder<I> builder) { return (I) OGraph.super.io(builder.onMapper(mb -> mb.addRegistry(OrientIoRegistry.getInstance()))); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public <I extends Io> I io(final Io.Builder<I> builder) { return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(HugeGraphIoRegistry.instance()) ).create(); }
@SuppressWarnings("unchecked") @Override public <I extends Io> I io(final Io.Builder<I> builder) { if (builder.requiresVersion(GryoVersion.V1_0) || builder.requiresVersion(GraphSONVersion.V1_0)) return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(SqlgIoRegistryV1.instance())).create(); else if (builder.requiresVersion(GraphSONVersion.V2_0)) // there is no gryo v2 return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(SqlgIoRegistryV2.instance())).create(); else return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(SqlgIoRegistryV3.instance())).create(); }
@Override public <I extends Io> I io(final Io.Builder<I> builder) { if (builder.requiresVersion(GryoVersion.V1_0) || builder.requiresVersion(GraphSONVersion.V1_0)) return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV1d0.instance())).create(); else if (builder.requiresVersion(GraphSONVersion.V2_0)) // there is no gryo v2 return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV2d0.instance())).create(); else return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV3d0.instance())).create(); }
@Override public <I extends Io> I io(final Io.Builder<I> builder) { if (builder.requiresVersion(GryoVersion.V1_0) || builder.requiresVersion(GraphSONVersion.V1_0)) return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV1d0.instance())).create(); else if (builder.requiresVersion(GraphSONVersion.V2_0)) // there is no gryo v2 return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV2d0.instance())).create(); else return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV3d0.instance())).create(); }
@Override public Consumer<Mapper.Builder<?>> onMapper(@SuppressWarnings("rawtypes") Consumer<Mapper.Builder> onMapper) { Consumer<Mapper.Builder<?>> bdioRegistry = b -> b.addRegistry(REGISTRY); return onMapper != null ? bdioRegistry.andThen(onMapper::accept) : bdioRegistry; }
/** * 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 getInstance() 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); } }); }
/** * Adds a vendor supplied {@link IoRegistry} to the {@code Mapper.Builder} which enables it to check for * vendor custom serializers to add to the {@link Mapper}. All {@link Io} implementations should expose * this method via this {@link Builder} so that it is compatible with {@link Graph#io}. Successive calls * to this method will add multiple registries. Registry order must be respected when doing so. In * other words, data written with {@link IoRegistry} {@code A} added first and {@code B} second must be read * by a {@code Mapper} with that same registry ordering. Attempting to add {@code B} before {@code A} will * result in errors. */ public default B addRegistries(final List<IoRegistry> registries) { B b = (B) this; for (final IoRegistry registry : registries) { b = this.addRegistry(registry); } return b; } }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public <I extends Io> I io(final Io.Builder<I> builder) { return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(HugeGraphIoRegistry.instance()) ).create(); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public <I extends Io> I io(final Io.Builder<I> builder) { return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(HugeGraphIoRegistry.instance()) ).create(); }
@Override public <I extends Io> I io(final Io.Builder<I> builder) { if (builder.requiresVersion(GryoVersion.V1_0) || builder.requiresVersion(GraphSONVersion.V1_0)) return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV1d0.instance())).create(); else if (builder.requiresVersion(GraphSONVersion.V2_0)) // there is no gryo v2 return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV2d0.instance())).create(); else return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistryV3d0.instance())).create(); }
@Override public <I extends Io> I io(final Io.Builder<I> builder) { if (builder.requiresVersion(GryoVersion.V1_0) || builder.requiresVersion(GraphSONVersion.V1_0)) { return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(JanusGraphIoRegistryV1d0.getInstance())).create(); } else if (builder.requiresVersion(GraphSONVersion.V2_0)) { return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(JanusGraphIoRegistry.getInstance())).create(); } else { return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(JanusGraphIoRegistry.getInstance())).create(); } }