org.apache.tinkerpop.shaded.kryo.Kryo.readObject()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中org.apache.tinkerpop.shaded.kryo.Kryo.readObject()方法的一些代码示例,展示了Kryo.readObject()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kryo.readObject()方法的具体详情如下:
包路径:org.apache.tinkerpop.shaded.kryo.Kryo
类名称:Kryo
方法名:readObject

Kryo.readObject介绍

暂无

代码示例

代码示例来源:origin: apache/tinkerpop

@Override
public <T> T readObject(final ShadedInputAdapter input, final Class<T> type) {
  return shadedKryo.readObject(input.getShadedInput(), type);
}

代码示例来源:origin: hugegraph/hugegraph

@SuppressWarnings("unused")
private static Map<HugeKeys, Object> readEntry(Kryo kryo, Input input) {
  int columnSize = input.readInt();
  Map<HugeKeys, Object> map = new LinkedHashMap<>();
  for (int i = 0; i < columnSize; i++) {
    HugeKeys key = kryo.readObject(input, HugeKeys.class);
    Object val = kryo.readClassAndObject(input);
    map.put(key, val);
  }
  return map;
}

代码示例来源:origin: apache/tinkerpop

@Override
public RequestMessage deserializeRequest(final ByteBuf msg) throws SerializationException {
  try {
    final Kryo kryo = kryoThreadLocal.get();
    final byte[] payload = new byte[msg.readableBytes()];
    msg.readBytes(payload);
    try (final Input input = new Input(payload)) {
      // by the time the message gets here, the mime length/type have been already read, so this part just
      // needs to process the payload.
      return kryo.readObject(input, RequestMessage.class);
    }
  } catch (Exception ex) {
    logger.warn(String.format("Request [%s] could not be deserialized by %s.", msg, AbstractGryoMessageSerializerV3d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

代码示例来源:origin: apache/tinkerpop

@Override
public ResponseMessage deserializeResponse(final ByteBuf msg) throws SerializationException {
  try {
    final Kryo kryo = kryoThreadLocal.get();
    final byte[] payload = new byte[msg.capacity()];
    msg.readBytes(payload);
    try (final Input input = new Input(payload)) {
      return kryo.readObject(input, ResponseMessage.class);
    }
  } catch (Exception ex) {
    logger.warn(String.format("Response [%s] could not be deserialized by %s.", msg, AbstractGryoMessageSerializerV3d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

代码示例来源:origin: apache/tinkerpop

/**
 * Read an {@link Edge} from output generated by {@link GryoWriter#writeEdge(OutputStream, Edge)} or via
 * an {@link Edge} passed to {@link GryoWriter#writeObject(OutputStream, Object)}.
 *
 * @param inputStream      a stream containing at least one {@link Edge} as defined by the accompanying
 *                         {@link GraphWriter#writeEdge(OutputStream, Edge)} method.
 * @param edgeAttachMethod a function that creates re-attaches a {@link Edge} to a {@link Host} object.
 */
@Override
public Edge readEdge(final InputStream inputStream, final Function<Attachable<Edge>, Edge> edgeAttachMethod) throws IOException {
  final Input input = new Input(inputStream);
  readHeader(input);
  final Attachable<Edge> attachable = kryo.readObject(input, DetachedEdge.class);
  return edgeAttachMethod.apply(attachable);
}

代码示例来源:origin: apache/tinkerpop

/**
 * Read a {@link Property} from output generated by  {@link GryoWriter#writeProperty(OutputStream, Property)} or
 * via an {@link Property} passed to {@link GryoWriter#writeObject(OutputStream, Object)}.
 *
 * @param inputStream          a stream containing at least one {@link Property} as written by the accompanying
 *                             {@link GraphWriter#writeProperty(OutputStream, Property)} method.
 * @param propertyAttachMethod a function that creates re-attaches a {@link Property} to a {@link Host} object.
 */
@Override
public Property readProperty(final InputStream inputStream,
               final Function<Attachable<Property>, Property> propertyAttachMethod) throws IOException {
  final Input input = new Input(inputStream);
  readHeader(input);
  final Attachable<Property> attachable = kryo.readObject(input, DetachedProperty.class);
  return propertyAttachMethod.apply(attachable);
}

代码示例来源:origin: apache/tinkerpop

/**
 * Read a {@link VertexProperty} from output generated by
 * {@link GryoWriter#writeVertexProperty(OutputStream, VertexProperty)} or via an {@link VertexProperty} passed
 * to {@link GryoWriter#writeObject(OutputStream, Object)}.
 *
 * @param inputStream                a stream containing at least one {@link VertexProperty} as written by the accompanying
 *                                   {@link GraphWriter#writeVertexProperty(OutputStream, VertexProperty)} method.
 * @param vertexPropertyAttachMethod a function that creates re-attaches a {@link VertexProperty} to a
 *                                   {@link Host} object.
 */
@Override
public VertexProperty readVertexProperty(final InputStream inputStream,
                     final Function<Attachable<VertexProperty>, VertexProperty> vertexPropertyAttachMethod) throws IOException {
  final Input input = new Input(inputStream);
  readHeader(input);
  final Attachable<VertexProperty> attachable = kryo.readObject(input, DetachedVertexProperty.class);
  return vertexPropertyAttachMethod.apply(attachable);
}

代码示例来源:origin: hugegraph/hugegraph

public static <T> T fromKryo(byte[] value, Class<T> clazz) {
    E.checkState(value != null,
           "Kryo value can't be null for '%s'",
           clazz.getSimpleName());
    return kryo().readObject(new Input(value), clazz);
  }
}

代码示例来源:origin: apache/tinkerpop

@Override
public Optional<Vertex> readVertex(final InputStream inputStream, final GraphFilter graphFilter) throws IOException {
  StarGraphGryoSerializer serializer = this.graphFilterCache.get(graphFilter);
  if (null == serializer) {
    serializer = StarGraphGryoSerializer.withGraphFilter(graphFilter);
    this.graphFilterCache.put(graphFilter, serializer);
  }
  final Input input = new Input(inputStream);
  this.readHeader(input);
  final StarGraph starGraph = this.kryo.readObject(input, StarGraph.class, serializer);
  // read the terminator
  this.kryo.readClassAndObject(input);
  return Optional.ofNullable(starGraph == null ? null : starGraph.getStarVertex());
}

代码示例来源:origin: apache/tinkerpop

private Vertex readVertexInternal(final Function<Attachable<Vertex>, Vertex> vertexMaker,
                 final Function<Attachable<Edge>, Edge> edgeMaker,
                 final Direction d,
                 final Input input) throws IOException {
  readHeader(input);
  final StarGraph starGraph = kryo.readObject(input, StarGraph.class);
  // read the terminator
  kryo.readClassAndObject(input);
  final Vertex v = vertexMaker.apply(starGraph.getStarVertex());
  if (edgeMaker != null)
    starGraph.getStarVertex().edges(d).forEachRemaining(e -> edgeMaker.apply((Attachable<Edge>) e));
  return v;
}

代码示例来源:origin: apache/tinkerpop

@Override
public RequestMessage deserializeRequest(final ByteBuf msg) throws SerializationException {
  try {
    final Kryo kryo = kryoThreadLocal.get();
    final byte[] payload = new byte[msg.readableBytes()];
    msg.readBytes(payload);
    try (final Input input = new Input(payload)) {
      // by the time the message gets here, the mime length/type have been already read, so this part just
      // needs to process the payload.
      final UUID id = kryo.readObject(input, UUID.class);
      final String processor = input.readString();
      final String op = input.readString();
      final RequestMessage.Builder builder = RequestMessage.build(op)
          .overrideRequestId(id)
          .processor(processor);
      final Map<String, Object> args = kryo.readObject(input, HashMap.class);
      args.forEach(builder::addArg);
      return builder.create();
    }
  } catch (Exception ex) {
    logger.warn(String.format("Request [%s] could not be deserialized by %s.", msg, AbstractGryoMessageSerializerV1d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

@Override
public <T> T readObject(final ShadedInputAdapter input, final Class<T> type) {
  return shadedKryo.readObject(input.getShadedInput(), type);
}

代码示例来源:origin: com.baidu.hugegraph/hugegraph-core

@SuppressWarnings("unused")
private static Map<HugeKeys, Object> readEntry(Kryo kryo, Input input) {
  int columnSize = input.readInt();
  Map<HugeKeys, Object> map = new LinkedHashMap<>();
  for (int i = 0; i < columnSize; i++) {
    HugeKeys key = kryo.readObject(input, HugeKeys.class);
    Object val = kryo.readClassAndObject(input);
    map.put(key, val);
  }
  return map;
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-driver

@Override
public RequestMessage deserializeRequest(final ByteBuf msg) throws SerializationException {
  try {
    final Kryo kryo = kryoThreadLocal.get();
    final byte[] payload = new byte[msg.readableBytes()];
    msg.readBytes(payload);
    try (final Input input = new Input(payload)) {
      // by the time the message gets here, the mime length/type have been already read, so this part just
      // needs to process the payload.
      return kryo.readObject(input, RequestMessage.class);
    }
  } catch (Exception ex) {
    logger.warn(String.format("Request [%s] could not be deserialized by %s.", msg, AbstractGryoMessageSerializerV3d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-driver

@Override
public ResponseMessage deserializeResponse(final ByteBuf msg) throws SerializationException {
  try {
    final Kryo kryo = kryoThreadLocal.get();
    final byte[] payload = new byte[msg.capacity()];
    msg.readBytes(payload);
    try (final Input input = new Input(payload)) {
      return kryo.readObject(input, ResponseMessage.class);
    }
  } catch (Exception ex) {
    logger.warn(String.format("Response [%s] could not be deserialized by %s.", msg, AbstractGryoMessageSerializerV3d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

/**
 * Read an {@link Edge} from output generated by {@link GryoWriter#writeEdge(OutputStream, Edge)} or via
 * an {@link Edge} passed to {@link GryoWriter#writeObject(OutputStream, Object)}.
 *
 * @param inputStream      a stream containing at least one {@link Edge} as defined by the accompanying
 *                         {@link GraphWriter#writeEdge(OutputStream, Edge)} method.
 * @param edgeAttachMethod a function that creates re-attaches a {@link Edge} to a {@link Host} object.
 */
@Override
public Edge readEdge(final InputStream inputStream, final Function<Attachable<Edge>, Edge> edgeAttachMethod) throws IOException {
  final Input input = new Input(inputStream);
  readHeader(input);
  final Attachable<Edge> attachable = kryo.readObject(input, DetachedEdge.class);
  return edgeAttachMethod.apply(attachable);
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

/**
 * Read a {@link Property} from output generated by  {@link GryoWriter#writeProperty(OutputStream, Property)} or
 * via an {@link Property} passed to {@link GryoWriter#writeObject(OutputStream, Object)}.
 *
 * @param inputStream          a stream containing at least one {@link Property} as written by the accompanying
 *                             {@link GraphWriter#writeProperty(OutputStream, Property)} method.
 * @param propertyAttachMethod a function that creates re-attaches a {@link Property} to a {@link Host} object.
 */
@Override
public Property readProperty(final InputStream inputStream,
               final Function<Attachable<Property>, Property> propertyAttachMethod) throws IOException {
  final Input input = new Input(inputStream);
  readHeader(input);
  final Attachable<Property> attachable = kryo.readObject(input, DetachedProperty.class);
  return propertyAttachMethod.apply(attachable);
}

代码示例来源:origin: com.baidu.hugegraph/hugegraph-core

public static <T> T fromKryo(byte[] value, Class<T> clazz) {
    E.checkState(value != null,
           "Kryo value can't be null for '%s'",
           clazz.getSimpleName());
    return kryo().readObject(new Input(value), clazz);
  }
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

private Vertex readVertexInternal(final Function<Attachable<Vertex>, Vertex> vertexMaker,
                 final Function<Attachable<Edge>, Edge> edgeMaker,
                 final Direction d,
                 final Input input) throws IOException {
  readHeader(input);
  final StarGraph starGraph = kryo.readObject(input, StarGraph.class);
  // read the terminator
  kryo.readClassAndObject(input);
  final Vertex v = vertexMaker.apply(starGraph.getStarVertex());
  if (edgeMaker != null)
    starGraph.getStarVertex().edges(d).forEachRemaining(e -> edgeMaker.apply((Attachable<Edge>) e));
  return v;
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

@Override
public Optional<Vertex> readVertex(final InputStream inputStream, final GraphFilter graphFilter) throws IOException {
  StarGraphGryoSerializer serializer = this.graphFilterCache.get(graphFilter);
  if (null == serializer) {
    serializer = StarGraphGryoSerializer.withGraphFilter(graphFilter);
    this.graphFilterCache.put(graphFilter, serializer);
  }
  final Input input = new Input(inputStream);
  this.readHeader(input);
  final StarGraph starGraph = this.kryo.readObject(input, StarGraph.class, serializer);
  // read the terminator
  this.kryo.readClassAndObject(input);
  return Optional.ofNullable(starGraph == null ? null : starGraph.getStarVertex());
}

相关文章