lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r1673270 - /lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java
Date Mon, 13 Apr 2015 20:15:53 GMT
Author: yonik
Date: Mon Apr 13 20:15:53 2015
New Revision: 1673270

URL: http://svn.apache.org/r1673270
Log:
SOLR-7110: tests - java7 compilable

Modified:
    lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java

Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java?rev=1673270&r1=1673269&r2=1673270&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java
(original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java
Mon Apr 13 20:15:53 2015
@@ -424,7 +424,7 @@ public class TestJavaBinCodec extends So
 
       }
     };
-    JavaBinCodec.StringCache STRING_CACHE = new JavaBinCodec.StringCache(cache1);
+    final JavaBinCodec.StringCache STRING_CACHE = new JavaBinCodec.StringCache(cache1);
 
 //    STRING_CACHE = new JavaBinCodec.StringCache(cache);
     byte[] bytes = new byte[0];
@@ -441,17 +441,20 @@ public class TestJavaBinCodec extends So
     printMem("after cache init");
 
     long ms = System.currentTimeMillis();
-    int ITERS = 1000000;
+    final int ITERS = 1000000;
     int THREADS = 10;
 
-    runInThreads(THREADS,  () -> {
-      JavaBinCodec.StringBytes stringBytes1 = new JavaBinCodec.StringBytes(new byte[0], 0,0);
-      for(int i=0;i< ITERS;i++){
-        JavaBinCodec.StringBytes b = l.get(i % l.size());
-        stringBytes1.reset(b.bytes,0,b.bytes.length);
-        if(STRING_CACHE.get(stringBytes1) == null) throw new RuntimeException("error");
-      }
+    runInThreads(THREADS, new Runnable() {
+      @Override
+      public void run() {
+        JavaBinCodec.StringBytes stringBytes1 = new JavaBinCodec.StringBytes(new byte[0],
0, 0);
+        for (int i = 0; i < ITERS; i++) {
+          JavaBinCodec.StringBytes b = l.get(i % l.size());
+          stringBytes1.reset(b.bytes, 0, b.bytes.length);
+          if (STRING_CACHE.get(stringBytes1) == null) throw new RuntimeException("error");
+        }
 
+      }
     });
 
 
@@ -460,14 +463,17 @@ public class TestJavaBinCodec extends So
     System.out.println("time taken by LRUCACHE "+ (System.currentTimeMillis()-ms));
     ms = System.currentTimeMillis();
 
-    runInThreads(THREADS,  ()-> {
-      String a = null;
-      CharArr arr = new CharArr();
-      for (int i = 0; i < ITERS; i++) {
-        JavaBinCodec.StringBytes sb = l.get(i % l.size());
-        arr.reset();
-        ByteUtils.UTF8toUTF16(sb.bytes, 0, sb.bytes.length, arr);
-        a = arr.toString();
+    runInThreads(THREADS, new Runnable() {
+      @Override
+      public void run() {
+        String a = null;
+        CharArr arr = new CharArr();
+        for (int i = 0; i < ITERS; i++) {
+          JavaBinCodec.StringBytes sb = l.get(i % l.size());
+          arr.reset();
+          ByteUtils.UTF8toUTF16(sb.bytes, 0, sb.bytes.length, arr);
+          a = arr.toString();
+        }
       }
     });
 
@@ -525,12 +531,12 @@ public class TestJavaBinCodec extends So
     int arg=0;
     int nThreads = Integer.parseInt(args[arg++]);
     int nBuffers = Integer.parseInt(args[arg++]);
-    long iter = Long.parseLong(args[arg++]);
+    final long iter = Long.parseLong(args[arg++]);
     int cacheSz = Integer.parseInt(args[arg++]);
 
     Random r = new Random(0);
 
-    byte[][] buffers = new byte[nBuffers][];
+    final byte[][] buffers = new byte[nBuffers][];
 
     for (int bufnum=0; bufnum<nBuffers; bufnum++) {
       SolrDocument sdoc = new SolrDocument();
@@ -566,7 +572,7 @@ public class TestJavaBinCodec extends So
     int ret = 0;
     long start = System.currentTimeMillis();
     ConcurrentLRUCache underlyingCache = cacheSz > 0 ? new ConcurrentLRUCache<>(cacheSz,cacheSz-cacheSz/10,cacheSz,cacheSz/10,false,true,null)
: null;  // the cache in the first version of the patch was 10000,9000,10000,1000,false,true,null
-    JavaBinCodec.StringCache stringCache = underlyingCache==null ? null : new JavaBinCodec.StringCache(underlyingCache);
+    final JavaBinCodec.StringCache stringCache = underlyingCache==null ? null : new JavaBinCodec.StringCache(underlyingCache);
     if (nThreads <= 0) {
       ret += doDecode(buffers, iter, stringCache);
     } else {
@@ -591,7 +597,6 @@ public class TestJavaBinCodec extends So
   public static int doDecode(byte[][] buffers, long iter, JavaBinCodec.StringCache stringCache)
throws IOException {
     int ret = 0;
     int bufnum = -1;
-    byte[] tmp = new byte[8192];
 
     InputStream empty = new InputStream() {
       @Override



Mime
View raw message