Example #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;
     }
   }
 }
Example #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);
   }
 }
Example #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));
     }
   }
 }
Example #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;
   }
 }
Example #5
0
 public long getLong() {
   return Unsafe.getUnsafe().getLong(nextAddress(8));
 }
Example #6
0
 public int getInt() {
   return Unsafe.getUnsafe().getInt(nextAddress(4));
 }
Example #7
0
 public byte get() {
   return Unsafe.getUnsafe().getByte(nextAddress(1));
 }
Example #8
0
 public void put(boolean value) {
   Unsafe.getUnsafe().putByte(nextAddress(1), (byte) (value ? 1 : 0));
 }
Example #9
0
 public void put(long value) {
   Unsafe.getUnsafe().putLong(nextAddress(8), value);
 }
Example #10
0
 public void put(byte value) {
   Unsafe.getUnsafe().putByte(nextAddress(1), value);
 }
Example #11
0
 public void put(int value) {
   Unsafe.getUnsafe().putInt(nextAddress(4), value);
 }