本文整理了Java中org.apache.tinkerpop.shaded.kryo.io.Output
类的一些代码示例,展示了Output
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Output
类的具体详情如下:
包路径:org.apache.tinkerpop.shaded.kryo.io.Output
类名称:Output
暂无
代码示例来源: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: 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: 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: thinkaurelius/titan
@Override
public void write(Kryo kryo, Output output, Geoshape geoshape) {
float[][] coordinates = geoshape.coordinates;
assert (coordinates.length==2);
assert (coordinates[0].length==coordinates[1].length && coordinates[0].length>0);
int length = coordinates[0].length;
output.writeLong(length);
for (int i = 0; i < 2; i++) {
for (int j = 0; j < length; j++) {
output.writeFloat(coordinates[i][j]);
}
}
}
代码示例来源: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: 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: pietermartin/sqlg
@Override
public void write(Kryo kryo, Output output) {
output.writeString(this.getSchemaTable().getSchema());
output.writeString(this.getSchemaTable().getTable());
if (hasSequenceId()) {
output.writeString("s");
output.writeLong(this.getID().sequenceId);
} else {
output.writeString("i");
output.writeInt(getIdentifiers().size());
for (Comparable identifier : getIdentifiers()) {
output.writeString((CharSequence) identifier);
}
}
}
代码示例来源: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);
final ResponseMessage msgToWrite = !serializeToString ? responseMessage :
ResponseMessage.build(responseMessage.getRequestId())
.code(responseMessage.getStatus().getCode())
.statusAttributes(responseMessage.getStatus().getAttributes())
.responseMetaData(responseMessage.getResult().getMeta())
.result(serializeResultToString(responseMessage))
.statusMessage(responseMessage.getStatus().getMessage()).create();
kryo.writeObject(output, msgToWrite);
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, AbstractGryoMessageSerializerV3d0.class.getName()), ex);
throw new SerializationException(ex);
}
}
代码示例来源:origin: apache/tinkerpop
@Override
public void writeLong(final long l) {
shadedOutput.writeLong(l);
}
代码示例来源: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 writeString(final String s) {
shadedOutput.writeString(s);
}
代码示例来源:origin: apache/tinkerpop
@Override
public void writeInt(final int i) {
shadedOutput.writeInt(i);
}
代码示例来源:origin: apache/tinkerpop
@Override
public void flush() {
shadedOutput.flush();
}
代码示例来源:origin: apache/tinkerpop
public GryoSerializationStream(final GryoSerializerInstance gryoSerializer, final OutputStream outputStream) {
this.output = new Output(outputStream);
this.gryoSerializer = gryoSerializer;
}
代码示例来源: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: apache/tinkerpop
protected void writeName(final Output output, final Class type) {
output.writeVarInt(NAME + 2, true);
if (classToNameId != null) {
final int nameId = classToNameId.get(type, -1);
if (nameId != -1) {
output.writeVarInt(nameId, true);
return;
}
}
// Only write the class name the first time encountered in object graph.
final int nameId = nextNameId++;
if (classToNameId == null) classToNameId = new IdentityObjectIntMap<>();
classToNameId.put(type, nameId);
output.writeVarInt(nameId, true);
output.writeString(type.getName());
}
代码示例来源:origin: apache/tinkerpop
@Override
public void writeByte(final byte b) {
shadedOutput.writeByte(b);
}
代码示例来源:origin: apache/tinkerpop
@Override
public void writeBytes(final byte[] array, final int offset, final int count) {
shadedOutput.writeBytes(array, offset, count);
}
代码示例来源:origin: apache/tinkerpop
@Override
public void writeBoolean(final boolean b) {
shadedOutput.writeBoolean(b);
}
内容来源于网络,如有侵权,请联系作者删除!