incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [2/2] git commit: Small code refactoring.
Date Fri, 29 Nov 2013 15:47:29 GMT
Small code refactoring.


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

Branch: refs/heads/master
Commit: 8ee31026fd6dc1e77c9e276740bff4f108850460
Parents: fce280d
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Fri Nov 29 10:46:36 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Fri Nov 29 10:47:32 2013 -0500

----------------------------------------------------------------------
 .../java/org/apache/blur/utils/BlurUtil.java    |  7 +++-
 .../apache/blur/manager/IndexManagerTest.java   | 42 +++++++++++++-------
 2 files changed, 34 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8ee31026/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
index 4f2e830..18f4102 100644
--- a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
+++ b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java
@@ -380,9 +380,13 @@ public class BlurUtil {
   }
 
   public static Serializable fromBytes(byte[] bs) {
+    return fromBytes(bs, 0, bs.length);
+  }
+
+  public static Serializable fromBytes(byte[] bs, int offset, int length) {
     ObjectInputStream stream = null;
     try {
-      stream = new ObjectInputStream(new ByteArrayInputStream(bs));
+      stream = new ObjectInputStream(new ByteArrayInputStream(bs, offset, length));
       return (Serializable) stream.readObject();
     } catch (Exception e) {
       throw new RuntimeException(e);
@@ -974,4 +978,5 @@ public class BlurUtil {
     };
     return (Iface) Proxy.newProxyInstance(Iface.class.getClassLoader(), new Class[] { Iface.class
}, handler);
   }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/8ee31026/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
index 47342e2..2be0c9c 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTest.java
@@ -274,33 +274,47 @@ public class IndexManagerTest {
 
   @Test
   public void testMutationReplaceLargeRow() throws Exception {
-    String rowId = "largerow";
+    final String rowId = "largerow";
     indexManager.mutate(getLargeRow(rowId));
     TraceReporter oldReporter = Trace.getReporter();
     Trace.setReporter(new TraceReporter(new BlurConfiguration()) {
-      
+
       @Override
       public void close() throws IOException {
-        
+
       }
-      
+
       @Override
       public void report(TraceCollector collector) {
         System.out.println(collector.toJson());
       }
     });
-    
+
     Trace.setupTrace(rowId);
 
-    Selector selector = new Selector().setRowId(rowId);
-    FetchResult fetchResult = new FetchResult();
-    long s = System.nanoTime();
-    indexManager.fetchRow(TABLE, selector, fetchResult);
-    long e = System.nanoTime();
-    assertNotNull(fetchResult.rowResult.row);
-    Trace.tearDownTrace();
-    System.out.println((e - s) / 1000000.0);
-    
+    for (int i = 0; i < 1000; i++) {
+      Thread thread = new Thread(new Runnable() {
+        @Override
+        public void run() {
+          Selector selector = new Selector().setRowId(rowId);
+          FetchResult fetchResult = new FetchResult();
+          long s = System.nanoTime();
+          try {
+            indexManager.fetchRow(TABLE, selector, fetchResult);
+          } catch (BlurException e1) {
+            e1.printStackTrace();
+          }
+          long e = System.nanoTime();
+          assertNotNull(fetchResult.rowResult.row);
+          Trace.tearDownTrace();
+          System.out.println((e - s) / 1000000.0);
+        }
+      });
+
+      thread.start();
+      thread.join();
+    }
+
     Trace.setReporter(oldReporter);
 
   }


Mime
View raw message