incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [6/10] git commit: Fixed a unit test.
Date Tue, 29 Jan 2013 01:47:44 GMT
Fixed a unit test.


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

Branch: refs/heads/0.2-dev
Commit: 259706ab07ad10c9a6f2199922ab2aabf58dd128
Parents: 2691117
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun Jan 27 15:02:55 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun Jan 27 15:02:55 2013 -0500

----------------------------------------------------------------------
 .../blur/manager/writer/BlurNRTIndexTest.java      |   32 ++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/259706ab/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 57818c0..c711fcf 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
@@ -23,7 +23,9 @@ import java.io.File;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Random;
 import java.util.concurrent.ExecutorService;
 
@@ -31,6 +33,7 @@ import org.apache.blur.analysis.BlurAnalyzer;
 import org.apache.blur.concurrent.Executors;
 import org.apache.blur.server.ShardContext;
 import org.apache.blur.server.TableContext;
+import org.apache.blur.server.TypeManager;
 import org.apache.blur.thrift.generated.Document;
 import org.apache.blur.thrift.generated.Field;
 import org.apache.blur.thrift.generated.TYPE;
@@ -86,7 +89,34 @@ public class BlurNRTIndexTest {
     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, null);
+    TableContext context = TableContext.create(tableDescriptor, new TypeManager() {
+
+      private Map<String, TYPE> types = new HashMap<String, TYPE>();
+
+      @Override
+      public void validate(Field field) throws IOException {
+        String name = field.getName();
+        TYPE fieldType = field.getType();
+        TYPE type = types.get(name);
+        if (type == null) {
+          types.put(name, fieldType);
+          return;
+        }
+        if (type != fieldType) {
+          throw new IOException("Type [" + fieldType + "] for field [" + name + "] should
be [" + type + "]");
+        }
+      }
+
+      @Override
+      public Map<String, TYPE> getTypeMap() throws IOException {
+        return types;
+      }
+
+      @Override
+      public TYPE getType(String name) throws IOException {
+        return getTypeMap().get(name);
+      }
+    });
     writer.setContext(ShardContext.create(context, "testing-shard"));
     // writer.setAnalyzer(analyzer);
     // writer.setTable("testing-table");


Mime
View raw message