Esempio n. 1
0
 public void put(long[] values) {
   if (values == null) {
     put(-1);
   } else {
     long address = nextAddress(values.length * 8 + 4);
     Unsafe.getUnsafe().putInt(address, values.length);
     address += 4;
     for (int i = 0; i < values.length; i++) {
       Unsafe.getUnsafe().putLong(address, values[i]);
       address += 8;
     }
   }
 }
Esempio n. 2
0
 public String getStr() {
   int len = Unsafe.getUnsafe().getInt(nextAddress(4));
   if (len == -1) {
     return null;
   } else {
     long address = nextAddress(len * 2);
     char c[] = new char[len];
     for (int i = 0; i < len; i++) {
       c[i] = Unsafe.getUnsafe().getChar(address);
       address += 2;
     }
     return new String(c);
   }
 }
Esempio n. 3
0
 public void put(CharSequence value) {
   if (value == null) {
     put(-1);
   } else {
     int len;
     long address = nextAddress((len = value.length()) * 2 + 4);
     Unsafe.getUnsafe().putInt(address, len);
     address += 2;
     for (int i = 0; i < len; i++) {
       address += 2;
       Unsafe.getUnsafe().putChar(address, value.charAt(i));
     }
   }
 }
Esempio n. 4
0
 public long[] get(long[] container) {
   int len = getInt();
   if (len == -1) {
     return null;
   } else {
     if (container == null || len != container.length) {
       container = new long[len];
     }
     long address = nextAddress(len * 8);
     for (int i = 0; i < len; i++) {
       container[i] = Unsafe.getUnsafe().getLong(address);
       address += 8;
     }
     return container;
   }
 }
Esempio n. 5
0
 public long getLong() {
   return Unsafe.getUnsafe().getLong(nextAddress(8));
 }
Esempio n. 6
0
 public int getInt() {
   return Unsafe.getUnsafe().getInt(nextAddress(4));
 }
Esempio n. 7
0
 public byte get() {
   return Unsafe.getUnsafe().getByte(nextAddress(1));
 }
Esempio n. 8
0
 public void put(boolean value) {
   Unsafe.getUnsafe().putByte(nextAddress(1), (byte) (value ? 1 : 0));
 }
Esempio n. 9
0
 public void put(long value) {
   Unsafe.getUnsafe().putLong(nextAddress(8), value);
 }
Esempio n. 10
0
 public void put(byte value) {
   Unsafe.getUnsafe().putByte(nextAddress(1), value);
 }
Esempio n. 11
0
 public void put(int value) {
   Unsafe.getUnsafe().putInt(nextAddress(4), value);
 }