搜尋
首頁資料庫mysql教程HBase intra row scanning

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
在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中集成hbaseMay 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

熱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.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具