@Test public void phys_append_alloc_link2(){ long[] ret = e.physAllocate(100 + MAX_REC_SIZE); long exp1 = MASK_IS_LINKED |((long)MAX_REC_SIZE)<<48 | 8L; long exp2 = 112L<<48 | (8L+MAX_REC_SIZE); assertArrayEquals(new long[]{exp1, exp2}, ret); }
protected long[] physAllocate(int size) { if(size<MAX_REC_SIZE){ long physSize = index.getLong(IO_PHYS_SIZE); index.putLong(IO_PHYS_SIZE, physSize+size); phys.ensureAvailable(physSize+size); physSize = physSize ^ (((long)size)<<48); return new long[]{physSize}; }else{ long[] ret = new long[2]; int retPos = 0; int c = 12; while(size>0){ if(retPos == ret.length) ret = Arrays.copyOf(ret, ret.length*2); int allocSize = Math.min(size, MAX_REC_SIZE); size -= allocSize - c; long physSize = index.getLong(IO_PHYS_SIZE); index.putLong(IO_PHYS_SIZE, physSize+allocSize); phys.ensureAvailable(physSize+allocSize); physSize = physSize ^ (((long)allocSize)<<48); if(c!=0) physSize|=MASK_IS_LINKED; ret[retPos++] = physSize; c = size<=MAX_REC_SIZE ? 0 : 8; } if(size!=0) throw new InternalError(); return Arrays.copyOf(ret, retPos); } }
StorageDirect2 implements Engine { protected long[] physAllocate(int size) { if(size<MAX_REC_SIZE){ long physSize = index.getLong(IO_PHYS_SIZE); index.putLong(IO_PHYS_SIZE, physSize+size); phys.ensureAvailable(physSize+size); physSize = physSize ^ (((long)size)<<48); return new long[]{physSize}; }else{ long[] ret = new long[2]; int retPos = 0; int c = 12; while(size>0){ if(retPos == ret.length) ret = Arrays.copyOf(ret, ret.length*2); int allocSize = Math.min(size, MAX_REC_SIZE); size -= allocSize - c; long physSize = index.getLong(IO_PHYS_SIZE); index.putLong(IO_PHYS_SIZE, physSize+allocSize); phys.ensureAvailable(physSize+allocSize); physSize = physSize ^ (((long)allocSize)<<48); if(c!=0) physSize|=MASK_IS_LINKED; ret[retPos++] = physSize; c = size<=MAX_REC_SIZE ? 0 : 8; } if(size!=0) throw new InternalError(); return Arrays.copyOf(ret, retPos); } } }
StorageDirect2 implements Engine { protected long[] physAllocate(int size) { if(size<MAX_REC_SIZE){ long physSize = index.getLong(IO_PHYS_SIZE); index.putLong(IO_PHYS_SIZE, physSize+size); phys.ensureAvailable(physSize+size); physSize = physSize ^ (((long)size)<<48); return new long[]{physSize}; }else{ long[] ret = new long[2]; int retPos = 0; int c = 12; while(size>0){ if(retPos == ret.length) ret = Arrays.copyOf(ret, ret.length*2); int allocSize = Math.min(size, MAX_REC_SIZE); size -= allocSize - c; long physSize = index.getLong(IO_PHYS_SIZE); index.putLong(IO_PHYS_SIZE, physSize+allocSize); phys.ensureAvailable(physSize+allocSize); physSize = physSize ^ (((long)allocSize)<<48); if(c!=0) physSize|=MASK_IS_LINKED; ret[retPos++] = physSize; c = size<=MAX_REC_SIZE ? 0 : 8; } if(size!=0) throw new InternalError(); return Arrays.copyOf(ret, retPos); } } StorageDirect2(Volume.Factory volFac, boolean readOnly); }
StorageDirect2 implements Engine { protected long[] physAllocate(int size) { if(size<MAX_REC_SIZE){ long physSize = index.getLong(IO_PHYS_SIZE); index.putLong(IO_PHYS_SIZE, physSize+size); phys.ensureAvailable(physSize+size); physSize = physSize ^ (((long)size)<<48); return new long[]{physSize}; }else{ long[] ret = new long[2]; int retPos = 0; int c = 12; while(size>0){ if(retPos == ret.length) ret = Arrays.copyOf(ret, ret.length*2); int allocSize = Math.min(size, MAX_REC_SIZE); size -= allocSize - c; long physSize = index.getLong(IO_PHYS_SIZE); index.putLong(IO_PHYS_SIZE, physSize+allocSize); phys.ensureAvailable(physSize+allocSize); physSize = physSize ^ (((long)allocSize)<<48); if(c!=0) physSize|=MASK_IS_LINKED; ret[retPos++] = physSize; c = size<=MAX_REC_SIZE ? 0 : 8; } if(size!=0) throw new InternalError(); return Arrays.copyOf(ret, retPos); } } StorageDirect2(Volume.Factory volFac, boolean readOnly); @Override long put(A value, Serializer<A> serializer); @Override A get(long recid, Serializer<A> serializer); @Override void update(long recid, A value, Serializer<A> serializer); @Override boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer); @Override void delete(long recid, Serializer<A> serializer); @Override void close(); @Override boolean isClosed(); @Override void commit(); @Override void rollback(); @Override boolean isReadOnly(); @Override void compact(); }
StorageDirect2 implements Engine { protected long[] physAllocate(int size) { if(size<MAX_REC_SIZE){ long physSize = index.getLong(IO_PHYS_SIZE); index.putLong(IO_PHYS_SIZE, physSize+size); phys.ensureAvailable(physSize+size); physSize = physSize ^ (((long)size)<<48); return new long[]{physSize}; }else{ long[] ret = new long[2]; int retPos = 0; int c = 12; while(size>0){ if(retPos == ret.length) ret = Arrays.copyOf(ret, ret.length*2); int allocSize = Math.min(size, MAX_REC_SIZE); size -= allocSize - c; long physSize = index.getLong(IO_PHYS_SIZE); index.putLong(IO_PHYS_SIZE, physSize+allocSize); phys.ensureAvailable(physSize+allocSize); physSize = physSize ^ (((long)allocSize)<<48); if(c!=0) physSize|=MASK_IS_LINKED; ret[retPos++] = physSize; c = size<=MAX_REC_SIZE ? 0 : 8; } if(size!=0) throw new InternalError(); return Arrays.copyOf(ret, retPos); } } StorageDirect2(Volume.Factory volFac, boolean readOnly); @Override long put(A value, Serializer<A> serializer); @Override A get(long recid, Serializer<A> serializer); @Override void update(long recid, A value, Serializer<A> serializer); @Override boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer); @Override void delete(long recid, Serializer<A> serializer); @Override void close(); @Override boolean isClosed(); @Override void commit(); @Override void rollback(); @Override boolean isReadOnly(); @Override void compact();  }