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

相关推荐
阿里云大数据AI技术12 小时前
EMR Serverless Spark 数据湖上新能力:一条 SQL 实现标量向量混合检索
人工智能·sql·spark
暴躁小师兄数据学院1 天前
【AI大数据工程师特训笔记】第16讲:大数据环境安装
大数据·hadoop·笔记·flink·spark·database
IDIOT___IDIOT2 天前
Docker 集群运行 Spark 的一些记录
docker·容器·spark
工业互联网专业3 天前
基于Spark的共享单车数据存储系统的设计与实现_flask+spider
spark·flask·毕业设计·源码·课程设计·spider·共享单车
X.AI6663 天前
英伟达RTX Spark发布:AI PC的下一战,不是跑分,而是本地Agent
大数据·人工智能·spark
KaMeidebaby4 天前
卡梅德生物技术快报|peg 修饰调控 MXene/WS2 异质结,氨气传感器制备与机理研究
大数据·前端·人工智能·架构·spark·新浪微博
零壹AI实验室4 天前
NVIDIA RTX Spark深度测评:个人AI智能体时代真的来了?
人工智能·ajax·spark
罗小罗同学5 天前
Nat Med发表SPARK智能体框架,可以自主思考、提出假设、设计实验并验证结果,让AI也能主动发现肿瘤生物学规律
大数据·人工智能·spark·医学图像处理
KaMeidebaby6 天前
卡梅德生物技术快报|Pull Down 实验在 lncRNA - 蛋白互作机制研究中的应用实例解析
大数据·前端·架构·spark·新浪微博
数据仓库_晨曦7 天前
【无标题】
大数据·sql·spark