`

HBase scannerCaching&caching

阅读更多

HBase Version: hbase-0.94.6-cdh4.3.0

在HBase Scan中有一优化: 使用 scannerCaching&caching.

意思是HBaseClient从HBase服务器一次取得多少条数据回来,减少从服务器来回取数据的次数,可以设置一次从HBase服务器取scannerCaching&caching条数据.

其中scannerCaching是HTable的属性;caching是Scan的属性;

在HTable源码中可以发现, 此两个方法都已经过时了.

public class HTable implements HTableInterface {
  protected int scannerCaching;
  /**
   * Gets the number of rows that a scanner will fetch at once.
   * <p>
   * The default value comes from {@code hbase.client.scanner.caching}.
   * @deprecated Use {@link Scan#setCaching(int)} and {@link Scan#getCaching()}
   */
  public int getScannerCaching() {
    return scannerCaching;
  }

  /**
   * Sets the number of rows that a scanner will fetch at once.
   * <p>
   * This will override the value specified by
   * {@code hbase.client.scanner.caching}.
   * Increasing this value will reduce the amount of work needed each time
   * {@code next()} is called on a scanner, at the expense of memory use
   * (since more rows will need to be maintained in memory by the scanners).
   * @param scannerCaching the number of rows a scanner will fetch at once.
   * @deprecated Use {@link Scan#setCaching(int)}
   */
  public void setScannerCaching(int scannerCaching) {
    this.scannerCaching = scannerCaching;
  }
}

 要我们在使用中, 使用Scan的{@link Scan#setCaching(int)} and {@link Scan#getCaching()}

通过HTable源码知道, HTable进行Scan时调用, 返回ResultScanner,再对查询出的ResultScanner进行处理; 

   /**
    * {@inheritDoc}
    */
  @Override
  public ResultScanner getScanner(final Scan scan) throws IOException {
    if (scan.getCaching() <= 0) {
      scan.setCaching(getScannerCaching());
    }
    return new ClientScanner(getConfiguration(), scan, getTableName(),
        this.connection);
  }

 通过上面代码知道,HBase HTable设置的scannerCaching是赋值到scan上的.

1. 在ClientScanner代码中获取了从HTable中过来的scannerCaching; 

2. 当然如果HTable中过来的scannerCaching;没有设置(scannerCaching=0); 则ClientScanner中的caching保留原值; 

    /**
     * Create a new ClientScanner for the specified table
     * Note that the passed {@link Scan}'s start row maybe changed changed. 
     * 
     * @param conf The {@link Configuration} to use.
     * @param scan {@link Scan} to use in this scanner
     * @param tableName The table that we wish to scan
     * @param connection Connection identifying the cluster
     * @throws IOException
     */
    public ClientScanner(final Configuration conf, final Scan scan,
      final byte[] tableName, HConnection connection) throws IOException {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Creating scanner over "
            + Bytes.toString(tableName)
            + " starting at key '" + Bytes.toStringBinary(scan.getStartRow()) + "'");
      }
      this.scan = scan;
      this.tableName = tableName;
      this.lastNext = System.currentTimeMillis();
      this.connection = connection;
      this.maxScannerResultSize = conf.getLong(
          HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY,
          HConstants.DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE);
      this.scannerTimeout = (int) conf.getLong(
          HConstants.HBASE_REGIONSERVER_LEASE_PERIOD_KEY,
          HConstants.DEFAULT_HBASE_REGIONSERVER_LEASE_PERIOD);

      // check if application wants to collect scan metrics
      byte[] enableMetrics = scan.getAttribute(
        Scan.SCAN_ATTRIBUTES_METRICS_ENABLE);
      if (enableMetrics != null && Bytes.toBoolean(enableMetrics)) {
        scanMetrics = new ScanMetrics();
      }

      // Use the caching from the Scan.  If not set, use the default cache setting for this table.
      if (this.scan.getCaching() > 0) {
        this.caching = this.scan.getCaching();
      } else {
        this.caching = conf.getInt("hbase.client.scanner.caching", 1);
      }

      // initialize the scanner
      nextScanner(this.caching, false);
    }

 3. 还有一个地方就是如果没有设置1和2(HTable和Scan都没有设置 scannerCaching&caching),;

     杯具就来了:使用默认的hbase.client.scanner.caching=1

0
1
分享到:
评论

相关推荐

    【Spark大数据习题】习题-Spark SQL&&&Kafka&& HBase&&HiveSpark第二次小测

    【Spark大数据习题】习题_Spark SQL&&&Kafka&& HBase&&HiveSpark第二次小测Spark第二次小测Spark第二次小测

    ⼤数据时代数据库-云HBase架构&⽣态&实践_阿里云.pdf

    【大数据时代数据库-云HBase架构&生态&实践】阿里云的高级技术专家封神(曹龙)在DTCC2018大会上分享了关于大数据数据库的最新实践,特别是聚焦于云HBase的架构、生态及其在实际业务中的应用。云HBase作为大数据存储...

    Architecting HBase Applications&HBase;.Design.Patterns两本书

    两本书, 每本下载1积分, 两本2积分: 第一本: Architecting HBase Applications A GUIDEBOOK FOR SUCCESSFUL DEVELOPMENT AND DESIGN 第二本: HBase Design Patterns

    ⼤数据时代数据库-云HBase架构&⽣态&实践_阿里云.zip

    云HBase作为一款由阿里云提供的分布式列式存储系统,已经成为了众多企业和开发者在大数据领域的重要选择。本文将深入探讨云HBase的架构、生态系统以及实际应用实践。 一、云HBase架构 1. 分布式存储:云HBase基于...

    HADOOP&ZK&HBASE&YCSB集群搭建验证

    HADOOP&ZOOKEEPER&HBASE&YCSB集群搭建验证 HADOOP&ZOOKEEPER&HBASE&YCSB集群搭建验证是大数据处理和存储的关键技术栈。该技术栈主要包括四个组件:HADOOP、ZOOKEEPER、HBASE 和 YCSB。了解这些技术的搭建和验证是大...

    hbase-shell批量命令执行脚本的方法

    批量执行hbase shell 命令 #!/bin/bash source /etc/profile exec $HBASE_HOME/bin/hbase shell &lt;&lt;EOF truncate 'tracker_total_apk_fact_zyt' major_compact('t_abc') disable 't_abc' drop 't_abc' create...

    hbase&hadoop初探

    标题中的“hbase&hadoop初探”表明我们将要探讨的是大数据处理领域中的两个关键组件:HBase和Hadoop。这两个技术是Apache软件基金会的重要项目,对于理解和掌握大数据存储与处理有着至关重要的作用。 首先,Hadoop...

    藏经阁-Use CCSMap to Improve HBase YGC Time & Efforts on SLA improv

    "藏经阁-Use CCSMap to Improve HBase YGC Time & Efforts on SLA improv" CCSMap 是阿里云开发的一种高效的内存管理技术,用于改进 HBase 的 YGC 时间和努力,并提高 SLA 改进。下面是 CCSMap 的详细知识点: 为...

    vagrant-hbase:一个Vagrantfile来启动和运行Hadoop和HBase开发

    一个Vagrantfile,用于启动和运行Hadoop和HBase开发。 概述 该项目的目的是在短短几分钟内建立一个可用于Hadoop和HBase开发的虚拟机。 VM是Ubuntu 14.04(可信任)盒,已通过。 在运行了vagrant up ,将以伪分布式...

    HbaseTemplate 操作hbase

    在IT行业中,尤其是在大数据处理领域,HBase是一个广泛使用的分布式、高性能、列式存储的NoSQL数据库。HBase是建立在Hadoop文件系统(HDFS)之上,为处理大规模数据提供了一个高效的数据存储解决方案。而Spring Data...

    pinpoint的hbase初始化脚本hbase-create.hbase

    搭建pinpoint需要的hbase初始化脚本hbase-create.hbase

    HBase(hbase-2.4.9-bin.tar.gz)

    HBase(hbase-2.4.9-bin.tar.gz)是一个分布式的、面向列的开源数据库,该技术来源于 Fay Chang 所撰写的Google论文“Bigtable:一个结构化数据的分布式存储系统”。就像Bigtable利用了Google文件系统(File System...

    hbase用于查询客户端工具

    HBase是一种分布式、基于列族的NoSQL数据库,它在大数据领域中扮演着重要的角色,尤其是在需要实时查询大规模数据集时。HBase以其高吞吐量、低延迟和水平扩展能力而闻名,常用于存储非结构化和半结构化数据。在HBase...

    hbase配置内置的zookeeper

    ### HBase 配置内置 ZooKeeper 的详细步骤与解析 #### 一、配置背景与目的 在 HBase 的部署环境中,ZooKeeper 起着非常重要的作用,它主要用于协调集群中的各个节点,并且管理 HBase 的元数据。通常情况下,HBase ...

    Hbase权威指南(HBase: The Definitive Guide)

    ### HBase权威指南知识点概述 #### 一、引言与背景 - **大数据时代的来临**:随着互联网技术的发展,人类社会产生了前所未为的数据量。这些数据不仅数量巨大,而且种类繁多,传统的数据库系统难以应对这样的挑战。 ...

    HBase开启审计日志

    ### HBase开启审计日志详解 #### 一、概述 HBase是一款分布式列式存储系统,基于Google的Bigtable论文实现。它具有高可靠性、高性能、面向列、可伸缩的特点,非常适合处理海量数据。在大数据领域,HBase被广泛用于...

    基于springboot集成hbase过程解析

    "基于SpringBoot集成HBase过程解析" SpringBoot集成HBase是当前大数据处理和存储解决方案中的一种常见组合。HBase是基于Hadoop的分布式、可扩展的NoSQL数据库,能够存储大量的结构化和非结构化数据。SpringBoot则...

    hbase-2.4.17-bin 安装包

    HBase是Apache Hadoop生态系统中的一个分布式、版本化、列族式存储系统,设计用于处理大规模数据集。这个“hbase-2.4.17-bin”安装包提供了HBase的最新稳定版本2.4.17,适用于大数据处理和分析场景。下面将详细介绍...

Global site tag (gtag.js) - Google Analytics