com.amazonaws.services.kinesis.model.Record.getData()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(92)

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

Record.getData介绍

[英]The data blob. The data in the blob is both opaque and immutable to Kinesis Data Streams, which does not inspect, interpret, or change the data in the blob in any way. When the data blob (the payload before base64-encoding) is added to the partition key size, the total size must not exceed the maximum record size (1 MB).

ByteBuffers are stateful. Calling their get methods changes their position. We recommend using java.nio.ByteBuffer#asReadOnlyBuffer() to create a read-only view of the buffer with an independent position, and calling get methods on this rather than directly on the returned ByteBuffer. Doing so will ensure that anyone else using the ByteBuffer will not be affected by changes to the position.
[中]数据块。blob中的数据对Kinesis数据流来说既不透明又不可变,Kinesis数据流不会以任何方式检查、解释或更改blob中的数据。将数据blob(base64编码之前的有效负载)添加到分区密钥大小时,总大小不得超过最大记录大小(1MB)。
字节缓冲区是有状态的。调用他们的get方法会改变他们的位置。我们建议使用java。尼奥。ByteBuffer#asReadOnlyBuffer()创建具有独立位置的缓冲区的只读视图,并对其调用get方法,而不是直接对返回的ByteBuffer调用get方法。这样做将确保其他使用ByteBuffer的人不会受到位置变化的影响。

代码示例

代码示例来源:origin: aws/aws-sdk-java

@Override
public int hashCode() {
  final int prime = 31;
  int hashCode = 1;
  hashCode = prime * hashCode + ((getSequenceNumber() == null) ? 0 : getSequenceNumber().hashCode());
  hashCode = prime * hashCode + ((getApproximateArrivalTimestamp() == null) ? 0 : getApproximateArrivalTimestamp().hashCode());
  hashCode = prime * hashCode + ((getData() == null) ? 0 : getData().hashCode());
  hashCode = prime * hashCode + ((getPartitionKey() == null) ? 0 : getPartitionKey().hashCode());
  hashCode = prime * hashCode + ((getEncryptionType() == null) ? 0 : getEncryptionType().hashCode());
  return hashCode;
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
 * redacted from this string using a placeholder value.
 *
 * @return A string representation of this object.
 *
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("{");
  if (getSequenceNumber() != null)
    sb.append("SequenceNumber: ").append(getSequenceNumber()).append(",");
  if (getApproximateArrivalTimestamp() != null)
    sb.append("ApproximateArrivalTimestamp: ").append(getApproximateArrivalTimestamp()).append(",");
  if (getData() != null)
    sb.append("Data: ").append(getData()).append(",");
  if (getPartitionKey() != null)
    sb.append("PartitionKey: ").append(getPartitionKey()).append(",");
  if (getEncryptionType() != null)
    sb.append("EncryptionType: ").append(getEncryptionType());
  sb.append("}");
  return sb.toString();
}

代码示例来源:origin: aws/aws-sdk-java

if (other.getApproximateArrivalTimestamp() != null && other.getApproximateArrivalTimestamp().equals(this.getApproximateArrivalTimestamp()) == false)
  return false;
if (other.getData() == null ^ this.getData() == null)
  return false;
if (other.getData() != null && other.getData().equals(this.getData()) == false)
  return false;
if (other.getPartitionKey() == null ^ this.getPartitionKey() == null)

代码示例来源:origin: aws/aws-sdk-java

/**
 * Marshall the given parameter object.
 */
public void marshall(Record record, ProtocolMarshaller protocolMarshaller) {
  if (record == null) {
    throw new SdkClientException("Invalid argument passed to marshall(...)");
  }
  try {
    protocolMarshaller.marshall(record.getSequenceNumber(), SEQUENCENUMBER_BINDING);
    protocolMarshaller.marshall(record.getApproximateArrivalTimestamp(), APPROXIMATEARRIVALTIMESTAMP_BINDING);
    protocolMarshaller.marshall(record.getData(), DATA_BINDING);
    protocolMarshaller.marshall(record.getPartitionKey(), PARTITIONKEY_BINDING);
    protocolMarshaller.marshall(record.getEncryptionType(), ENCRYPTIONTYPE_BINDING);
  } catch (Exception e) {
    throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
  }
}

代码示例来源:origin: apache/incubator-druid

data = Collections.singletonList(toByteArray(kinesisRecord.getData()));

代码示例来源:origin: aws-amplify/aws-sdk-android

@Override
public int hashCode() {
  final int prime = 31;
  int hashCode = 1;
  hashCode = prime * hashCode
      + ((getSequenceNumber() == null) ? 0 : getSequenceNumber().hashCode());
  hashCode = prime
      * hashCode
      + ((getApproximateArrivalTimestamp() == null) ? 0
          : getApproximateArrivalTimestamp().hashCode());
  hashCode = prime * hashCode + ((getData() == null) ? 0 : getData().hashCode());
  hashCode = prime * hashCode
      + ((getPartitionKey() == null) ? 0 : getPartitionKey().hashCode());
  hashCode = prime * hashCode
      + ((getEncryptionType() == null) ? 0 : getEncryptionType().hashCode());
  return hashCode;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Returns a string representation of this object; useful for testing and
 * debugging.
 *
 * @return A string representation of this object.
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder();
  sb.append("{");
  if (getSequenceNumber() != null)
    sb.append("SequenceNumber: " + getSequenceNumber() + ",");
  if (getApproximateArrivalTimestamp() != null)
    sb.append("ApproximateArrivalTimestamp: " + getApproximateArrivalTimestamp() + ",");
  if (getData() != null)
    sb.append("Data: " + getData() + ",");
  if (getPartitionKey() != null)
    sb.append("PartitionKey: " + getPartitionKey() + ",");
  if (getEncryptionType() != null)
    sb.append("EncryptionType: " + getEncryptionType());
  sb.append("}");
  return sb.toString();
}

代码示例来源:origin: aws-amplify/aws-sdk-android

this.getApproximateArrivalTimestamp()) == false)
  return false;
if (other.getData() == null ^ this.getData() == null)
  return false;
if (other.getData() != null && other.getData().equals(this.getData()) == false)
  return false;
if (other.getPartitionKey() == null ^ this.getPartitionKey() == null)

代码示例来源:origin: com.sonymobile/lumbermill-aws-kcl

private int calculateSize(List<Record> records) {
  int bytes = 0;
  for (Record r : records) {
    bytes += r.getData().remaining();
  }
  // We get it in binary, but it's actually sent as Base64
  return bytes * 3 / 2;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

public void marshall(Record record, AwsJsonWriter jsonWriter) throws Exception {
  jsonWriter.beginObject();
  if (record.getSequenceNumber() != null) {
    String sequenceNumber = record.getSequenceNumber();
    jsonWriter.name("SequenceNumber");
    jsonWriter.value(sequenceNumber);
  }
  if (record.getApproximateArrivalTimestamp() != null) {
    java.util.Date approximateArrivalTimestamp = record.getApproximateArrivalTimestamp();
    jsonWriter.name("ApproximateArrivalTimestamp");
    jsonWriter.value(approximateArrivalTimestamp);
  }
  if (record.getData() != null) {
    java.nio.ByteBuffer data = record.getData();
    jsonWriter.name("Data");
    jsonWriter.value(data);
  }
  if (record.getPartitionKey() != null) {
    String partitionKey = record.getPartitionKey();
    jsonWriter.name("PartitionKey");
    jsonWriter.value(partitionKey);
  }
  if (record.getEncryptionType() != null) {
    String encryptionType = record.getEncryptionType();
    jsonWriter.name("EncryptionType");
    jsonWriter.value(encryptionType);
  }
  jsonWriter.endObject();
}

代码示例来源:origin: awslabs/amazon-kinesis-connectors

@Override
public String toClass(Record record) {
  return new String(record.getData().array());
}

代码示例来源:origin: awslabs/amazon-kinesis-connectors

@Override
public T toClass(Record record) throws IOException {
  try {
    return new ObjectMapper().readValue(record.getData().array(), this.inputClass);
  } catch (IOException e) {
    String message = "Error parsing record from JSON: " + new String(record.getData().array());
    LOG.error(message, e);
    throw new IOException(message, e);
  }
}

代码示例来源:origin: com.amazonaws/amazon-kinesis-connectors

@Override
public T toClass(Record record) throws IOException {
  try {
    return new ObjectMapper().readValue(record.getData().array(), this.inputClass);
  } catch (IOException e) {
    String message = "Error parsing record from JSON: " + new String(record.getData().array());
    LOG.error(message, e);
    throw new IOException(message, e);
  }
}

代码示例来源:origin: awslabs/dynamodb-cross-region-library

/**
   * {@inheritDoc}
   */
  @Override
  public Record toClass(final com.amazonaws.services.kinesis.model.Record record) throws IOException {
    if (record instanceof RecordAdapter) {
      return ((RecordAdapter) record).getInternalObject();
    } else {
      return MAPPER.readValue(new String(record.getData().array(), ENCODING), Record.class);
    }
  }
}

代码示例来源:origin: spring-cloud/spring-cloud-stream-samples

@StreamListener(Sink.INPUT)
public void kinesisSink(Flux<List<Record>> recordFlux) {
  this.recordFlux = recordFlux
      .flatMap(Flux::fromIterable)
      .map(record -> new String(record.getData().array(), StandardCharsets.UTF_8));
}

代码示例来源:origin: apache/apex-malhar

public String getData(Record rc)
{
 ByteBuffer buffer = rc.getData();
 byte[] bytes = new byte[buffer.remaining()];
 buffer.get(bytes);
 return new String(bytes);
}

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

public void updateMetrics(String stream, Record record) {
  eventReadRates.get(stream).inc();
  aggEventReadRate.inc();

  long recordSize = record.getData().array().length + record.getPartitionKey().length();
  eventByteReadRates.get(stream).inc(recordSize);
  aggEventByteReadRate.inc(recordSize);

  long latencyMs = Duration.between(Instant.now(), record.getApproximateArrivalTimestamp().toInstant()).toMillis();
  readLatencies.get(stream).update(latencyMs);
  aggReadLatency.update(latencyMs);
 }
}

代码示例来源:origin: com.amazonaws/amazon-kinesis-connectors

private void filterAndBufferRecord(T transformedRecord, Record record) {
  if (filter.keepRecord(transformedRecord)) {
    buffer.consumeRecord(transformedRecord, record.getData().array().length, record.getSequenceNumber());
  }
}

代码示例来源:origin: awslabs/amazon-kinesis-connectors

private void filterAndBufferRecord(T transformedRecord, Record record) {
  if (filter.keepRecord(transformedRecord)) {
    buffer.consumeRecord(transformedRecord, record.getData().array().length, record.getSequenceNumber());
  }
}

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

private IncomingMessageEnvelope translate(SystemStreamPartition ssp, Record record) {
 String shardId = processors.get(ssp).getShardId();
 byte[] payload = new byte[record.getData().remaining()];
 metrics.updateMetrics(ssp.getStream(), record);
 record.getData().get(payload);
 KinesisSystemConsumerOffset offset = new KinesisSystemConsumerOffset(shardId, record.getSequenceNumber());
 return new KinesisIncomingMessageEnvelope(ssp, offset.toString(), record.getPartitionKey(),
   payload, shardId, record.getSequenceNumber(), record.getApproximateArrivalTimestamp());
}

相关文章