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

相关推荐
NiNg_1_23410 小时前
Spark常用的转化操作和动作操作详解
大数据·ajax·spark
岑梓铭16 小时前
(CentOs系统虚拟机)Standalone模式下安装部署“基于Python编写”的Spark框架
linux·python·spark·centos
Data跳动1 天前
Spark内存都消耗在哪里了?
大数据·分布式·spark
lucky_syq1 天前
流式处理,为什么Flink比Spark Streaming好?
大数据·flink·spark
goTsHgo1 天前
在 Spark 上实现 Graph Embedding
大数据·spark·embedding
程序猿小柒1 天前
【Spark】Spark SQL执行计划-精简版
大数据·sql·spark
隔着天花板看星星1 天前
Spark-Streaming集成Kafka
大数据·分布式·中间件·spark·kafka
lucky_syq3 天前
Spark和Hive的区别
大数据·hive·spark
隔着天花板看星星3 天前
Spark-Streaming receiver模式源码解析
大数据·分布式·spark