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

相关推荐
云器科技19 小时前
NinjaVan x 云器Lakehouse: 从传统自建Spark架构升级到新一代湖仓架构
大数据·ai·架构·spark·湖仓平台
是阿威啊1 天前
【用户行为归因分析项目】- 【企业级项目开发第一站】项目架构和需求设计
大数据·hive·hadoop·架构·spark·scala
qq_12498707531 天前
基于spark的西南天气数据的分析与应用(源码+论文+部署+安装)
大数据·分布式·爬虫·python·spark·毕业设计·数据可视化
心止水j1 天前
spark rdd
大数据·分布式·spark
小白学大数据2 天前
海量小说数据采集:Spark 爬虫系统设计
大数据·开发语言·爬虫·spark
嘉禾望岗5032 天前
Spark-Submit参数介绍及任务资源使用测试
大数据·分布式·spark
ha_lydms2 天前
5、Spark函数_s/t
java·大数据·python·spark·数据处理·maxcompute·spark 函数
嘉禾望岗5033 天前
spark算子类型
大数据·分布式·spark
是阿威啊4 天前
【maap-analysis】spark离线数仓项目完整的开发流程
大数据·分布式·spark·scala
ha_lydms5 天前
3、Spark 函数_d/e/f/j/h/i/j/k/l
大数据·分布式·spark·函数·数据处理·dataworks·maxcompute