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

x33g5p2x  于2022-01-20 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(106)

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

Input.setBuffer介绍

[英]Sets a new buffer. The position and total are reset, discarding any buffered bytes.
[中]设置一个新的缓冲区。重置位置和总数,丢弃所有缓冲字节。

代码示例

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

/**
 * Returns an Object which is created using Kryo deserialization of given byte array instance.
 *
 * @param buff byte array to be deserialized into an Object
 */
public Object deserialize(byte[] buff) {
  input.setBuffer(buff);
  return kryo.readClassAndObject(input);
}

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

public Object deserializeObject(byte[] ser) {
    _kryoInput.setBuffer(ser);
    return _kryo.readClassAndObject(_kryoInput);
  }
}

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

/**
   * Returns an Object which is created using Kryo deserialization of given {@code byteBuffer} instance.
   *
   * @param byteBuffer byte buffer to be deserialized into an Object
   */
  public Object deserialize(ByteBuffer byteBuffer) {
    input.setBuffer(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.position());
    return kryo.readClassAndObject(input);
  }
}

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

public List<Object> deserialize(byte[] ser) {
  _kryoInput.setBuffer(ser);
  return deserializeFrom(_kryoInput);
}

代码示例来源:origin: alibaba/jstorm

@Override
  public T deserialize(byte[] b) {
    input.setBuffer(b); 
    return (T) kryo.readClassAndObject(input); 
  }
}

代码示例来源:origin: alibaba/jstorm

public Tuple deserialize(byte[] ser) {
  _kryoInput.setBuffer(ser);
  return deserialize(_kryoInput);
}

代码示例来源:origin: alibaba/jstorm

@Override 
protected Object deserialize(byte[] data) { 
  input.setBuffer(data); 
  return kryo.readObject(input, ArrayList.class); 
}

代码示例来源:origin: alibaba/jstorm

/**
   * just get target taskId
   */
  public static int deserializeTaskId(byte[] ser) {
    Input _kryoInput = new Input(1);
    _kryoInput.setBuffer(ser);

    return _kryoInput.readInt();
  }
}

代码示例来源:origin: alibaba/jstorm

public List<Object> deserialize(byte[] ser) throws IOException {
  _kryoInput.setBuffer(ser);
  return deserializeFrom(_kryoInput);
}

代码示例来源:origin: alibaba/jstorm

public Tuple deserialize(byte[] ser, int offset, int count) {
  _kryoInput.setBuffer(ser, offset, count);
  return deserialize(_kryoInput);
}

代码示例来源:origin: alibaba/jstorm

public Object deserializeObject(byte[] ser) throws IOException {
  _kryoInput.setBuffer(ser);
  return _kryo.readClassAndObject(_kryoInput);
}

代码示例来源:origin: apache/rocketmq-externals

public Event read(final byte[] bytes) {
  Input input = new Input();
  input.setBuffer(bytes);
  return (Event)this.kryo.readClassAndObject(input);
}

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

@Override
  public TupleImpl deserialize(byte[] ser) {
    try {
      _kryoInput.setBuffer(ser);
      int taskId = _kryoInput.readInt(true);
      int streamId = _kryoInput.readInt(true);
      String componentName = _context.getComponentId(taskId);
      String streamName = _ids.getStreamName(componentName, streamId);
      MessageId id = MessageId.deserialize(_kryoInput);
      List<Object> values = _kryo.deserializeFrom(_kryoInput);
      return new TupleImpl(_context, values, componentName, taskId, streamName, id);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
}

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

/**
   * Reads a string encrypted by another instance with a shared key
   */
  private void testEncryptsAndDecryptsMessage(Map<String, Object> topoConf) {
    String testText = "Tetraodontidae is a family of primarily marine and estuarine fish of the order" +
             " Tetraodontiformes. The family includes many familiar species, which are" +
             " variously called pufferfish, puffers, balloonfish, blowfish, bubblefish," +
             " globefish, swellfish, toadfish, toadies, honey toads, sugar toads, and sea" +
             " squab.[1] They are morphologically similar to the closely related" +
             " porcupinefish, which have large external spines (unlike the thinner, hidden" +
             " spines of Tetraodontidae, which are only visible when the fish has puffed up)." +
             " The scientific name refers to the four large teeth, fused into an upper and" +
             " lower plate, which are used for crushing the shells of crustaceans and" +
             " mollusks, their natural prey.";
    Kryo kryo = new Kryo();
    BlowfishTupleSerializer writerBTS = new BlowfishTupleSerializer(kryo, topoConf);
    BlowfishTupleSerializer readerBTS = new BlowfishTupleSerializer(kryo, topoConf);
    int bufferSize = 1024;
    Output output = new Output(bufferSize, bufferSize);
    Input input = new Input(bufferSize);
    String[] stringList = testText.split(" ");
    ListDelegate delegate = new ListDelegate();
    delegate.addAll(Arrays.asList(stringList));

    writerBTS.write(kryo, output, delegate);
    input.setBuffer(output.getBuffer());
    ListDelegate outDelegate = readerBTS.read(kryo, input, ListDelegate.class);
    Assert.assertEquals(testText, Joiner.on(" ").join(outDelegate.toArray()));
  }
}

代码示例来源:origin: alibaba/jstorm

kryoInput.setBuffer(data);
kryoInput.setPosition(13); // Skip targetTaskId, timeStamp, isBatch
kryoInput.readInt(true); // Skip sourceTaskId

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

/** Creates a new Input for reading from a byte array.
 * @param buffer An exception is thrown if more bytes than this are read. */
public Input (byte[] buffer, int offset, int count) {
  setBuffer(buffer, offset, count);
}

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

/** Creates a new Input for reading from a byte array.
 * @param buffer An exception is thrown if more bytes than this are read. */
public Input (byte[] buffer) {
  setBuffer(buffer, 0, buffer.length);
}

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

/** Creates a new Input for reading from a byte array.
 * @param buffer An exception is thrown if more bytes than this are read. */
public Input (byte[] buffer, int offset, int count) {
  setBuffer(buffer, offset, count);
}

代码示例来源:origin: com.twitter.heron/heron-storm

@Override
 public Object deserialize(byte[] input) {
  kryoIn.setBuffer(input);
  return kryo.readClassAndObject(kryoIn);
 }
}

代码示例来源:origin: org.apache.storm/storm-core

/**
 * Returns an Object which is created using Kryo deserialization of given byte array instance.
 *
 * @param buff byte array to be deserialized into an Object
 */
public Object deserialize(byte[] buff) {
  input.setBuffer(buff);
  return kryo.readClassAndObject(input);
}

相关文章

微信公众号

最新文章

更多