test_class.file: store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
test_class.identifier: MappedFileQueueTest
test_case.body: @Test
      public void testFindMappedFileByOffset() {
          // four-byte string.
          final String fixedMsg = "abcd";
  
          MappedFileQueue mappedFileQueue =
              new MappedFileQueue("target/unit_test_store/b/", 1024, null);
  
          for (int i = 0; i < 1024; i++) {
              MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0);
              assertThat(mappedFile).isNotNull();
              assertThat(mappedFile.appendMessage(fixedMsg.getBytes())).isTrue();
          }
  
          assertThat(mappedFileQueue.getMappedMemorySize()).isEqualTo(fixedMsg.getBytes().length * 1024);
  
          MappedFile mappedFile = mappedFileQueue.findMappedFileByOffset(0);
          assertThat(mappedFile).isNotNull();
          assertThat(mappedFile.getFileFromOffset()).isEqualTo(0);
  
          mappedFile = mappedFileQueue.findMappedFileByOffset(100);
          assertThat(mappedFile).isNotNull();
          assertThat(mappedFile.getFileFromOffset()).isEqualTo(0);
  
          mappedFile = mappedFileQueue.findMappedFileByOffset(1024);
          assertThat(mappedFile).isNotNull();
          assertThat(mappedFile.getFileFromOffset()).isEqualTo(1024);
  
          mappedFile = mappedFileQueue.findMappedFileByOffset(1024 + 100);
          assertThat(mappedFile).isNotNull();
          assertThat(mappedFile.getFileFromOffset()).isEqualTo(1024);
  
          mappedFile = mappedFileQueue.findMappedFileByOffset(1024 * 2);
          assertThat(mappedFile).isNotNull();
          assertThat(mappedFile.getFileFromOffset()).isEqualTo(1024 * 2);
  
          mappedFile = mappedFileQueue.findMappedFileByOffset(1024 * 2 + 100);
          assertThat(mappedFile).isNotNull();
          assertThat(mappedFile.getFileFromOffset()).isEqualTo(1024 * 2);
  
          // over mapped memory size.
          mappedFile = mappedFileQueue.findMappedFileByOffset(1024 * 4);
          assertThat(mappedFile).isNull();
  
          mappedFile = mappedFileQueue.findMappedFileByOffset(1024 * 4 + 100);
          assertThat(mappedFile).isNull();
  
          mappedFileQueue.shutdown(1000);
          mappedFileQueue.destroy();
      }
test_case.class_method_signature: MappedFileQueueTest.testFindMappedFileByOffset()
test_case.full_signature: @Test public void testFindMappedFileByOffset()
test_case.identifier: testFindMappedFileByOffset
test_case.invocations: getLastMappedFile isNotNull assertThat isTrue assertThat appendMessage getBytes isEqualTo assertThat getMappedMemorySize getBytes findMappedFileByOffset isNotNull assertThat isEqualTo assertThat getFileFromOffset findMappedFileByOffset isNotNull assertThat isEqualTo assertThat getFileFromOffset findMappedFileByOffset isNotNull assertThat isEqualTo assertThat getFileFromOffset findMappedFileByOffset isNotNull assertThat isEqualTo assertThat getFileFromOffset findMappedFileByOffset isNotNull assertThat isEqualTo assertThat getFileFromOffset findMappedFileByOffset isNotNull assertThat isEqualTo assertThat getFileFromOffset findMappedFileByOffset isNull assertThat findMappedFileByOffset isNull assertThat shutdown destroy
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFindMappedFileByOffset()
focal_class.declarator: log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: LOG_ERROR = LoggerFactory.getLogger(LoggerName.STORE_ERROR_LOGGER_NAME)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG_ERROR = LoggerFactory.getLogger(LoggerName.STORE_ERROR_LOGGER_NAME);
focal_class.type: Logger
focal_class.var_name: LOG_ERROR
focal_class.declarator: DELETE_FILES_BATCH_MAX = 10
focal_class.modifier: private static final
focal_class.original_string: private static final int DELETE_FILES_BATCH_MAX = 10;
focal_class.type: int
focal_class.var_name: DELETE_FILES_BATCH_MAX
focal_class.declarator: storePath
focal_class.modifier: private final
focal_class.original_string: private final String storePath;
focal_class.type: String
focal_class.var_name: storePath
focal_class.declarator: mappedFileSize
focal_class.modifier: private final
focal_class.original_string: private final int mappedFileSize;
focal_class.type: int
focal_class.var_name: mappedFileSize
focal_class.declarator: mappedFiles = new CopyOnWriteArrayList<MappedFile>()
focal_class.modifier: private final
focal_class.original_string: private final CopyOnWriteArrayList<MappedFile> mappedFiles = new CopyOnWriteArrayList<MappedFile>();
focal_class.type: CopyOnWriteArrayList<MappedFile>
focal_class.var_name: mappedFiles
focal_class.declarator: allocateMappedFileService
focal_class.modifier: private final
focal_class.original_string: private final AllocateMappedFileService allocateMappedFileService;
focal_class.type: AllocateMappedFileService
focal_class.var_name: allocateMappedFileService
focal_class.declarator: flushedWhere = 0
focal_class.modifier: private
focal_class.original_string: private long flushedWhere = 0;
focal_class.type: long
focal_class.var_name: flushedWhere
focal_class.declarator: committedWhere = 0
focal_class.modifier: private
focal_class.original_string: private long committedWhere = 0;
focal_class.type: long
focal_class.var_name: committedWhere
focal_class.declarator: storeTimestamp = 0
focal_class.modifier: private volatile
focal_class.original_string: private volatile long storeTimestamp = 0;
focal_class.type: long
focal_class.var_name: storeTimestamp
focal_class.file: store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
focal_class.identifier: MappedFileQueue
focal_class.class_method_signature: MappedFileQueue.MappedFileQueue(final String storePath, int mappedFileSize,
          AllocateMappedFileService allocateMappedFileService)
focal_class.full_signature: public  MappedFileQueue(final String storePath, int mappedFileSize,
          AllocateMappedFileService allocateMappedFileService)
focal_class.identifier: MappedFileQueue
focal_class.modifiers: public
focal_class.parameters: (final String storePath, int mappedFileSize,
          AllocateMappedFileService allocateMappedFileService)
focal_class.signature:  MappedFileQueue(final String storePath, int mappedFileSize,
          AllocateMappedFileService allocateMappedFileService)
focal_class.class_method_signature: MappedFileQueue.checkSelf()
focal_class.full_signature: public void checkSelf()
focal_class.identifier: checkSelf
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void checkSelf()
focal_class.class_method_signature: MappedFileQueue.getMappedFileByTime(final long timestamp)
focal_class.full_signature: public MappedFile getMappedFileByTime(final long timestamp)
focal_class.identifier: getMappedFileByTime
focal_class.modifiers: public
focal_class.parameters: (final long timestamp)
focal_class.return: MappedFile
focal_class.signature: MappedFile getMappedFileByTime(final long timestamp)
focal_class.class_method_signature: MappedFileQueue.copyMappedFiles(final int reservedMappedFiles)
focal_class.full_signature: private Object[] copyMappedFiles(final int reservedMappedFiles)
focal_class.identifier: copyMappedFiles
focal_class.modifiers: private
focal_class.parameters: (final int reservedMappedFiles)
focal_class.return: Object[]
focal_class.signature: Object[] copyMappedFiles(final int reservedMappedFiles)
focal_class.class_method_signature: MappedFileQueue.truncateDirtyFiles(long offset)
focal_class.full_signature: public void truncateDirtyFiles(long offset)
focal_class.identifier: truncateDirtyFiles
focal_class.modifiers: public
focal_class.parameters: (long offset)
focal_class.return: void
focal_class.signature: void truncateDirtyFiles(long offset)
focal_class.class_method_signature: MappedFileQueue.deleteExpiredFile(List<MappedFile> files)
focal_class.full_signature:  void deleteExpiredFile(List<MappedFile> files)
focal_class.identifier: deleteExpiredFile
focal_class.parameters: (List<MappedFile> files)
focal_class.return: void
focal_class.signature: void deleteExpiredFile(List<MappedFile> files)
focal_class.class_method_signature: MappedFileQueue.load()
focal_class.full_signature: public boolean load()
focal_class.identifier: load
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean load()
focal_class.class_method_signature: MappedFileQueue.howMuchFallBehind()
focal_class.full_signature: public long howMuchFallBehind()
focal_class.identifier: howMuchFallBehind
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long howMuchFallBehind()
focal_class.class_method_signature: MappedFileQueue.getLastMappedFile(final long startOffset, boolean needCreate)
focal_class.full_signature: public MappedFile getLastMappedFile(final long startOffset, boolean needCreate)
focal_class.identifier: getLastMappedFile
focal_class.modifiers: public
focal_class.parameters: (final long startOffset, boolean needCreate)
focal_class.return: MappedFile
focal_class.signature: MappedFile getLastMappedFile(final long startOffset, boolean needCreate)
focal_class.class_method_signature: MappedFileQueue.getLastMappedFile(final long startOffset)
focal_class.full_signature: public MappedFile getLastMappedFile(final long startOffset)
focal_class.identifier: getLastMappedFile
focal_class.modifiers: public
focal_class.parameters: (final long startOffset)
focal_class.return: MappedFile
focal_class.signature: MappedFile getLastMappedFile(final long startOffset)
focal_class.class_method_signature: MappedFileQueue.getLastMappedFile()
focal_class.full_signature: public MappedFile getLastMappedFile()
focal_class.identifier: getLastMappedFile
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: MappedFile
focal_class.signature: MappedFile getLastMappedFile()
focal_class.class_method_signature: MappedFileQueue.resetOffset(long offset)
focal_class.full_signature: public boolean resetOffset(long offset)
focal_class.identifier: resetOffset
focal_class.modifiers: public
focal_class.parameters: (long offset)
focal_class.return: boolean
focal_class.signature: boolean resetOffset(long offset)
focal_class.class_method_signature: MappedFileQueue.getMinOffset()
focal_class.full_signature: public long getMinOffset()
focal_class.identifier: getMinOffset
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getMinOffset()
focal_class.class_method_signature: MappedFileQueue.getMaxOffset()
focal_class.full_signature: public long getMaxOffset()
focal_class.identifier: getMaxOffset
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getMaxOffset()
focal_class.class_method_signature: MappedFileQueue.getMaxWrotePosition()
focal_class.full_signature: public long getMaxWrotePosition()
focal_class.identifier: getMaxWrotePosition
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getMaxWrotePosition()
focal_class.class_method_signature: MappedFileQueue.remainHowManyDataToCommit()
focal_class.full_signature: public long remainHowManyDataToCommit()
focal_class.identifier: remainHowManyDataToCommit
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long remainHowManyDataToCommit()
focal_class.class_method_signature: MappedFileQueue.remainHowManyDataToFlush()
focal_class.full_signature: public long remainHowManyDataToFlush()
focal_class.identifier: remainHowManyDataToFlush
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long remainHowManyDataToFlush()
focal_class.class_method_signature: MappedFileQueue.deleteLastMappedFile()
focal_class.full_signature: public void deleteLastMappedFile()
focal_class.identifier: deleteLastMappedFile
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void deleteLastMappedFile()
focal_class.class_method_signature: MappedFileQueue.deleteExpiredFileByTime(final long expiredTime,
          final int deleteFilesInterval,
          final long intervalForcibly,
          final boolean cleanImmediately)
focal_class.full_signature: public int deleteExpiredFileByTime(final long expiredTime,
          final int deleteFilesInterval,
          final long intervalForcibly,
          final boolean cleanImmediately)
focal_class.identifier: deleteExpiredFileByTime
focal_class.modifiers: public
focal_class.parameters: (final long expiredTime,
          final int deleteFilesInterval,
          final long intervalForcibly,
          final boolean cleanImmediately)
focal_class.return: int
focal_class.signature: int deleteExpiredFileByTime(final long expiredTime,
          final int deleteFilesInterval,
          final long intervalForcibly,
          final boolean cleanImmediately)
focal_class.class_method_signature: MappedFileQueue.deleteExpiredFileByOffset(long offset, int unitSize)
focal_class.full_signature: public int deleteExpiredFileByOffset(long offset, int unitSize)
focal_class.identifier: deleteExpiredFileByOffset
focal_class.modifiers: public
focal_class.parameters: (long offset, int unitSize)
focal_class.return: int
focal_class.signature: int deleteExpiredFileByOffset(long offset, int unitSize)
focal_class.class_method_signature: MappedFileQueue.flush(final int flushLeastPages)
focal_class.full_signature: public boolean flush(final int flushLeastPages)
focal_class.identifier: flush
focal_class.modifiers: public
focal_class.parameters: (final int flushLeastPages)
focal_class.return: boolean
focal_class.signature: boolean flush(final int flushLeastPages)
focal_class.class_method_signature: MappedFileQueue.commit(final int commitLeastPages)
focal_class.full_signature: public boolean commit(final int commitLeastPages)
focal_class.identifier: commit
focal_class.modifiers: public
focal_class.parameters: (final int commitLeastPages)
focal_class.return: boolean
focal_class.signature: boolean commit(final int commitLeastPages)
focal_class.class_method_signature: MappedFileQueue.findMappedFileByOffset(final long offset, final boolean returnFirstOnNotFound)
focal_class.full_signature: public MappedFile findMappedFileByOffset(final long offset, final boolean returnFirstOnNotFound)
focal_class.identifier: findMappedFileByOffset
focal_class.modifiers: public
focal_class.parameters: (final long offset, final boolean returnFirstOnNotFound)
focal_class.return: MappedFile
focal_class.signature: MappedFile findMappedFileByOffset(final long offset, final boolean returnFirstOnNotFound)
focal_class.class_method_signature: MappedFileQueue.deleteMappedFileByOffset(final long offset)
focal_class.full_signature: public void deleteMappedFileByOffset(final long offset)
focal_class.identifier: deleteMappedFileByOffset
focal_class.modifiers: public
focal_class.parameters: (final long offset)
focal_class.return: void
focal_class.signature: void deleteMappedFileByOffset(final long offset)
focal_class.class_method_signature: MappedFileQueue.getFirstMappedFile()
focal_class.full_signature: public MappedFile getFirstMappedFile()
focal_class.identifier: getFirstMappedFile
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: MappedFile
focal_class.signature: MappedFile getFirstMappedFile()
focal_class.class_method_signature: MappedFileQueue.findMappedFileByOffset(final long offset)
focal_class.full_signature: public MappedFile findMappedFileByOffset(final long offset)
focal_class.identifier: findMappedFileByOffset
focal_class.modifiers: public
focal_class.parameters: (final long offset)
focal_class.return: MappedFile
focal_class.signature: MappedFile findMappedFileByOffset(final long offset)
focal_class.class_method_signature: MappedFileQueue.getMappedMemorySize()
focal_class.full_signature: public long getMappedMemorySize()
focal_class.identifier: getMappedMemorySize
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getMappedMemorySize()
focal_class.class_method_signature: MappedFileQueue.retryDeleteFirstFile(final long intervalForcibly)
focal_class.full_signature: public boolean retryDeleteFirstFile(final long intervalForcibly)
focal_class.identifier: retryDeleteFirstFile
focal_class.modifiers: public
focal_class.parameters: (final long intervalForcibly)
focal_class.return: boolean
focal_class.signature: boolean retryDeleteFirstFile(final long intervalForcibly)
focal_class.class_method_signature: MappedFileQueue.shutdown(final long intervalForcibly)
focal_class.full_signature: public void shutdown(final long intervalForcibly)
focal_class.identifier: shutdown
focal_class.modifiers: public
focal_class.parameters: (final long intervalForcibly)
focal_class.return: void
focal_class.signature: void shutdown(final long intervalForcibly)
focal_class.class_method_signature: MappedFileQueue.destroy()
focal_class.full_signature: public void destroy()
focal_class.identifier: destroy
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void destroy()
focal_class.class_method_signature: MappedFileQueue.getFlushedWhere()
focal_class.full_signature: public long getFlushedWhere()
focal_class.identifier: getFlushedWhere
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getFlushedWhere()
focal_class.class_method_signature: MappedFileQueue.setFlushedWhere(long flushedWhere)
focal_class.full_signature: public void setFlushedWhere(long flushedWhere)
focal_class.identifier: setFlushedWhere
focal_class.modifiers: public
focal_class.parameters: (long flushedWhere)
focal_class.return: void
focal_class.signature: void setFlushedWhere(long flushedWhere)
focal_class.class_method_signature: MappedFileQueue.getStoreTimestamp()
focal_class.full_signature: public long getStoreTimestamp()
focal_class.identifier: getStoreTimestamp
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getStoreTimestamp()
focal_class.class_method_signature: MappedFileQueue.getMappedFiles()
focal_class.full_signature: public List<MappedFile> getMappedFiles()
focal_class.identifier: getMappedFiles
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: List<MappedFile>
focal_class.signature: List<MappedFile> getMappedFiles()
focal_class.class_method_signature: MappedFileQueue.getMappedFileSize()
focal_class.full_signature: public int getMappedFileSize()
focal_class.identifier: getMappedFileSize
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getMappedFileSize()
focal_class.class_method_signature: MappedFileQueue.getCommittedWhere()
focal_class.full_signature: public long getCommittedWhere()
focal_class.identifier: getCommittedWhere
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getCommittedWhere()
focal_class.class_method_signature: MappedFileQueue.setCommittedWhere(final long committedWhere)
focal_class.full_signature: public void setCommittedWhere(final long committedWhere)
focal_class.identifier: setCommittedWhere
focal_class.modifiers: public
focal_class.parameters: (final long committedWhere)
focal_class.return: void
focal_class.signature: void setCommittedWhere(final long committedWhere)
focal_method.body: public MappedFile findMappedFileByOffset(final long offset, final boolean returnFirstOnNotFound) {
          try {
              MappedFile mappedFile = this.getFirstMappedFile();
              if (mappedFile != null) {
                  int index = (int) ((offset / this.mappedFileSize) - (mappedFile.getFileFromOffset() / this.mappedFileSize));
                  if (index < 0 || index >= this.mappedFiles.size()) {
                      LOG_ERROR.warn("Offset for {} not matched. Request offset: {}, index: {}, " +
                              "mappedFileSize: {}, mappedFiles count: {}",
                          mappedFile,
                          offset,
                          index,
                          this.mappedFileSize,
                          this.mappedFiles.size());
                  }
  
                  try {
                      return this.mappedFiles.get(index);
                  } catch (Exception e) {
                      if (returnFirstOnNotFound) {
                          return mappedFile;
                      }
                      LOG_ERROR.warn("findMappedFileByOffset failure. ", e);
                  }
              }
          } catch (Exception e) {
              log.error("findMappedFileByOffset Exception", e);
          }
  
          return null;
      }
focal_method.class_method_signature: MappedFileQueue.findMappedFileByOffset(final long offset, final boolean returnFirstOnNotFound)
focal_method.full_signature: public MappedFile findMappedFileByOffset(final long offset, final boolean returnFirstOnNotFound)
focal_method.identifier: findMappedFileByOffset
focal_method.invocations: getFirstMappedFile getFileFromOffset size warn size get warn error
focal_method.modifiers: public
focal_method.parameters: (final long offset, final boolean returnFirstOnNotFound)
focal_method.return: MappedFile
focal_method.signature: MappedFile findMappedFileByOffset(final long offset, final boolean returnFirstOnNotFound)