You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2018/08/07 13:14:14 UTC

activemq-artemis git commit: ARTEMIS-1997 - un-needed SimpleString creation on hotpath with Filters

Repository: activemq-artemis
Updated Branches:
  refs/heads/2.6.x 091dcbea4 -> e55549b94


ARTEMIS-1997 - un-needed SimpleString creation on hotpath with Filters

Create the SimpleString on construction of PropertyExpression so it can be re-used instead of creating it every time its filtered in the FilterImpl

(cherry picked from commit 332cee8e663e729e2af274715cf0e1911a320297)


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/e55549b9
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/e55549b9
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/e55549b9

Branch: refs/heads/2.6.x
Commit: e55549b944e5808e074535a2804c53a679c93ecf
Parents: 091dcbe
Author: Michael André Pearce <mi...@me.com>
Authored: Sun Jul 22 04:17:50 2018 +0100
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Aug 7 09:14:07 2018 -0400

----------------------------------------------------------------------
 artemis-selector/pom.xml                                |  5 +++++
 .../activemq/artemis/selector/filter/Filterable.java    |  4 +++-
 .../artemis/selector/filter/PropertyExpression.java     | 12 +++++++++---
 .../apache/activemq/artemis/selector/SelectorTest.java  | 10 ++++++----
 .../activemq/artemis/core/filter/impl/FilterImpl.java   | 10 +++++-----
 5 files changed, 28 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e55549b9/artemis-selector/pom.xml
----------------------------------------------------------------------
diff --git a/artemis-selector/pom.xml b/artemis-selector/pom.xml
index 1fc51b3..7d9b644 100644
--- a/artemis-selector/pom.xml
+++ b/artemis-selector/pom.xml
@@ -33,6 +33,11 @@
 
    <dependencies>
       <dependency>
+         <groupId>org.apache.activemq</groupId>
+         <artifactId>artemis-commons</artifactId>
+         <version>${project.version}</version>
+      </dependency>
+      <dependency>
          <groupId>xml-apis</groupId>
          <artifactId>xml-apis</artifactId>
          <optional>true</optional>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e55549b9/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/Filterable.java
----------------------------------------------------------------------
diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/Filterable.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/Filterable.java
index 5339613..4ac7620 100755
--- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/Filterable.java
+++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/Filterable.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.artemis.selector.filter;
 
+import org.apache.activemq.artemis.api.core.SimpleString;
+
 /**
  * A Filterable is the object being evaluated by the filters.  It provides
  * access to filtered properties.
@@ -41,7 +43,7 @@ public interface Filterable {
     * @param name
     * @return
     */
-   Object getProperty(String name);
+   Object getProperty(SimpleString name);
 
    /**
     * Used by the NoLocal filter.

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e55549b9/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/PropertyExpression.java
----------------------------------------------------------------------
diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/PropertyExpression.java b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/PropertyExpression.java
index 4c8c8c5..9fa6267 100755
--- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/PropertyExpression.java
+++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/PropertyExpression.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.artemis.selector.filter;
 
+import org.apache.activemq.artemis.api.core.SimpleString;
+
 /**
  * Represents a property expression
  *
@@ -23,9 +25,13 @@ package org.apache.activemq.artemis.selector.filter;
  */
 public class PropertyExpression implements Expression {
 
-   private final String name;
+   private final SimpleString name;
 
    public PropertyExpression(String name) {
+      this(SimpleString.toSimpleString(name));
+   }
+
+   public PropertyExpression(SimpleString name) {
       this.name = name;
    }
 
@@ -35,7 +41,7 @@ public class PropertyExpression implements Expression {
    }
 
    public String getName() {
-      return name;
+      return name.toString();
    }
 
    /**
@@ -43,7 +49,7 @@ public class PropertyExpression implements Expression {
     */
    @Override
    public String toString() {
-      return name;
+      return name.toString();
    }
 
    /**

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e55549b9/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java
----------------------------------------------------------------------
diff --git a/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java b/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java
index a540ed7..1be9d47 100755
--- a/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java
+++ b/artemis-selector/src/test/java/org/apache/activemq/artemis/selector/SelectorTest.java
@@ -18,6 +18,7 @@ package org.apache.activemq.artemis.selector;
 
 import java.util.HashMap;
 
+import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.selector.filter.BooleanExpression;
 import org.apache.activemq.artemis.selector.filter.FilterException;
 import org.apache.activemq.artemis.selector.filter.Filterable;
@@ -100,14 +101,15 @@ public class SelectorTest {
       }
 
       @Override
-      public Object getProperty(String name) {
-         if ("JMSType".equals(name)) {
+      public Object getProperty(SimpleString name) {
+         String stringName = name.toString();
+         if ("JMSType".equals(stringName)) {
             return type;
          }
-         if ("JMSMessageID".equals(name)) {
+         if ("JMSMessageID".equals(stringName)) {
             return messageId;
          }
-         return properties.get(name);
+         return properties.get(stringName);
       }
 
       public Object getDestination() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/e55549b9/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
index 33a1187..7ee7b6b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java
@@ -154,7 +154,7 @@ public class FilterImpl implements Filter {
             // Proton stores JMSMessageID as NATIVE_MESSAGE_ID that is an arbitrary string
             String amqpNativeID = msg.getStringProperty(NATIVE_MESSAGE_ID);
             if (amqpNativeID != null) {
-               return new SimpleString(amqpNativeID);
+               return SimpleString.toSimpleString(amqpNativeID);
             }
          }
          // It's the stringified (hex) representation of a user id that can be used in a selector expression
@@ -162,7 +162,7 @@ public class FilterImpl implements Filter {
          if (userID.startsWith("ID:")) {
             return SimpleString.toSimpleString(userID);
          } else {
-            return new SimpleString("ID:" + msg.getUserID());
+            return SimpleString.toSimpleString("ID:" + msg.getUserID());
          }
       } else if (FilterConstants.ACTIVEMQ_PRIORITY.equals(fieldName)) {
          return Integer.valueOf(msg.getPriority());
@@ -190,10 +190,10 @@ public class FilterImpl implements Filter {
       }
 
       @Override
-      public Object getProperty(String id) {
+      public Object getProperty(SimpleString id) {
          Object result = null;
-         if (id.startsWith(FilterConstants.ACTIVEMQ_PREFIX.toString())) {
-            result = getHeaderFieldValue(message, new SimpleString(id));
+         if (id.startsWith(FilterConstants.ACTIVEMQ_PREFIX)) {
+            result = getHeaderFieldValue(message, id);
          }
          if (result == null) {
             result = message.getObjectProperty(id);