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

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

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

Kryo.writeClassAndObject介绍

暂无

代码示例

代码示例来源:origin: JanusGraph/janusgraph

@Override
public void write(Kryo kryo, Output output, P p) {
  output.writeString(
      p instanceof ConnectiveP ? (p instanceof AndP ? "and" : "or") : p.getBiPredicate().toString());
  if (p instanceof ConnectiveP || p.getValue() instanceof Collection) {
    output.writeByte((byte) 0);
    final Collection<?> coll = p instanceof ConnectiveP ? ((ConnectiveP<?>) p).getPredicates()
        : (Collection) p.getValue();
    output.writeInt(coll.size());
    coll.forEach(v -> kryo.writeClassAndObject(output, v));
  } else {
    output.writeByte((byte) 1);
    kryo.writeClassAndObject(output, p.getValue());
  }
}

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

@Override
public void write(final Kryo kryo, final Output output, final Map.Entry entry) {
  kryo.writeClassAndObject(output, entry.getKey());
  kryo.writeClassAndObject(output, entry.getValue());
}

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

@Override
public void write(final Kryo kryo, final Output output, final Tuple2<A, B> tuple2) {
  kryo.writeClassAndObject(output, tuple2._1());
  kryo.writeClassAndObject(output, tuple2._2());
}

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

@Override
public void write(final Kryo kryo, final Output output, final Tuple3<A, B, C> tuple3) {
  kryo.writeClassAndObject(output, tuple3._1());
  kryo.writeClassAndObject(output, tuple3._2());
  kryo.writeClassAndObject(output, tuple3._3());
}

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

@Override
public void write(Kryo kryo, Output output, Optional<?> optional) {
  if (optional.isPresent()) {
    kryo.writeClassAndObject(output, optional.get());
  } else {
    kryo.writeObject(output, null);
  }
}

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

@Override
public void writeClassAndObject(final ShadedOutputAdapter output, final Object object) {
  shadedKryo.writeClassAndObject(output.getShadedOutput(), object);
}

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

@Override
public void write(final Kryo kryo, final Output output, final Vertex vertex) {
  kryo.writeClassAndObject(output, ReferenceFactory.detach(vertex));
}

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

@Override
public void write(final Kryo kryo, final Output output, final Path path) {
  kryo.writeClassAndObject(output, ReferenceFactory.detach(path));
}

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

@Override
public void write(final Kryo kryo, final Output output, final Edge edge) {
  kryo.writeClassAndObject(output, ReferenceFactory.detach(edge));
}

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

@Override
public void write(final Kryo kryo, final Output output, final VertexProperty vertexProperty) {
  kryo.writeClassAndObject(output, ReferenceFactory.detach(vertexProperty));
}

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

private static void writeEntry(Kryo kryo,
                Output output,
                Map<HugeKeys, Object> schema) {
  /* Write columns size and data */
  output.writeInt(schema.keySet().size());
  for (Map.Entry<HugeKeys, Object> entry : schema.entrySet()) {
    kryo.writeObject(output, entry.getKey());
    kryo.writeClassAndObject(output, entry.getValue());
  }
}

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

@Override
public <T> SerializationStream writeObject(final T t, final ClassTag<T> classTag) {
  this.gryoSerializer.getGryoPool().writeWithKryo(kryo -> kryo.writeClassAndObject(this.output, t));
  return this;
}

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

/**
 * {@inheritDoc}
 */
@Override
public void writeObject(final OutputStream outputStream, final Object object) {
  final Output output = new Output(outputStream);
  this.kryo.writeClassAndObject(output, object);
  output.flush();
}

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

@Override
public void write(final Kryo kryo, final Output output, final Property property) {
  kryo.writeClassAndObject(output, property instanceof VertexProperty ? ReferenceFactory.detach((VertexProperty) property) : ReferenceFactory.detach(property));
}

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

@Override
public void write(final Kryo kryo, final Output output, final WrappedArray<T> iterable) {
  output.writeVarInt(iterable.size(), true);
  JavaConversions.asJavaCollection(iterable).forEach(t -> {
    kryo.writeClassAndObject(output, t);
  });
}

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

@Override
public <T> ByteBuffer serialize(final T t, final ClassTag<T> classTag) {
  this.gryoSerializer.getGryoPool().writeWithKryo(kryo -> kryo.writeClassAndObject(this.output, t));
  return ByteBuffer.wrap(this.output.getBuffer());
}

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

void writeVertexInternal(final Output output, final Vertex v) throws IOException {
  writeHeader(output);
  kryo.writeObject(output, StarGraph.of(v));
  kryo.writeClassAndObject(output, VertexTerminator.INSTANCE);
}

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

@Override
public void writeClassAndObject(final Object object, final OutputStream outputStream) {
  HadoopPools.getGryoPool().writeWithKryo(kryo -> {
    final Output output = new Output(outputStream);
    kryo.writeClassAndObject(output, object);
    output.flush();
  });
}

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

@Override
public ByteBuf serializeResponseAsBinary(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException {
  ByteBuf encodedMessage = null;
  try {
    final Kryo kryo = kryoThreadLocal.get();
    try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
      final Output output = new Output(baos, bufferSize);
      // request id - if present
      kryo.writeObjectOrNull(output, responseMessage.getRequestId() != null ? responseMessage.getRequestId() : null, UUID.class);
      // status
      output.writeShort(responseMessage.getStatus().getCode().getValue());
      output.writeString(responseMessage.getStatus().getMessage());
      kryo.writeClassAndObject(output, responseMessage.getStatus().getAttributes());
      // result
      kryo.writeClassAndObject(output, serializeToString ? serializeResultToString(responseMessage) : responseMessage.getResult().getData());
      kryo.writeClassAndObject(output, responseMessage.getResult().getMeta());
      final long size = output.total();
      if (size > Integer.MAX_VALUE)
        throw new SerializationException(String.format("Message size of %s exceeds allocatable space", size));
      output.flush();
      encodedMessage = allocator.buffer((int) size);
      encodedMessage.writeBytes(baos.toByteArray());
    }
    return encodedMessage;
  } catch (Exception ex) {
    if (encodedMessage != null) ReferenceCountUtil.release(encodedMessage);
    logger.warn(String.format("Response [%s] could not be serialized by %s.", responseMessage, AbstractGryoMessageSerializerV1d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

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

@Override
public <T> ByteBuffer serialize(final T t, final ClassTag<T> classTag) {
  this.gryoSerializer.getGryoPool().writeWithKryo(kryo -> kryo.writeClassAndObject(this.output, t));
  return ByteBuffer.wrap(this.output.getBuffer());
}

相关文章