hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1155969 [1/2] - in /hbase/trunk: ./ src/docbkx/ src/main/java/org/apache/hadoop/hbase/filter/ src/main/java/org/apache/hadoop/hbase/zookeeper/ src/test/java/org/apache/hadoop/hbase/filter/ src/test/java/org/apache/hadoop/hbase/zookeeper/
Date Tue, 09 Aug 2011 23:28:57 GMT
Author: stack
Date: Tue Aug  9 23:28:56 2011
New Revision: 1155969

URL: http://svn.apache.org/viewvc?rev=1155969&view=rev
Log:
HBASE-4156 ZKConfig defaults clientPort improperly

Added:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ParseConstants.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ParseFilter.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/filter/TestParseFilter.java
Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/docbkx/book.xml
    hbase/trunk/src/docbkx/developer.xml
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FamilyFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/Filter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FirstKeyOnlyFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/KeyOnlyFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/MultipleColumnPrefixFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/QualifierFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/RowFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueExcludeFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/TimestampsFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ValueFilter.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKConfig.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/zookeeper/TestHQuorumPeer.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Tue Aug  9 23:28:56 2011
@@ -196,6 +196,7 @@ Release 0.91.0 - Unreleased
                (Michael Weng)
    HBASE-4181  HConnectionManager can't find cached HRegionInterface and makes clients
                work very slow (Jia Liu)
+   HBASE-4156  ZKConfig defaults clientPort improperly (Michajlo Matijkiw)
 
   IMPROVEMENTS
    HBASE-3290  Max Compaction Size (Nicolas Spiegelberg via Stack)  
@@ -416,6 +417,7 @@ Release 0.91.0 - Unreleased
                (Nichole Treadway and Nicholas Telford)
    HBASE-2233  Support both Hadoop 0.20 and 0.22
    HBASE-3857  Change the HFile Format (Mikhail & Liyin)
+   HBASE-4176  Exposing HBase Filters to the Thrift API (Anirudh Todi)
 
 Release 0.90.5 - Unreleased
 

Modified: hbase/trunk/src/docbkx/book.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/src/docbkx/book.xml?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/docbkx/book.xml (original)
+++ hbase/trunk/src/docbkx/book.xml Tue Aug  9 23:28:56 2011
@@ -1745,6 +1745,336 @@ When I build, why do I always get <code>
   </appendix>
 
 
+<appendix>
+   <title>HFile format version 2</title>
+
+   <appendixinfo>
+           <personname>Mikhail Bautin</personname>
+       <authorgroup>
+           <author><personname>Mikhail Bautin</personname></author>
+           <author><personname>Liyin Tang</personname></author>
+           <author><personname>Kannan Muthukarrupan</personname></author>
+       </authorgroup>
+   </appendixinfo>
+
+   <section><title>Motivation </title>
+   <para>We found it necessary to revise the HFile format after encountering high memory usage and slow startup times caused by large Bloom filters and block indexes in the region server. Bloom filters can get as large as 100 MB per HFile, which adds up to 2 GB when aggregated over 20 regions. Block indexes can grow as large as 6 GB in aggregate size over the same set of regions. A region is not considered opened until all of its block index data is loaded. Large Bloom filters produce a different performance problem: the first get request that requires a Bloom filter lookup will incur the latency of loading the entire Bloom filter bit array.</para>
+   <para>To speed up region server startup we break Bloom filters and block indexes into multiple blocks and write those blocks out as they fill up, which also reduces the HFile writer’s memory footprint. In the Bloom filter case, “filling up a block” means accumulating enough keys to efficiently utilize a fixed-size bit array, and in the block index case we accumulate an “index block” of the desired size. Bloom filter blocks and index blocks (we call these “inline blocks”) become interspersed with data blocks, and as a side effect we can no longer rely on the difference between block offsets to determine data block length, as it was done in version 1.</para>
+   <para>HFile is a low-level file format by design, and it should not deal with application-specific details such as Bloom filters, which are handled at StoreFile level. Therefore, we call Bloom filter blocks in an HFile "inline" blocks. We also supply HFile with an interface to write those inline blocks. </para>
+   <para>Another format modification aimed at reducing the region server startup time is to use a contiguous “load-on-open” section that has to be loaded in memory at the time an HFile is being opened. Currently, as an HFile opens, there are separate seek operations to read the trailer, data/meta indexes, and file info. To read the Bloom filter, there are two more seek operations for its “data” and “meta” portions. In version 2, we seek once to read the trailer and seek again to read everything else we need to open the file from a contiguous block.</para></section>
+   <section><title>HFile format version 1 overview </title><para>As we will be discussing the changes we are making to the HFile format, it is useful to give a short overview of the previous (HFile version 1) format. An HFile in the existing format is structured as follows:
+           <inlinemediaobject>
+               <imageobject>
+                   <imagedata align="middle" valign="middle" fileref="images/hfile.png"/>
+               </imageobject>
+               <textobject>
+                 <phrase>HFile Version 1</phrase>
+               </textobject>
+               <caption>
+                   <para>HFile Version 1 
+                 </para>
+               </caption>
+           </inlinemediaobject>
+           <footnote><para>Image courtesy of Lars George, <link xlink:href="http://www.larsgeorge.com/2009/10/hbase-architecture-101-storage.html">hbase-architecture-101-storage.html</link>.</para></footnote>
+       </para>
+       <section><title> Block index format in version 1 </title>
+   <para>The block index in version 1 is very straightforward. For each entry, it contains: </para>
+   <orderedlist>
+      <listitem>
+         <para>Offset (long)</para>
+      </listitem>
+      <listitem>
+         <para>Uncompressed size (int)</para>
+      </listitem>
+      <listitem>
+         <para>Key (a serialized byte array written using Bytes.writeByteArray) </para>
+      </listitem>
+   </orderedlist>
+   <para>The number of entries in the block index is stored in the fixed file trailer, and has to be passed in to the method that reads the block index. One of the limitations of the block index in version 1 is that it does not provide the compressed size of a block, which turns out to be necessary for decompression. Therefore, the HFile reader has to infer this compressed size from the offset difference between blocks. We fix this limitation in version 2, where we store on-disk block size instead of uncompressed size, and get uncompressed size from the block header.</para></section></section><section><title>
+      HBase file format with inline blocks (version 2)
+      </title>
+      <section><title> Overview</title>
+   <para>The version of HBase introducing the above features reads both version 1 and 2 HFiles, but only writes version 2 HFiles. A version 2 HFile is structured as follows:
+<table xml:id="ex.calstable" frame='all'>
+<title>HFile Version 2</title>
+<tgroup cols='4' align='left' colsep='1' rowsep='1'>
+<colspec colname='c1'/>
+<colspec colname='c2'/>
+<colspec colname='c3'/>
+<colspec colname='c4'/>
+<tbody>
+    <row>
+  <entry morerows="9">"Scanned block" section</entry>
+  </row>
+  <row><entry namest="c2" nameend="c4">Data Block</entry>
+  </row>
+  <row><entry namest="c2" nameend="c4">...</entry>
+  </row>
+  <row><entry >Leaf index block/Bloom block</entry>
+  </row>
+  <row ><entry namest="c2" nameend="c4">...</entry></row>
+  <row ><entry namest="c2" nameend="c4">Data Block</entry></row>
+  <row ><entry namest="c2" nameend="c4">...</entry></row>
+  <row ><entry namest="c2" nameend="c4">Leaf index block/Bloom block</entry></row>
+  <row ><entry namest="c2" nameend="c4">...</entry></row>
+  <row ><entry namest="c2" nameend="c4">Data Block</entry></row>
+<row>
+  <entry>c1</entry>
+  <entry namest="c2" nameend="c3" align='center' morerows='1' valign='bottom'>Span Both</entry>
+  <entry>c4</entry>
+</row>
+<row>
+  <entry>d1</entry>
+  <entry>d4</entry>
+  <entry>d5</entry>
+</row>
+</tbody>
+</tgroup>
+</table>
+   </para>
+   </section>
+   <section><title>Unified version 2 block format</title>
+   <para>In the version 2 every block in the data section contains the following fields: </para>
+   <orderedlist>
+      <listitem>
+         <para>8 bytes: Block type, a sequence of bytes equivalent to version 1's "magic records". Supported block types are: </para>
+      </listitem>
+      <listitem>
+         <para>Compressed size of the block's data, not including the header (int) </para>
+      </listitem>
+      <listitem>
+         <para>Uncompressed size of the block's data, not including the header (int)</para>
+      </listitem>
+      <listitem>
+         <para>File offset of the previous block of the same type (long)</para>
+      </listitem>
+      <listitem>
+         <para>Compressed data (or uncompressed data if the compression algorithm is NONE).</para>
+      </listitem>
+   </orderedlist>
+   <para>The above format of blocks is used in the following HFile sections:</para>
+   <orderedlist>
+      <listitem>
+         <para>Scanned block section. The section is named so because it contains all data blocks that need to be read when an HFile is scanned sequentially.  Also contains leaf block index and Bloom chunk blocks. </para>
+      </listitem>
+      <listitem>
+         <para>Non-scanned block section. This section still contains unified-format v2 blocks but it does not have to be read when doing a sequential scan. This section contains “meta” blocks and intermediate-level index blocks.<anchor id="Meta_blocks_in_version_2"/>
+         </para>
+      </listitem>
+   </orderedlist>
+   <para>We are supporting “meta” blocks in version 2 the same way they were supported in version 1, even though we do not store Bloom filter data in these blocks anymore. </para></section><section><title>
+      Block index in version 2</title>
+   <para>There are three types of block indexes in HFile version 2, stored in two different formats (root and non-root): </para>
+   <orderedlist>
+      <listitem>
+         <para>Data index — version 2 multi-level block index, consisting of:</para>
+      </listitem>
+      <listitem>
+         <para>Meta index — version 2 root index format only, stored in the meta index section of the file</para>
+      </listitem>
+      <listitem>
+         <para>Bloom index — version 2 root index format only, stored in the “load-on-open” section as part of Bloom filter metadata.</para>
+      </listitem>
+   </orderedlist></section><section><title>
+      Root block index format in version 2</title>
+   <para>This format applies to:</para>
+   <orderedlist>
+      <listitem>
+         <para>Root level of the version 2 data index</para>
+      </listitem>
+      <listitem>
+         <para>Entire meta and Bloom indexes in version 2, which are always single-level. </para>
+      </listitem>
+   </orderedlist>
+   <para>A version 2 root index block is a sequence of entries of the following format, similar to entries of a version 1 block index, but storing on-disk size instead of uncompressed size. </para>
+   <orderedlist>
+      <listitem>
+         <para>Offset (long) </para>
+      </listitem>
+      <listitem>
+         <para>On-disk size (int) </para>
+      </listitem>
+      <listitem>
+         <para>Key (a serialized byte array stored using Bytes.writeByteArray) </para>
+      </listitem>
+   </orderedlist>
+   <para>A single-level version 2 block index consists of just a single root index block. To read a root index block of version 2, one needs to know the number of entries. For the data index and the meta index the number of entries is stored in the trailer, and for the Bloom index it is stored in the compound Bloom filter metadata.</para>
+   <para>For a multi-level block index we also store the following fields in the root index block in the load-on-open section of the HFile, in addition to the data structure described above:</para>
+   <orderedlist>
+      <listitem>
+         <para>Middle leaf index block offset</para>
+      </listitem>
+      <listitem>
+         <para>Middle leaf block on-disk size (meaning the leaf index block containing the reference to the “middle” data block of the file) </para>
+      </listitem>
+      <listitem>
+         <para>The index of the mid-key (defined below) in the middle leaf-level block.</para>
+      </listitem>
+   </orderedlist>
+   <para/>
+   <para>These additional fields are used to efficiently retrieve the mid-key of the HFile used in HFile splits, which we define as the first key of the block with a zero-based index of (n – 1) / 2, if the total number of blocks in the HFile is n. This definition is consistent with how the mid-key was determined in HFile version 1, and is reasonable in general, because blocks are likely to be the same size on average, but we don’t have any estimates on individual key/value pair sizes. </para>
+   <para/>
+   <para>When writing a version 2 HFile, the total number of data blocks pointed to by every leaf-level index block is kept track of. When we finish writing and the total number of leaf-level blocks is determined, it is clear which leaf-level block contains the mid-key, and the fields listed above are computed.  When reading the HFile and the mid-key is requested, we retrieve the middle leaf index block (potentially from the block cache) and get the mid-key value from the appropriate position inside that leaf block.</para></section><section><title>
+      Non-root block index format in version 2</title>
+   <para>This format applies to intermediate-level and leaf index blocks of a version 2 multi-level data block index. Every non-root index block is structured as follows. </para>
+   <orderedlist>
+      <listitem>
+         <para>numEntries: the number of entries (int). </para>
+      </listitem>
+      <listitem>
+         <para>entryOffsets: the “secondary index” of offsets of entries in the block, to facilitate a quick binary search on the key (numEntries + 1 int values). The last value is the total length of all entries in this index block. For example, in a non-root index block with entry sizes 60, 80, 50 the “secondary index” will contain the following int array: {0, 60, 140, 190}.</para>
+      </listitem>
+      <listitem>
+         <para>Entries. Each entry contains: </para>
+      </listitem>
+   </orderedlist></section><section><title>
+      Bloom filters in version 2</title>
+   <para>In contrast with version 1, in a version 2 HFile Bloom filter metadata is stored in the load-on-open section of the HFile for quick startup. </para>
+   <orderedlist>
+      <listitem>
+         <para>A compound Bloom filter. </para>
+      </listitem>
+   </orderedlist></section><section><title>File Info format in versions 1 and 2</title>
+   <para>The file info block is a serialized <ulink url="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/io/HbaseMapWritable.html">HbaseMapWritable</ulink> (essentially a map from byte arrays to byte arrays) with the following keys, among others. StoreFile-level logic adds more keys to this.</para>
+   <informaltable frame="all">
+      <tgroup cols="2"><tbody><row>
+            <entry>
+               <para>hfile.LASTKEY </para>
+            </entry>
+            <entry>
+               <para>The last key of the file (byte array) </para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para>hfile.AVG_KEY_LEN </para>
+            </entry>
+            <entry>
+               <para>The average key length in the file (int) </para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para>hfile.AVG_VALUE_LEN </para>
+            </entry>
+            <entry>
+               <para>The average value length in the file (int) </para>
+            </entry>
+         </row></tbody></tgroup>
+   </informaltable>
+   <para>File info format did not change in version 2. However, we moved the file info to the final section of the file, which can be loaded as one block at the time the HFile is being opened. Also, we do not store comparator in the version 2 file info anymore. Instead, we store it in the fixed file trailer. This is because we need to know the comparator at the time of parsing the load-on-open section of the HFile.</para></section><section><title>
+      Fixed_file_trailer_format_differences_be"/>Fixed file trailer format differences between versions 1 and 2</title>
+   <para>The following table shows common and different fields between fixed file trailers in versions 1 and 2. Note that the size of the trailer is different depending on the version, so it is “fixed” only within one version. However, the version is always stored as the last four-byte integer in the file. </para>
+   <para/>
+   <informaltable frame="all">
+      <tgroup cols="1.5"><tbody><row>
+            <entry>
+               <para>Version 1 </para>
+            </entry>
+            <entry>
+               <para>Version 2 </para>
+            </entry>
+         </row>
+         <row>
+            <entry namest="c1" nameend="c2">
+               <para>File info offset (long) </para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para>Data index offset (long) </para>
+            </entry>
+            <entry>
+               <para>loadOnOpenOffset (long)</para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para>The offset of the section that we need to load when opening the file. </para>
+            </entry>
+         </row>
+         <row>
+            <entry namest="c1" nameend="c2">
+               <para>Number of data index entries (int) </para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para>metaIndexOffset (long)</para>
+               <para>This field is not being used by the version 1 reader, so we removed it from version 2.</para>
+            </entry>
+            <entry>
+               <para>uncompressedDataIndexSize (long)</para>
+               <para>The total uncompressed size of the whole data block index, including root-level, intermediate-level, and leaf-level blocks.</para>
+            </entry>
+         </row>
+         <row>
+            <entry namest="c1" nameend="c2">
+               <para>Number of meta index entries (int) </para>
+            </entry>
+         </row>
+         <row>
+            <entry namest="c1" nameend="c2">
+               <para>Total uncompressed bytes (long) </para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para>numEntries (int) </para>
+            </entry>
+            <entry>
+               <para>numEntr<anchor id="_GoBack"/>ies (long) </para>
+            </entry>
+         </row>
+         <row>
+            <entry namest="c1" nameend="c2">
+               <para>Compression codec: 0 = LZO, 1 = GZ, 2 = NONE (int) </para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para> </para>
+            </entry>
+            <entry>
+               <para>The number of levels in the data block index (int) </para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para> </para>
+            </entry>
+            <entry>
+               <para>firstDataBlockOffset (long)</para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para>The offset of the first first data block. Used when scanning. </para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para> </para>
+            </entry>
+            <entry>
+               <para>lastDataBlockEnd (long)</para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para>The offset of the first byte after the last key/value data block. We don't need to go beyond this offset when scanning. </para>
+            </entry>
+         </row>
+         <row>
+            <entry>
+               <para>Version: 1 (int) </para>
+            </entry>
+            <entry>
+               <para>Version: 2 (int) </para>
+            </entry>
+         </row></tbody></tgroup>
+   </informaltable>
+   <para/></section></section></appendix>
 
 
   <index xml:id="book_index">

Modified: hbase/trunk/src/docbkx/developer.xml
URL: http://svn.apache.org/viewvc/hbase/trunk/src/docbkx/developer.xml?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/docbkx/developer.xml (original)
+++ hbase/trunk/src/docbkx/developer.xml Tue Aug  9 23:28:56 2011
@@ -112,7 +112,7 @@ mvn test -Dtest=TestXYZ
             <link xlink:href="http://blog.sematext.com/2010/08/30/hbase-case-study-using-hbasetestingutility-for-local-testing-development/">HBase Case-Study: Using HBaseTestingUtility for Local Testing and Development</link> (2010).
         </para>
         <section xml:id="mockito">
-          <title>Mocito</title>
+          <title>Mockito</title>
           <para>Sometimes you don't need a full running server
               unit testing.  For example, some methods can make do with a
               a <classname>org.apache.hadoop.hbase.Server</classname> instance

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java Tue Aug  9 23:28:56 2011
@@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.KeyValue;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
+import java.util.ArrayList;
 
 /**
  * Simple filter that returns first N columns on row only.
@@ -45,6 +46,9 @@ public class ColumnCountGetFilter extend
   }
 
   public ColumnCountGetFilter(final int n) {
+    if (n < 0) {
+      throw new IllegalArgumentException("Limit must not be negative");
+    }
     this.limit = n;
   }
 
@@ -69,6 +73,16 @@ public class ColumnCountGetFilter extend
   }
 
   @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    if (filterArguments.size() != 1) {
+      throw new IllegalArgumentException("Incorrect Arguments passed to ColumnCountGetFilter. " +
+                                         "Expected: 1 but got: " + filterArguments.size());
+    }
+    int limit = ParseFilter.convertByteArrayToInt(filterArguments.get(0));
+    return new ColumnCountGetFilter(limit);
+  }
+
+  @Override
   public void readFields(DataInput in) throws IOException {
     this.limit = in.readInt();
   }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java Tue Aug  9 23:28:56 2011
@@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.filter;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
+import java.util.ArrayList;
 
 import org.apache.hadoop.hbase.KeyValue;
 
@@ -46,6 +47,12 @@ public class ColumnPaginationFilter exte
 
   public ColumnPaginationFilter(final int limit, final int offset)
   {
+    if (limit < 0) {
+      throw new IllegalArgumentException("Limit must not be negative");
+    }
+    if (offset < 0) {
+      throw new IllegalArgumentException("Offset must not be negative");
+    }
     this.limit = limit;
     this.offset = offset;
   }
@@ -83,6 +90,17 @@ public class ColumnPaginationFilter exte
     this.count = 0;
   }
 
+  @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    if (filterArguments.size() != 2) {
+      throw new IllegalArgumentException("Incorrect Arguments passed to ColumnPaginationFilter. " +
+                                         "Expected: 2 but got: " + filterArguments.size());
+    }
+    int limit = ParseFilter.convertByteArrayToInt(filterArguments.get(0));
+    int offset = ParseFilter.convertByteArrayToInt(filterArguments.get(1));
+    return new ColumnPaginationFilter(limit, offset);
+  }
+
   public void readFields(DataInput in) throws IOException
   {
     this.limit = in.readInt();

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.java Tue Aug  9 23:28:56 2011
@@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.util.Byte
 import java.io.DataOutput;
 import java.io.IOException;
 import java.io.DataInput;
+import java.util.ArrayList;
 
 /**
  * This filter is used for selecting only those keys with columns that matches
@@ -78,6 +79,17 @@ public class ColumnPrefixFilter extends 
     }
   }
 
+  @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    if (filterArguments.size() != 1) {
+      throw new IllegalArgumentException("Incorrect Arguments passed to ColumnPrefixFilter. " +
+                                         "Expected: 1 but got: " + filterArguments.size());
+    }
+
+    byte [] columnPrefix = ParseFilter.convertByteArrayToString(filterArguments.get(0));
+    return new ColumnPrefixFilter(columnPrefix);
+  }
+
   public void write(DataOutput out) throws IOException {
     Bytes.writeByteArray(out, this.prefix);
   }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java Tue Aug  9 23:28:56 2011
@@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.util.Byte
 import java.io.DataOutput;
 import java.io.IOException;
 import java.io.DataInput;
+import java.util.ArrayList;
 
 /**
  * This filter is used for selecting only those keys with columns that are
@@ -144,6 +145,26 @@ public class ColumnRangeFilter extends F
   }
 
   @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    if (filterArguments.size() != 4) {
+      throw new IllegalArgumentException("Incorrect arguments passed to ColumnRangeFilter. " +
+                                         "Expected: 4 but got: " + filterArguments.size());
+    }
+
+    byte [] minColumn = ParseFilter.convertByteArrayToString(filterArguments.get(0));
+    boolean minColumnInclusive = ParseFilter.convertByteArrayToBoolean(filterArguments.get(1));
+    byte [] maxColumn = ParseFilter.convertByteArrayToString(filterArguments.get(2));
+    boolean maxColumnInclusive = ParseFilter.convertByteArrayToBoolean(filterArguments.get(3));
+
+    if (minColumn.length == 0)
+      minColumn = null;
+    if (maxColumn.length == 0)
+      maxColumn = null;
+    return new ColumnRangeFilter(minColumn, minColumnInclusive,
+                                 maxColumn, maxColumnInclusive);
+  }
+
+  @Override
   public void write(DataOutput out) throws IOException {
     // need to write out a flag for null value separately. Otherwise,
     // we will not be able to differentiate empty string and null

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java Tue Aug  9 23:28:56 2011
@@ -27,7 +27,7 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.util.Arrays;
-
+import java.util.ArrayList;
 /**
  * This is a generic filter to be used to filter by comparison.  It takes an
  * operator (equal, greater, not equal, etc) and a byte [] comparator.
@@ -108,23 +108,45 @@ public abstract class CompareFilter exte
         offset + length));
     switch (compareOp) {
       case LESS:
-        return compareResult <= 0;
-      case LESS_OR_EQUAL:
         return compareResult < 0;
+      case LESS_OR_EQUAL:
+        return compareResult <= 0;
       case EQUAL:
-        return compareResult != 0;
-      case NOT_EQUAL:
         return compareResult == 0;
+      case NOT_EQUAL:
+        return compareResult != 0;
       case GREATER_OR_EQUAL:
-        return compareResult > 0;
-      case GREATER:
         return compareResult >= 0;
+      case GREATER:
+        return compareResult > 0;
       default:
         throw new RuntimeException("Unknown Compare op " +
           compareOp.name());
     }
   }
 
+  @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    if (filterArguments.size() != 2) {
+      throw new IllegalArgumentException("Incorrect Arguments passed to Compare Filter. " +
+                                         "Expected: 2 but got: " + filterArguments.size());
+    }
+
+    this.compareOp = ParseFilter.createCompareOp(filterArguments.get(0));
+    this.comparator = ParseFilter.createComparator(
+      ParseFilter.convertByteArrayToString(filterArguments.get(1)));
+
+    if (this.comparator instanceof RegexStringComparator ||
+        this.comparator instanceof SubstringComparator) {
+      if (this.compareOp != CompareOp.EQUAL &&
+          this.compareOp != CompareOp.NOT_EQUAL) {
+        throw new IllegalArgumentException ("A regexstring comparator and substring comparator" +
+                                            " can only be used with EQUAL and NOT_EQUAL");
+      }
+    }
+    return this;
+  }
+
   public void readFields(DataInput in) throws IOException {
     compareOp = CompareOp.valueOf(in.readUTF());
     comparator = (WritableByteArrayComparable)

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java Tue Aug  9 23:28:56 2011
@@ -26,6 +26,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.ArrayList;
 
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -34,8 +35,8 @@ import org.apache.hadoop.hbase.util.Byte
  * A filter for adding inter-column timestamp matching
  * Only cells with a correspondingly timestamped entry in
  * the target column will be retained
- * Not compatible with Scan.setBatch as operations need 
- * full rows for correct filtering 
+ * Not compatible with Scan.setBatch as operations need
+ * full rows for correct filtering
  */
 public class DependentColumnFilter extends CompareFilter {
 
@@ -44,52 +45,52 @@ public class DependentColumnFilter exten
   protected boolean dropDependentColumn;
 
   protected Set<Long> stampSet = new HashSet<Long>();
-  
+
   /**
    * Should only be used for writable
    */
   public DependentColumnFilter() {
   }
-  
+
   /**
    * Build a dependent column filter with value checking
    * dependent column varies will be compared using the supplied
    * compareOp and comparator, for usage of which
    * refer to {@link CompareFilter}
-   * 
+   *
    * @param family dependent column family
    * @param qualifier dependent column qualifier
    * @param dropDependentColumn whether the column should be discarded after
-   * @param valueCompareOp comparison op 
+   * @param valueCompareOp comparison op
    * @param valueComparator comparator
    */
   public DependentColumnFilter(final byte [] family, final byte[] qualifier,
 		  final boolean dropDependentColumn, final CompareOp valueCompareOp,
 	      final WritableByteArrayComparable valueComparator) {
-    // set up the comparator   
+    // set up the comparator
     super(valueCompareOp, valueComparator);
     this.columnFamily = family;
     this.columnQualifier = qualifier;
     this.dropDependentColumn = dropDependentColumn;
   }
-  
+
   /**
    * Constructor for DependentColumn filter.
-   * Keyvalues where a keyvalue from target column 
-   * with the same timestamp do not exist will be dropped. 
-   * 
+   * Keyvalues where a keyvalue from target column
+   * with the same timestamp do not exist will be dropped.
+   *
    * @param family name of target column family
    * @param qualifier name of column qualifier
    */
   public DependentColumnFilter(final byte [] family, final byte [] qualifier) {
     this(family, qualifier, false);
   }
-  
+
   /**
    * Constructor for DependentColumn filter.
-   * Keyvalues where a keyvalue from target column 
-   * with the same timestamp do not exist will be dropped. 
-   * 
+   * Keyvalues where a keyvalue from target column
+   * with the same timestamp do not exist will be dropped.
+   *
    * @param family name of dependent column family
    * @param qualifier name of dependent qualifier
    * @param dropDependentColumn whether the dependent columns keyvalues should be discarded
@@ -120,6 +121,10 @@ public class DependentColumnFilter exten
     return this.dropDependentColumn;
   }
 
+  public boolean getDropDependentColumn() {
+    return this.dropDependentColumn;
+  }
+
   @Override
   public boolean filterAllRemaining() {
     return false;
@@ -134,8 +139,8 @@ public class DependentColumnFilter exten
   	}
   	// If it doesn't pass the op, skip it
   	if(comparator != null && doCompare(compareOp, comparator, v.getValue(), 0, v.getValueLength()))
-  	  return ReturnCode.SKIP;  	  
-	
+  	  return ReturnCode.SKIP;
+
     stampSet.add(v.getTimestamp());
     if(dropDependentColumn) {
     	return ReturnCode.SKIP;
@@ -159,7 +164,7 @@ public class DependentColumnFilter exten
   public boolean hasFilterRow() {
     return true;
   }
-  
+
   @Override
   public boolean filterRow() {
     return false;
@@ -169,10 +174,37 @@ public class DependentColumnFilter exten
   public boolean filterRowKey(byte[] buffer, int offset, int length) {
     return false;
   }
-
   @Override
   public void reset() {
-    stampSet.clear();    
+    stampSet.clear();
+  }
+
+  @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    if (filterArguments.size() == 2) {
+      byte [] family = ParseFilter.convertByteArrayToString(filterArguments.get(0));
+      byte [] qualifier = ParseFilter.convertByteArrayToString(filterArguments.get(1));
+      return new DependentColumnFilter(family, qualifier);
+
+    } else if (filterArguments.size() == 3) {
+      byte [] family = ParseFilter.convertByteArrayToString(filterArguments.get(0));
+      byte [] qualifier = ParseFilter.convertByteArrayToString(filterArguments.get(1));
+      boolean dropDependentColumn = ParseFilter.convertByteArrayToBoolean(filterArguments.get(2));
+      return new DependentColumnFilter(family, qualifier, dropDependentColumn);
+
+    } else if (filterArguments.size() == 5) {
+      byte [] family = ParseFilter.convertByteArrayToString(filterArguments.get(0));
+      byte [] qualifier = ParseFilter.convertByteArrayToString(filterArguments.get(1));
+      boolean dropDependentColumn = ParseFilter.convertByteArrayToBoolean(filterArguments.get(2));
+      CompareOp compareOp = ParseFilter.createCompareOp(filterArguments.get(3));
+      WritableByteArrayComparable comparator = ParseFilter.createComparator(
+        ParseFilter.convertByteArrayToString(filterArguments.get(4)));
+      return new DependentColumnFilter(family, qualifier, dropDependentColumn,
+                                       compareOp, comparator);
+    } else {
+      throw new IllegalArgumentException("Incorrect Arguments passed to DependentColumnFilter. " +
+                                         "Expected: 2, 3 or 5 but got: " + filterArguments.size());
+    }
   }
 
   @Override
@@ -182,12 +214,12 @@ public class DependentColumnFilter exten
 	if(this.columnFamily.length == 0) {
 	  this.columnFamily = null;
 	}
-    
+
     this.columnQualifier = Bytes.readByteArray(in);
     if(this.columnQualifier.length == 0) {
       this.columnQualifier = null;
-    }	
-    
+    }
+
     this.dropDependentColumn = in.readBoolean();
   }
 
@@ -196,7 +228,7 @@ public class DependentColumnFilter exten
     super.write(out);
     Bytes.writeByteArray(out, this.columnFamily);
     Bytes.writeByteArray(out, this.columnQualifier);
-    out.writeBoolean(this.dropDependentColumn);    
+    out.writeBoolean(this.dropDependentColumn);
   }
 
 }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FamilyFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FamilyFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FamilyFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FamilyFilter.java Tue Aug  9 23:28:56 2011
@@ -22,6 +22,8 @@ package org.apache.hadoop.hbase.filter;
 
 import org.apache.hadoop.hbase.KeyValue;
 
+import java.util.ArrayList;
+
 /**
  * This filter is used to filter based on the column family. It takes an
  * operator (equal, greater, not equal, etc) and a byte [] comparator for the
@@ -64,4 +66,9 @@ public class FamilyFilter extends Compar
     }
     return ReturnCode.INCLUDE;
   }
+
+  @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    return super.createFilterFromArguments(filterArguments);
+  }
 }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/Filter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/Filter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/Filter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/Filter.java Tue Aug  9 23:28:56 2011
@@ -24,6 +24,7 @@ import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.io.Writable;
 
 import java.util.List;
+import java.util.ArrayList;
 
 /**
  * Interface for row and column filters directly applied within the regionserver.
@@ -45,7 +46,7 @@ import java.util.List;
  *
  * When implementing your own filters, consider inheriting {@link FilterBase} to help
  * you reduce boilerplate.
- * 
+ *
  * @see FilterBase
  */
 public interface Filter extends Writable {
@@ -148,4 +149,12 @@ public interface Filter extends Writable
    * not sure which key to seek to next.
    */
   public KeyValue getNextKeyHint(KeyValue currentKV);
+
+  /**
+   * Given the filter's arguments it constructs the filter
+   * <p>
+   * @param filterArguments the filter's arguments
+   * @return constructed filter object
+   */
+   public Filter createFilterFromArguments (ArrayList<byte []> filterArguments);
 }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java Tue Aug  9 23:28:56 2011
@@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.filter;
 import org.apache.hadoop.hbase.KeyValue;
 
 import java.util.List;
+import java.util.ArrayList;
 
 /**
  * Abstract base class to help you implement new Filters.  Common "ignore" or NOOP type
@@ -119,4 +120,8 @@ public abstract class FilterBase impleme
     return null;
   }
 
+  @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    throw new IllegalArgumentException("This function has not been implemented");
+  }
 }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java Tue Aug  9 23:28:56 2011
@@ -276,4 +276,10 @@ public class FilterList implements Filte
   public KeyValue getNextKeyHint(KeyValue currentKV) {
     return null;
   }
+
+  @Override
+  public Filter createFilterFromArguments(ArrayList<byte[]> filterArguments) {
+    throw new IllegalArgumentException("This function has not been implemented" +
+                                       "A FilterList can be created using the AND/OR operators)");
+  }
 }
\ No newline at end of file

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FirstKeyOnlyFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FirstKeyOnlyFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FirstKeyOnlyFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/FirstKeyOnlyFilter.java Tue Aug  9 23:28:56 2011
@@ -26,6 +26,8 @@ import java.io.IOException;
 import java.io.DataInput;
 import java.util.List;
 
+import java.util.ArrayList;
+
 /**
  * A filter that will only return the first KV from each row.
  * <p>
@@ -47,6 +49,16 @@ public class FirstKeyOnlyFilter extends 
     return ReturnCode.INCLUDE;
   }
 
+  @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    if (filterArguments.size() != 0) {
+      throw new IllegalArgumentException("Incorrect Arguments passed to FirstKeyOnlyFilter. " +
+                                         "Expected: 0 but got: " + filterArguments.size());
+    }
+
+    return new FirstKeyOnlyFilter();
+  }
+
   public void write(DataOutput out) throws IOException {
   }
 

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java Tue Aug  9 23:28:56 2011
@@ -27,6 +27,7 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.util.List;
+import java.util.ArrayList;
 
 /**
  * A Filter that stops after the given row.  There is no "RowStopFilter" because
@@ -72,6 +73,16 @@ public class InclusiveStopFilter extends
     return done;
   }
 
+  @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    if (filterArguments.size() != 1) {
+      throw new IllegalArgumentException("Incorrect arguments passed to InclusiveStopFilter. " +
+                                         "Expected: 1 but got: " + filterArguments.size());
+    }
+    byte [] stopRowKey = ParseFilter.convertByteArrayToString(filterArguments.get(0));
+    return new InclusiveStopFilter(stopRowKey);
+  }
+
   public void write(DataOutput out) throws IOException {
     Bytes.writeByteArray(out, this.stopRowKey);
   }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/KeyOnlyFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/KeyOnlyFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/KeyOnlyFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/KeyOnlyFilter.java Tue Aug  9 23:28:56 2011
@@ -25,6 +25,8 @@ import java.io.IOException;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.util.Bytes;
 
+import java.util.ArrayList;
+
 /**
  * A filter that will only return the key component of each KV (the value will
  * be rewritten as empty).
@@ -44,6 +46,15 @@ public class KeyOnlyFilter extends Filte
     return ReturnCode.INCLUDE;
   }
 
+  @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    if (filterArguments.size() != 0) {
+      throw new IllegalArgumentException("Incorrect Arguments passed to KeyOnlyFilter. " +
+                                         "Expected: 0 but got: " + filterArguments.size());
+    }
+    return new KeyOnlyFilter();
+  }
+
   public void write(DataOutput out) throws IOException {
     out.writeBoolean(this.lenAsVal);
   }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/MultipleColumnPrefixFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/MultipleColumnPrefixFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/MultipleColumnPrefixFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/MultipleColumnPrefixFilter.java Tue Aug  9 23:28:56 2011
@@ -26,6 +26,7 @@ import java.io.DataInput;
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.TreeSet;
+import java.util.ArrayList;
 
 /**
  * This filter is used for selecting only those keys with columns that matches
@@ -75,11 +76,11 @@ public class MultipleColumnPrefixFilter 
 
     if (lesserOrEqualPrefixes.size() != 0) {
       byte [] largestPrefixSmallerThanQualifier = lesserOrEqualPrefixes.last();
-      
+
       if (Bytes.startsWith(qualifier, largestPrefixSmallerThanQualifier)) {
         return ReturnCode.INCLUDE;
       }
-      
+
       if (lesserOrEqualPrefixes.size() == sortedPrefixes.size()) {
         return ReturnCode.NEXT_ROW;
       } else {
@@ -92,6 +93,16 @@ public class MultipleColumnPrefixFilter 
     }
   }
 
+  @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    byte [][] prefixes = new byte [filterArguments.size()][];
+    for (int i = 0 ; i < filterArguments.size(); i++) {
+      byte [] columnPrefix = ParseFilter.convertByteArrayToString(filterArguments.get(i));
+      prefixes[i] = columnPrefix;
+    }
+    return new MultipleColumnPrefixFilter(prefixes);
+  }
+
   public void write(DataOutput out) throws IOException {
     out.writeInt(sortedPrefixes.size());
     for (byte [] element : sortedPrefixes) {

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java?rev=1155969&r1=1155968&r2=1155969&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java Tue Aug  9 23:28:56 2011
@@ -25,6 +25,7 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.util.List;
+import java.util.ArrayList;
 
 /**
  * Implementation of Filter interface that limits results to a specific page
@@ -55,6 +56,9 @@ public class PageFilter extends FilterBa
    * @param pageSize Maximum result size.
    */
   public PageFilter(final long pageSize) {
+    if (pageSize < 0) {
+      throw new IllegalArgumentException("Page Size must not be negative");
+    }
     this.pageSize = pageSize;
   }
 
@@ -71,6 +75,16 @@ public class PageFilter extends FilterBa
     return this.rowsAccepted > this.pageSize;
   }
 
+  @Override
+  public Filter createFilterFromArguments (ArrayList<byte []> filterArguments) {
+    if (filterArguments.size() != 1) {
+      throw new IllegalArgumentException("Incorrect Arguments passed to PageFilter. " +
+                                         "Expected: 1 but got: " + filterArguments.size());
+    }
+    long pageSize = ParseFilter.convertByteArrayToLong(filterArguments.get(0));
+    return new PageFilter(pageSize);
+  }
+
   public void readFields(final DataInput in) throws IOException {
     this.pageSize = in.readLong();
   }

Added: hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ParseConstants.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ParseConstants.java?rev=1155969&view=auto
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ParseConstants.java (added)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/filter/ParseConstants.java Tue Aug  9 23:28:56 2011
@@ -0,0 +1,258 @@
+/**
+ * Copyright 2011 The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.filter;
+
+import org.apache.hadoop.hbase.ipc.HRegionInterface;
+import org.apache.hadoop.hbase.util.Bytes;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import org.apache.hadoop.hbase.filter.*;
+
+/**
+ * ParseConstants holds a bunch of constants related to parsing Filter Strings
+ * Used by {@link ParseFilter}
+ */
+public final class ParseConstants {
+
+  /**
+   * ASCII code for LPAREN
+   */
+  public static final int LPAREN = '(';
+
+  /**
+   * ASCII code for RPAREN
+   */
+  public static final int RPAREN = ')';
+
+  /**
+   * ASCII code for whitespace
+   */
+  public static final int WHITESPACE = ' ';
+
+  /**
+   * ASCII code for tab
+   */
+  public static final int TAB = '\t';
+
+  /**
+   * ASCII code for 'A'
+   */
+  public static final int A = 'A';
+
+  /**
+   * ASCII code for 'N'
+   */
+  public static final int N = 'N';
+
+  /**
+   * ASCII code for 'D'
+   */
+  public static final int D = 'D';
+
+  /**
+   * ASCII code for 'O'
+   */
+  public static final int O = 'O';
+
+  /**
+   * ASCII code for 'R'
+   */
+  public static final int R = 'R';
+
+  /**
+   * ASCII code for 'S'
+   */
+  public static final int S = 'S';
+
+  /**
+   * ASCII code for 'K'
+   */
+  public static final int K = 'K';
+
+  /**
+   * ASCII code for 'I'
+   */
+  public static final int I = 'I';
+
+  /**
+   * ASCII code for 'P'
+   */
+  public static final int P = 'P';
+
+  /**
+   * SKIP Array
+   */
+  public static final byte [] SKIP_ARRAY = new byte [ ] {'S', 'K', 'I', 'P'};
+  public static final ByteBuffer SKIP_BUFFER = ByteBuffer.wrap(SKIP_ARRAY);
+
+  /**
+   * ASCII code for 'W'
+   */
+  public static final int W = 'W';
+
+  /**
+   * ASCII code for 'H'
+   */
+  public static final int H = 'H';
+
+  /**
+   * ASCII code for 'L'
+   */
+  public static final int L = 'L';
+
+  /**
+   * ASCII code for 'E'
+   */
+  public static final int E = 'E';
+
+  /**
+   * WHILE Array
+   */
+  public static final byte [] WHILE_ARRAY = new byte [] {'W', 'H', 'I', 'L', 'E'};
+  public static final ByteBuffer WHILE_BUFFER = ByteBuffer.wrap(WHILE_ARRAY);
+
+  /**
+   * OR Array
+   */
+  public static final byte [] OR_ARRAY = new byte [] {'O','R'};
+  public static final ByteBuffer OR_BUFFER = ByteBuffer.wrap(OR_ARRAY);
+
+  /**
+   * AND Array
+   */
+  public static final byte [] AND_ARRAY = new byte [] {'A','N', 'D'};
+  public static final ByteBuffer AND_BUFFER = ByteBuffer.wrap(AND_ARRAY);
+
+  /**
+   * ASCII code for Backslash
+   */
+  public static final int BACKSLASH = '\\';
+
+  /**
+   * ASCII code for a single quote
+   */
+  public static final int SINGLE_QUOTE = '\'';
+
+  /**
+   * ASCII code for a comma
+   */
+  public static final int COMMA = ',';
+
+  /**
+   * LESS_THAN Array
+   */
+  public static final byte [] LESS_THAN_ARRAY = new byte [] {'<'};
+  public static final ByteBuffer LESS_THAN_BUFFER = ByteBuffer.wrap(LESS_THAN_ARRAY);
+
+  /**
+   * LESS_THAN_OR_EQUAL_TO Array
+   */
+  public static final byte [] LESS_THAN_OR_EQUAL_TO_ARRAY = new byte [] {'<', '='};
+  public static final ByteBuffer LESS_THAN_OR_EQUAL_TO_BUFFER =
+    ByteBuffer.wrap(LESS_THAN_OR_EQUAL_TO_ARRAY);
+
+  /**
+   * GREATER_THAN Array
+   */
+  public static final byte [] GREATER_THAN_ARRAY = new byte [] {'>'};
+  public static final ByteBuffer GREATER_THAN_BUFFER = ByteBuffer.wrap(GREATER_THAN_ARRAY);
+
+  /**
+   * GREATER_THAN_OR_EQUAL_TO Array
+   */
+  public static final byte [] GREATER_THAN_OR_EQUAL_TO_ARRAY = new byte [] {'>', '='};
+  public static final ByteBuffer GREATER_THAN_OR_EQUAL_TO_BUFFER =
+    ByteBuffer.wrap(GREATER_THAN_OR_EQUAL_TO_ARRAY);
+
+  /**
+   * EQUAL_TO Array
+   */
+  public static final byte [] EQUAL_TO_ARRAY = new byte [] {'='};
+  public static final ByteBuffer EQUAL_TO_BUFFER = ByteBuffer.wrap(EQUAL_TO_ARRAY);
+
+  /**
+   * NOT_EQUAL_TO Array
+   */
+  public static final byte [] NOT_EQUAL_TO_ARRAY = new byte [] {'!', '='};
+  public static final ByteBuffer NOT_EQUAL_TO_BUFFER = ByteBuffer.wrap(NOT_EQUAL_TO_ARRAY);
+
+  /**
+   * ASCII code for equal to (=)
+   */
+  public static final int EQUAL_TO = '=';
+
+  /**
+   * AND Byte Array
+   */
+  public static final byte [] AND = new byte [] {'A','N','D'};
+
+  /**
+   * OR Byte Array
+   */
+  public static final byte [] OR = new byte [] {'O', 'R'};
+
+  /**
+   * LPAREN Array
+   */
+  public static final byte [] LPAREN_ARRAY = new byte [] {'('};
+  public static final ByteBuffer LPAREN_BUFFER = ByteBuffer.wrap(LPAREN_ARRAY);
+
+  /**
+   * ASCII code for colon (:)
+   */
+  public static final int COLON = ':';
+
+  /**
+   * ASCII code for Zero
+   */
+  public static final int ZERO = '0';
+
+  /**
+   * ASCII code foe Nine
+   */
+  public static final int NINE = '9';
+
+  /**
+   * BinaryType byte array
+   */
+  public static final byte [] binaryType = new byte [] {'b','i','n','a','r','y'};
+
+  /**
+   * BinaryPrefixType byte array
+   */
+  public static final byte [] binaryPrefixType = new byte [] {'b','i','n','a','r','y',
+                                                              'p','r','e','f','i','x'};
+
+  /**
+   * RegexStringType byte array
+   */
+  public static final byte [] regexStringType = new byte [] {'r','e','g','e', 'x',
+                                                             's','t','r','i','n','g'};
+
+  /**
+   * SubstringType byte array
+   */
+  public static final byte [] substringType = new byte [] {'s','u','b','s','t','r','i','n','g'};
+
+  /**
+   * ASCII for Minus Sign
+   */
+  public static final int MINUS_SIGN = '-';
+}
\ No newline at end of file



Mime
View raw message