com.esotericsoftware.kryo.io.Output.setBuffer()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(162)

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

Output.setBuffer介绍

[英]Sets the buffer that will be written to. #setBuffer(byte[],int) is called with the specified buffer's length as the maxBufferSize.
[中]设置要写入的缓冲区#使用指定缓冲区的长度作为maxBufferSize调用setBuffer(字节[],int)。

代码示例

代码示例来源:origin: fengjiachun/Jupiter

public static void clearOutput(Output output) {
  output.clear();
  // 防止hold过大的内存块一直不释放
  byte[] bytes = output.getBuffer();
  if (bytes == null) {
    return;
  }
  if (bytes.length > MAX_CACHED_BUF_SIZE) {
    output.setBuffer(new byte[DEFAULT_BUF_SIZE], -1);
  }
}

代码示例来源:origin: fengjiachun/Jupiter

public static void clearOutput(Output output) {
  output.clear();
  // 防止hold过大的内存块一直不释放
  byte[] bytes = output.getBuffer();
  if (bytes == null) {
    return;
  }
  if (bytes.length > MAX_CACHED_BUF_SIZE) {
    output.setBuffer(new byte[DEFAULT_BUF_SIZE], -1);
  }
}

代码示例来源:origin: com.esotericsoftware/kryo-shaded

/** Sets the buffer that will be written to. {@link #setBuffer(byte[], int)} is called with the specified buffer's length as
 * the maxBufferSize. */
public void setBuffer (byte[] buffer) {
  setBuffer(buffer, buffer.length);
}

代码示例来源:origin: com.esotericsoftware/kryo

/** Sets the buffer that will be written to. {@link #setBuffer(byte[], int)} is called with the specified buffer's length as
 * the maxBufferSize. */
public void setBuffer (byte[] buffer) {
  setBuffer(buffer, buffer.length);
}

代码示例来源:origin: com.esotericsoftware.kryo/kryo

/** Sets the buffer that will be written to. {@link #setBuffer(byte[], int)} is called with the specified buffer's length as the
 * maxBufferSize. */
public void setBuffer (byte[] buffer) {
  setBuffer(buffer, buffer.length);
}

代码示例来源:origin: svn2github/kryo

/** Sets the buffer that will be written to. {@link #setBuffer(byte[], int)} is called with the specified buffer's length as the
 * maxBufferSize. */
public void setBuffer (byte[] buffer) {
  setBuffer(buffer, buffer.length);
}

代码示例来源:origin: svn2github/kryo

/** Creates a new Output for writing to a byte array.
 * @see #setBuffer(byte[], int) */
public Output (byte[] buffer, int maxBufferSize) {
  if (buffer == null) throw new IllegalArgumentException("buffer cannot be null.");
  setBuffer(buffer, maxBufferSize);
}

代码示例来源:origin: com.esotericsoftware/kryo

/** Creates a new Output for writing to a byte array.
 * @see #setBuffer(byte[], int) */
public Output (byte[] buffer, int maxBufferSize) {
  if (buffer == null) throw new IllegalArgumentException("buffer cannot be null.");
  setBuffer(buffer, maxBufferSize);
}

代码示例来源:origin: com.esotericsoftware.kryo/kryo

/** Creates a new Output for writing to a byte array.
 * @see #setBuffer(byte[], int) */
public Output (byte[] buffer, int maxBufferSize) {
  if (buffer == null) throw new IllegalArgumentException("buffer cannot be null.");
  setBuffer(buffer, maxBufferSize);
}

代码示例来源:origin: com.esotericsoftware/kryo-shaded

/** Creates a new Output for writing to a byte array.
 * @see #setBuffer(byte[], int) */
public Output (byte[] buffer, int maxBufferSize) {
  if (buffer == null) throw new IllegalArgumentException("buffer cannot be null.");
  setBuffer(buffer, maxBufferSize);
}

代码示例来源:origin: us.ihmc/IHMCCommunication

public KryoStreamSerializer(int outputBufferSize)
{
 kryo = new Kryo();
 kryo.setReferences(false);
 kryo.setRegistrationRequired(true);
 
 writeBuffer = new byte[outputBufferSize];
 output = new Output();
 
 output.setBuffer(writeBuffer);
}

代码示例来源:origin: org.jupiter-rpc/jupiter-serialization-kryo

public static void clearOutput(Output output) {
  output.clear();
  // 防止hold过大的内存块一直不释放
  byte[] bytes = output.getBuffer();
  if (bytes == null) {
    return;
  }
  if (bytes.length > MAX_CACHED_BUF_SIZE) {
    output.setBuffer(new byte[DEFAULT_BUF_SIZE], -1);
  }
}

代码示例来源:origin: org.jupiter-rpc/jupiter-all

public static void clearOutput(Output output) {
  output.clear();
  // 防止hold过大的内存块一直不释放
  byte[] bytes = output.getBuffer();
  if (bytes == null) {
    return;
  }
  if (bytes.length > MAX_CACHED_BUF_SIZE) {
    output.setBuffer(new byte[DEFAULT_BUF_SIZE], -1);
  }
}

代码示例来源:origin: net.dempsy/dempsy-serialization.kryo

@Override
  public void close() {
    output.close();
    input.close();
    input.setBuffer(park); // clean input
    output.setBuffer(park, Integer.MAX_VALUE); // clear output
    kryopool.offer(this);
  }
}

代码示例来源:origin: net.dempsy/dempsy-serialization.kryo

@Override
public <T> void serialize(final T object, final MessageBufferOutput buffer) throws IOException {
  try (Holder k = getKryoHolder()) {
    final Output output = k.output;
    // this will allow kryo to grow the buffer as needed.
    output.setBuffer(buffer.getBuffer(), Integer.MAX_VALUE);
    output.setPosition(buffer.getPosition()); // set the position to where we already are.
    kryoRunner.doSerialize(k, output, object);
    // if we resized then we need to adjust the message buffer
    if (output.getBuffer() != buffer.getBuffer())
      buffer.replace(output.getBuffer());
    buffer.setPosition(output.position());
  } catch (final KryoException ke) {
    throw new IOException("Failed to serialize.", ke);
  } catch (final IllegalArgumentException e) { // this happens when requiring registration but serializing an unregistered class
    throw new IOException("Failed to serialize " + objectDescription(object) +
        " (did you require registration and attempt to serialize an unregistered class?)", e);
  }
}

相关文章