Instantly share code, notes, and snippets.

Embed
What would you like to do?
HBase Stargate REST API Scanner Filter Examples

Stargate Scanner Filter Examples

Introduction

So yeah... no documentation for the HBase REST API in regards to what should a filter look like...

So I installed Eclipse, got the library, and took some time to find some of the (seemingly) most useful filters you could use. I'm very green at anything regarding HBase, and I hope this will help anyone trying to get started with it.

What I discovered is that basically, attributes of the filter object follow the same naming than in the documentation. For this reason, I have made the link clickable and direct them to the HBase Class documentation attached to it; check for the instantiation argument names, and you will have your attribute list (more or less).

Don't forget, values are encoded.

References:

ColumnPrefixFilter

{
  "type": "ColumnPrefixFilter",
  "value": "cHJlZml4"
}

ColumnRangeFilter

{
  "type": "ColumnRangeFilter",
  "minColumn": "Zmx1ZmZ5",
  "minColumnInclusive": true,
  "maxColumn": "Zmx1ZmZ6",
  "maxColumnInclusive": false
}

ColumnPaginationFilter

Could not generate an example, but I guess it should be pretty simple to test if it works just by intuitively plugging variables a certain way...

DependentColumnFilter

null

FamilyFilter

{
  "type": "FamilyFilter",
  "op": "EQUAL",
  "comparator": {
    "type": "BinaryComparator",
    "value": "dGVzdHJvdw\u003d\u003d"
  }
}

FilterList with RowFilter and ColumnRangeFilter

{
  "type": "FilterList",
  "op": "MUST_PASS_ALL",
  "filters": [
    {
      "type": "RowFilter",
      "op": "EQUAL",
      "comparator": {
        "type": "BinaryComparator",
        "value": "dGVzdHJvdw\u003d\u003d"
      }
    },
    {
      "type": "ColumnRangeFilter",
      "minColumn": "Zmx1ZmZ5",
      "minColumnInclusive": true,
      "maxColumn": "Zmx1ZmZ6",
      "maxColumnInclusive": false
    }
  ]
}

FirstKeyOnlyFilter (Can be used for more efficiently perform row count operation)

{
  "type": "FirstKeyOnlyFilter"
}

InclusiveStopFilter

{
  "type": "InclusiveStopFilter",
  "value": "cm93a2V5"
}

MultipleColumnPrefixFilter

{
  "type": "MultipleColumnPrefixFilter",
  "prefixes": [
    "YWxwaGE\u003d",
    "YnJhdm8\u003d",
    "Y2hhcmxpZQ\u003d\u003d"
  ]
}

PageFilter

{
  "type": "PageFilter",
  "value": "10"
}

PrefixFilter

{
  "type": "PrefixFilter",
  "value": "cm93cHJlZml4"
}

QualifierFilter

{
  "type": "QualifierFilter",
  "op": "GREATER",
  "comparator": {
    "type": "BinaryComparator",
    "value": "cXVhbGlmaWVycHJlZml4"
  }
}

RowFilter

{
  "type": "RowFilter",
  "op": "EQUAL",
  "comparator": {
    "type": "BinaryComparator",
    "value": "dGVzdHJvdw\u003d\u003d"
  }
}

SingleColumnValueFilter

{
  "type": "SingleColumnValueFilter",
  "op": "EQUAL",
  "family": "ZmFtaWx5",
  "qualifier": "Y29sMQ\u003d\u003d",
  "latestVersion": true,
  "comparator": {
    "type": "BinaryComparator",
    "value": "MQ\u003d\u003d"
  }
}

TimestampsFilter

{
  "type": "TimestampsFilter",
  "timestamps": [
    "1351586939"
  ]
}
@themauveavenger

This comment has been minimized.

Show comment
Hide comment
@themauveavenger

themauveavenger Jun 10, 2014

Thanks! I've been looking for a comprehensive guide on this. You rock!

themauveavenger commented Jun 10, 2014

Thanks! I've been looking for a comprehensive guide on this. You rock!

@PSD91

This comment has been minimized.

Show comment
Hide comment
@PSD91

PSD91 Oct 26, 2015

Thankyou!

PSD91 commented Oct 26, 2015

Thankyou!

@csalperwyck

This comment has been minimized.

Show comment
Hide comment
@csalperwyck

csalperwyck Mar 3, 2016

Great job! Thanks!

csalperwyck commented Mar 3, 2016

Great job! Thanks!

@suncq

This comment has been minimized.

Show comment
Hide comment
@suncq

suncq Mar 21, 2016

great job! l
Thanks!

suncq commented Mar 21, 2016

great job! l
Thanks!

@vandelay

This comment has been minimized.

Show comment
Hide comment
@vandelay

vandelay May 3, 2016

Thank you

vandelay commented May 3, 2016

Thank you

@turbopape

This comment has been minimized.

Show comment
Hide comment
@turbopape

turbopape Jun 1, 2016

Great Job ! Many Thanks!
You have to put these in an XML document right ?
<Scanner ...
<filter ...
the json
?
Just is there a way to let the scanner spit sets of results instead of giving them one by one ?

turbopape commented Jun 1, 2016

Great Job ! Many Thanks!
You have to put these in an XML document right ?
<Scanner ...
<filter ...
the json
?
Just is there a way to let the scanner spit sets of results instead of giving them one by one ?

@riazraza

This comment has been minimized.

Show comment
Hide comment
@riazraza

riazraza Dec 11, 2017

Great Job! Thanks alot.
But why is DependentColumnFilter null? We can use it through REST Client, right?

riazraza commented Dec 11, 2017

Great Job! Thanks alot.
But why is DependentColumnFilter null? We can use it through REST Client, right?

@rpwils

This comment has been minimized.

Show comment
Hide comment
@rpwils

rpwils May 30, 2018

do you know if there is a way to paginate a response? I wanted to use something like this or even something with an unlimited response.

rpwils commented May 30, 2018

do you know if there is a way to paginate a response? I wanted to use something like this or even something with an unlimited response.

@sjschmid

This comment has been minimized.

Show comment
Hide comment
@sjschmid

sjschmid Jul 13, 2018

How do you AND / OR several filters using the REST API? Can you make an example?

sjschmid commented Jul 13, 2018

How do you AND / OR several filters using the REST API? Can you make an example?

@hapiman

This comment has been minimized.

Show comment
Hide comment
@hapiman

hapiman Aug 7, 2018

@sjschmid I met the same question, have you solved it ?

hapiman commented Aug 7, 2018

@sjschmid I met the same question, have you solved it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment