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
相关推荐
【Spark大数据习题】习题_Spark SQL&&&Kafka&& HBase&&HivePDF资源路径-Spark2PDF资源路径-Spark2
【Spark大数据习题】习题_Spark SQL&&&Kafka&& HBase&&HiveSpark第二次小测Spark第二次小测Spark第二次小测
⼤数据时代数据库-云HBase架构&⽣态&实践_阿里云
⼤数据时代数据库-云HBase架构&⽣态&实践_阿里云.pdf
两本书, 每本下载1积分, 两本2积分: 第一本: Architecting HBase Applications A GUIDEBOOK FOR SUCCESSFUL DEVELOPMENT AND DESIGN 第二本: HBase Design Patterns
HADOOP&ZK&HBASE&YCSB集群搭建验证
批量执行hbase shell 命令 #!/bin/bash source /etc/profile exec $HBASE_HOME/bin/hbase shell <<EOF truncate 'tracker_total_apk_fact_zyt' major_compact('t_abc') disable 't_abc' drop 't_abc' create...
本文来自于yq.aliyun.com,主要内容有三个方面:首先介绍了业务挑战带来的架构演进,其次分析了ApsaraDBHBase及生态,最后分享了大数据数据库的实际案例。...这个时候MySQL变成了HBase,检索变成了Solr
藏经阁-Use CCSMap to Improve HBase YGC Time & Efforts on SLA improv
NULL 博文链接:https://lingqi1818.iteye.com/blog/908466
一个Vagrantfile,用于启动和运行Hadoop和HBase开发。 概述 该项目的目的是在短短几分钟内建立一个可用于Hadoop和HBase开发的虚拟机。 VM是Ubuntu 14.04(可信任)盒,已通过。 在运行了vagrant up ,将以伪分布式...
java 利用 sping-data-hadoop HbaseTemplate 操作hbase find get execute 等方法 可以直接运行
搭建pinpoint需要的hbase初始化脚本hbase-create.hbase
HBase(hbase-2.4.9-bin.tar.gz)是一个分布式的、面向列的开源数据库,该技术来源于 Fay Chang 所撰写的Google论文“Bigtable:一个结构化数据的分布式存储系统”。就像Bigtable利用了Google文件系统(File System...
1. HBase有哪些基本的特征? 1 HBase特征: 1 2. HBase相对于关系数据库能解决的问题是什么? 2 HBase与关系数据的区别? 2 HBase与RDBMS的区别? 2 3. HBase的数据模式是怎么样的?即有哪些元素?如何存储?等 3 1...
Nosql&hbase;原理,深度分析了为什么要用hbase?hbase的优缺点,适用场景
SpringBootDemo 2018.06.08 -完成整合Hbase 2.0.0 API,kafka 0.8 API,redis 2.9.0 API单机和集群,增加redis集群key超时失效监听 2018.07.16 -完成企业级maven依赖,以后扩展,将采用子模块形式
hbase-sdk是基于hbase-client和hbase-thrift的原生API封装的一款轻量级的HBase ORM框架。 针对HBase各版本API(1.x~2.x)间的差异,在其上剥离出了一层统一的抽象。并提供了以类SQL的方式来读写HBase表中的数据。对...
注意:zookeeper3.4.13和hbase2.3.5都是采用docker-compose方式部署 原文链接:https://blog.csdn.net/m0_37814112/article/details/120915194 说明:使用外部zookeeper3.4.13之hbase2.3.5一键部署工具,支持部署、...