mirror of
https://github.com/apache/rocketmq.git
synced 2026-08-30 18:10:44 +08:00
[ISSUE #6406] Add more visual comments on IndexFile & IndexHeader & ConsumeQueue
1. add more visual comments
This commit is contained in:
@@ -43,6 +43,19 @@ import org.apache.rocketmq.store.queue.ReferredIterator;
|
||||
public class ConsumeQueue implements ConsumeQueueInterface, FileQueueLifeCycle {
|
||||
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
|
||||
|
||||
/**
|
||||
* ConsumeQueue's store unit. Format:
|
||||
* <pre>
|
||||
* ┌───────────────────────────────┬───────────────────┬───────────────────────────────┐
|
||||
* │ CommitLog Physical Offset │ Body Size │ Tag HashCode │
|
||||
* │ (8 Bytes) │ (4 Bytes) │ (8 Bytes) │
|
||||
* ├───────────────────────────────┴───────────────────┴───────────────────────────────┤
|
||||
* │ Store Unit │
|
||||
* │ │
|
||||
* </pre>
|
||||
* ConsumeQueue's store unit. Size:
|
||||
* CommitLog Physical Offset(8) + Body Size(4) + Tag HashCode(8) = 20 Bytes
|
||||
*/
|
||||
public static final int CQ_STORE_UNIT_SIZE = 20;
|
||||
public static final int MSG_TAG_OFFSET_INDEX = 12;
|
||||
private static final Logger LOG_ERROR = LoggerFactory.getLogger(LoggerName.STORE_ERROR_LOGGER_NAME);
|
||||
|
||||
@@ -30,6 +30,19 @@ import org.apache.rocketmq.store.logfile.MappedFile;
|
||||
public class IndexFile {
|
||||
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
|
||||
private static int hashSlotSize = 4;
|
||||
/**
|
||||
* Each index's store unit. Format:
|
||||
* <pre>
|
||||
* ┌───────────────┬───────────────────────────────┬───────────────┬───────────────┐
|
||||
* │ Key HashCode │ Physical Offset │ Time Diff │ Next Index Pos│
|
||||
* │ (4 Bytes) │ (8 Bytes) │ (4 Bytes) │ (4 Bytes) │
|
||||
* ├───────────────┴───────────────────────────────┴───────────────┴───────────────┤
|
||||
* │ Index Store Unit │
|
||||
* │ │
|
||||
* </pre>
|
||||
* Each index's store unit. Size:
|
||||
* Key HashCode(4) + Physical Offset(8) + Time Diff(4) + Next Index Pos(4) = 20 Bytes
|
||||
*/
|
||||
private static int indexSize = 20;
|
||||
private static int invalidIndex = 0;
|
||||
private final int hashSlotNum;
|
||||
|
||||
@@ -20,6 +20,19 @@ import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* Index File Header. Format:
|
||||
* <pre>
|
||||
* ┌───────────────────────────────┬───────────────────────────────┬───────────────────────────────┬───────────────────────────────┬───────────────────┬───────────────────┐
|
||||
* │ Begin Timestamp │ End Timestamp │ Begin Physical Offset │ End Physical Offset │ Hash Slot Count │ Index Count │
|
||||
* │ (8 Bytes) │ (8 Bytes) │ (8 Bytes) │ (8 Bytes) │ (4 Bytes) │ (4 Bytes) │
|
||||
* ├───────────────────────────────┴───────────────────────────────┴───────────────────────────────┴───────────────────────────────┴───────────────────┴───────────────────┤
|
||||
* │ Index File Header │
|
||||
* │
|
||||
* </pre>
|
||||
* Index File Header. Size:
|
||||
* Begin Timestamp(8) + End Timestamp(8) + Begin Physical Offset(8) + End Physical Offset(8) + Hash Slot Count(4) + Index Count(4) = 40 Bytes
|
||||
*/
|
||||
public class IndexHeader {
|
||||
public static final int INDEX_HEADER_SIZE = 40;
|
||||
private static int beginTimestampIndex = 0;
|
||||
|
||||
Reference in New Issue
Block a user