Exemplo n.º 1
0
 public int compareTo(Object o) {
   if (o == this) {
     return 0;
   }
   if (o instanceof ByteArray) {
     ByteArray rhs = (ByteArray) o;
     return ArrayUtils.compareTo(bytea, rhs.bytea);
   }
   throw new IllegalArgumentException("Uncomparable: " + o.getClass().getName());
 }
Exemplo n.º 2
0
 @Override
 protected char[] getChars(final long addr) {
   final long ptr = indexOf(addr);
   final char[] ch;
   if ((addr & BIG_STRING_MASK) != 0L) { // is big string
     final byte[] b = getStringInternal(addr, ptr);
     ch = decompress(compressor, b);
   } else {
     final char[] cc = getCharChunkInternal(ptr);
     final int block = (int) (ptr & BLOCK_MASK);
     final int length = cc[block]; // the first char is the length of the string
     final int from = block + 1;
     ch = ArrayUtils.copyOfRange(cc, from, from + length);
   }
   return ch;
 }
Exemplo n.º 3
0
 protected final long storeCharChunk(final char[] ch, final int start, final int length) {
   final int hcode = HashUtils.hashCode(ch, start, length);
   final long haddr = _hashv2addr.get(hcode);
   if (haddr != -1L) {
     final char[] strInAddr = getChars(haddr);
     assert (strInAddr != null);
     if (ArrayUtils.equals(strInAddr, ch, start, length)) {
       return haddr;
     } else {
       _hashv2addr.remove(hcode);
     }
   }
   final long raddr = allocateCharChunk(ch, start, length);
   _hashv2addr.put(hcode, raddr);
   return raddr;
 }
Exemplo n.º 4
0
 protected char[] getChars(final long addr) {
   final long ptr = indexOf(addr);
   final char[] ch;
   if ((addr & BIG_STRING_MASK) != 0) { // is big string
     assert (ptr <= 0x7fffffffL) : ptr;
     final byte[] b = _strPool.get((int) ptr);
     ch = decompress(compressor, b);
   } else {
     assert (ptr <= _cpointer) : ptr;
     final long lp = ptr >> BLOCK_SHIFT;
     final int page = (int) lp;
     if (lp != page) {
       throw new IllegalStateException("Illegal page number: " + lp);
     }
     final int block = (int) (ptr & BLOCK_MASK);
     final char[] cc = _cchunks[page];
     final int length = cc[block]; // the first char is the length of the string
     final int from = block + 1;
     ch = ArrayUtils.copyOfRange(cc, from, from + length);
   }
   return ch;
 }