Read using a value range filter (HBase)
Stay organized with collections
Save and categorize content based on your preferences.
Creates a limiting filter on a range of cell values.
Explore further
For detailed documentation that includes this code sample, see the following:
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis code sample demonstrates how to use a filter to limit the range of cell values within a Bigtable table.\u003c/p\u003e\n"],["\u003cp\u003eThe filter utilizes \u003ccode\u003eValueFilter\u003c/code\u003e with \u003ccode\u003eGREATER_OR_EQUAL\u003c/code\u003e and \u003ccode\u003eLESS_OR_EQUAL\u003c/code\u003e comparison operators to define the upper and lower bounds of the desired value range.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eFilterList\u003c/code\u003e with the \u003ccode\u003eMUST_PASS_ALL\u003c/code\u003e operator combines the two \u003ccode\u003eValueFilter\u003c/code\u003e instances to ensure only values falling within both defined limits are included.\u003c/p\u003e\n"],["\u003cp\u003eThe code uses a scan function with the created filter to read data from the table.\u003c/p\u003e\n"],["\u003cp\u003eThe code shows the setting of authentication and links to the page for more details.\u003c/p\u003e\n"]]],[],null,["# Read using a value range filter (HBase)\n\nCreates a limiting filter on a range of cell values.\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Use filters](/bigtable/docs/using-filters)\n\nCode sample\n-----------\n\n### Java\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n public static void filterLimitValueRange() {\n // TODO(developer): Replace these variables before running the sample.\n String projectId = \"my-project-id\";\n String instanceId = \"my-instance-id\";\n String tableId = \"mobile-time-series\";\n filterLimitValueRange(projectId, instanceId, tableId);\n }\n\n public static void filterLimitValueRange(String projectId, String instanceId, String tableId) {\n // A filter that matches cells whose values are between the given values\n ValueFilter valueGreaterFilter =\n new ValueFilter(\n CompareFilter.CompareOp.GREATER_OR_EQUAL,\n new BinaryComparator(Bytes.toBytes(\"PQ2A.190405\")));\n ValueFilter valueLesserFilter =\n new ValueFilter(\n CompareFilter.CompareOp.LESS_OR_EQUAL,\n new BinaryComparator(Bytes.toBytes(\"PQ2A.190406\")));\n\n FilterList filter = new FilterList(FilterList.Operator.MUST_PASS_ALL);\n filter.addFilter(valueGreaterFilter);\n filter.addFilter(valueLesserFilter);\n\n Scan scan = new Scan().setFilter(filter);\n readWithFilter(projectId, instanceId, tableId, scan);\n }\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=bigtable)."]]