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

相关推荐
大数据CLUB7 小时前
基于spark的航班价格分析预测及可视化
大数据·hadoop·分布式·数据分析·spark·数据可视化
Cachel wood10 天前
Spark教程6:Spark 底层执行原理详解
大数据·数据库·分布式·计算机网络·spark
大数据CLUB10 天前
基于pyspark的北京历史天气数据分析及可视化_离线
大数据·hadoop·数据挖掘·数据分析·spark
Cachel wood10 天前
Spark教程1:Spark基础介绍
大数据·数据库·数据仓库·分布式·计算机网络·spark
张昕玥2023032211910 天前
Spark应用开发--WordCount实战
大数据·spark
阳光下是个孩子10 天前
基于 Spark 实现 COS 海量数据处理
大数据·分布式·spark
GawynKing10 天前
Apache SeaTunnel Spark引擎执行流程源码分析
spark·源码·seatunnel
heart000_111 天前
大数据≠大样本:基于Spark的特征降维实战(提升10倍训练效率)
大数据·分布式·spark
254054652011 天前
710SJBH基于Apriori算法的学籍课程成绩关联规则挖掘研究
大数据·算法·spark
qq_4639448612 天前
【Spark征服之路-3.2-Spark-SQL核心编程(一)】
sql·ajax·spark