Index: src/main/java/org/apache/hadoop/hbase/filter/ParseFilter.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/filter/ParseFilter.java (revision 1161203) +++ src/main/java/org/apache/hadoop/hbase/filter/ParseFilter.java (working copy) @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Stack; import java.util.HashMap; +import java.util.Set; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Writables; @@ -50,14 +51,50 @@ */ public class ParseFilter { - private HashMap operatorPrecedenceHashMap; + private static HashMap operatorPrecedenceHashMap; + private static HashMap filterHashMap; - /** - * Constructor - *

- * Creates the operatorPrecedenceHashMap - */ - public ParseFilter() { + static { + // Registers all the filter supported by the Filter Language + filterHashMap = new HashMap(); + filterHashMap.put("KeyOnlyFilter", ParseConstants.FILTER_PACKAGE + "." + + "KeyOnlyFilter"); + filterHashMap.put("FirstKeyOnlyFilter", ParseConstants.FILTER_PACKAGE + "." + + "FirstKeyOnlyFilter"); + filterHashMap.put("PrefixFilter", ParseConstants.FILTER_PACKAGE + "." + + "PrefixFilter"); + filterHashMap.put("ColumnPrefixFilter", ParseConstants.FILTER_PACKAGE + "." + + "ColumnPrefixFilter"); + filterHashMap.put("MultipleColumnPrefixFilter", ParseConstants.FILTER_PACKAGE + "." + + "MultipleColumnPrefixFilter"); + filterHashMap.put("ColumnCountGetFilter", ParseConstants.FILTER_PACKAGE + "." + + "ColumnCountGetFilter"); + filterHashMap.put("PageFilter", ParseConstants.FILTER_PACKAGE + "." + + "PageFilter"); + filterHashMap.put("ColumnPaginationFilter", ParseConstants.FILTER_PACKAGE + "." + + "ColumnPaginationFilter"); + filterHashMap.put("InclusiveStopFilter", ParseConstants.FILTER_PACKAGE + "." + + "InclusiveStopFilter"); + filterHashMap.put("TimestampsFilter", ParseConstants.FILTER_PACKAGE + "." + + "TimestampsFilter"); + filterHashMap.put("RowFilter", ParseConstants.FILTER_PACKAGE + "." + + "RowFilter"); + filterHashMap.put("FamilyFilter", ParseConstants.FILTER_PACKAGE + "." + + "FamilyFilter"); + filterHashMap.put("QualifierFilter", ParseConstants.FILTER_PACKAGE + "." + + "QualifierFilter"); + filterHashMap.put("ValueFilter", ParseConstants.FILTER_PACKAGE + "." + + "ValueFilter"); + filterHashMap.put("ColumnRangeFilter", ParseConstants.FILTER_PACKAGE + "." + + "ColumnRangeFilter"); + filterHashMap.put("SingleColumnValueFilter", ParseConstants.FILTER_PACKAGE + "." + + "SingleColumnValueFilter"); + filterHashMap.put("SingleColumnValueExcludeFilter", ParseConstants.FILTER_PACKAGE + "." + + "SingleColumnValueExcludeFilter"); + filterHashMap.put("DependentColumnFilter", ParseConstants.FILTER_PACKAGE + "." + + "DependentColumnFilter"); + + // Creates the operatorPrecedenceHashMap operatorPrecedenceHashMap = new HashMap(); operatorPrecedenceHashMap.put(ParseConstants.SKIP_BUFFER, 1); operatorPrecedenceHashMap.put(ParseConstants.WHILE_BUFFER, 1); @@ -199,8 +236,11 @@ String filterName = Bytes.toString(getFilterName(filterStringAsByteArray)); ArrayList filterArguments = getFilterArguments(filterStringAsByteArray); + if (!filterHashMap.containsKey(filterName)) { + throw new IllegalArgumentException("Filter Name " + filterName + " not supported"); + } try { - filterName = ParseConstants.FILTER_PACKAGE + "." + filterName; + filterName = filterHashMap.get(filterName); Class c = Class.forName(filterName); Class[] argTypes = new Class [] {ArrayList.class}; Method m = c.getDeclaredMethod("createFilterFromArguments", argTypes); @@ -793,4 +833,11 @@ return result; } + +/** + * Return a Set of filters supported by the Filter Language + */ + public Set getSupportedFilters () { + return filterHashMap.keySet(); + } } Index: src/main/ruby/shell/commands/show_filters.rb =================================================================== --- src/main/ruby/shell/commands/show_filters.rb (revision 0) +++ src/main/ruby/shell/commands/show_filters.rb (revision 0) @@ -0,0 +1,50 @@ +# +# 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. +# + +java_import org.apache.hadoop.hbase.filter.ParseFilter + +module Shell + module Commands + class ShowFilters < Command + def help + return <<-EOF +Show all the filters in hbase. Example: + hbase> show_filters + + ColumnPrefixFilter + TimestampsFilter + PageFilter + ..... + KeyOnlyFilter +EOF + end + + def command( ) + now = Time.now + parseFilter = ParseFilter.new + supportedFilters = parseFilter.getSupportedFilters + + supportedFilters.each do |filter| + formatter.row([filter]) + end + end + end + end +end Index: src/main/ruby/shell.rb =================================================================== --- src/main/ruby/shell.rb (revision 1161203) +++ src/main/ruby/shell.rb (working copy) @@ -227,6 +227,7 @@ is_enabled exists list + show_filters ] )