54958

Simple integer comparison in HBase

Question:

I am trying out a very simple example in HBase. Following is how I create table and put data:

create 'newdb3','data' put 'newdb3','row1','data:name','Thexxx Beatles' put 'newdb3','row2','data:name','The Beatles' put 'newdb3','row3','data:name','Beatles' put 'newdb3','row4','data:name','Thexxx' put 'newdb3','row1','data:duration',400 put 'newdb3','row2','data:duration',300 put 'newdb3','row3','data:duration',200 put 'newdb3','row4','data:duration',100 scan 'newdb3', {COLUMNS => 'data:name', FILTER => "SingleColumnValueFilter('data','duration', > ,'binaryprefix:200')"}

But the result is always all 4 columns. I tried number with or without string, and using hex values. I also tried 'binary' instead of 'binaryprefix'. How do I store and compare integer in hbase?

Answer1:

Does this produce the expected output?

import org.apache.hadoop.hbase.filter.CompareFilter import org.apache.hadoop.hbase.filter.SingleColumnValueFilter import org.apache.hadoop.hbase.filter.SubstringComparator import org.apache.hadoop.hbase.util.Bytes scan 'newdb3', { FILTER => SingleColumnValueFilter.new(Bytes.toBytes('data'), \ Bytes.toBytes('duration'), CompareFilter::CompareOp.valueOf('GREATER'), \ BinaryComparator.new(Bytes.toBytes('200'))) }

NOTE: This will do a binary comparison and for numbers it will work only if they are 0-padded

Recommend

  • How do you send reminder date based on cell date in Google Sheets?
  • How to update listview automatically after adding a new item into DB
  • How to set the GOOGLE_APPLICATION_CREDENTIALS from Google Cloud Vision in C#?
  • Enable a textarea only if a radio button is selected
  • Setting headers for CakePHP Controller unit tests
  • How to get .mpd file for a youtube video
  • Footer appears next to section instead of below
  • Why context.Wait in StartAsync didn't stop the dialog
  • Quartz clustering load balancing algorithm internal implementation in Jdbcjobstore
  • IE6 postback in asp.net
  • hadoop jar command points to local filesystem
  • Converting array with Different data type
  • NOTE or WARNING from package check when README.md includes images
  • AppEngine Paypal integration giving SSLCertificateError on localhost, using Python
  • How to set a dynamic form fields to dirty or touched with angular?
  • PHP users local time
  • Create One-To-One relationship between table and view in EF4?
  • Can Node.JS on OpenShift be upgraded?
  • Check 'Manager can update membership list' in AD
  • if you have a DLL creating a bitmap in memory, how to return it to the browser?
  • Signed Java web start application with Glassfish 4.1 and Java7
  • Facebook Error (#200) The user hasn't authorized the application to perform this action (PHP)
  • Ruby on Rails: Get mediaplayer information (iTunes, TRAKTOR, Cog; current song + playlist)
  • Thumbnails for mxml components in Flex
  • How to use Kaminari pagination gem with Sinatra and Mongoid?
  • Runtime complexity of getting the length of a string in different representations
  • Problems to understand DXGI DirectX 11 Desktop Duplication to get a Buffer or Array
  • JavaScript Regex to Match Boundaries of Words with diacritics
  • VSTS work items list through REST API
  • How to get rgb from transparent pixel in js
  • ssh remote server login script
  • Computing the discrete fourier transform of audio data with FFTW
  • multiple button click in asp.net MVC 3
  • Sql - ON DUPLICATE KEY UPDATE
  • How to use FirstOrDefault inside Include
  • PHP Permalinks.. how to change?
  • media foundation H264 decoder not working properly
  • Running R's aov() mixed effects model from Python using rpy2
  • Access to a Matlab gui from the web
  • convert json to excel in java