class AODataSyncFile {

	public int read(ByteBuffer readBuffer, long position) throws IOException {
		if (position < FileHeader.HEADER_SIZE) {
			throw new IllegalArgumentException("position must >= file header size:" + FileHeader.HEADER_SIZE + " current pos:" + position);
		}
		readBufferLock.lock();
		try	{
			// 文件大小，包括之前写入的缓存
			long allFileSize = size();
			if (allFileSize == 0) {
				return -1;
			}
			if (position >= allFileSize) {
				throw new IllegalArgumentException("position must < file size[" + allFileSize + "]!");
			}
			// 最大读取的数据量
			int readSize = readBuffer.remaining();
			// 读取的数据长度
			int count = 0;
			// 获取需要读取的数据对应的文件块的位置
			long[] blockIndexes = getBlockIndexes(position, readSize);
			for (int i = 0; i < blockIndexes.length; ++i) {
				ByteDynamicArray blockDataDArray = getBlockData(blockIndexes[i]);
				int readPos = 0;
				if (i == 0) {
					// 移除头部后的相对位置
					long removedHeaderPos = position - FileHeader.HEADER_SIZE;
					// 第一个数据块，可能只读取部分数据
					readPos = (int) (removedHeaderPos % blockSize);
				}
				count += blockDataDArray.read(readBuffer, readPos);
			}
			return count;
		} finally {
			readBufferLock.unlock();
		}
	}

	public  AODataSyncFile(File file, int syncStrategy);
	public  AODataSyncFile(File file, int blockSize, boolean blockCache, int maxCacheCapacity, int maxDataBufferSize, int syncStrategy);

}