Spark Plan 之 SQLMetric

SQLMetric

Spark Plan 包含以下基本 方法,

复制代码
  /**
   * @return All metrics containing metrics of this SparkPlan.
   */
  def metrics: Map[String, SQLMetric] = Map.empty

  /**
   * @return [[SQLMetric]] for the `name`.
   */
  def longMetric(name: String): SQLMetric = metrics(name)
BytesToBytesMap
复制代码
public final class BytesToBytesMap extends MemoryConsumer {

  /**
   * Returns the average number of probes per key lookup.
   */
  public double getAvgHashProbesPerKey() {
    return (1.0 * numProbes) / numKeyLookups;
  }

  /**
   * Looks up a key, and saves the result in provided `loc`.
   *
   * This is a thread-safe version of `lookup`, could be used by multiple threads.
   */
  public void safeLookup(Object keyBase, long keyOffset, int keyLength, Location loc, int hash) {
    assert(longArray != null);

    numKeyLookups++;

    int pos = hash & mask;
    int step = 1;
    while (true) {
      numProbes++;
      if (longArray.get(pos * 2) == 0) {
        // This is a new key.
        loc.with(pos, hash, false);
        return;
      } else {
        long stored = longArray.get(pos * 2 + 1);
        if ((int) (stored) == hash) {
          // Full hash code matches.  Let's compare the keys for equality.
          loc.with(pos, hash, true);
          if (loc.getKeyLength() == keyLength) {
            final boolean areEqual = ByteArrayMethods.arrayEquals(
              keyBase,
              keyOffset,
              loc.getKeyBase(),
              loc.getKeyOffset(),
              keyLength
            );
            if (areEqual) {
              return;
            }
          }
        }
      }
      pos = (pos + step) & mask;
      step++;
    }
  }

这里, hashprobe 本质上就是一个 hash lookup 的过程

相关推荐
什么芮.1 小时前
Kafka和flume整合
spark·kafka·flume
2401_871290589 小时前
如何在idea中写spark程序
大数据·spark·intellij-idea
只因只因爆9 小时前
如何在idea中写spark程序
java·spark·intellij-idea
!chen11 小时前
Hadoop和Spark大数据挖掘与实战
hadoop·数据挖掘·spark
漂流瓶66666612 小时前
如何搭建spark yarn 模式的集群
大数据·spark·eclipse
啊喜拔牙13 小时前
如何搭建spark yarn模式的集群
大数据·分布式·spark
yuhuhuh16 小时前
如何在idea中写spark程序
ajax·spark·intellij-idea
anqi2716 小时前
如何在 IntelliJ IDEA 中编写 Speak 程序
java·大数据·开发语言·spark·intellij-idea
刘翔在线犯法18 小时前
如何搭建spark yarn模式的集合集群
大数据·分布式·spark
富能量爆棚18 小时前
如何搭建spark yarn 模式的集群
大数据·javascript·spark