@Override public void configure(final Map<String, Object> config, final Map<String, Graph> graphs) { final GryoMapper.Builder builder; final Object graphToUseForMapper = config.get(TOKEN_USE_MAPPER_FROM_GRAPH); if (graphToUseForMapper != null) { if (null == graphs) throw new IllegalStateException( String.format( "No graphs have been provided to the serializer and therefore %s is not a valid configuration", TOKEN_USE_MAPPER_FROM_GRAPH)); final Graph g = graphs.get(graphToUseForMapper.toString()); if (null == g) throw new IllegalStateException( String.format( "There is no graph named [%s] configured to be used in the %s setting", graphToUseForMapper, TOKEN_USE_MAPPER_FROM_GRAPH)); // a graph was found so use the mapper it constructs. this allows gryo to be auto-configured // with any // custom classes that the implementation allows for builder = g.io(GryoIo.build()).mapper(); } else { // no graph was supplied so just use the default - this will likely be the case when using a // graph // with no custom classes or a situation where the user needs complete control like when using // two // distinct implementations each with their own custom classes. builder = GryoMapper.build(); } addIoRegistries(config, builder); addCustomClasses(config, builder); this.serializeToString = Boolean.parseBoolean( config.getOrDefault(TOKEN_SERIALIZE_RESULT_TO_STRING, "false").toString()); this.gryoMapper = builder.create(); }
/** * Creates an instance with a standard {@link * org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper} instance. Note that this instance * will be overriden by {@link #configure} is called. */ public GryoMessageSerializerV1d0() { gryoMapper = GryoMapper.build().create(); }
@Override protected Kryo initialValue() { return gryoMapper.createMapper(); }