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 的过程

相关推荐
D愿你归来仍是少年10 小时前
Apache Spark 从入门到精通:完整学习指南
大数据·spark
D愿你归来仍是少年12 小时前
Apache Spark Real-Time Mode 深度解析:打破微批次壁垒,挑战 Flink 的实时王座
flink·spark·apache
jerryinwuhan12 小时前
Spark 安装配置1
大数据·分布式·spark
sunxunyong1 天前
spark History Server 重启失败
大数据·分布式·spark
jerryinwuhan1 天前
Spark数据分析1_环境配置
大数据·数据分析·spark
我要用代码向我喜欢的女孩表白1 天前
spark介绍
大数据·分布式·spark
大大大大晴天2 天前
Hudi生产问题排障-insert overwrite 路径不存在
大数据·spark
Light602 天前
SPARK View:从“AI手工作坊”到“软件工业革命
大数据·人工智能·spark
潘达斯奈基~3 天前
Spark踩坑:如何优化pandas_udf中的多维数组传输效率
大数据·spark·pandas
最初的↘那颗心3 天前
Spark Job 调度机制拆解:从 Action 算子到 Task 执行
大数据·spark·分布式计算