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

相关推荐
乌恩大侠8 小时前
DGX Spark 恢复系统
大数据·分布式·spark
梦里不知身是客111 天前
spark读取table中的数据【hive】
大数据·hive·spark
赞奇科技Xsuperzone1 天前
DGX Spark 实战解析:模型选择与效率优化全指南
大数据·人工智能·gpt·spark·nvidia
更深兼春远1 天前
Spark on Yarn安装部署
大数据·分布式·spark
涤生大数据2 天前
日均亿级数据的实时分析:Doris如何接过Spark的接力棒?
大数据·spark·doris·实时计算·大数据开发·实时分析·实时技术
Hello.Reader2 天前
Spark RDD 编程从驱动程序到共享变量、Shuffle 与持久化
大数据·分布式·spark
梦里不知身是客113 天前
sparkSQL读取数据的方式
spark
少废话h3 天前
Spark 中数据读取方式详解:SparkSQL(DataFrame)与 SparkCore(RDD)方法对比及实践
大数据·sql·spark
大千AI助手4 天前
分布式奇异值分解(SVD)详解
人工智能·分布式·spark·奇异值分解·svd·矩阵分解·分布式svd
Hello.Reader4 天前
用 Spark Shell 做交互式数据分析从入门到自包含应用
大数据·数据分析·spark