@Override
    protected void loadFromDisk() throws IOException {

        FileUtils.createDirIfNotExist(storeConfig.getIndexPath());

        String[] indexFiles = getIndexFiles();
        if (indexFiles == null || indexFiles.length == 0) {
            return;
        }

        FileChannel fileChannel = null;
        try {
            File lastSnapshot = new File(storeConfig.getIndexPath(), indexFiles[indexFiles.length - 1]);
            fileChannel = FileUtils.newFileChannel(lastSnapshot, "rw");
            IndexSnapshotFileHeader fileHeader = new IndexSnapshotFileHeader();
            fileHeader.read(fileChannel);

            ConcurrentMap<K, IndexItem<K>> indexMap = null;
            if (fileHeader.getStoreTxLogRecordId() != 0) {
                if (LOGGER.isInfoEnabled()) {
                    LOGGER.info("Start to read IndexSnapshot File ....");
                }

                UnsafeByteArrayOutputStream os = new UnsafeByteArrayOutputStream();
                WritableByteChannel target = Channels.newChannel(os);
                long readLength = fileChannel.size() - fileHeader.getLength();
                if (readLength != 0) {
                    fileChannel.transferTo(fileHeader.getLength(), readLength, target);

                    UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream(os.toByteArray());

                    indexMap = serializer.deserialize(is,
                            new TypeReference<ConcurrentSkipListMap<K, IndexItem<K>>>() {
                            }.getType());
                }

                if (LOGGER.isInfoEnabled()) {
                    LOGGER.info("Finish read IndexSnapshot File");
                }
            }

            if (indexMap == null) {
                indexMap = new ConcurrentSkipListMap<K, IndexItem<K>>();
            }

            ((MemIndex<K, V>) index).setIndexMap(indexMap);

            StoreTxLogPosition lastTxLog = new StoreTxLogPosition();
            lastTxLog.setRecordId(fileHeader.getStoreTxLogRecordId());

            ((MemIndex<K, V>) index).setLastTxLog(lastTxLog);

        } finally {
            if (fileChannel != null) {
                fileChannel.close();
            }
        }
    }
@author Robert HG (254963746@qq.com) on 12/19/15.
lts-core/src/main/java/com/github/ltsopensource/kv/index/MemIndexSnapshot.java