You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2020/03/17 01:33:01 UTC

[GitHub] [activemq-artemis] clebertsuconic opened a new pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

clebertsuconic opened a new pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021
 
 
   The encodeSize wouldn't be guaranteed to be equivalent to a value just read from some protcols.
   As the protocol may add additional bytes right after decoded.
   
   We may avoid that and make it safe, but at this point I would rather make it independent.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393545064
 
 

 ##########
 File path: artemis-server/src/test/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageReaderTest.java
 ##########
 @@ -58,7 +58,7 @@ public void testPageReadMessage() throws Exception {
             PagePosition pagePosition = new PagePositionImpl(10, i);
             pagedMessage = pageReader.getMessage(pagePosition);
          } else {
-            int nextFileOffset = pagedMessage == null ? -1 : offsets[i - 1] + pagedMessage.getEncodeSize() + Page.SIZE_RECORD;
+            int nextFileOffset = pagedMessage == null ? -1 : offsets[i - 1] + pagedMessage.getStoredSize() + Page.SIZE_RECORD;
 
 Review comment:
   I don't know why, but my IDEA isn't happy with this test, see
   ![image](https://user-images.githubusercontent.com/13125299/76842129-1486ec80-683a-11ea-8c10-3d48418c9bdf.png)
   Although I can run it and it compiles correctly...:(

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] asfgit merged pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
asfgit merged pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393544454
 
 

 ##########
 File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java
 ##########
 @@ -47,6 +47,8 @@
 
    private long transactionID = 0;
 
+   private int storedSize = 0;
 
 Review comment:
   If it cannot change anymore, I would make it `final` instead

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] asfgit closed pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393554279
 
 

 ##########
 File path: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/paging/AmqpPageReaderTest.java
 ##########
 @@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.integration.amqp.paging;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.paging.cursor.impl.PageReaderTest;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPStandardMessage;
+import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
+import org.apache.activemq.artemis.tests.integration.amqp.AmqpTestSupport;
+import org.apache.activemq.transport.amqp.client.AmqpMessage;
+import org.apache.qpid.proton.message.impl.MessageImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class AmqpPageReaderTest extends PageReaderTest {
+
+   public MessageImpl createProtonMessage(String address) {
+      AmqpMessage message = new AmqpMessage();
+      final StringBuilder builder = new StringBuilder();
+      for (int i = 0; i < 1000; i++) {
+         builder.append('0');
+      }
+      final String data = builder.toString();
+      message.setText(data);
+      message.setAddress(address);
+      message.setDurable(true);
+
+      MessageImpl protonMessage = (MessageImpl) message.getWrappedMessage();
+
+      return protonMessage;
+   }
+
+   @Override
+   protected Message createMessage(SimpleString address, int msgId, byte[] content) {
+      MessageImpl protonMessage = createProtonMessage(address.toString());
+      AMQPStandardMessage amqpStandardMessage =  AmqpTestSupport.encodeAndDecodeMessage(0, protonMessage, 2 * 1024);
+      amqpStandardMessage.setMessageID(msgId);
+
+      return amqpStandardMessage;
+   }
+
+
+   @Test
+   public void testEncodeSize() throws Exception {
+
+      Message message = createMessage(SimpleString.toSimpleString("Test"), 1, new byte[10]);
+
+      MessagePersister persister = (MessagePersister)message.getPersister();
+
+      ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(1024);
+      persister.encode(buffer, message);
+
+      Assert.assertEquals(persister.getEncodeSize(message), buffer.writerIndex());
+
+      // the very first byte is the persisterID, we skip that since we are calling the Persister directly
+      buffer.readerIndex(1);
+      Message messageRead = persister.decode(buffer, null, null);
+
+      // The current persister does not guarantee the same encode size after loading
+      // and it does not need to
+      // Assert.assertEquals(persister.getEncodeSize(message), persister.getEncodeSize(messageRead));
 
 Review comment:
   I intended to keep it commented out, as it would fail if commented out.. nothing to be cleaned.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393527033
 
 

 ##########
 File path: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/paging/AmqpPageReaderTest.java
 ##########
 @@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.integration.amqp.paging;
+
+import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
+import org.apache.activemq.artemis.api.core.Message;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.paging.cursor.impl.PageReaderTest;
+import org.apache.activemq.artemis.protocol.amqp.broker.AMQPStandardMessage;
+import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
+import org.apache.activemq.artemis.tests.integration.amqp.AmqpTestSupport;
+import org.apache.activemq.transport.amqp.client.AmqpMessage;
+import org.apache.qpid.proton.message.impl.MessageImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class AmqpPageReaderTest extends PageReaderTest {
+
+   public MessageImpl createProtonMessage(String address) {
+      AmqpMessage message = new AmqpMessage();
+      final StringBuilder builder = new StringBuilder();
+      for (int i = 0; i < 1000; i++) {
+         builder.append('0');
+      }
+      final String data = builder.toString();
+      message.setText(data);
+      message.setAddress(address);
+      message.setDurable(true);
+
+      MessageImpl protonMessage = (MessageImpl) message.getWrappedMessage();
+
+      return protonMessage;
+   }
+
+   @Override
+   protected Message createMessage(SimpleString address, int msgId, byte[] content) {
+      MessageImpl protonMessage = createProtonMessage(address.toString());
+      AMQPStandardMessage amqpStandardMessage =  AmqpTestSupport.encodeAndDecodeMessage(0, protonMessage, 2 * 1024);
+      amqpStandardMessage.setMessageID(msgId);
+
+      return amqpStandardMessage;
+   }
+
+
+   @Test
+   public void testEncodeSize() throws Exception {
+
+      Message message = createMessage(SimpleString.toSimpleString("Test"), 1, new byte[10]);
+
+      MessagePersister persister = (MessagePersister)message.getPersister();
+
+      ActiveMQBuffer buffer = ActiveMQBuffers.dynamicBuffer(1024);
+      persister.encode(buffer, message);
+
+      Assert.assertEquals(persister.getEncodeSize(message), buffer.writerIndex());
+
+      // the very first byte is the persisterID, we skip that since we are calling the Persister directly
+      buffer.readerIndex(1);
+      Message messageRead = persister.decode(buffer, null, null);
+
+      // The current persister does not guarantee the same encode size after loading
+      // and it does not need to
+      // Assert.assertEquals(persister.getEncodeSize(message), persister.getEncodeSize(messageRead));
 
 Review comment:
   This test class should be cleaned up a bit 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393544002
 
 

 ##########
 File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java
 ##########
 @@ -59,8 +61,19 @@ public PagedMessageImpl(final Message message, final long[] queueIDs) {
       this.message = message;
    }
 
-   public PagedMessageImpl(StorageManager storageManager) {
+   public PagedMessageImpl(int storedSize, StorageManager storageManager) {
       this.storageManager = storageManager;
+      this.storedSize = storedSize;
+   }
+
+
+   @Override
+   public int getStoredSize() {
+      if (storedSize <= 0) {
 
 Review comment:
   Instead of using this logic, woudn't simpler to correctly initialize `storedSize` for both protocols: for core `== encodeSize`, for AMQP, using a different value?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] clebertsuconic commented on issue #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on issue #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#issuecomment-599845353
 
 
   @franz1981 I was working with you on this. this is the issue we were running after.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393542458
 
 

 ##########
 File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java
 ##########
 @@ -1357,7 +1357,7 @@ private PagedReference moveNext() {
                   break;
                }
 
-               int nextFileOffset = message.getPosition().getFileOffset() == -1 ? -1 : message.getPosition().getFileOffset() + message.getPagedMessage().getEncodeSize() + Page.SIZE_RECORD;
+               int nextFileOffset = message.getPosition().getFileOffset() == -1 ? -1 : message.getPosition().getFileOffset() + message.getPagedMessage().getStoredSize() + Page.SIZE_RECORD;
 
 Review comment:
   I would encapsulate this computation as part of `PagedMessage` or `PagePosition` , possibly adding a test

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393557525
 
 

 ##########
 File path: artemis-server/src/test/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageReaderTest.java
 ##########
 @@ -58,7 +58,7 @@ public void testPageReadMessage() throws Exception {
             PagePosition pagePosition = new PagePositionImpl(10, i);
             pagedMessage = pageReader.getMessage(pagePosition);
          } else {
-            int nextFileOffset = pagedMessage == null ? -1 : offsets[i - 1] + pagedMessage.getEncodeSize() + Page.SIZE_RECORD;
+            int nextFileOffset = pagedMessage == null ? -1 : offsets[i - 1] + pagedMessage.getStoredSize() + Page.SIZE_RECORD;
 
 Review comment:
   PageReaderTest is from a different testsuite. IDEA may not like it.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393556064
 
 

 ##########
 File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java
 ##########
 @@ -47,6 +47,8 @@
 
    private long transactionID = 0;
 
+   private int storedSize = 0;
 
 Review comment:
   I didn't think it was final.. I thought I was going to have a setter when I wrote this.. changing it.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393562799
 
 

 ##########
 File path: artemis-server/src/test/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageReaderTest.java
 ##########
 @@ -58,7 +58,7 @@ public void testPageReadMessage() throws Exception {
             PagePosition pagePosition = new PagePositionImpl(10, i);
             pagedMessage = pageReader.getMessage(pagePosition);
          } else {
-            int nextFileOffset = pagedMessage == null ? -1 : offsets[i - 1] + pagedMessage.getEncodeSize() + Page.SIZE_RECORD;
+            int nextFileOffset = pagedMessage == null ? -1 : offsets[i - 1] + pagedMessage.getStoredSize() + Page.SIZE_RECORD;
 
 Review comment:
   It's not that simple to move this test. it uses a lot of package private methods.. moving would need to make them public or a bigger refactoring.
   
   I had a version where I did this at some point. I would go for the simpler version now in case we ever need to cherry-pick to a point release.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393557182
 
 

 ##########
 File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java
 ##########
 @@ -59,8 +61,19 @@ public PagedMessageImpl(final Message message, final long[] queueIDs) {
       this.message = message;
    }
 
-   public PagedMessageImpl(StorageManager storageManager) {
+   public PagedMessageImpl(int storedSize, StorageManager storageManager) {
       this.storageManager = storageManager;
+      this.storedSize = storedSize;
+   }
+
+
+   @Override
+   public int getStoredSize() {
+      if (storedSize <= 0) {
 
 Review comment:
   I am not sure it's safe to do that in case the encodeSize changed between the contruction and when getStoredSize is used.
   
   We can change this If you're sure it's safe. I wasn't bold enough.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393566890
 
 

 ##########
 File path: artemis-server/src/test/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageReaderTest.java
 ##########
 @@ -58,7 +58,7 @@ public void testPageReadMessage() throws Exception {
             PagePosition pagePosition = new PagePositionImpl(10, i);
             pagedMessage = pageReader.getMessage(pagePosition);
          } else {
-            int nextFileOffset = pagedMessage == null ? -1 : offsets[i - 1] + pagedMessage.getEncodeSize() + Page.SIZE_RECORD;
+            int nextFileOffset = pagedMessage == null ? -1 : offsets[i - 1] + pagedMessage.getStoredSize() + Page.SIZE_RECORD;
 
 Review comment:
   > PageReaderTest is from a different testsuite. IDEA may not like it.
   
   What's strange is that I rememeber while doing it the same (basically same code) IDEA wasn't complaining that much, but is really a minor eh, can be ignored

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393556934
 
 

 ##########
 File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java
 ##########
 @@ -1357,7 +1357,7 @@ private PagedReference moveNext() {
                   break;
                }
 
-               int nextFileOffset = message.getPosition().getFileOffset() == -1 ? -1 : message.getPosition().getFileOffset() + message.getPagedMessage().getEncodeSize() + Page.SIZE_RECORD;
+               int nextFileOffset = message.getPosition().getFileOffset() == -1 ? -1 : message.getPosition().getFileOffset() + message.getPagedMessage().getStoredSize() + Page.SIZE_RECORD;
 
 Review comment:
   I agree, and I raised that with you. but this is not part of my change here though. this could be a different PR.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [activemq-artemis] franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset

Posted by GitBox <gi...@apache.org>.
franz1981 commented on a change in pull request #3021: ARTEMIS-2662 Using previously stored encodeSize on page record offset
URL: https://github.com/apache/activemq-artemis/pull/3021#discussion_r393566179
 
 

 ##########
 File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagedMessageImpl.java
 ##########
 @@ -59,8 +61,19 @@ public PagedMessageImpl(final Message message, final long[] queueIDs) {
       this.message = message;
    }
 
-   public PagedMessageImpl(StorageManager storageManager) {
+   public PagedMessageImpl(int storedSize, StorageManager storageManager) {
       this.storageManager = storageManager;
+      this.storedSize = storedSize;
+   }
+
+
+   @Override
+   public int getStoredSize() {
+      if (storedSize <= 0) {
 
 Review comment:
   > We can change this If you're sure it's safe. I wasn't bold enough.
   
   Agree, I'm not sure of it as well (let me check around on the code) 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services