org.apache.storm.utils.Utils.join()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(118)

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

Utils.join介绍

[英]Joins any number of maps together into a single map, combining their values into a list, maintaining values in the order the maps were passed in. Nulls are inserted for given keys when the map does not contain that key. i.e. joinMaps({'a' => 1, 'b' => 2}, {'b' => 3}, {'a' => 4, 'c' => 5}) -> {'a' => [1, null, 4], 'b' => [2, 3, null], 'c' => [null, null, 5]}
[中]将任意数量的映射合并到一个映射中,将它们的值合并到一个列表中,并按照映射传递的顺序维护值。当贴图不包含给定键时,会为该键插入空值。i、 e.joinMaps({'a'=>1,'b'=>2},{'b'=>3},{'a'=>4,'c'=>5})->{'a'=>[1,null,4],'b'=>[2,3,null],'c'=>[null,null,5]}

代码示例

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

void writeLine(PrintWriter writer) {
  List<String> line = new LinkedList<String>();
  for (String h : header) {
    line.add(metrics.get(h));
  }
  String str = Utils.join(line, ",");
  writer.println(str);
  writer.flush();
}

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

private static String getGroupName(Group g) {
  TreeMap<Integer, String> sortedNames = new TreeMap<>();
  for (Node n : g.nodes) {
    if (n.name != null) {
      sortedNames.put(n.creationIndex, n.name);
    }
  }
  List<String> names = new ArrayList<>();
  String prevName = null;
  for (String n : sortedNames.values()) {
    if (prevName == null || !n.equals(prevName)) {
      prevName = n;
      names.add(n);
    }
  }
  return Utils.join(names, "-");
}

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

void writeHeader(PrintWriter writer) {
  header.add(TIME);
  if (collectTopologyStats) {
    header.add(WORKERS);
    header.add(TASKS);
    header.add(EXECUTORS);
  }
  if (collectThroughput) {
    header.add(TRANSFERRED);
    header.add(XSFER_RATE);
  }
  if (collectSpoutThroughput) {
    header.add(SPOUT_EXECUTORS);
    header.add(SPOUT_TRANSFERRED);
    header.add(SPOUT_ACKED);
    header.add(SPOUT_THROUGHPUT);
  }
  if (collectSpoutLatency) {
    header.add(SPOUT_AVG_COMPLETE_LATENCY);
    header.add(SPOUT_MAX_COMPLETE_LATENCY);
  }
  writer.println(
    "\n------------------------------------------------------------------------------------------------------------------");
  String str = Utils.join(header, ",");
  writer.println(str);
  writer
    .println("------------------------------------------------------------------------------------------------------------------");
  writer.flush();
}

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

private static Map<Group, String> genBoltIds(Collection<Group> groups) {
  Map<Group, String> ret = new HashMap<>();
  int ctr = 0;
  for (Group g : groups) {
    if (!isSpoutGroup(g)) {
      List<String> name = new ArrayList<>();
      name.add("b");
      name.add("" + ctr);
      String groupName = getGroupName(g);
      if (groupName != null && !groupName.isEmpty()) {
        name.add(getGroupName(g));
      }
      ret.put(g, Utils.join(name, "-"));
      ctr++;
    }
  }
  return ret;
}

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

public Stream multiReduce(List<Fields> inputFields, List<Stream> streams, MultiReducer function, Fields outputFields) {
  List<String> names = new ArrayList<>();
  for (Stream s : streams) {
    if (s._name != null) {
      names.add(s._name);
    }
  }
  Node n = new ProcessorNode(getUniqueStreamId(), Utils.join(names, "-"), outputFields, outputFields,
                new MultiReducerProcessor(inputFields, function));
  return addSourcedNode(streams, n);
}

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

private static String getGroupName(Group g) {
  TreeMap<Integer, String> sortedNames = new TreeMap<>();
  for(Node n: g.nodes) {
    if(n.name!=null) {
      sortedNames.put(n.creationIndex, n.name);
    }
  }
  List<String> names = new ArrayList<>();
  String prevName = null;
  for(String n: sortedNames.values()) {
    if(prevName==null || !n.equals(prevName)) {
      prevName = n;
      names.add(n);
    }
  }
  return Utils.join(names, "-");
}

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

private static Map<Group, String> genBoltIds(Collection<Group> groups) {
  Map<Group, String> ret = new HashMap<>();
  int ctr = 0;
  for(Group g: groups) {
    if(!isSpoutGroup(g)) {
      List<String> name = new ArrayList<>();
      name.add("b");
      name.add("" + ctr);
      String groupName = getGroupName(g);
      if(groupName!=null && !groupName.isEmpty()) {
        name.add(getGroupName(g));                
      }
      ret.put(g, Utils.join(name, "-"));
      ctr++;
    }
  }
  return ret;
}

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

public Stream multiReduce(List<Fields> inputFields, List<Stream> streams, MultiReducer function, Fields outputFields) {
  List<String> names = new ArrayList<>();
  for(Stream s: streams) {
    if(s._name!=null) {
      names.add(s._name);
    }
  }
  Node n = new ProcessorNode(getUniqueStreamId(), Utils.join(names, "-"), outputFields, outputFields, new MultiReducerProcessor(inputFields, function));
  return addSourcedNode(streams, n);
}

相关文章

Utils类方法