From 0c32d781352ca7153f218d4533ab680225dd9c2c Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Mon, 13 Apr 2015 20:15:53 +0000 Subject: [PATCH] SOLR-7110: tests - java7 compilable git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1673270 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/common/util/TestJavaBinCodec.java | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java b/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java index 9917d93d115..061b05344b8 100644 --- a/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java +++ b/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java @@ -424,7 +424,7 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 { } }; - 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 SolrTestCaseJ4 { 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 SolrTestCaseJ4 { 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 SolrTestCaseJ4 { 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 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 SolrTestCaseJ4 { 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