class StorageDirect2 implements Engine {

    protected long[] physAllocate(int size) {
        //append to end of file
        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;

                //append to end of file
                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);
        }
    }

    public  StorageDirect2(Volume.Factory volFac, boolean readOnly);

}