public boolean appendMsg(MsgStoreStatsHolder memStatsHolder,
            int partitionId, int keyCode, long timeRecv,
            ByteBuffer indexEntry, int dataEntryLength,
            ByteBuffer dataEntry, AppendResult appendResult) {
        long dataOffset;
        long indexOffset;
        int indexSizePos;
        boolean isAppended = true;
        boolean fullDataSize = false;
        boolean fullIndexSize = false;
        boolean fullCount = false;
        this.writeLock.lock();
        try {
            // judge whether can write to memory or not.
            fullDataSize =
                    (this.cacheDataOffset.get() + dataEntryLength > this.maxDataCacheSize);
            fullCount =
                    (this.curMessageCount.get() + 1 > maxAllowedMsgCount);
            fullIndexSize =
                    (this.cacheIndexOffset.get() + DataStoreUtils.STORE_INDEX_HEAD_LEN > this.maxIndexCacheSize);
            if (fullDataSize || fullCount || fullIndexSize) {
                isAppended = false;
                return false;
            }
            // conduct message with filling process
            indexOffset = this.writeIndexStartPos + this.cacheIndexOffset.get();
            dataOffset = this.writeDataStartPos + this.cacheDataOffset.get();
            indexEntry.putLong(DataStoreUtils.INDEX_POS_DATAOFFSET, dataOffset);
            dataEntry.putLong(DataStoreUtils.STORE_HEADER_POS_QUEUE_LOGICOFF, indexOffset);
            this.cacheDataSegment.put(dataEntry.array());
            this.cachedIndexSegment.put(indexEntry.array());
            this.cacheDataOffset.getAndAdd(dataEntryLength);
            indexSizePos = cacheIndexOffset.getAndAdd(DataStoreUtils.STORE_INDEX_HEAD_LEN);
            this.queuesMap.put(partitionId, indexSizePos);
            this.keysMap.put(keyCode, indexSizePos);
            this.curMessageCount.getAndIncrement();
            this.rightAppendTime.set(timeRecv);
            if (indexSizePos == 0) {
                this.leftAppendTime.set(timeRecv);
            }
        } finally {
            this.writeLock.unlock();
            if (!isAppended) {
                memStatsHolder.addCacheFullType(fullDataSize, fullIndexSize, fullCount);
            }
        }
        appendResult.putAppendResult(indexOffset, dataOffset);
        return true;
    }
Append message to memory cache

@param memStatsHolder    statistical information object
@param partitionId       the partitionId for append messages
@param keyCode           the filter item hash code
@param timeRecv          the received timestamp
@param indexEntry        the stored index entry
@param dataEntryLength   the stored data entry length
@param dataEntry         the stored data entry
@param appendResult      the append result

@return    the process result
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/broker/msgstore/mem/MsgMemStore.java