package com.xqbase.block;

import com.xqbase.stroage.StorageConfig;

import java.io.IOException;

public class DefaultStorageBlock implements IBlock {

    @Override
    public byte[] get(int position) {
        return new byte[0];
    }

    @Override
    public void store(byte[] key, byte[] value, long ttl) {

    }

    @Override
    public long markDirty(int dirtySize) {
        return 0;
    }

    @Override
    public long getCapacity() {
        return 0;
    }

    @Override
    public long getDirty() {
        return 0;
    }

    @Override
    public long getUsed() {
        return 0;
    }

    @Override
    public double getDirtyRatio() {
        return 0;
    }

    @Override
    public int getIndex() {
        return 0;
    }

    @Override
    public StorageConfig.StorageMode getStorageMode() {
        return null;
    }

    @Override
    public void free() {

    }

    @Override
    public void close() throws IOException {

    }

    @Override
    public int compareTo(IBlock o) {
        return 0;
    }
}

@@ -46,29 +46,17 @@
 stroage.
-StorageConfig
+*
 ;%0A%0Aimpor
@@ -77,16 +77,66 @@
 ception;
+%0Aimport java.util.concurrent.atomic.AtomicInteger;
 %0A%0Apublic
@@ -179,24 +179,1260 @@
 s IBlock %7B%0A%0A
+    private final int index;%0A%0A    private final int capacity;%0A%0A    private StorageConfig.StorageMode storageMode;%0A%0A    private final AtomicInteger usedStorage = new AtomicInteger(0);%0A%0A    private final AtomicInteger dirtyStorage = new AtomicInteger(0);%0A%0A    private final AtomicInteger currentItemOffset = new AtomicInteger(0);%0A%0A    private IStorage underlyingStorage;%0A%0A    /**%0A     * Create a new storage block%0A     * @param dir the directory%0A     * @param index the file index%0A     * @param capacity capacity of block%0A     * @param storageMode storage-mode of the block%0A     */%0A    public DefaultStorageBlock(String dir, int index, int capacity, StorageConfig.StorageMode storageMode) throws IOException %7B%0A        this.index = index;%0A        this.capacity = capacity;%0A        this.storageMode = storageMode;%0A        switch (storageMode) %7B%0A            case File:%0A                this.underlyingStorage = new FileStorage(dir, index, capacity);%0A                break;%0A            case MapFile:%0A                this.underlyingStorage = new MapFileStorage(dir, index, capacity);%0A                break;%0A            case OffHeap:%0A                this.underlyingStorage = new OffHeapStorage(capacity);%0A                break;%0A        %7D%0A    %7D%0A%0A
     @Overrid
@@ -2222,32 +2222,207 @@
 ption %7B%0A%0A    %7D%0A%0A
+    private static class Allocation %7B%0A%0A        private int itemOffset;%0A%0A        public Allocation(int itemOffset) %7B%0A            this.itemOffset = itemOffset;%0A        %7D%0A    %7D%0A%0A
     @Override%0A  

add a DefaultStorageBlock....