首页 数据库 mysql教程 HBase intra row scanning

HBase intra row scanning

Jun 07, 2016 pm 04:26 PM
hbase

By Lars Hofhansl Updated (again) Wednesday, January 25th, 2012. As I painfully worked through HBASE-5229 I realized that HBase already has all the building blocks needed for complex (local) transactions. What's important here is that (see

By Lars Hofhansl

Updated (again) Wednesday, January 25th, 2012.

As I painfully worked through HBASE-5229 I realized that HBase already has all the building blocks needed for complex (local) transactions.

What's important here is that (see my introduction to HBase):
  1. HBase ensures atomicity for operations for the same row key
  2. HBase keys have internal structure: (row-key, column family, column, ...)
The missing piece was ColumnRangeFilter. With this filter it is possible to retrieve all columns whose identifier starts with "abc", or all columns whose identifier sorts > "test". For example:

// all columns whose identifier starts with "abc"
Filter f = new ColumnRangeFilter(Bytes.toBytes("abc"), true,
Bytes.toBytes("abd"), false);

// all columns whose identifier sorts after "test"
Filter f = new ColumnRangeFilter(Bytes.toBytes("test"), true,
null, true);


So this allows to search (scan) inside a row by column identifier just  as HBase allows searching by row key.

A client application can exploit this to achieve transactions by grouping all entities that can participate in the same transaction into a single row (and single column family).
Then using prefixes of the column identifiers can be used to define rows inside that group. Basically the search criteria for keys was moved one level down to the column identifier.

Say we wanted to implement a store with transactional tables that contain rows and columns. One way to doing this with HBase as follows:
  • the HBase row-key/column-family maps to a "table"
  • a prefix of the HBase column identifier maps to a "row"
  • the rest of the HBase column identifier identifies the "column"
This is in fact similar to what Google's Megastore (pdf) does.

This leads to potentially wide HBase rows with many columns. The missing piece is allowing a Scan to efficiently retrieve a slice of a wide row.

This where ColumnRangeFilter comes into play. This filter seeks efficiently into the row by seeking ahead to the first HBase block that contains the first KeyValue (or cell) for that column.

Let's model a table "pets" this way. And let's say a pet has a name and a species. The HBase key for entries would look like this:
(table, CF1, rowA|column1) -> value for column1 in rowA
The code would look something like this:
(apologies for the initial incorrect code that I had posted here)

HTable t = ...;
Scan s = ...;
s.setStartRow("pets");
s.setStopRow("pets");
// get all columns for my pet "fluffy".
Filter f = new ColumnRangeFilter(Bytes.toBytes("fluffy"), true,
                                 Bytes.toBytes("fluffz"), false);
s.setFilter(f);
s.setBatch(20); // avoid getting all columns for the HBase row
ResultScanner rs = t.getScanner(s);
for (Result r = rs.next(); r != null; r = rs.next()) {

  // r will now have all HBase columns that start with "fluffy",

  // which would represent a single row
  for (KeyValue kv : r.raw()) {
    // each kv represent - the latest version of - a column
  }
}

The downside of this is that HBase achieves atomicity by collocating all cells with the same row-key, so it has to be hosted by a single region server.
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌
威尔R.E.P.O.有交叉游戏吗?
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

在Beego中使用Hadoop和HBase进行大数据存储和查询 在Beego中使用Hadoop和HBase进行大数据存储和查询 Jun 22, 2023 am 10:21 AM

随着大数据时代的到来,数据处理和存储变得越来越重要,如何高效地管理和分析大量的数据也成为企业面临的挑战。Hadoop和HBase作为Apache基金会的两个项目,为大数据存储和分析提供了一种解决方案。本文将介绍如何在Beego中使用Hadoop和HBase进行大数据存储和查询。一、Hadoop和HBase简介Hadoop是一个开源的分布式存储和计算系统,它可

怎么在springboot中集成hbase 怎么在springboot中集成hbase May 30, 2023 pm 04:31 PM

依赖:org.springframework.dataspring-data-hadoop-hbase2.5.0.RELEASEorg.apache.hbasehbase-client1.1.2org.springframework.dataspring-data-hadoop2.5.0.RELEASE增加配置官方提供的方式是通过xml方式,简单改写后如下:@ConfigurationpublicclassHBaseConfiguration{@Value("${hbase.zooke

如何使用Java开发一个基于HBase的NoSQL数据库应用 如何使用Java开发一个基于HBase的NoSQL数据库应用 Sep 20, 2023 am 08:39 AM

如何使用Java开发一个基于HBase的NoSQL数据库应用引言:随着大数据时代的到来,NoSQL数据库成为处理海量数据的重要工具之一。HBase作为一种开源的分布式NoSQL数据库系统,在大数据领域具有广泛的应用。本文将介绍如何使用Java来开发基于HBase的NoSQL数据库应用,并提供具体的代码示例。一、HBase介绍:HBase是基于Hadoop的分

在Go语言中使用HBase实现高效的NoSQL数据库应用 在Go语言中使用HBase实现高效的NoSQL数据库应用 Jun 15, 2023 pm 08:56 PM

随着大数据时代的到来,海量数据的存储和处理显得尤为重要。在NoSQL数据库方面,HBase是目前广泛应用的一种解决方案。Go语言作为一种静态强类型编程语言,由于其语法简单、性能优秀,被越来越多地应用于云计算、网站开发和数据科学等领域。本文将介绍如何在Go语言中使用HBase来实现高效的NoSQL数据库应用。HBase介绍HBase是一个高可扩展、高可靠性、基

PHP和Apache HBase集成实现NoSQL数据库和分布式存储 PHP和Apache HBase集成实现NoSQL数据库和分布式存储 Jun 25, 2023 pm 06:01 PM

随着互联网应用和数据量的不断增长,传统的关系型数据库已经不能满足存储和处理海量数据的需求。而NoSQL(NotOnlySQL)作为一种新型的数据库管理系统,其能够在海量数据存储和处理方面具有显著的优势,得到越来越多的关注和应用。在NoSQL数据库中,ApacheHBase是一个非常流行的开源分布式数据库,它基于Google的BigTable思想设计,具

在Beego中使用HBase进行数据存储和查询 在Beego中使用HBase进行数据存储和查询 Jun 22, 2023 am 11:58 AM

在Beego框架中使用HBase进行数据存储和查询随着互联网时代的不断发展,数据储存和查询变得越来越关键。大数据时代来临,各种数据源都在各自不同的领域占据着重要地位,其中非关系型数据库是一种在数据存储和查询方面优势明显的数据库,而HBase是一种基于Hadoop的分布式非关系型数据库。本文将介绍如何在Beego框架中使用HBase进行数据存储和查询。一、H

如何在Workerman中使用HBase进行数据存储与查询 如何在Workerman中使用HBase进行数据存储与查询 Nov 07, 2023 am 08:30 AM

Workerman是一款高性能的PHPsocket框架,它的特点是可以承载大量的并发连接。与传统的PHP框架不同的是,Workerman不依赖于Apache或Nginx等Web服务器,而是通过开启一个PHP进程,独自运行整个应用程序。Workerman具有极高的运行效率和更好的负载能力。与此同时,HBase是一个分布式的NoSQL数据库系统,广泛应用于大数

了解 HBase 缓存技术 了解 HBase 缓存技术 Jun 20, 2023 pm 07:15 PM

HBase是一个基于Hadoop的分布式存储系统,旨在存储和处理大规模结构化数据。为了优化它的读写性能,HBase提供了多种缓存机制,可以通过合理的配置来提高查询效率,减少读写延迟。本文将介绍HBase缓存技术以及如何进行配置。HBase缓存种类HBase提供了两种基本缓存机制:块缓存(BlockCache)和MemStore缓存(也称为写缓存)。块缓存是在

See all articles