本文整理匯總了Java中org.apache.rocketmq.store.MappedFile類的典型用法代碼示例。如果您正苦於以下問題:Java MappedFile類的具體用法?Java MappedFile怎麽用?Java MappedFile使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MappedFile類屬於org.apache.rocketmq.store包,在下文中一共展示了MappedFile類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: IndexFile
import org.apache.rocketmq.store.MappedFile; //導入依賴的package包/類
public IndexFile(final String fileName, final int hashSlotNum, final int indexNum,
final long endPhyOffset, final long endTimestamp) throws IOException {
int fileTotalSize =
IndexHeader.INDEX_HEADER_SIZE + (hashSlotNum * hashSlotSize) + (indexNum * indexSize);
this.mappedFile = new MappedFile(fileName, fileTotalSize);
this.fileChannel = this.mappedFile.getFileChannel();
this.mappedByteBuffer = this.mappedFile.getMappedByteBuffer();
this.hashSlotNum = hashSlotNum;
this.indexNum = indexNum;
ByteBuffer byteBuffer = this.mappedByteBuffer.slice();
this.indexHeader = new IndexHeader(byteBuffer);
if (endPhyOffset > 0) {
this.indexHeader.setBeginPhyOffset(endPhyOffset);
this.indexHeader.setEndPhyOffset(endPhyOffset);
}
if (endTimestamp > 0) {
this.indexHeader.setBeginTimestamp(endTimestamp);
this.indexHeader.setEndTimestamp(endTimestamp);
}
}
示例2: IndexFile
import org.apache.rocketmq.store.MappedFile; //導入依賴的package包/類
/**
*
* @param fileName userRootPath/index/YYMMDDhhmmss + mmm(毫秒)
* @param hashSlotNum default value = 5000000
* @param indexNum default value = 5000000 * 4
*
* 如果IndexFile 在IndexService.indexFileList.isEmpty()空時創建,則 endPhyOffset = endTimestamp = 0;
* 否則, endPhyOffset = IndexService.indexFileList.last().endPhyOffset
* endTimestamp = IndexService.indexFileList.last().endTimestamp
* @param endPhyOffset
* @param endTimestamp
* @throws IOException
*/
public IndexFile(final String fileName, final int hashSlotNum, final int indexNum,
final long endPhyOffset, final long endTimestamp) throws IOException {
//fileTotalSize = 40 + (5,000,000[hashSlotNum] * 4[hashSlotSize]) + ((4 * 5,000,000)[indexNum] * 20[indexSize])
//1G = 1024 * 1024 * 1024 = 1,073,741,824 (10億級)
int fileTotalSize =
IndexHeader.INDEX_HEADER_SIZE + (hashSlotNum * hashSlotSize) + (indexNum * indexSize);
this.mappedFile = new MappedFile(fileName, fileTotalSize);
this.fileChannel = this.mappedFile.getFileChannel();
this.mappedByteBuffer = this.mappedFile.getMappedByteBuffer();
this.hashSlotNum = hashSlotNum;
this.indexNum = indexNum;
ByteBuffer byteBuffer = this.mappedByteBuffer.slice();
this.indexHeader = new IndexHeader(byteBuffer);
if (endPhyOffset > 0) {
this.indexHeader.setBeginPhyOffset(endPhyOffset);
this.indexHeader.setEndPhyOffset(endPhyOffset);
}
if (endTimestamp > 0) {
this.indexHeader.setBeginTimestamp(endTimestamp);
this.indexHeader.setEndTimestamp(endTimestamp);
}
}