This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo-access.git


The following commit(s) were added to refs/heads/main by this push:
     new 3568c09  replaces stream with loop to increase performance (#30)
3568c09 is described below

commit 3568c093eb0cc6c56b0302acb9864191f534ba5f
Author: Keith Turner <ktur...@apache.org>
AuthorDate: Mon Oct 30 09:15:31 2023 -0400

    replaces stream with loop to increase performance (#30)
    
    This commit removes a stream used during expression evaluation.
    Removing it made a noticeable performance difference. Seeing the
    following numbers in the performance test related to evaluation with
    this change.
    
    ```
    Benchmark                                               Mode  Cnt   Score   
Error   Units
    AccessExpressionBenchmark.measureEvaluation            thrpt   12  20.230 ± 
0.331  ops/us
    AccessExpressionBenchmark.measureEvaluationAndParsing  thrpt   12   8.415 ± 
0.206  ops/us
    ```
    
    Running the same test without these changes seeing the following.
    
    ```
    Benchmark                                               Mode  Cnt   Score   
Error   Units
    AccessExpressionBenchmark.measureEvaluation            thrpt   12  14.664 ± 
0.937  ops/us
    AccessExpressionBenchmark.measureEvaluationAndParsing  thrpt   12   6.988 ± 
0.352  ops/us
    ```
---
 src/main/java/org/apache/accumulo/access/AccessEvaluatorImpl.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/accumulo/access/AccessEvaluatorImpl.java 
b/src/main/java/org/apache/accumulo/access/AccessEvaluatorImpl.java
index 0bbc5e7..360ff55 100644
--- a/src/main/java/org/apache/accumulo/access/AccessEvaluatorImpl.java
+++ b/src/main/java/org/apache/accumulo/access/AccessEvaluatorImpl.java
@@ -148,7 +148,12 @@ class AccessEvaluatorImpl implements AccessEvaluator {
       throws IllegalAccessExpressionException {
     // The AccessEvaluator computes a trie from the given Authorizations, that 
AccessExpressions can
     // be evaluated against.
-    return 
authorizedPredicates.stream().allMatch(accessExpression.aeNode::canAccess);
+    for (var auths : authorizedPredicates) {
+      if (!accessExpression.aeNode.canAccess(auths)) {
+        return false;
+      }
+    }
+    return true;
   }
 
   private static class BuilderImpl implements AuthorizationsBuilder, 
EvaluatorBuilder {

Reply via email to