nowinkeyy commented on code in PR #5554:
URL: https://github.com/apache/rocketmq/pull/5554#discussion_r1042156606


##########
store/src/main/java/org/apache/rocketmq/store/logfile/DefaultMappedFile.java:
##########
@@ -314,6 +314,42 @@ public boolean appendMessage(final byte[] data, final int 
offset, final int leng
         return false;
     }
 
+    /**
+     * Content of data is written from the offset of the file.
+     *
+     * @param data the byte array to append
+     * @param offset the offset of data appended to the current {@code 
MappedFile}
+     */
+    @Override
+    public int appendMessageConcurrently(final byte[] data, final long offset) 
{
+        int expectOffset = (int) (offset % this.fileSize);
+        if ((expectOffset + data.length) <= this.fileSize) {
+            try {
+                ByteBuffer buf = this.mappedByteBuffer.slice();
+                buf.position(expectOffset);
+                buf.put(data, 0, data.length);
+            } catch (Throwable e) {
+                log.error("Error occurred when append message to mappedFile.", 
e);
+            }
+            int length = 0;
+            int currentPos = WROTE_POSITION_UPDATER.get(this);
+            if (currentPos == expectOffset) {
+                // todo how to traverse two mappedByteBuffer
+                for (int index = currentPos; index <= 
this.mappedByteBuffer.limit(); index += 20) {

Review Comment:
   > 20 is magic number. Does it support batch cq?
   
   It doesn't support bcq. Only ordinary cq are supported for now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to