You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2015/04/13 13:39:56 UTC

svn commit: r1673161 - /lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java

Author: yonik
Date: Mon Apr 13 11:39:56 2015
New Revision: 1673161

URL: http://svn.apache.org/r1673161
Log:
SOLR-7110: reformat new code

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

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java?rev=1673161&r1=1673160&r2=1673161&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java Mon Apr 13 11:39:56 2015
@@ -606,7 +606,7 @@ public class JavaBinCodec {
     dis.readFully(bytes, 0, sz);
     if (stringCache != null) {
       return stringCache.get(bytesRef.reset(bytes, 0, sz));
-    }else {
+    } else {
       arr.reset();
       ByteUtils.UTF8toUTF16(bytes, 0, sz, arr);
       return arr.toString();
@@ -832,44 +832,52 @@ public class JavaBinCodec {
   }
 
   public static class StringCache {
-    private final Cache<StringBytes,String> cache ;
+    private final Cache<StringBytes, String> cache;
 
     public StringCache(Cache<StringBytes, String> cache) {
       this.cache = cache;
     }
 
-    public String get(StringBytes b){
-      String result  = cache.get(b);
-      if(result== null){
+    public String get(StringBytes b) {
+      String result = cache.get(b);
+      if (result == null) {
         //make a copy because the buffer received may be changed later by the caller
-        StringBytes copy = new StringBytes(Arrays.copyOfRange(b.bytes, b.offset, b.offset + b.length), 0,b.length);
+        StringBytes copy = new StringBytes(Arrays.copyOfRange(b.bytes, b.offset, b.offset + b.length), 0, b.length);
         CharArr arr = new CharArr();
         ByteUtils.UTF8toUTF16(b.bytes, b.offset, b.length, arr);
         result = arr.toString();
-        cache.put(copy,result);
+        cache.put(copy, result);
       }
       return result;
     }
   }
+
   public static class StringBytes {
     byte[] bytes;
 
-    /** Offset of first valid byte. */
+    /**
+     * Offset of first valid byte.
+     */
     int offset;
 
-    /** Length of used bytes. */
+    /**
+     * Length of used bytes.
+     */
     private int length;
     private int hash;
+
     public StringBytes(byte[] bytes, int offset, int length) {
-      reset(bytes,offset,length);
+      reset(bytes, offset, length);
     }
-    StringBytes reset(byte[] bytes, int offset, int length){
+
+    StringBytes reset(byte[] bytes, int offset, int length) {
       this.bytes = bytes;
       this.offset = offset;
       this.length = length;
       hash = bytes == null ? 0 : Hash.murmurhash3_x86_32(bytes, offset, length, 0);
       return this;
     }
+
     @Override
     public boolean equals(Object other) {
       if (other == null) {
@@ -887,7 +895,7 @@ public class JavaBinCodec {
         int otherUpto = other.offset;
         final byte[] otherBytes = other.bytes;
         final int end = offset + length;
-        for(int upto=offset;upto<end;upto++,otherUpto++) {
+        for (int upto = offset; upto < end; upto++, otherUpto++) {
           if (bytes[upto] != otherBytes[otherUpto]) {
             return false;
           }
@@ -903,5 +911,4 @@ public class JavaBinCodec {
       return hash;
     }
   }
-
 }