incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Adding a new example command.
Date Fri, 29 Aug 2014 13:00:44 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master 1deca99d2 -> 122f30ee0


Adding a new example command.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/122f30ee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/122f30ee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/122f30ee

Branch: refs/heads/master
Commit: 122f30ee0b8989c401a0a5d03198a785df276b0b
Parents: 1deca99
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Fri Aug 29 09:00:44 2014 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Fri Aug 29 09:00:44 2014 -0400

----------------------------------------------------------------------
 .../manager/command/BaseCommandManager.java     |  6 +-
 .../command/cmds/DocumentCountAggregator.java   | 65 --------------------
 .../command/cmds/DocumentCountCombiner.java     | 65 ++++++++++++++++++++
 .../command/cmds/DocumentCountNoCombine.java    | 54 ++++++++++++++++
 .../apache/blur/thrift/util/CommandExample.java |  1 +
 5 files changed, 124 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/122f30ee/blur-core/src/main/java/org/apache/blur/manager/command/BaseCommandManager.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/BaseCommandManager.java
b/blur-core/src/main/java/org/apache/blur/manager/command/BaseCommandManager.java
index 950d074..e6c729c 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/command/BaseCommandManager.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/command/BaseCommandManager.java
@@ -9,7 +9,8 @@ import java.util.concurrent.ExecutorService;
 import org.apache.blur.concurrent.Executors;
 import org.apache.blur.manager.command.cmds.BaseCommand;
 import org.apache.blur.manager.command.cmds.DocumentCount;
-import org.apache.blur.manager.command.cmds.DocumentCountAggregator;
+import org.apache.blur.manager.command.cmds.DocumentCountCombiner;
+import org.apache.blur.manager.command.cmds.DocumentCountNoCombine;
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -36,7 +37,8 @@ public class BaseCommandManager implements Closeable {
 
   public BaseCommandManager(int threadCount) throws IOException {
     register(DocumentCount.class);
-    register(DocumentCountAggregator.class);
+    register(DocumentCountNoCombine.class);
+    register(DocumentCountCombiner.class);
     _executorService = Executors.newThreadPool("command-", threadCount);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/122f30ee/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountAggregator.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountAggregator.java
b/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountAggregator.java
deleted file mode 100644
index ebb06fc..0000000
--- a/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountAggregator.java
+++ /dev/null
@@ -1,65 +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.manager.command.cmds;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.blur.manager.command.ClusterCommand;
-import org.apache.blur.manager.command.ClusterContext;
-import org.apache.blur.manager.command.IndexContext;
-import org.apache.blur.manager.command.IndexReadCombiningCommand;
-import org.apache.blur.manager.command.Server;
-import org.apache.blur.manager.command.Shard;
-
-@SuppressWarnings("serial")
-public class DocumentCountAggregator extends BaseCommand implements ClusterCommand<Long>,
-    IndexReadCombiningCommand<Integer, Long> {
-
-  private static final String DOC_COUNT_AGGREGATE = "docCountAggregate";
-
-  @Override
-  public String getName() {
-    return DOC_COUNT_AGGREGATE;
-  }
-
-  @Override
-  public Integer execute(IndexContext context) throws IOException {
-    return context.getIndexReader().numDocs();
-  }
-
-  @Override
-  public Long combine(Map<Shard, Integer> results) throws IOException {
-    long total = 0;
-    for (Integer i : results.values()) {
-      total += i;
-    }
-    return total;
-  }
-
-  @Override
-  public Long clusterExecute(ClusterContext context) throws IOException {
-    Map<Server, Long> results = context.readServers(null, DocumentCountAggregator.class);
-    long total = 0;
-    for (Entry<Server, Long> e : results.entrySet()) {
-      total += e.getValue();
-    }
-    return total;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/122f30ee/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountCombiner.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountCombiner.java
b/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountCombiner.java
new file mode 100644
index 0000000..e2e074e
--- /dev/null
+++ b/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountCombiner.java
@@ -0,0 +1,65 @@
+/**
+ * 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.manager.command.cmds;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.blur.manager.command.ClusterCommand;
+import org.apache.blur.manager.command.ClusterContext;
+import org.apache.blur.manager.command.IndexContext;
+import org.apache.blur.manager.command.IndexReadCombiningCommand;
+import org.apache.blur.manager.command.Server;
+import org.apache.blur.manager.command.Shard;
+
+@SuppressWarnings("serial")
+public class DocumentCountCombiner extends BaseCommand implements ClusterCommand<Long>,
+    IndexReadCombiningCommand<Integer, Long> {
+
+  private static final String DOC_COUNT_AGGREGATE = "docCountAggregate";
+
+  @Override
+  public String getName() {
+    return DOC_COUNT_AGGREGATE;
+  }
+
+  @Override
+  public Integer execute(IndexContext context) throws IOException {
+    return context.getIndexReader().numDocs();
+  }
+
+  @Override
+  public Long combine(Map<Shard, Integer> results) throws IOException {
+    long total = 0;
+    for (Integer i : results.values()) {
+      total += i;
+    }
+    return total;
+  }
+
+  @Override
+  public Long clusterExecute(ClusterContext context) throws IOException {
+    Map<Server, Long> results = context.readServers(null, DocumentCountCombiner.class);
+    long total = 0;
+    for (Entry<Server, Long> e : results.entrySet()) {
+      total += e.getValue();
+    }
+    return total;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/122f30ee/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountNoCombine.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountNoCombine.java
b/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountNoCombine.java
new file mode 100644
index 0000000..e3d1f07
--- /dev/null
+++ b/blur-core/src/main/java/org/apache/blur/manager/command/cmds/DocumentCountNoCombine.java
@@ -0,0 +1,54 @@
+/**
+ * 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.manager.command.cmds;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.blur.manager.command.ClusterCommand;
+import org.apache.blur.manager.command.ClusterContext;
+import org.apache.blur.manager.command.IndexContext;
+import org.apache.blur.manager.command.IndexReadCommand;
+import org.apache.blur.manager.command.Shard;
+
+@SuppressWarnings("serial")
+public class DocumentCountNoCombine extends BaseCommand implements IndexReadCommand<Integer>,
ClusterCommand<Long> {
+
+  private static final String DOC_COUNT_NO_COMBINE = "docCountNoCombine";
+
+  @Override
+  public String getName() {
+    return DOC_COUNT_NO_COMBINE;
+  }
+
+  @Override
+  public Integer execute(IndexContext context) throws IOException {
+    return context.getIndexReader().numDocs();
+  }
+
+  @Override
+  public Long clusterExecute(ClusterContext context) throws IOException {
+    Map<Shard, Integer> indexes = context.readIndexes(null, DocumentCountNoCombine.class);
+    long total = 0;
+    for (Entry<Shard, Integer> e : indexes.entrySet()) {
+      total += e.getValue();
+    }
+    return total;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/122f30ee/blur-thrift/src/main/java/org/apache/blur/thrift/util/CommandExample.java
----------------------------------------------------------------------
diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/util/CommandExample.java b/blur-thrift/src/main/java/org/apache/blur/thrift/util/CommandExample.java
index 1f434f2..276ae96 100644
--- a/blur-thrift/src/main/java/org/apache/blur/thrift/util/CommandExample.java
+++ b/blur-thrift/src/main/java/org/apache/blur/thrift/util/CommandExample.java
@@ -28,6 +28,7 @@ public class CommandExample {
   public static void main(String[] args) throws BlurException, TException, IOException {
     Iface client = BlurClient.getClient("localhost:40010");
     System.out.println(client.execute("test", "docCount", null));
+    System.out.println(client.execute("test", "docCountNoCombine", null));
     System.out.println(client.execute("test", "docCountAggregate", null));
   }
 }


Mime
View raw message