org.apache.accumulo.examples.simple.dirlist
Class QueryUtil

java.lang.Object
  extended by org.apache.accumulo.examples.simple.dirlist.QueryUtil

public class QueryUtil
extends Object

Provides utility methods for getting the info for a file, listing the contents of a directory, and performing single wild card searches on file or directory names. See docs/examples/README.dirlist for instructions.


Field Summary
static org.apache.hadoop.io.Text COUNTS_COLQ
           
static org.apache.hadoop.io.Text DIR_COLF
           
static org.apache.hadoop.io.Text FORWARD_PREFIX
           
static org.apache.hadoop.io.Text INDEX_COLF
           
static org.apache.hadoop.io.Text REVERSE_PREFIX
           
 
Constructor Summary
QueryUtil(String instanceName, String zooKeepers, String user, String password, String tableName, Authorizations auths)
           
 
Method Summary
 Iterable<Map.Entry<Key,Value>> exactTermSearch(String term)
          Scans over the index table for files or directories with a given name.
 Map<String,String> getData(String path)
          Scans over the directory table and pulls out stat information about a path.
static int getDepth(String path)
          Calculates the depth of a path, i.e.
 Map<String,Map<String,String>> getDirList(String path)
          Uses the directory table to list the contents of a directory.
static org.apache.hadoop.io.Text getForwardIndex(String path)
          Given a path, construct an accumulo row prepended with the FORWARD_PREFIX for the index table.
static org.apache.hadoop.io.Text getReverseIndex(String path)
          Given a path, construct an accumulo row prepended with the REVERSE_PREFIX with the path reversed for the index table.
static org.apache.hadoop.io.Text getRow(String path)
          Given a path, construct an accumulo row prepended with the path's depth for the directory table.
static String getType(org.apache.hadoop.io.Text colf)
          Returns either the DIR_COLF or a decoded string version of the colf.
static void main(String[] args)
          Lists the contents of a directory using the directory table, or searches for file or directory names (if the -search flag is included).
 Iterable<Map.Entry<Key,Value>> singleRestrictedWildCardSearch(String exp)
          Scans over the index table for files or directories with a given name, prefix, or suffix (indicated by a wildcard '*' at the beginning or end of the term.
 Iterable<Map.Entry<Key,Value>> singleWildCardSearch(String exp)
          Scans over the index table for files or directories with a given name that can contain a single wildcard '*' anywhere in the term.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIR_COLF

public static final org.apache.hadoop.io.Text DIR_COLF

FORWARD_PREFIX

public static final org.apache.hadoop.io.Text FORWARD_PREFIX

REVERSE_PREFIX

public static final org.apache.hadoop.io.Text REVERSE_PREFIX

INDEX_COLF

public static final org.apache.hadoop.io.Text INDEX_COLF

COUNTS_COLQ

public static final org.apache.hadoop.io.Text COUNTS_COLQ
Constructor Detail

QueryUtil

public QueryUtil(String instanceName,
                 String zooKeepers,
                 String user,
                 String password,
                 String tableName,
                 Authorizations auths)
          throws AccumuloException,
                 AccumuloSecurityException
Throws:
AccumuloException
AccumuloSecurityException
Method Detail

getDepth

public static int getDepth(String path)
Calculates the depth of a path, i.e. the number of forward slashes in the path name.

Parameters:
path - the full path of a file or directory
Returns:
the depth of the path

getRow

public static org.apache.hadoop.io.Text getRow(String path)
Given a path, construct an accumulo row prepended with the path's depth for the directory table.

Parameters:
path - the full path of a file or directory
Returns:
the accumulo row associated with this path

getForwardIndex

public static org.apache.hadoop.io.Text getForwardIndex(String path)
Given a path, construct an accumulo row prepended with the FORWARD_PREFIX for the index table.

Parameters:
path - the full path of a file or directory
Returns:
the accumulo row associated with this path

getReverseIndex

public static org.apache.hadoop.io.Text getReverseIndex(String path)
Given a path, construct an accumulo row prepended with the REVERSE_PREFIX with the path reversed for the index table.

Parameters:
path - the full path of a file or directory
Returns:
the accumulo row associated with this path

getType

public static String getType(org.apache.hadoop.io.Text colf)
Returns either the DIR_COLF or a decoded string version of the colf.

Parameters:
colf - the column family

getData

public Map<String,String> getData(String path)
                           throws TableNotFoundException
Scans over the directory table and pulls out stat information about a path.

Parameters:
path - the full path of a file or directory
Throws:
TableNotFoundException

getDirList

public Map<String,Map<String,String>> getDirList(String path)
                                          throws TableNotFoundException
Uses the directory table to list the contents of a directory.

Parameters:
path - the full path of a directory
Throws:
TableNotFoundException

exactTermSearch

public Iterable<Map.Entry<Key,Value>> exactTermSearch(String term)
                                               throws Exception
Scans over the index table for files or directories with a given name.

Parameters:
term - the name a file or directory to search for
Throws:
Exception

singleRestrictedWildCardSearch

public Iterable<Map.Entry<Key,Value>> singleRestrictedWildCardSearch(String exp)
                                                              throws Exception
Scans over the index table for files or directories with a given name, prefix, or suffix (indicated by a wildcard '*' at the beginning or end of the term.

Parameters:
exp - the name a file or directory to search for with an optional wildcard '*' at the beginning or end
Throws:
Exception

singleWildCardSearch

public Iterable<Map.Entry<Key,Value>> singleWildCardSearch(String exp)
                                                    throws Exception
Scans over the index table for files or directories with a given name that can contain a single wildcard '*' anywhere in the term.

Parameters:
exp - the name a file or directory to search for with one optional wildcard '*'
Throws:
Exception

main

public static void main(String[] args)
                 throws Exception
Lists the contents of a directory using the directory table, or searches for file or directory names (if the -search flag is included).

Parameters:
args -
Throws:
Exception


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.