Esempio n. 1
0
 public String readStr(DataInputInputStream dis, StringCache stringCache) throws IOException {
   int sz = readSize(dis);
   if (bytes == null || bytes.length < sz) bytes = new byte[sz];
   dis.readFully(bytes, 0, sz);
   if (stringCache != null) {
     return stringCache.get(bytesRef.reset(bytes, 0, sz));
   } else {
     arr.reset();
     ByteUtils.UTF8toUTF16(bytes, 0, sz, arr);
     return arr.toString();
   }
 }
Esempio n. 2
0
 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);
     CharArr arr = new CharArr();
     ByteUtils.UTF8toUTF16(b.bytes, b.offset, b.length, arr);
     result = arr.toString();
     cache.put(copy, result);
   }
   return result;
 }