[
https://issues.apache.org/jira/browse/ARTEMIS-2617?focusedWorklogId=385379&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-385379
]
ASF GitHub Bot logged work on ARTEMIS-2617:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 11/Feb/20 19:16
Start Date: 11/Feb/20 19:16
Worklog Time Spent: 10m
Work Description: tabish121 commented on pull request #2975: ARTEMIS-2617
Improve AMQP Journal loading
URL: https://github.com/apache/activemq-artemis/pull/2975#discussion_r377843580
##########
File path:
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
##########
@@ -1183,8 +1263,129 @@ public Object getCorrelationID() {
return this;
}
+ /**
+ *
https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm jump
table
+ */
+ private static int[] createJumpTable(byte[] needle) {
+ final int[] jumpTable = new int[needle.length + 1];
+ int j = 0;
+ for (int i = 1; i < needle.length; i++) {
+ while (j > 0 && needle[j] != needle[i]) {
+ j = jumpTable[j];
+ }
+ if (needle[j] == needle[i]) {
+ j++;
+ }
+ jumpTable[i + 1] = j;
+ }
+ for (int i = 1; i < jumpTable.length; i++) {
+ if (jumpTable[i] != 0) {
+ return jumpTable;
+ }
+ }
+ // optimization over the original algorithm: it would save from
accessing any jump table
+ return null;
+ }
+
+ /**
+ *
https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm
search algorithm:
+ *
+ * This version differ from the original algorithm, because allows to fail
fast (and faster) if
+ * the remaining haystack to be processed is < of the remaining needle to
be matched.
+ */
+ private static int indexOf(ReadableBuffer haystack, int start, int end,
byte[] needle, int[] jumpTable) {
+ assert end >= 0 && start >= 0 && end >= start;
+ final int length = end - start;
+ int j = 0;
+ final int needleLength = needle.length;
+ int remainingNeedle = needleLength;
+ for (int i = 0; i < length; i++) {
+ final int remainingHayStack = length - i;
+ if (remainingNeedle > remainingHayStack) {
+ return -1;
+ }
+ final int index = start + i;
+ final byte value = haystack.get(index);
+ while (j > 0 && needle[j] != value) {
+ j = jumpTable == null ? 0 : jumpTable[j];
+ remainingNeedle = needleLength - j;
+ }
+ if (needle[j] == value) {
+ j++;
+ remainingNeedle--;
+ assert remainingNeedle >= 0;
+ }
+ if (j == needleLength) {
+ final int startMatch = index - needleLength + 1;
+ return startMatch;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public boolean hasScheduledDeliveryTime() {
+ if (scheduledTime >= 0) {
+ return true;
+ }
+ return anyMessageAnnotations(SCHEDULED_DELIVERY_SYMBOLS,
+ SCHEDULED_DELIVERY_ENCODED,
+ SCHEDULED_DELIVERY_JUMP_TABLES);
+ }
+
+ private boolean anyMessageAnnotations(Symbol[] symbols, byte[][]
encodedSymbols, int[][] jumpTables) {
+ final int count = symbols.length;
+ if (messageDataScanned == SCANNED) {
+ final MessageAnnotations messageAnnotations = this.messageAnnotations;
+ if (messageAnnotations == null) {
+ return false;
+ }
+ Map<Symbol, Object> map = messageAnnotations.getValue();
+ if (map == null) {
+ return false;
+ }
+ for (int i = 0; i < count; i++) {
+ if (map.containsKey(symbols[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+ // messageDataScanned != SCANNED;
+ final ReadableBuffer data = this.data;
+ DecoderImpl decoder = TLSEncode.getDecoder();
+ final int position = data.position();
+ decoder.setBuffer(data.rewind());
+ try {
+ while (data.hasRemaining()) {
+ TypeConstructor<?> constructor = decoder.readConstructor();
Review comment:
Basically need to deal with case where TypeConstructor you get back isn't an
AbstractDescribedType for some unknown reason, should have blown up on ingress
but you never know.
----------------------------------------------------------------
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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 385379)
Time Spent: 4h 40m (was: 4.5h)
> Improve AMQP Journal loading
> ----------------------------
>
> Key: ARTEMIS-2617
> URL: https://issues.apache.org/jira/browse/ARTEMIS-2617
> Project: ActiveMQ Artemis
> Issue Type: Improvement
> Reporter: Francesco Nigro
> Priority: Major
> Time Spent: 4h 40m
> Remaining Estimate: 0h
>
> Journal loading AMQP messages always force decoding message data thus
> creating garbage
> on broker startup.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)