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

相关推荐
chaofan98012 小时前
Meta Muse Spark 深度解构:并联智能体架构与开发者接入实战指南
大数据·架构·spark
初遇见12 小时前
【DGX Spark v3.0:基于多智能体交互网络与 Alpaca 实盘集成的企业级量化交易系统】
大数据·网络·spark·nvidia
talen_hx2962 天前
《零基础入门Spark》学习笔记 Day 13
笔记·学习·spark
zml.~2 天前
基于 Spark 的新能源汽车大数据分析全流程实践
数据分析·spark·汽车
zml.~2 天前
Spark 数据分析:从核心原理到企业级实战全解析
大数据·数据挖掘·数据分析·spark
zml.~2 天前
大数据分析实战:基于 Spark 的新能源汽车全链路数据分析指南
大数据·数据分析·spark·汽车
talen_hx2963 天前
《零基础入门Spark》学习笔记 Day 12
笔记·学习·spark
橘子编程4 天前
Spark全栈指南:从入门到精通
大数据·分布式·spark
zxfBdd4 天前
Spark Map算子异常处理方法
大数据·分布式·spark