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

相关推荐
Thomas21431 天前
spark view永久保存 + paimon对应的view
大数据·分布式·spark
徐先生 @_@|||1 天前
大数据技术演进(从传统Hadoop到Spark到云原生的技术演进路径)
大数据·hadoop·spark
petrel20151 天前
【Spark 核心内参】2025.10:从 Parquet 谓词下推的“度”到语义建模的“野心”
大数据·spark
查士丁尼·绵1 天前
hadoop集群存算分离
hive·hdfs·zookeeper·spark·hbase·yarn·galera
鸿乃江边鸟2 天前
Spark Datafusion Comet 向量化Rule--CometExecRule Shuffle分析
大数据·spark·native·arrow
!chen4 天前
大数据技术领域发展与Spark的性能优化
大数据·性能优化·spark
大鳥4 天前
Hive on Spark SQL 性能优化权威指南
hive·sql·spark
Lansonli4 天前
大数据Spark(七十七):Action行动算子first、collect和collectAsMap使用案例
大数据·分布式·spark
计算机毕业编程指导师4 天前
【计算机毕设选题】基于Spark的拉勾网招聘数据分析系统源码,Python+Django全流程
大数据·hadoop·python·spark·django·招聘·拉勾网
m0_748254666 天前
Perl 变量类型
spark·scala·perl