org.apache.storm.tuple.Tuple.getBinaryByField()方法的使用及代码示例

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

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

Tuple.getBinaryByField介绍

[英]Gets the Byte array field with a specific name.
[中]获取具有特定名称的字节数组字段。

代码示例

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

private void doExecute(Tuple input) throws ParseException, UnsupportedEncodingException {
 // retrieve the input message
 byte[] data = input.getBinaryByField(VALUE.getFieldName());
 if(data == null) {
  LOG.debug("Received null message. Nothing to do.");
  return;
 }
 // ensure there is a valid profiler configuration
 ProfilerConfig config = getProfilerConfig();
 if(config == null || getProfilerConfig().getProfiles().size() == 0) {
  LOG.debug("No Profiler configuration found. Nothing to do.");
  return;
 }
 JSONObject message = (JSONObject) parser.parse(new String(data, "UTF8"));
 routeMessage(input, message, config);
}

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

for (String cq : columnFamilies.get(cf)) {
 byte[] cqBytes = Bytes.toBytes(cq);
 byte[] val = tuple.getBinaryByField(cq);

代码示例来源:origin: DigitalPebble/storm-crawler

@Override
public byte[] format(Tuple tuple) {
  byte[] content = tuple.getBinaryByField("content");
  String url = tuple.getStringByField("url");
  Metadata metadata = (Metadata) tuple.getValueByField("metadata");

代码示例来源:origin: DigitalPebble/storm-crawler

protected void parse(String url, byte[] content, Metadata metadata)
    throws IOException {
  Tuple tuple = mock(Tuple.class);
  when(tuple.getBinaryByField("content")).thenReturn(content);
  when(tuple.getStringByField("url")).thenReturn(url);
  when(tuple.getValueByField("metadata")).thenReturn(metadata);
  bolt.execute(tuple);
}

代码示例来源:origin: DigitalPebble/storm-crawler

protected void index(String url, String content, Metadata metadata)
      throws IOException {
    Tuple tuple = mock(Tuple.class);
    when(tuple.getBinaryByField("content")).thenReturn(content.getBytes());
    when(tuple.getStringByField("url")).thenReturn(url);
    when(tuple.getValueByField("metadata")).thenReturn(metadata);
    bolt.execute(tuple);
  }
}

代码示例来源:origin: DigitalPebble/storm-crawler

public static Tuple getMockedTestTuple(String url, String content,
    Metadata metadata) {
  Tuple tuple = mock(Tuple.class);
  when(tuple.getStringByField("url")).thenReturn(url);
  when(tuple.getBinaryByField("content")).thenReturn(
      content.getBytes(Charset.defaultCharset()));
  if (metadata == null) {
    when(tuple.contains("metadata")).thenReturn(Boolean.FALSE);
  } else {
    when(tuple.contains("metadata")).thenReturn(Boolean.TRUE);
    when(tuple.getValueByField("metadata")).thenReturn(metadata);
  }
  return tuple;
}

代码示例来源:origin: DigitalPebble/storm-crawler

protected void parse(String url, String filename, Metadata metadata)
    throws IOException {
  byte[] content = readContent(filename);
  Tuple tuple = mock(Tuple.class);
  when(tuple.getBinaryByField("content")).thenReturn(content);
  when(tuple.getStringByField("url")).thenReturn(url);
  when(tuple.getValueByField("metadata")).thenReturn(metadata);
  bolt.execute(tuple);
}

代码示例来源:origin: DigitalPebble/storm-crawler

@Override
public void execute(Tuple tuple) {
  String url = tuple.getStringByField("url");
  byte[] content = tuple.getBinaryByField("content");
  Metadata metadata = (Metadata) tuple.getValueByField("metadata");
  String text = tuple.getStringByField("text");
  Values v = new Values(url, content, metadata, text);
  // if there is a text - no need to parse it again
  if (StringUtils.isNotBlank(text)) {
    collector.emit(tuple, v);
  } else {
    collector.emit("tika", tuple, v);
  }
  collector.ack(tuple);
}

代码示例来源:origin: DigitalPebble/storm-crawler

@Override
public void execute(Tuple tuple) {
  byte[] content = tuple.getBinaryByField("content");
  String url = tuple.getStringByField("url");
  Metadata metadata = (Metadata) tuple.getValueByField("metadata");

代码示例来源:origin: commoncrawl/news-crawl

Metadata metadata = (Metadata) tuple.getValueByField("metadata");
byte[] content = tuple.getBinaryByField("content");
String url = tuple.getStringByField("url");

代码示例来源:origin: commoncrawl/news-crawl

Metadata metadata = (Metadata) tuple.getValueByField("metadata");
byte[] content = tuple.getBinaryByField("content");
String url = tuple.getStringByField("url");

代码示例来源:origin: DigitalPebble/storm-crawler

byte[] content = tuple.getBinaryByField("content");
String url = tuple.getStringByField("url");
final Metadata metadata = (Metadata) tuple.getValueByField("metadata");

代码示例来源:origin: DigitalPebble/storm-crawler

@Override
public void execute(Tuple tuple) {
  Metadata metadata = (Metadata) tuple.getValueByField("metadata");
  byte[] content = tuple.getBinaryByField("content");
  String url = tuple.getStringByField("url");

代码示例来源:origin: DigitalPebble/storm-crawler

eventCounter.scope("tuple_in").incrBy(1);
byte[] content = tuple.getBinaryByField("content");

代码示例来源:origin: DigitalPebble/storm-crawler

@Override
public void execute(Tuple tuple) {
  Metadata metadata = (Metadata) tuple.getValueByField("metadata");
  byte[] content = tuple.getBinaryByField("content");
  String url = tuple.getStringByField("url");

代码示例来源:origin: commoncrawl/news-crawl

byte[] content = tuple.getBinaryByField("content");
String url = tuple.getStringByField("url");

相关文章