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

相关推荐
yumgpkpm1 小时前
腾讯云TBDS与CDH迁移常见问题有哪些?建议由CDH迁移到CMP 7.13 平台(类Cloudera CDP,如华为鲲鹏 ARM 版)
hive·hadoop·zookeeper·flink·spark·kafka·hbase
bigdata-rookie1 天前
Spark 部署模式
大数据·分布式·spark
sheji34161 天前
【开题答辩全过程】以 基于Spark的药品库存可视化分析系统为例,包含答辩的问题和答案
大数据·分布式·spark
larance1 天前
spark-submit 常用方式
大数据·spark
A尘埃1 天前
Spark基于内存计算的数据处理
大数据·分布式·spark
bigdata-rookie2 天前
Flink Checkpoint 和 Spark Checkpoint 的区别
大数据·flink·spark
灯下夜无眠2 天前
conda打包环境上传spark集群
大数据·spark·conda
杂家2 天前
Hive on Spark && Spark on Hive配置
大数据·数据仓库·hive·hadoop·spark
bigdata-rookie2 天前
Spark SQL 简介
大数据·sql·spark
lhyzws3 天前
CENTOS上的网络安全工具(二十八)SPARK+NetSA Security Tools容器化部署(4)
linux·spark·centos