incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [4/4] git commit: Fixed the test.
Date Sun, 02 Dec 2012 04:23:16 GMT
Fixed the 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/fab00ffa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/fab00ffa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/fab00ffa

Branch: refs/heads/0.2-dev-removing-old-thrift
Commit: fab00ffa2709e6e65ca5459290e97dfa4dab54e3
Parents: eb77851
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sat Dec 1 16:14:20 2012 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sat Dec 1 16:14:20 2012 -0500

----------------------------------------------------------------------
 .../blur/manager/writer/BlurNRTIndexTest.java      |   44 +++++++--------
 1 files changed, 20 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fab00ffa/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 a4e0b14..5e0d2a4 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
@@ -21,11 +21,17 @@ import static org.junit.Assert.assertEquals;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Random;
 import java.util.concurrent.ExecutorService;
 
 import org.apache.blur.analysis.BlurAnalyzer;
 import org.apache.blur.concurrent.Executors;
+import org.apache.blur.thrift.generated.Document;
+import org.apache.blur.thrift.generated.Field;
+import org.apache.blur.thrift.generated.TYPE;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
@@ -65,7 +71,7 @@ public class BlurNRTIndexTest {
 
     refresher = new BlurIndexRefresher();
     refresher.init();
-    
+
     service = Executors.newThreadPool("test", 10);
   }
 
@@ -109,7 +115,7 @@ public class BlurNRTIndexTest {
     long s = System.nanoTime();
     int total = 0;
     for (int i = 0; i < TEST_NUMBER_WAIT_VISIBLE; i++) {
-//      writer.replaceRow(true, true, genRow());
+      writer.addDocuments(true, true, getDocs(1));
       IndexReader reader = writer.getIndexReader();
       assertEquals(i + 1, reader.numDocs());
       total++;
@@ -127,38 +133,28 @@ public class BlurNRTIndexTest {
     setupWriter(configuration, analyzer, 100);
     long s = System.nanoTime();
     int total = 0;
+    long generation = 0;
     for (int i = 0; i < TEST_NUMBER; i++) {
-      if (i == TEST_NUMBER - 1) {
-//        writer.replaceRow(true, true, genRow());
-      } else {
-//        writer.replaceRow(false, true, genRow());
-      }
+      generation = writer.addDocuments(false, true, getDocs(1));
       total++;
     }
+    writer.blockUntilGenerationIsVisible(generation, true);
     long e = System.nanoTime();
     double seconds = (e - s) / 1000000000.0;
     double rate = total / seconds;
     System.out.println("Rate " + rate);
-    // //wait one second for the data to become visible the test is set to
-    // refresh once every 25 ms
-    // Thread.sleep(1000);
-    writer.refresh();
     IndexReader reader = writer.getIndexReader();
     assertEquals(TEST_NUMBER, reader.numDocs());
     reader.decRef();
   }
 
-//  private Row genRow() {
-//    Row row = new Row();
-//    row.setId(Long.toString(random.nextLong()));
-//    Record record = new Record();
-//    record.setFamily("testing");
-//    record.setRecordId(Long.toString(random.nextLong()));
-//    for (int i = 0; i < 10; i++) {
-//      record.addToColumns(new Column("col" + i, Long.toString(random.nextLong())));
-//    }
-//    row.addToRecords(record);
-//    return row;
-//  }
-
+  private List<Document> getDocs(int count) {
+    List<Document> docs = new ArrayList<Document>();
+    for (int i = 0; i < count; i++) {
+      Document document = new Document();
+      document.addToFields(new Field("test", ByteBuffer.wrap(Long.toString(random.nextLong()).getBytes()),
TYPE.STRING, 1.0));
+      docs.add(document);
+    }
+    return docs;
+  }
 }


Mime
View raw message