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

相关推荐
Q26433650235 小时前
【有源码】spark与hadoop-情感挖掘+画像建模的携程酒店评价数据分析可视化系统-基于机器学习的携程酒店评价情感分析与竞争态势可视化
大数据·hadoop·python·机器学习·数据分析·spark·毕业设计
Just_Do_IT_OK1 天前
Docker--Spark
docker·容器·spark
会编程的李较瘦1 天前
【Spark学习】数据清洗
学习·ajax·spark
百度Geek说2 天前
百度大数据成本治理实践
hadoop·spark
梦里不知身是客113 天前
sparkSQL连接报错的一个解决方法
spark
源码之家3 天前
基于Python房价预测系统 数据分析 Flask框架 爬虫 随机森林回归预测模型、链家二手房 可视化大屏 大数据毕业设计(附源码)✅
大数据·爬虫·python·随机森林·数据分析·spark·flask
2501_941142643 天前
云计算与大数据:现代企业数字化转型的双引擎
spark
Saniffer_SH3 天前
通过近期测试简单聊一下究竟是直接选择Nvidia Spark还是4090/5090 GPU自建环境
大数据·服务器·图像处理·人工智能·驱动开发·spark·硬件工程
Q26433650233 天前
【有源码】基于Python的睡眠压力监测分析系统-基于Spark数据挖掘的睡眠压力动态可视化分析系统
大数据·hadoop·python·机器学习·数据挖掘·spark·课程设计
阳爱铭4 天前
ClickHouse 中至关重要的两类复制表引擎——ReplicatedMergeTree和 ReplicatedReplacingMergeTree
大数据·hive·hadoop·sql·clickhouse·spark·hbase