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

相关推荐
随缘而动,随遇而安11 小时前
第九十八篇 工程落地视角:Session/Cookie/Token 原理辨析与大数据实战
大数据·spark·token·cookie·session
霑潇雨2 天前
Spark学习基础转换算子案例(单词计数(WordCount))
java·大数据·分布式·学习·spark·maven
zhojiew2 天前
使用 Spark Connect 在 Amazon EMR on EC2 上实现远程 Spark开发
大数据·分布式·spark
大江东去浪淘尽千古风流人物2 天前
【Kimera】MIT SPARK 实时度量-语义 SLAM 全栈解析:VIO + 鲁棒 PGO + 语义网格四模块架构与 EuRoC 实测深度剖析
大数据·架构·spark
大江东去浪淘尽千古风流人物2 天前
【Kimera-VIO】MIT SPARK 实时度量-语义 VIO/SLAM:六模块并行架构与智能因子图优化深度解析
大数据·架构·spark
大江东去浪淘尽千古风流人物2 天前
【Kimera-Semantics】实时三维语义重建深度解析:Fast/Merged 双路积分、对数概率体素 Bayesian 融合与 ROS 全链路实现
大数据·架构·spark
陆水A4 天前
运输时效预测模型:静态路由时效的计算与验证
大数据·人工智能·算法·spark·数据库开发·etl工程师
SeaTunnel4 天前
Apache SeaTunnel 4 月有何新动作?连接器增强与 Zeta 稳定性提升等亮点速览
大数据·数据仓库·spark·apache·seatunnel
淡定一生23334 天前
spark 3.3+ 之BloomFilter Runtime Filter
大数据·分布式·spark