incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [7/9] Tons of changes to make shell work. This has uncovered some limitations in the queryargs object. Refactored to allow for different query types.
Date Mon, 31 Dec 2012 20:44:03 GMT
http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-core/src/main/java/org/apache/blur/utils/ThriftLuceneConversion.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/utils/ThriftLuceneConversion.java b/src/blur-core/src/main/java/org/apache/blur/utils/ThriftLuceneConversion.java
index 741b0d1..a71210e 100644
--- a/src/blur-core/src/main/java/org/apache/blur/utils/ThriftLuceneConversion.java
+++ b/src/blur-core/src/main/java/org/apache/blur/utils/ThriftLuceneConversion.java
@@ -32,6 +32,7 @@ import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.queryparser.classic.ParseException;
 import org.apache.lucene.queryparser.classic.QueryParser;
+import org.apache.lucene.queryparser.classic.QueryParserBase;
 import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Sort;
@@ -305,26 +306,43 @@ public class ThriftLuceneConversion {
     return docs;
   }
 
-  public static Query[] toLucene(ByteBuffer[] queries) throws IOException {
+  public static Query[] toLuceneQueryFromBinary(ByteBuffer[] queries) throws IOException {
     Query[] result = new Query[queries.length];
     for (int i = 0; i < queries.length; i++) {
-      result[i] = toLuceneQuery(queries[i]);
+      result[i] = toLuceneQueryFromBinary(queries[i]);
     }
     return result;
   }
 
-  public static Query toLuceneQuery(ByteBuffer byteBuffer) throws IOException {
+  public static Query toLuceneQueryFromBinary(ByteBuffer byteBuffer) throws IOException {
     DataInputBuffer in = new DataInputBuffer();
     in.reset(byteBuffer.array(), byteBuffer.arrayOffset() + byteBuffer.position(), byteBuffer.remaining());
     QueryWritable qw = new QueryWritable();
     qw.readFields(in);
     return qw.getQuery();
   }
-
-  public static Query toLucene(QueryArgs queryArgs) throws IOException {
+  
+  public static Query toLuceneQuery(QueryArgs queryArgs) {
     return toLuceneQuery(queryArgs.getQuery());
   }
 
+  public static Query toLuceneQuery(org.apache.blur.thrift.generated.Query query) {
+    switch (query.getType()) {
+    case STRING:
+
+      break;
+    case JSON:
+
+      break;
+    case BINARY:
+
+      break;
+    default:
+      break;
+    }
+    return null;
+  }
+
   public static Query toLuceneQuery(byte[] bs) throws IOException {
     DataInputBuffer in = new DataInputBuffer();
     in.reset(bs, bs.length);
@@ -481,4 +499,5 @@ public class ThriftLuceneConversion {
     System.arraycopy(buffer.getData(), 0, buf, 0, buf.length);
     return buf;
   }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-core/src/test/java/org/apache/blur/manager/writer/BlurNRTIndexTest.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/test/java/org/apache/blur/manager/writer/BlurNRTIndexTest.java b/src/blur-core/src/test/java/org/apache/blur/manager/writer/BlurNRTIndexTest.java
index 5e0d2a4..e81e76a 100644
--- a/src/blur-core/src/test/java/org/apache/blur/manager/writer/BlurNRTIndexTest.java
+++ b/src/blur-core/src/test/java/org/apache/blur/manager/writer/BlurNRTIndexTest.java
@@ -29,11 +29,14 @@ import java.util.concurrent.ExecutorService;
 
 import org.apache.blur.analysis.BlurAnalyzer;
 import org.apache.blur.concurrent.Executors;
+import org.apache.blur.thrift.ShardContext;
+import org.apache.blur.thrift.TableContext;
 import org.apache.blur.thrift.generated.Document;
 import org.apache.blur.thrift.generated.Field;
 import org.apache.blur.thrift.generated.TYPE;
+import org.apache.blur.thrift.generated.TableDescriptor;
+import org.apache.blur.utils.BlurConstants;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.Path;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.store.FSDirectory;
@@ -79,12 +82,18 @@ public class BlurNRTIndexTest {
     writer = new BlurNRTIndex();
     writer.setDirectory(FSDirectory.open(new File(base, "index")));
     writer.setCloser(closer);
-    writer.setAnalyzer(analyzer);
-    writer.setTable("testing-table");
-    writer.setShard("testing-shard");
-    writer.setWalPath(new Path(new File(base, "wal").toURI()));
-    writer.setConfiguration(configuration);
-    writer.setTimeBetweenRefreshs(refresh);
+    TableDescriptor tableDescriptor = new TableDescriptor();
+    tableDescriptor.setStoragePath(new File(base, "index").toURI().toString());
+    tableDescriptor.setName("testing-table");
+    tableDescriptor.putToProperties(BlurConstants.BLUR_SHARD_TIME_BETWEEN_REFRESHS, Long.toString(refresh));
+    TableContext context = TableContext.create(tableDescriptor);
+    writer.setContext(ShardContext.create(context, "testing-shard"));
+    // writer.setAnalyzer(analyzer);
+    // writer.setTable("testing-table");
+    // writer.setShard("testing-shard");
+    // writer.setWalPath(new Path(new File(base, "wal").toURI()));
+    // writer.setConfiguration(configuration);
+    // writer.setTimeBetweenRefreshs(refresh);
     writer.init();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-core/src/test/java/org/apache/blur/thrift/ITBlurClusterTest.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/test/java/org/apache/blur/thrift/ITBlurClusterTest.java b/src/blur-core/src/test/java/org/apache/blur/thrift/ITBlurClusterTest.java
index 3a8971e..88a7f5c 100644
--- a/src/blur-core/src/test/java/org/apache/blur/thrift/ITBlurClusterTest.java
+++ b/src/blur-core/src/test/java/org/apache/blur/thrift/ITBlurClusterTest.java
@@ -35,22 +35,21 @@ import org.apache.blur.thrift.generated.Document;
 import org.apache.blur.thrift.generated.Field;
 import org.apache.blur.thrift.generated.Generation;
 import org.apache.blur.thrift.generated.MutateOptions;
+import org.apache.blur.thrift.generated.Query;
 import org.apache.blur.thrift.generated.QueryArgs;
+import org.apache.blur.thrift.generated.QueryType;
 import org.apache.blur.thrift.generated.Session;
 import org.apache.blur.thrift.generated.TYPE;
 import org.apache.blur.thrift.generated.TableDescriptor;
 import org.apache.blur.thrift.generated.TopFieldDocs;
 import org.apache.blur.thrift.generated.UpdatePackage;
 import org.apache.blur.utils.BlurUtil;
-import org.apache.blur.utils.ThriftLuceneConversion;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.LocalFileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsAction;
 import org.apache.hadoop.fs.permission.FsPermission;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.TermQuery;
 import org.apache.thrift.TException;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -137,9 +136,10 @@ public class ITBlurClusterTest {
 
     Session session = client.openReadSession(tableDescriptor.getName());
     QueryArgs queryArgs = new QueryArgs();
-    Term term = new Term("value", "test");
-    TermQuery query = new TermQuery(term);
-    queryArgs.setQuery(ThriftLuceneConversion.toBytes(query));
+    Query query = new Query();
+    query.setType(QueryType.STRING);
+    query.setQueryString("value:test");
+    queryArgs.setQuery(query);
     List<TopFieldDocs> results = client.search(session, queryArgs);
     long totalHits = 0;
     for (TopFieldDocs fieldDocs : results) {
@@ -185,9 +185,10 @@ public class ITBlurClusterTest {
 
     Session session = client.openReadSession(tableDescriptor.getName());
     QueryArgs queryArgs = new QueryArgs();
-    Term term = new Term("value", "test");
-    TermQuery query = new TermQuery(term);
-    queryArgs.setQuery(ThriftLuceneConversion.toBytes(query));
+    Query query = new Query();
+    query.setType(QueryType.STRING);
+    query.setQueryString("value:test");
+    queryArgs.setQuery(query);
     List<TopFieldDocs> results = client.search(session, queryArgs);
     long totalHits = 0;
     for (TopFieldDocs fieldDocs : results) {
@@ -240,9 +241,10 @@ public class ITBlurClusterTest {
 
     Session session = client.openReadSession(tableDescriptor.getName());
     QueryArgs queryArgs = new QueryArgs();
-    Term term = new Term("value", "test");
-    TermQuery query = new TermQuery(term);
-    queryArgs.setQuery(ThriftLuceneConversion.toBytes(query));
+    Query query = new Query();
+    query.setType(QueryType.STRING);
+    query.setQueryString("value:test");
+    queryArgs.setQuery(query);
     List<TopFieldDocs> results = client.search(session, queryArgs);
     long totalHits = 0;
     for (TopFieldDocs fieldDocs : results) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-mapred/src/main/java/org/apache/blur/example/BlurExampleIndexReader.java
----------------------------------------------------------------------
diff --git a/src/blur-mapred/src/main/java/org/apache/blur/example/BlurExampleIndexReader.java b/src/blur-mapred/src/main/java/org/apache/blur/example/BlurExampleIndexReader.java
index cd09716..e3a692f 100644
--- a/src/blur-mapred/src/main/java/org/apache/blur/example/BlurExampleIndexReader.java
+++ b/src/blur-mapred/src/main/java/org/apache/blur/example/BlurExampleIndexReader.java
@@ -20,7 +20,9 @@ import java.io.IOException;
 import java.util.Collection;
 
 import org.apache.blur.mapreduce.lib.BlurMapReduceUtil;
+import org.apache.blur.thrift.generated.Query;
 import org.apache.blur.thrift.generated.QueryArgs;
+import org.apache.blur.thrift.generated.QueryType;
 import org.apache.blur.utils.ThriftLuceneConversion;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
@@ -53,7 +55,10 @@ public class BlurExampleIndexReader {
     job.setNumReduceTasks(0);
     job.setMapperClass(BlurExampleReaderMapper.class);
     QueryArgs queryArgs = new QueryArgs();
-    queryArgs.setQuery(ThriftLuceneConversion.toBytes(new MatchAllDocsQuery()));
+    Query query = new Query();
+    query.setType(QueryType.BINARY);
+    query.setQueryBinary(ThriftLuceneConversion.toBytes(new MatchAllDocsQuery()));
+    queryArgs.setQuery(query);
     BlurMapReduceUtil.setupReaderJob(job, connectionStr, table, null, queryArgs);
     job.setOutputFormatClass(TextOutputFormat.class);
     job.setOutputKeyClass(LongWritable.class);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/AddCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/AddCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/AddCommand.java
new file mode 100644
index 0000000..03dcf35
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/AddCommand.java
@@ -0,0 +1,79 @@
+/**
+ * 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.blur.shell;
+
+import java.io.PrintWriter;
+
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.thrift.TException;
+
+public class AddCommand extends Command {
+  public AddCommand(Iface client) {
+    super(client);
+  }
+
+  @Override
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
+    if (args.length != 7) {
+      throw new CommandException("Invalid args: " + help());
+    }
+    String tablename = args[1];
+    String rowid = args[2];
+    String recordid = args[3];
+    String columnfamily = args[4];
+    String columnname = args[5];
+    String value = args[6];
+
+    throw new CommandException("Needs to be implemented");
+
+    // List<Column> columns = new ArrayList<Column>();
+    // columns.add(new Column(columnname, value));
+    //
+    // Record record = new Record();
+    // record.setRecordId(recordid);
+    // record.setFamily(columnfamily);
+    // record.setColumns(columns);
+    //
+    // RecordMutation recordMutation = new RecordMutation();
+    // recordMutation.setRecord(record);
+    // recordMutation.setRecordMutationType(RecordMutationType.REPLACE_ENTIRE_RECORD);
+    //
+    // List<RecordMutation> recordMutations = new ArrayList<RecordMutation>();
+    // recordMutations.add(recordMutation);
+    //
+    // RowMutation mutation = new RowMutation();
+    // mutation.setTable(tablename);
+    // mutation.setRowId(rowid);
+    // mutation.setRowMutationType(RowMutationType.REPLACE_ROW);
+    // mutation.setRecordMutations(recordMutations);
+    //
+    // client.mutate(mutation);
+  }
+
+  @Override
+  public String help() {
+    return "mutate the specified row, args; tablename rowid recordid columnfamily columnname value";
+  }
+
+  @Override
+  public String getName() {
+    return "add";
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/Command.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/Command.java b/src/blur-shell/src/main/java/org/apache/blur/shell/Command.java
index 0e11f8c..b0143c0 100644
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/Command.java
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/Command.java
@@ -18,21 +18,106 @@
 
 package org.apache.blur.shell;
 
+import static jline.internal.Preconditions.checkNotNull;
+
 import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
-import org.apache.thrift.TException;
+import jline.console.completer.Completer;
 
+import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.thrift.TException;
+
+public abstract class Command implements Completer {
+
+  private Iface client;
 
-public abstract class Command {
   @SuppressWarnings("serial")
   public static class CommandException extends Exception {
     public CommandException(String msg) {
       super(msg);
     }
   }
-  abstract public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException;
-  abstract public String help();
+
+  private static SortedSet<String> commandSet = new TreeSet<String>();
+  private static Map<String, Command> commandMap = new HashMap<String, Command>();
+
+  public Command(Iface client) {
+    this.client = client;
+    commandSet.add(getName());
+    commandMap.put(getName(), this);
+  }
+
+  public Iface getClient() {
+    return client;
+  }
+
+  public abstract void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException;
+
+  public abstract String help();
+
+  public abstract String getName();
+
+  @Override
+  public final int complete(String buffer, int cursor, List<CharSequence> candidates) {
+    // buffer could be null
+    checkNotNull(candidates);
+    
+    if (buffer == null) {
+      candidates.addAll(commandSet);
+    } else {
+      String key = firstString(buffer);
+      Command command = commandMap.get(key);
+      if (command != null) {
+        try {
+          return commandComplete(buffer, cursor, candidates);
+        } catch (BlurException e) {
+          return -1;
+        } catch (TException e) {
+          return -1;
+        }
+      }
+
+      for (String match : commandSet.tailSet(buffer)) {
+        if (!match.startsWith(buffer)) {
+          break;
+        }
+        candidates.add(match);
+      }
+    }
+
+    if (candidates.size() == 1) {
+      candidates.set(0, candidates.get(0) + " ");
+    }
+
+    return candidates.isEmpty() ? -1 : 0;
+  }
+
+  protected int commandComplete(String buffer, int cursor, List<CharSequence> candidates) throws BlurException, TException {
+    return -1;
+  }
+
+  protected String firstString(String buffer) {
+    int index = buffer.indexOf(' ');
+    if (index < 0) {
+      return buffer;
+    }
+    return buffer.substring(0, index);
+  }
+  
+  protected String[] getArgs(String buffer) {
+    return buffer.split("\\s+");
+  }
+
+  protected boolean thisCommand(String[] args) {
+    if (args[0].equals(getName())) {
+      return true;
+    }
+    return false;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/CreateCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/CreateCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/CreateCommand.java
new file mode 100644
index 0000000..5ad402e
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/CreateCommand.java
@@ -0,0 +1,123 @@
+/**
+ * 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.blur.shell;
+
+import java.io.PrintWriter;
+
+import org.apache.blur.thrift.generated.Analyzer;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.TableDescriptor;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+import org.apache.thrift.TException;
+
+public class CreateCommand extends Command {
+
+  public CreateCommand(Iface client) {
+    super(client);
+  }
+
+  private static final String CREATE = "create";
+  private static final String DISABLED = "disabled";
+  private static final String READONLY = "readonly";
+  private static final String SHARDS = "shards";
+  private static final String PATH = "path";
+  private static final String NAME = "name";
+  private static final String HELP = "help";
+  private String[] requiredOptions = new String[] { NAME, PATH, SHARDS };
+
+  @Override
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
+    Options options = new Options();
+    options.addOption("h", HELP, false, "Print the help for this command.");
+    options.addOption("t", NAME, true, "The name of the new table. (Required)");
+    options.addOption("p", PATH, true, "The storage path of the new table (e.g. hdfs://hostname/path). (Required)");
+    options.addOption("s", SHARDS, true, "The number of indexes shards. (Required)");
+    options.addOption("r", READONLY, false, "The make the table in read only mode.");
+    options.addOption("d", DISABLED, false, "Disable the newly created table.");
+
+    CommandLineParser parser = new PosixParser();
+    try {
+      CommandLine line = parser.parse(options, args);
+      boolean printHelp = false;
+      if (line.hasOption(HELP)) {
+        printHelp = true;
+      }
+
+      for (String n : requiredOptions) {
+        if (!line.hasOption(n)) {
+          System.err.println("Missing required argument (" + options.getOption(n) + ")");
+          printHelp = true;
+        }
+      }
+
+      if (printHelp) {
+        HelpFormatter formatter = new HelpFormatter();
+        formatter.printHelp(getName(), options);
+        return;
+      }
+
+      String tablename = line.getOptionValue(NAME);
+      String path = line.getOptionValue(PATH);
+      String shards = line.getOptionValue(SHARDS);
+
+      Analyzer analyzer = new Analyzer();
+
+      TableDescriptor td = new TableDescriptor();
+      td.setStoragePath(path);
+      td.setAnalyzer(analyzer);
+      td.setName(tablename);
+      td.setShardCount(Integer.parseInt(shards));
+
+      if (line.hasOption(READONLY)) {
+        td.setReadOnly(true);
+      }
+      if (line.hasOption(DISABLED)) {
+        td.setEnabled(false);
+      }
+
+      // td.setProperties(properties);
+
+      if (Main.debug) {
+        out.println(td.toString());
+        out.flush();
+      }
+
+      client.createTable(td);
+
+    } catch (ParseException e) {
+      throw new CommandException(e.getMessage());
+    }
+  }
+
+  @Override
+  public String help() {
+    return "create the named table, args; tableuri tablename shardcount";
+  }
+
+  @Override
+  public String getName() {
+    return CREATE;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommand.java
deleted file mode 100644
index b52b4ad..0000000
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/CreateTableCommand.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * 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.blur.shell;
-
-import java.io.PrintWriter;
-
-import org.apache.blur.thrift.generated.AnalyzerDefinition;
-import org.apache.blur.thrift.generated.Blur.Client;
-import org.apache.blur.thrift.generated.BlurException;
-import org.apache.blur.thrift.generated.TableDescriptor;
-import org.apache.thrift.TException;
-
-public class CreateTableCommand extends Command {
-  @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
-    if (args.length != 4) {
-      throw new CommandException("Invalid args: " + help());
-    }
-    String tableuri = args[1];
-    String tablename = args[2];
-    int shardCount = Integer.parseInt(args[3]);
-
-    AnalyzerDefinition ad = new AnalyzerDefinition();
-
-    TableDescriptor td = new TableDescriptor(); 
-    td.setTableUri(tableuri);
-    td.setCluster("default");
-    td.setAnalyzerDefinition(ad);
-    td.setName(tablename);
-
-    td.setShardCount(shardCount);
-
-    if (Main.debug) {
-      out.println(td.toString());
-      out.flush();
-    }
-
-    client.createTable(td);
-  }
-
-  @Override
-  public String help() {
-    return "create the named table, args; tableuri tablename shardcount";
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/DescribeCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/DescribeCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/DescribeCommand.java
new file mode 100644
index 0000000..8b45529
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/DescribeCommand.java
@@ -0,0 +1,103 @@
+/**
+ * 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.blur.shell;
+
+import java.io.PrintWriter;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.blur.thrift.generated.Analyzer;
+import org.apache.blur.thrift.generated.AnalyzerSubType;
+import org.apache.blur.thrift.generated.AnalyzerType;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.TableDescriptor;
+import org.apache.thrift.TException;
+
+public class DescribeCommand extends TableSingleArgumentCommand {
+  public DescribeCommand(Iface client) {
+    super(client);
+  }
+
+  @Override
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
+    if (args.length != 2) {
+      throw new CommandException("Invalid args: " + help());
+    }
+    String tablename = args[1];
+
+    TableDescriptor descriptor = client.describe(tablename);
+    String name = descriptor.getName();
+    out.println("Name:     " + name);
+
+    boolean enabled = descriptor.isEnabled();
+    out.println("Enabled:  " + enabled);
+
+    boolean readOnly = descriptor.isReadOnly();
+    out.println("Readonly: " + readOnly);
+
+    String storagePath = descriptor.getStoragePath();
+    out.println("Path:     " + storagePath);
+
+    int shardCount = descriptor.getShardCount();
+    out.println("Shards:   " + shardCount);
+
+    Analyzer analyzer = descriptor.getAnalyzer();
+    if (analyzer != null) {
+      List<AnalyzerType> analyzerTypes = analyzer.getAnalyzerTypes();
+      if (analyzerTypes != null) {
+        out.println("Analyzer");
+        for (AnalyzerType type : analyzerTypes) {
+          out.println("Field:     " + type.getFieldName());
+          out.println("Class Def: " + type.getClassDefinition());
+          List<AnalyzerSubType> analyzerSubTypes = type.getAnalyzerSubTypes();
+          if (analyzerSubTypes != null) {
+            for (AnalyzerSubType subType : analyzerSubTypes) {
+              out.println("  Sub Field: " + subType.getSubFieldName());
+              out.println("  Class Def: " + subType.getClassDefinition());
+            }
+          }
+        }
+      }
+    }
+
+    Map<String, String> properties = descriptor.getProperties();
+    if (properties != null) {
+      out.println("Properties");
+      Set<String> keySet = new TreeSet<String>(properties.keySet());
+      for (String propKey : keySet) {
+        String propValue = properties.get(propKey);
+        out.println("Key:   " + propKey);
+        out.println("Value: " + propValue);
+      }
+    }
+  }
+
+  @Override
+  public String help() {
+    return "describe the named table, args; tablename";
+  }
+
+  @Override
+  public String getName() {
+    return "describe";
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/DescribeTableCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/DescribeTableCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/DescribeTableCommand.java
deleted file mode 100644
index ecf86c2..0000000
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/DescribeTableCommand.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.blur.shell;
-
-import java.io.PrintWriter;
-
-import org.apache.blur.thrift.generated.Blur.Client;
-import org.apache.blur.thrift.generated.BlurException;
-import org.apache.thrift.TException;
-
-public class DescribeTableCommand extends Command {
-  @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
-    if (args.length != 2) {
-      throw new CommandException("Invalid args: " + help());
-    }
-    String tablename = args[1];
-
-    out.println(client.describe(tablename));
-  }
-
-  @Override
-  public String help() {
-    return "describe the named table, args; tablename";
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/DisableTableCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/DisableTableCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/DisableTableCommand.java
new file mode 100644
index 0000000..ef2377d
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/DisableTableCommand.java
@@ -0,0 +1,57 @@
+/**
+ * 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.blur.shell;
+
+import java.io.PrintWriter;
+
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.thrift.TException;
+
+public class DisableTableCommand extends TableSingleArgumentCommand {
+  public DisableTableCommand(Iface client) {
+    super(client);
+  }
+
+  private static final String DISABLE = "disable";
+
+  @Override
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
+    if (args.length != 2) {
+      throw new CommandException("Invalid args: " + help());
+    }
+    String tablename = args[1];
+
+    if (args[0].equalsIgnoreCase(DISABLE)) {
+      client.disableTable(tablename);
+    } else {
+      throw new CommandException("unknown command" + args[0]);
+    }
+  }
+
+  @Override
+  public String help() {
+    return "change status of the named table, args; tablename";
+  }
+
+  @Override
+  public String getName() {
+    return DISABLE;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/EnableDisableTableCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/EnableDisableTableCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/EnableDisableTableCommand.java
deleted file mode 100644
index 4b26a7d..0000000
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/EnableDisableTableCommand.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.blur.shell;
-
-import java.io.PrintWriter;
-
-import org.apache.blur.thrift.generated.Blur.Client;
-import org.apache.blur.thrift.generated.BlurException;
-import org.apache.thrift.TException;
-
-public class EnableDisableTableCommand extends Command {
-  @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
-    if (args.length != 2) {
-      throw new CommandException("Invalid args: " + help());
-    }
-    String tablename = args[1];
-
-    if (args[0].equalsIgnoreCase("enabletable")) {
-      client.enableTable(tablename);
-    } else if (args[0].equalsIgnoreCase("disabletable")) {
-      client.disableTable(tablename);
-    } else {
-      throw new CommandException("unknown command" + args[0]);
-    }
-  }
-
-  @Override
-  public String help() {
-    return "change status of the named table, args; tablename";
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/EnableTableCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/EnableTableCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/EnableTableCommand.java
new file mode 100644
index 0000000..66efbc6
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/EnableTableCommand.java
@@ -0,0 +1,57 @@
+/**
+ * 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.blur.shell;
+
+import java.io.PrintWriter;
+
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.thrift.TException;
+
+public class EnableTableCommand extends TableSingleArgumentCommand {
+  public EnableTableCommand(Iface client) {
+    super(client);
+  }
+
+  private static final String ENABLE = "enable";
+
+  @Override
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
+    if (args.length != 2) {
+      throw new CommandException("Invalid args: " + help());
+    }
+    String tablename = args[1];
+
+    if (args[0].equalsIgnoreCase(ENABLE)) {
+      client.enableTable(tablename);
+    } else {
+      throw new CommandException("unknown command" + args[0]);
+    }
+  }
+
+  @Override
+  public String help() {
+    return "change status of the named table, args; tablename";
+  }
+
+  @Override
+  public String getName() {
+    return ENABLE;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/GetDocumentCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/GetDocumentCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/GetDocumentCommand.java
new file mode 100644
index 0000000..e283e43
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/GetDocumentCommand.java
@@ -0,0 +1,61 @@
+/**
+ * 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.blur.shell;
+
+import java.io.PrintWriter;
+
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.thrift.TException;
+
+public class GetDocumentCommand extends Command {
+  public GetDocumentCommand(Iface client) {
+    super(client);
+  }
+
+  @Override
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
+    if (args.length != 3) {
+      throw new CommandException("Invalid args: " + help());
+    }
+    String tablename = args[1];
+    String rowId = args[2];
+
+    throw new CommandException("Needs to be implemented");
+
+    //
+    // Selector selector = new Selector();
+    // selector.setRowId(rowId);
+    // FetchResult fetchRow = client.fetchRow(tablename, selector);
+    // FetchRowResult rowResult = fetchRow.getRowResult();
+    // Row row = rowResult.getRow();
+    //
+    // out.println(row);
+  }
+
+  @Override
+  public String help() {
+    return "display the specified row, args; tablename query";
+  }
+
+  @Override
+  public String getName() {
+    return "get";
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/GetRowCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/GetRowCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/GetRowCommand.java
deleted file mode 100644
index 9ba1f7e..0000000
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/GetRowCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.blur.shell;
-
-import java.io.PrintWriter;
-
-import org.apache.blur.thrift.generated.Blur.Client;
-import org.apache.blur.thrift.generated.BlurException;
-import org.apache.blur.thrift.generated.FetchResult;
-import org.apache.blur.thrift.generated.FetchRowResult;
-import org.apache.blur.thrift.generated.Row;
-import org.apache.blur.thrift.generated.Selector;
-import org.apache.thrift.TException;
-
-public class GetRowCommand extends Command {
-  @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
-    if (args.length != 3) {
-      throw new CommandException("Invalid args: " + help());
-    }
-    String tablename = args[1];
-    String rowId = args[2];
-
-    Selector selector = new Selector();
-    selector.setRowId(rowId);
-    FetchResult fetchRow = client.fetchRow(tablename, selector);
-    FetchRowResult rowResult = fetchRow.getRowResult();
-    Row row = rowResult.getRow();
-
-    out.println(row);
-  }
-
-  @Override
-  public String help() {
-    return "display the specified row, args; tablename query";
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/IndexAccessLogCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/IndexAccessLogCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/IndexAccessLogCommand.java
index 6351e9a..48cce2c 100644
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/IndexAccessLogCommand.java
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/IndexAccessLogCommand.java
@@ -19,32 +19,19 @@
 package org.apache.blur.shell;
 
 import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.LineNumberReader;
 import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
-import org.apache.blur.thrift.generated.Column;
-import org.apache.blur.thrift.generated.Record;
-import org.apache.blur.thrift.generated.RecordMutation;
-import org.apache.blur.thrift.generated.RecordMutationType;
-import org.apache.blur.thrift.generated.RowMutation;
-import org.apache.blur.thrift.generated.RowMutationType;
 import org.apache.thrift.TException;
 
-import com.google.common.collect.Lists;
-
 public class IndexAccessLogCommand extends Command {
+  public IndexAccessLogCommand(Iface client) {
+    super(client);
+  }
+
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
     if (args.length < 6) {
       throw new CommandException("Invalid args: " + help());
     }
@@ -53,67 +40,75 @@ public class IndexAccessLogCommand extends Command {
     String tablename = args[3];
     String regex = args[4];
 
-    if (Main.debug) {
-      out.println(regex);
-    }
-
-    Pattern p = Pattern.compile(regex);
-    
-    try {
-      LineNumberReader reader = new LineNumberReader(new FileReader(logfile));
-      try {
-        String line;
-        List<RowMutation> mutations = Lists.newArrayList();
-        while((line = reader.readLine()) != null) {
-          Matcher m = p.matcher(line);
-          if (!m.matches()) {
-            continue;
-          }
-
-          List<Column> columns = new ArrayList<Column>();
-          for (int i = 5; i < args.length; i++) {
-            columns.add(new Column(args[i], m.group(i - 4)));
-          }
-
-          Record record = new Record();
-          record.setRecordId(UUID.randomUUID().toString());
-          record.setFamily("cf1");
-          record.setColumns(columns);
-
-          RecordMutation recordMutation = new RecordMutation();
-          recordMutation.setRecord(record);
-          recordMutation.setRecordMutationType(RecordMutationType.REPLACE_ENTIRE_RECORD);
+    throw new CommandException("Needs to be implemented");
 
-          List<RecordMutation> recordMutations = new ArrayList<RecordMutation>();
-          recordMutations.add(recordMutation);
-
-          RowMutation mutation = new RowMutation();
-          mutation.setTable(tablename);
-          mutation.setRowId(UUID.randomUUID().toString());
-          mutation.setRowMutationType(RowMutationType.REPLACE_ROW);
-          mutation.setRecordMutations(recordMutations);
-
-          mutations.add(mutation);
-
-          if (mutations.size() == batchSize) {
-            client.mutateBatch(mutations);
-            mutations.clear();
-          }
-        }
-        if (mutations.size() > 0) {
-          client.mutateBatch(mutations);
-          mutations.clear();
-        }
-      } finally {
-        reader.close();
-      }
-    } catch (IOException e) {
-      throw new CommandException(e.getMessage());
-    }
+    // if (Main.debug) {
+    // out.println(regex);
+    // }
+    //
+    // Pattern p = Pattern.compile(regex);
+    //
+    // try {
+    // LineNumberReader reader = new LineNumberReader(new FileReader(logfile));
+    // try {
+    // String line;
+    // List<RowMutation> mutations = Lists.newArrayList();
+    // while((line = reader.readLine()) != null) {
+    // Matcher m = p.matcher(line);
+    // if (!m.matches()) {
+    // continue;
+    // }
+    //
+    // List<Column> columns = new ArrayList<Column>();
+    // for (int i = 5; i < args.length; i++) {
+    // columns.add(new Column(args[i], m.group(i - 4)));
+    // }
+    //
+    // Record record = new Record();
+    // record.setRecordId(UUID.randomUUID().toString());
+    // record.setFamily("cf1");
+    // record.setColumns(columns);
+    //
+    // RecordMutation recordMutation = new RecordMutation();
+    // recordMutation.setRecord(record);
+    // recordMutation.setRecordMutationType(RecordMutationType.REPLACE_ENTIRE_RECORD);
+    //
+    // List<RecordMutation> recordMutations = new ArrayList<RecordMutation>();
+    // recordMutations.add(recordMutation);
+    //
+    // RowMutation mutation = new RowMutation();
+    // mutation.setTable(tablename);
+    // mutation.setRowId(UUID.randomUUID().toString());
+    // mutation.setRowMutationType(RowMutationType.REPLACE_ROW);
+    // mutation.setRecordMutations(recordMutations);
+    //
+    // mutations.add(mutation);
+    //
+    // if (mutations.size() == batchSize) {
+    // client.mutateBatch(mutations);
+    // mutations.clear();
+    // }
+    // }
+    // if (mutations.size() > 0) {
+    // client.mutateBatch(mutations);
+    // mutations.clear();
+    // }
+    // } finally {
+    // reader.close();
+    // }
+    // } catch (IOException e) {
+    // throw new CommandException(e.getMessage());
+    // }
   }
 
   @Override
   public String help() {
     return "index an access log, args; file batchsize tablename regex colnames+";
   }
+
+  @Override
+  public String getName() {
+    // TODO Auto-generated method stub
+    return null;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
index d2a1e66..79d4e3b 100644
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/ListTablesCommand.java
@@ -20,19 +20,29 @@ package org.apache.blur.shell;
 
 import java.io.PrintWriter;
 
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.thrift.TException;
 
 public class ListTablesCommand extends Command {
+  public ListTablesCommand(Iface client) {
+    super(client);
+  }
+
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
-    out.println("tables: " + client.tableList());
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
+    for (String table : client.tableList()) {
+      System.out.println(table);
+    }
   }
 
   @Override
   public String help() {
     return "list tables";
   }
+
+  @Override
+  public String getName() {
+    return "list";
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/Main.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/Main.java b/src/blur-shell/src/main/java/org/apache/blur/shell/Main.java
index 86809ce..dd5ec4b 100644
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/Main.java
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/Main.java
@@ -18,8 +18,8 @@
 
 package org.apache.blur.shell;
 
+import java.io.IOException;
 import java.io.PrintWriter;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -27,21 +27,19 @@ import java.util.concurrent.TimeUnit;
 
 import jline.console.ConsoleReader;
 import jline.console.completer.Completer;
+import jline.console.completer.CompletionHandler;
 import jline.console.completer.FileNameCompleter;
 import jline.console.completer.StringsCompleter;
 
 import org.apache.blur.shell.Command.CommandException;
 import org.apache.blur.shell.Main.QuitCommand.QuitCommandException;
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.BlurClient;
+import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.thrift.TException;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.transport.TFramedTransport;
-import org.apache.thrift.transport.TSocket;
-import org.apache.thrift.transport.TTransport;
 
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
 
 public class Main {
   /** is debugging enabled - off by default */
@@ -50,17 +48,19 @@ public class Main {
   static boolean timed = false;
 
   private static Map<String, Command> commands;
-  
+
   public static void usage() {
-    System.out.println("Usage: java " + Main.class.getName()
-        + " controller:port");
+    System.out.println("Usage: java " + Main.class.getName() + " controller:port");
   }
 
   private static class DebugCommand extends Command {
 
+    public DebugCommand(Iface client) {
+      super(client);
+    }
+
     @Override
-    public void doit(PrintWriter out, Client client, String[] args)
-        throws CommandException, TException, BlurException {
+    public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
       if (debug == true) {
         debug = false;
       } else {
@@ -73,14 +73,22 @@ public class Main {
     public String help() {
       return "toggle debugging on/off";
     }
-    
+
+    @Override
+    public String getName() {
+      return "debug";
+    }
+
   }
 
   private static class TimedCommand extends Command {
 
+    public TimedCommand(Iface client) {
+      super(client);
+    }
+
     @Override
-    public void doit(PrintWriter out, Client client, String[] args)
-        throws CommandException, TException, BlurException {
+    public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
       if (timed == true) {
         timed = false;
       } else {
@@ -93,15 +101,23 @@ public class Main {
     public String help() {
       return "toggle timing of commands on/off";
     }
-    
+
+    @Override
+    public String getName() {
+      return "timed";
+    }
+
   }
 
   private static class HelpCommand extends Command {
+    public HelpCommand(Iface client) {
+      super(client);
+    }
+
     @Override
-    public void doit(PrintWriter out, Client client, String[] args)
-        throws CommandException, TException, BlurException {
+    public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
       out.println("Available commands:");
-      for (Entry<String, Command> e: commands.entrySet()) {
+      for (Entry<String, Command> e : commands.entrySet()) {
         out.println("  " + e.getKey() + " - " + e.getValue().help());
       }
     }
@@ -110,9 +126,18 @@ public class Main {
     public String help() {
       return "display help";
     }
+
+    @Override
+    public String getName() {
+      return "help";
+    }
   }
 
   public static class QuitCommand extends Command {
+    public QuitCommand(Iface client) {
+      super(client);
+    }
+
     @SuppressWarnings("serial")
     public static class QuitCommandException extends CommandException {
       public QuitCommandException() {
@@ -121,8 +146,7 @@ public class Main {
     }
 
     @Override
-    public void doit(PrintWriter out, Client client, String[] args)
-        throws CommandException, TException, BlurException {
+    public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
       throw new QuitCommandException();
     }
 
@@ -130,30 +154,15 @@ public class Main {
     public String help() {
       return "exit the shell";
     }
+
+    @Override
+    public String getName() {
+      return "quit";
+    }
+
   }
 
   public static void main(String[] args) throws Throwable {
-    commands = new ImmutableMap.Builder<String,Command>()
-        .put("help", new HelpCommand())
-        .put("debug", new DebugCommand())
-        .put("timed", new TimedCommand())
-        .put("quit", new QuitCommand())
-        .put("listtables", new ListTablesCommand())
-        .put("createtable", new CreateTableCommand())
-        .put("enabletable", new EnableDisableTableCommand())
-        .put("disabletable", new EnableDisableTableCommand())
-        .put("removetable", new RemoveTableCommand())
-        .put("describetable", new DescribeTableCommand())
-        .put("tablestats", new TableStatsCommand())
-        .put("schema", new SchemaTableCommand())
-        .put("query", new QueryCommand())
-        .put("getrow", new GetRowCommand())
-        .put("mutaterow", new MutateRowCommand())
-        .put("indexaccesslog", new IndexAccessLogCommand())
-        .put("shardclusterlist", new ShardClusterListCommand())
-        .put("shardserverlayout", new ShardServerLayoutCommand())
-        .build();
-
     try {
       ConsoleReader reader = new ConsoleReader();
 
@@ -164,72 +173,63 @@ public class Main {
         return;
       }
 
-      String[] hostport = args[0].split(":"); 
+      Iface client = BlurClient.getClient(args[0]);
 
-      if (hostport.length != 2) {
-        usage();
-        return;
-      }
+      buildCommands(client);
 
-      List<Completer> completors = new LinkedList<Completer>();
+      // reader.addCompleter(new StringsCompleter(commands.keySet()));
+      // reader.addCompleter(new FileNameCompleter());
 
-      completors.add(new StringsCompleter(commands.keySet()));
-      completors.add(new FileNameCompleter());
+//      reader.setCompletionHandler(new CompletionHandler() {
+//        @Override
+//        public boolean complete(ConsoleReader reader, List<CharSequence> candidates, int position) throws IOException {
+//          return false;
+//        }
+//      });
 
-      for (Completer c : completors) {
-        reader.addCompleter(c);
+      for (Completer c : commands.values()) {
+        System.out.println("adding " + c + " " + reader.addCompleter(c));
       }
 
-      TTransport trans = new TSocket(hostport[0], Integer.parseInt(hostport[1]));
-      TProtocol proto = new TBinaryProtocol(new TFramedTransport(trans));
-      Client client = new Client(proto);
+      String line;
+      PrintWriter out = new PrintWriter(reader.getOutput());
       try {
-          trans.open();
-
-          String line;
-          PrintWriter out = new PrintWriter(reader.getOutput());
-          try {
-            while ((line = reader.readLine()) != null) {
-              line = line.trim();
-              // ignore empty lines and comments
-              if (line.length() == 0 || line.startsWith("#")) {
-                continue;
+        while ((line = reader.readLine()) != null) {
+          line = line.trim();
+          // ignore empty lines and comments
+          if (line.length() == 0 || line.startsWith("#")) {
+            continue;
+          }
+          String[] commandArgs = line.split("\\s");
+          Command command = commands.get(commandArgs[0]);
+          if (command == null) {
+            out.println("unknown command \"" + commandArgs[0] + "\"");
+          } else {
+            long start = System.nanoTime();
+            try {
+              command.doit(out, client, commandArgs);
+            } catch (QuitCommandException e) {
+              // exit gracefully
+              System.exit(0);
+            } catch (CommandException e) {
+              out.println(e.getMessage());
+              if (debug) {
+                e.printStackTrace(out);
+              }
+            } catch (BlurException e) {
+              out.println(e.getMessage());
+              if (debug) {
+                e.printStackTrace(out);
               }
-              String[] commandArgs = line.split("\\s");
-              Command command = commands.get(commandArgs[0]);
-              if (command == null) {
-                out.println("unknown command \"" + commandArgs[0] + "\"");
-              } else {
-                long start = System.nanoTime();
-                try {
-                  command.doit(out, client, commandArgs);
-                } catch (QuitCommandException e) {
-                  // exit gracefully
-                  System.exit(0);
-                } catch (CommandException e) {
-                  out.println(e.getMessage());
-                  if (debug) {
-                    e.printStackTrace(out);
-                  }
-                } catch (BlurException e) {
-                  out.println(e.getMessage());
-                  if (debug) {
-                    e.printStackTrace(out);
-                  }
-                } finally {
-                  if (timed) {
-                    out.println("Last command took "
-                        + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start)
-                        + "ms");
-                  }
-                }
+            } finally {
+              if (timed) {
+                out.println("Last command took " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) + "ms");
               }
             }
-          } finally {
-            out.close();
           }
+        }
       } finally {
-          trans.close();
+        out.close();
       }
     } catch (Throwable t) {
       t.printStackTrace();
@@ -237,4 +237,31 @@ public class Main {
     }
   }
 
+  private static void buildCommands(Iface client) {
+    Builder<String, Command> builder = new ImmutableMap.Builder<String, Command>();
+
+    add(builder, new HelpCommand(client));
+    add(builder, new DebugCommand(client));
+    add(builder, new TimedCommand(client));
+    add(builder, new QuitCommand(client));
+    add(builder, new ListTablesCommand(client));
+    add(builder, new CreateCommand(client));
+    add(builder, new EnableTableCommand(client));
+    add(builder, new DisableTableCommand(client));
+    add(builder, new RemoveTableCommand(client));
+    add(builder, new DescribeCommand(client));
+    // builder.put("tablestats", new TableStatsCommand());
+    // builder.put("schema", new SchemaTableCommand());
+    add(builder, new SearchCommand(client));
+    add(builder, new GetDocumentCommand(client));
+    add(builder, new AddCommand(client));
+    add(builder, new UpdateCommand(client));
+    // builder.put("indexaccesslog", new IndexAccessLogCommand());
+    // builder.put("shardlayout", new ShardServerLayoutCommand());
+    commands = builder.build();
+  }
+
+  private static void add(Builder<String, Command> builder, Command command) {
+    builder.put(command.getName(), command);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/MutateRowCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/MutateRowCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/MutateRowCommand.java
deleted file mode 100644
index dc4164f..0000000
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/MutateRowCommand.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * 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.blur.shell;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.blur.thrift.generated.Blur.Client;
-import org.apache.blur.thrift.generated.BlurException;
-import org.apache.blur.thrift.generated.Column;
-import org.apache.blur.thrift.generated.Record;
-import org.apache.blur.thrift.generated.RecordMutation;
-import org.apache.blur.thrift.generated.RecordMutationType;
-import org.apache.blur.thrift.generated.RowMutation;
-import org.apache.blur.thrift.generated.RowMutationType;
-import org.apache.thrift.TException;
-
-public class MutateRowCommand extends Command {
-  @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
-    if (args.length != 7) {
-      throw new CommandException("Invalid args: " + help());
-    }
-    String tablename = args[1];
-    String rowid = args[2];
-    String recordid = args[3];
-    String columnfamily = args[4];
-    String columnname = args[5];
-    String value = args[6];
-
-    List<Column> columns = new ArrayList<Column>();
-    columns.add(new Column(columnname, value));
-
-    Record record = new Record();
-    record.setRecordId(recordid);
-    record.setFamily(columnfamily);
-    record.setColumns(columns);
-
-    RecordMutation recordMutation = new RecordMutation();
-    recordMutation.setRecord(record);
-    recordMutation.setRecordMutationType(RecordMutationType.REPLACE_ENTIRE_RECORD);
-
-    List<RecordMutation> recordMutations = new ArrayList<RecordMutation>();
-    recordMutations.add(recordMutation);
-
-    RowMutation mutation = new RowMutation();
-    mutation.setTable(tablename);
-    mutation.setRowId(rowid);
-    mutation.setRowMutationType(RowMutationType.REPLACE_ROW);
-    mutation.setRecordMutations(recordMutations);
-
-    client.mutate(mutation);
-  }
-
-  @Override
-  public String help() {
-    return "mutate the specified row, args; tablename rowid recordid columnfamily columnname value";
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/QueryCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/QueryCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/QueryCommand.java
deleted file mode 100644
index 9791741..0000000
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/QueryCommand.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * 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.blur.shell;
-
-import java.io.PrintWriter;
-
-import org.apache.blur.thrift.generated.Blur.Client;
-import org.apache.blur.thrift.generated.BlurException;
-import org.apache.blur.thrift.generated.BlurQuery;
-import org.apache.blur.thrift.generated.BlurResult;
-import org.apache.blur.thrift.generated.BlurResults;
-import org.apache.blur.thrift.generated.Selector;
-import org.apache.blur.thrift.generated.SimpleQuery;
-import org.apache.thrift.TException;
-
-public class QueryCommand extends Command {
-  @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
-    if (args.length < 3) {
-      throw new CommandException("Invalid args: " + help());
-    }
-    String tablename = args[1];
-    String query = "";
-    for (int i = 2; i < args.length; i++) {
-      query += args[i] + " ";
-    }
-
-    BlurQuery blurQuery = new BlurQuery();
-    SimpleQuery simpleQuery = new SimpleQuery();
-    simpleQuery.setQueryStr(query);
-    blurQuery.setSimpleQuery(simpleQuery);
-    blurQuery.setSelector(new Selector());
-
-    if (Main.debug) {
-      out.println(blurQuery);
-    }
-
-    BlurResults blurResults = client.query(tablename, blurQuery);
-
-    if (Main.debug) {
-      out.println("shardinfo: " + blurResults.getShardInfo());
-    }
-
-    for (BlurResult result : blurResults.getResults()) {
-      out.println(result);
-    }
-  }
-
-  @Override
-  public String help() {
-    return "query the named table, args; tablename query";
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/RemoveTableCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/RemoveTableCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/RemoveTableCommand.java
index 0d160b8..fc3c5f8 100644
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/RemoveTableCommand.java
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/RemoveTableCommand.java
@@ -20,14 +20,17 @@ package org.apache.blur.shell;
 
 import java.io.PrintWriter;
 
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.thrift.TException;
 
-public class RemoveTableCommand extends Command {
+public class RemoveTableCommand extends TableSingleArgumentCommand {
+  public RemoveTableCommand(Iface client) {
+    super(client);
+  }
+
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());
     }
@@ -40,4 +43,9 @@ public class RemoveTableCommand extends Command {
   public String help() {
     return "remove the named table, args; tablename";
   }
+
+  @Override
+  public String getName() {
+    return "remove";
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
index 5e42835..5aa1515 100644
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/SchemaTableCommand.java
@@ -20,14 +20,17 @@ package org.apache.blur.shell;
 
 import java.io.PrintWriter;
 
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.thrift.TException;
 
 public class SchemaTableCommand extends Command {
+  public SchemaTableCommand(Iface client) {
+    super(client);
+  }
+
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());
     }
@@ -40,4 +43,9 @@ public class SchemaTableCommand extends Command {
   public String help() {
     return "schema of the named table, args; tablename";
   }
+
+  @Override
+  public String getName() {
+    return null;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/SearchCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/SearchCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/SearchCommand.java
new file mode 100644
index 0000000..52b8d3e
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/SearchCommand.java
@@ -0,0 +1,81 @@
+/**
+ * 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.blur.shell;
+
+import java.io.PrintWriter;
+
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.thrift.TException;
+
+public class SearchCommand extends TableSingleArgumentCommand {
+  public SearchCommand(Iface client) {
+    super(client);
+  }
+
+  @Override
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
+    if (args.length < 3) {
+      throw new CommandException("Invalid args: " + help());
+    }
+    String tablename = args[1];
+    String query = "";
+    for (int i = 2; i < args.length; i++) {
+      query += args[i] + " ";
+    }
+
+
+    // BlurQuery blurQuery = new BlurQuery();
+    // SimpleQuery simpleQuery = new SimpleQuery();
+    // simpleQuery.setQueryStr(query);
+    // blurQuery.setSimpleQuery(simpleQuery);
+    // blurQuery.setSelector(new Selector());
+    //
+    // // QueryArgs queryArgs = BlurUtil
+    //
+    // QueryArgs queryArgs = new QueryArgs();
+    // queryArgs.setQuery(ThriftLuceneConversion.toBytes(new
+    // MatchAllDocsQuery()));
+    //
+    // if (Main.debug) {
+    // out.println(blurQuery);
+    // }
+    //
+    // Session session = client.openReadSession(tablename);
+    // List<TopFieldDocs> topDocs = client.search(session, queryArgs);
+    //
+    // if (Main.debug) {
+    // out.println("shardinfo: " + blurResults.getShardInfo());
+    // }
+    //
+    // for (BlurResult result : blurResults.getResults()) {
+    // out.println(result);
+    // }
+  }
+
+  @Override
+  public String help() {
+    return "query the named table, args; tablename query";
+  }
+
+  @Override
+  public String getName() {
+    return "search";
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/ShardClusterListCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/ShardClusterListCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/ShardClusterListCommand.java
deleted file mode 100644
index b8781ec..0000000
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/ShardClusterListCommand.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.blur.shell;
-
-import java.io.PrintWriter;
-
-import org.apache.blur.thrift.generated.Blur.Client;
-import org.apache.blur.thrift.generated.BlurException;
-import org.apache.thrift.TException;
-
-public class ShardClusterListCommand extends Command {
-  @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
-    if (args.length != 1) {
-      throw new CommandException("Invalid args: " + help());
-    }
-
-    out.println(client.shardClusterList());
-  }
-
-  @Override
-  public String help() {
-    return "list the clusters";
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
index 3107539..7dd9d3f 100644
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
@@ -19,25 +19,38 @@
 package org.apache.blur.shell;
 
 import java.io.PrintWriter;
+import java.util.Map;
 
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.ShardLayout;
 import org.apache.thrift.TException;
 
 public class ShardServerLayoutCommand extends Command {
+  public ShardServerLayoutCommand(Iface client) {
+    super(client);
+  }
+
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());
     }
     String tablename = args[1];
 
-    out.println(client.shardServerLayout(tablename));
+    Map<String, ShardLayout> shardLayout = client.shardLayout(tablename);
+
+    out.println(shardLayout);
   }
 
   @Override
   public String help() {
     return "list the server layout for a table, args: tablename";
   }
+
+  @Override
+  public String getName() {
+    // TODO Auto-generated method stub
+    return null;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/TableCompleter.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/TableCompleter.java b/src/blur-shell/src/main/java/org/apache/blur/shell/TableCompleter.java
new file mode 100644
index 0000000..45b71f6
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/TableCompleter.java
@@ -0,0 +1,40 @@
+package org.apache.blur.shell;
+
+import static jline.internal.Preconditions.checkNotNull;
+
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.thrift.TException;
+
+public class TableCompleter {
+
+  public int complete(Iface client, String potentialTable, List<CharSequence> candidates, String commandName) throws BlurException, TException {
+    SortedSet<String> tableList = new TreeSet<String>(client.tableList());
+    // buffer could be null
+    checkNotNull(candidates);
+
+    if (potentialTable == null) {
+      for (String table : tableList) {
+        candidates.add(commandName + " " + table);
+      }
+    } else {
+      for (String match : tableList.tailSet(potentialTable)) {
+        if (!match.startsWith(potentialTable)) {
+          break;
+        }
+        candidates.add(commandName + " " + match);
+      }
+    }
+
+    if (candidates.size() == 1) {
+      candidates.set(0, candidates.get(0) + " ");
+    }
+
+    return candidates.isEmpty() ? -1 : 0;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/TableNameCompleter.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/TableNameCompleter.java b/src/blur-shell/src/main/java/org/apache/blur/shell/TableNameCompleter.java
new file mode 100644
index 0000000..d28238d
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/TableNameCompleter.java
@@ -0,0 +1,14 @@
+package org.apache.blur.shell;
+
+import java.util.List;
+
+import jline.console.completer.Completer;
+
+public class TableNameCompleter implements Completer {
+
+  @Override
+  public int complete(String buffer, int cursor, List<CharSequence> candidates) {
+    return 0;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/TableSingleArgumentCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/TableSingleArgumentCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/TableSingleArgumentCommand.java
new file mode 100644
index 0000000..6828c9b
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/TableSingleArgumentCommand.java
@@ -0,0 +1,30 @@
+package org.apache.blur.shell;
+
+import java.util.List;
+
+import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.thrift.TException;
+
+public abstract class TableSingleArgumentCommand extends Command {
+
+  public TableSingleArgumentCommand(Iface client) {
+    super(client);
+  }
+
+  @Override
+  public int commandComplete(String buffer, int cursor, List<CharSequence> candidates) throws BlurException, TException {
+    String[] args = getArgs(buffer);
+    if (!thisCommand(args)) {
+      return -1;
+    }
+
+    Iface client = getClient();
+    TableCompleter tableCompleter = new TableCompleter();
+    String potentialTable = null;
+    if (args.length != 1) {
+      potentialTable = args[args.length - 1];
+    }
+    return tableCompleter.complete(client, potentialTable, candidates, getName());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java b/src/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
index 317f453..04cb169 100644
--- a/src/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
@@ -20,14 +20,17 @@ package org.apache.blur.shell;
 
 import java.io.PrintWriter;
 
-import org.apache.blur.thrift.generated.Blur.Client;
+import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.thrift.TException;
 
 public class TableStatsCommand extends Command {
+  public TableStatsCommand(Iface client) {
+    super(client);
+  }
+
   @Override
-  public void doit(PrintWriter out, Client client, String[] args)
-      throws CommandException, TException, BlurException {
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException, TException, BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());
     }
@@ -40,4 +43,10 @@ public class TableStatsCommand extends Command {
   public String help() {
     return "print stats for the named table";
   }
+
+  @Override
+  public String getName() {
+    // TODO Auto-generated method stub
+    return null;
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f92d94a9/src/blur-shell/src/main/java/org/apache/blur/shell/TestingCli.java
----------------------------------------------------------------------
diff --git a/src/blur-shell/src/main/java/org/apache/blur/shell/TestingCli.java b/src/blur-shell/src/main/java/org/apache/blur/shell/TestingCli.java
new file mode 100644
index 0000000..6d8a40a
--- /dev/null
+++ b/src/blur-shell/src/main/java/org/apache/blur/shell/TestingCli.java
@@ -0,0 +1,42 @@
+package org.apache.blur.shell;
+
+import org.apache.commons.cli.*;
+
+public class TestingCli {
+
+  public static void main(String[] sargs) {
+    // create the command line parser
+    CommandLineParser parser = new PosixParser();
+
+    // create the Options
+    Options options = new Options();
+    options.addOption("a", "all", false, "do not hide entries starting with .");
+    options.addOption("A", "almost-all", false, "do not list implied . and ..");
+    options.addOption("b", "escape", false, "print octal escapes for nongraphic " + "characters");
+//    OptionBuilder.withLongOpt("block-size").withDescription("use SIZE-byte blocks").hasArg().withArgName("SIZE").create();
+//    options.addOption();
+    options.addOption("B", "ignore-backups", false, "do not list implied entried " + "ending with ~");
+    options.addOption("c", false, "with -lt: sort by, and show, ctime (time of last " + "modification of file status information) with "
+        + "-l:show ctime and sort by name otherwise: sort " + "by ctime");
+    options.addOption("C", false, "list entries by columns");
+
+    String[] args = new String[] { "-a" };
+
+    try {
+      // parse the command line arguments
+      CommandLine line = parser.parse(options, args);
+      
+      HelpFormatter formatter = new HelpFormatter();
+      formatter.printHelp( "", options );
+      
+      // validate that block-size has been set
+      if (line.hasOption("block-size")) {
+        // print the value of block-size
+        System.out.println(line.getOptionValue("block-size"));
+      }
+    } catch (ParseException exp) {
+      System.out.println("Unexpected exception:" + exp.getMessage());
+    }
+  }
+
+}


Mime
View raw message