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

相关推荐
BYSJMG5 小时前
大数据毕业设计选题推荐:基于大数据的全球气温历史演变分析与可视化,用Hadoop+Spark处理
大数据·hadoop·分布式·信息可视化·spark·kmeans·课程设计
IT研究室6 小时前
最新大数据毕业设计选题推荐-基于大数据的水质多指标关联分析与可视化的设计与实现-大数据-Spark-Hadoop-Bigdata
大数据·spark·课程设计
用户3610588626121 天前
SparkStreaming 之配置参数详解
大数据·spark
用户3610588626121 天前
SparkStreaming 之 Direct 模式并行度设置与 offset 管理
大数据·spark
BYSJMG1 天前
计算机毕业设计选题推荐|【基于大数据的植被光谱特征与环境因子关联分析及可视化】Spark+K-Means
大数据·python·信息可视化·数据分析·spark·kmeans·课程设计
阿里云大数据AI技术2 天前
EMR Serverless Spark多模态 Daft 算子市场免费公测 | 10分钟极速实战(附视频教程)
人工智能·spark
IT研究室2 天前
最新大数据毕业设计选题推荐-基于大数据的京东商品销售分析与可视化的设计与实现-大数据-Spark-Hadoop-Bigdata
大数据·spark·课程设计
用户3610588626123 天前
SparkStreaming 之 Driver HA 原理及搭建实操
大数据·spark
腾讯云大数据3 天前
AI Native数据湖的Spark+Ray一体化实践
大数据·人工智能·spark·腾讯云·腾讯云大数据