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

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

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

Output.writeString介绍

暂无

代码示例

代码示例来源: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 writeString(final String s) {
  shadedOutput.writeString(s);
}

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

@Override
public void write(final Kryo kryo, final Output output, final JsonBuilder jsonBuilder) {
  output.writeString(jsonBuilder.toString());
}

代码示例来源: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

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 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/gremlin-core

@Override
public void writeString(final String s) {
  shadedOutput.writeString(s);
}

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

@Override
public void write(final Kryo kryo, final Output output, final JsonBuilder jsonBuilder) {
  output.writeString(jsonBuilder.toString());
}

代码示例来源:origin: com.orientechnologies/orientdb-gremlin

@Override
public void write(final Kryo kryo, final Output output, final ORecordId rid) {
  output.writeString(rid.toString());
}

代码示例来源:origin: com.orientechnologies/orientdb-gremlin

@Override
public void write(final Kryo kryo, final Output output, final ORidBag bag) {
  StringBuilder ids = new StringBuilder();
  bag.forEach(rid -> ids.append(rid.getIdentity()).append(";"));
  output.writeString(ids);
}

代码示例来源: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: org.umlg/sqlg-core

@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: 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: org.apache.tinkerpop/gremlin-core

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: org.apache.tinkerpop/gremlin-driver

@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);
  }
}

相关文章