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

相关推荐
技术吧1 天前
Spark-TTS: AI语音合成的“变声大师“
大数据·人工智能·spark
MyikJ4 天前
Java互联网大厂面试:从Spring Boot到Kafka的技术深度探索
java·spring boot·微服务·面试·spark·kafka·spring security
向哆哆4 天前
Java 大数据处理:使用 Hadoop 和 Spark 进行大规模数据处理
java·hadoop·spark
阿里云大数据AI技术4 天前
Fusion引擎赋能:流利说如何用阿里云Serverless Spark实现数仓计算加速
大数据·人工智能·阿里云·spark·serverless·云计算
Matrix704 天前
大数据量下的数据修复与回写Spark on Hive 的大数据量主键冲突排查:COUNT(DISTINCT) 的陷阱
大数据·hive·spark
weixin_307779135 天前
Apache SeaTunnel 引擎深度解析:原理、技术与高效实践
大数据·flink·spark·数据库开发·etl
wuli玉shell5 天前
spark shuffle的分区支持动态调整,而hive不支持
大数据·hive·spark
程序员阿龙6 天前
基于大数据的个性化购房推荐系统设计与实现(源码+定制+开发)面向房产电商的智能购房推荐与数据可视化系统 基于Spark与Hive的房源数据挖掘与推荐系统设计
大数据·数据挖掘·spark·用户画像·hadoop生态·spark mllib·房源数据爬虫
NON-JUDGMENTAL6 天前
PySpark 中使用 SQL 语句和表进行计算
python·spark
itachi-uchiha7 天前
Docker部署Spark大数据组件:配置log4j日志
spark