org.apache.tinkerpop.shaded.kryo.io.Output.write()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(141)

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

Output.write介绍

暂无

代码示例

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

@Override
public void write(Kryo kryo, Output output, Geoshape geoshape) {
  try {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    GeoshapeBinarySerializer.write(outputStream, geoshape);
    byte[] bytes = outputStream.toByteArray();
    output.writeLong(bytes.length);
    output.write(bytes);
  } catch (IOException e) {
    throw new RuntimeException("I/O exception writing geoshape", e);
  }
}

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

@Override
public void write(Kryo kryo, Output output, EdgeId edgeId) {
  byte[] idBytes = edgeId.asBytes();
  output.write(idBytes.length);
  output.writeBytes(edgeId.asBytes());
}

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

@Override
public void write(Kryo kryo, Output output, Id id) {
  output.writeBoolean(id.number());
  byte[] idBytes = id.asBytes();
  output.write(idBytes.length);
  output.writeBytes(id.asBytes());
}

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

@Override
public void write(final Kryo kryo, final Output output, final TinkerGraph graph) {
  try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
    GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph);
    final byte[] bytes = stream.toByteArray();
    output.writeInt(bytes.length);
    output.write(bytes);
  } catch (Exception io) {
    throw new RuntimeException(io);
  }
}

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

@Override
public ByteBuf serializeRequestAsBinary(final RequestMessage requestMessage, 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);
      final String mimeType = mimeTypesSupported()[0];
      output.writeByte(mimeType.length());
      output.write(mimeType.getBytes(UTF8));
      kryo.writeObject(output, requestMessage.getRequestId());
      output.writeString(requestMessage.getProcessor());
      output.writeString(requestMessage.getOp());
      kryo.writeObject(output, requestMessage.getArgs());
      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("Request [%s] could not be serialized by %s.", requestMessage, AbstractGryoMessageSerializerV1d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

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

@Override
public ByteBuf serializeRequestAsBinary(final RequestMessage requestMessage, 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);
      final String mimeType = mimeTypesSupported()[0];
      output.writeByte(mimeType.length());
      output.write(mimeType.getBytes(UTF8));
      kryo.writeObject(output, requestMessage);
      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("Request [%s] could not be serialized by %s.", requestMessage, AbstractGryoMessageSerializerV3d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

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

@Override
public void write(final Kryo kryo, final Output output, final TinkerGraph graph) {
  try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
    GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph);
    final byte[] bytes = stream.toByteArray();
    output.writeInt(bytes.length);
    output.write(bytes);
  } catch (Exception io) {
    throw new RuntimeException(io);
  }
}

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

@Override
public ByteBuf serializeRequestAsBinary(final RequestMessage requestMessage, 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);
      final String mimeType = mimeTypesSupported()[0];
      output.writeByte(mimeType.length());
      output.write(mimeType.getBytes(UTF8));
      kryo.writeObject(output, requestMessage.getRequestId());
      output.writeString(requestMessage.getProcessor());
      output.writeString(requestMessage.getOp());
      kryo.writeObject(output, requestMessage.getArgs());
      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("Request [%s] could not be serialized by %s.", requestMessage, AbstractGryoMessageSerializerV1d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

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

@Override
public void write(Kryo kryo, Output output, Id id) {
  output.writeBoolean(id.number());
  byte[] idBytes = id.asBytes();
  output.write(idBytes.length);
  output.writeBytes(id.asBytes());
}

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

@Override
public ByteBuf serializeRequestAsBinary(final RequestMessage requestMessage, 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);
      final String mimeType = mimeTypesSupported()[0];
      output.writeByte(mimeType.length());
      output.write(mimeType.getBytes(UTF8));
      kryo.writeObject(output, requestMessage);
      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("Request [%s] could not be serialized by %s.", requestMessage, AbstractGryoMessageSerializerV3d0.class.getName()), ex);
    throw new SerializationException(ex);
  }
}

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

@Override
public void write(Kryo kryo, Output output, EdgeId edgeId) {
  byte[] idBytes = edgeId.asBytes();
  output.write(idBytes.length);
  output.writeBytes(edgeId.asBytes());
}

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

@Override
public void write(final Kryo kryo, final Output output, final TinkerGraph graph) {
  try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
    GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph);
    final byte[] bytes = stream.toByteArray();
    output.writeInt(bytes.length);
    output.write(bytes);
  } catch (Exception io) {
    throw new RuntimeException(io);
  }
}

代码示例来源:origin: io.shiftleft/tinkergraph-gremlin

@Override
public void write(final Kryo kryo, final Output output, final TinkerGraph graph) {
  try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
    GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph);
    final byte[] bytes = stream.toByteArray();
    output.writeInt(bytes.length);
    output.write(bytes);
  } catch (Exception io) {
    throw new RuntimeException(io);
  }
}

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

@Override
public void write(final Kryo kryo, final Output output, final TinkerGraph graph) {
  try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
    GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph);
    final byte[] bytes = stream.toByteArray();
    output.writeInt(bytes.length);
    output.write(bytes);
  } catch (Exception io) {
    throw new RuntimeException(io);
  }
}

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

@Override
public void write(final Kryo kryo, final Output output, final TinkerGraph graph) {
  try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
    GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph);
    final byte[] bytes = stream.toByteArray();
    output.writeInt(bytes.length);
    output.write(bytes);
  } catch (Exception io) {
    throw new RuntimeException(io);
  }
}

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

@Override
public void write(final Kryo kryo, final Output output, final TinkerGraph graph) {
  try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
    GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph);
    final byte[] bytes = stream.toByteArray();
    output.writeInt(bytes.length);
    output.write(bytes);
  } catch (Exception io) {
    throw new RuntimeException(io);
  }
}

代码示例来源:origin: io.shiftleft/tinkergraph-gremlin

@Override
public void write(final Kryo kryo, final Output output, final TinkerGraph graph) {
  try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
    GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph);
    final byte[] bytes = stream.toByteArray();
    output.writeInt(bytes.length);
    output.write(bytes);
  } catch (Exception io) {
    throw new RuntimeException(io);
  }
}

代码示例来源:origin: io.shiftleft/tinkergraph-gremlin

@Override
public void write(final Kryo kryo, final Output output, final TinkerGraph graph) {
  try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
    GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph);
    final byte[] bytes = stream.toByteArray();
    output.writeInt(bytes.length);
    output.write(bytes);
  } catch (Exception io) {
    throw new RuntimeException(io);
  }
}

相关文章