You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "ctubbsii (via GitHub)" <gi...@apache.org> on 2024/02/14 08:16:14 UTC

[I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

ctubbsii opened a new issue, #56:
URL: https://github.com/apache/accumulo-access/issues/56

   I think the entry point for AccessEvaluator entry point has room for improvement. Currently, the entry point is a static method named `of` that is overloaded. However, it almost exclusively takes an Authorizations object of some form.
   
   Rather than construct an Authorizations object, then construct a separate AccessEvaluator object, it would probably make more sense to have a method that dangles off of Authorizations that evaluates.
   
   For example:
   
   ```java
   var evaluator = AccessEvaluator.of(Authorizations.of("a", "b"));
   // vs.
   var evaluator = Authorizations.of("a", "b").evaluator();
   ```
   
   What I'm suggesting is similar to the way Java regex Patterns can construct a Matcher. You wouldn't do `Matcher m = new Matcher(Pattern.compile("p"), "other");`. Instead, you do `Pattern.compile("p").matcher("other")`. You start with the thing you have, then you derive the related objects from it. In our case, our starting point is the Authorizations.
   


-- 
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: notifications-unsubscribe@accumulo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on issue #56:
URL: https://github.com/apache/accumulo-access/issues/56#issuecomment-1944311859

   ```
   Stream.of(authorizations1, authorizations2).allMatch(authorizations -> authorizations.canAccess(expression));
   // or
   Stream.of(authorizations1, authorizations2).anyMatch(authorizations -> authorizations.canAccess(expression));
   ```
   
   I don't think it would be this simple, there is some escape-handling that is occurring in the AccessEvaluatorImpl constructors.


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on issue #56:
URL: https://github.com/apache/accumulo-access/issues/56#issuecomment-4035336452

   I think the API has evolved quite a bit from my initial suggestions, and I don't think it really applies anymore.
   
   ```java
   // given this:
   var auths = access.newAuthorizations(Set.of(authsInput));
   // I still prefer:
   auths.evaluator();
   // vs. this:
   access.newEvaluator(auths);
   ```
   
   However, I don't feel very strongly about it at this time.


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on issue #56:
URL: https://github.com/apache/accumulo-access/issues/56#issuecomment-1945117107

   This is the [code](https://github.com/apache/accumulo-access/blob/009246e93aaa91dc4ce0b2a35ae8f14ddf04e210/src/main/java/org/apache/accumulo/access/AccessEvaluatorImpl.java#L198-L211) the does the evaluation.  It seems like it could be decomposed, would lose the reuse of the thread local.  That code used to be a stream instead of a for loop, but we discovered that creating a stream for evaluating each access expression was cause a huge performance hit when benchmarking.


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on issue #56:
URL: https://github.com/apache/accumulo-access/issues/56#issuecomment-1944292402

   > The following proposed API
   > 
   > ```java
   > var evaluator = Authorizations.of("a", "b").evaluator();
   > ```
   > 
   > does not support the functionality of this [existing API](https://github.com/apache/accumulo-access/blob/009246e93aaa91dc4ce0b2a35ae8f14ddf04e210/src/main/java/org/apache/accumulo/access/AccessEvaluator.java#L100-L153)
   
   Yeah, I thought about that, but I was wondering if it would make more sense to do something like:
   
   ```java
   Stream.of(authorizations1, authorizations2).allMatch(authorizations -> authorizations.canAccess(expression));
   // or
   Stream.of(authorizations1, authorizations2).anyMatch(authorizations -> authorizations.canAccess(expression));
   ```
   
   I don't know how much optimization is actually being done, or how much utility there is in making the evaluator operate on sets of authorizations, rather than on something that I think is a bit more clear like the above on the caller's end. My instinct is that it's not much of an optimization and the above would be more clear, so we don't actually need the multiple-sets API, as it's superfluous, but I don't know for sure without digging more.


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on issue #56:
URL: https://github.com/apache/accumulo-access/issues/56#issuecomment-1945145050

   Opened #61 after looking at code for this issue.  For any changes made for this issue we can benchmark the changes before and after to see what the impact is.


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on issue #56:
URL: https://github.com/apache/accumulo-access/issues/56#issuecomment-1944123747

   > I think something like .compile(auths), .using(auths), or even .with(auths) might make more sense.
   
   I like the concept of replace `of` with one of those.


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on issue #56:
URL: https://github.com/apache/accumulo-access/issues/56#issuecomment-2211490600

   @ctubbsii  the changes in #71 move a bit closer to some the things mentioned in this PR.  From a performance perspective one thing I learned from #71 is that you probably only want to convert the expression to a byte array once even if there are multiple evaluators. 


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on issue #56:
URL: https://github.com/apache/accumulo-access/issues/56#issuecomment-1944080910

   The following proposed API
   
   ```java
   var evaluator = Authorizations.of("a", "b").evaluator();
   ```
   
   does not support the functionality of this [existing API](https://github.com/apache/accumulo-access/blob/009246e93aaa91dc4ce0b2a35ae8f14ddf04e210/src/main/java/org/apache/accumulo/access/AccessEvaluator.java#L100-L153)


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii closed issue #56: Consider removing AccessEvaluator as an API or improving its entry points
URL: https://github.com/apache/accumulo-access/issues/56


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on issue #56:
URL: https://github.com/apache/accumulo-access/issues/56#issuecomment-1947751246

   @keith-turner [wrote](#issuecomment-1945117107):
   > This is the [code](https://github.com/apache/accumulo-access/blob/009246e93aaa91dc4ce0b2a35ae8f14ddf04e210/src/main/java/org/apache/accumulo/access/AccessEvaluatorImpl.java#L198-L211) the does the evaluation. It seems like it could be decomposed, would lose the reuse of the thread local. That code used to be a stream instead of a for loop, but we discovered that creating a stream for evaluating each access expression was cause a huge performance hit when benchmarking.
   
   In case my use of Streams had any bearing on your comment, my example only used Streams for a concise expression of `allMatch` and `anyMatch`. Of course, the caller could use any functionally equivalent construction of their choosing, but it doesn't really have any bearing on my proposal. But, the performance cost of losing the reuse of internal reusable objects would certainly have a bearing on my proposal.
   
   @keith-turner [wrote](#issuecomment-1945145050):
   > Opened #61 after looking at code for this issue. For any changes made for this issue we can benchmark the changes before and after to see what the impact is.
   
   I haven't had a chance to play around with benchmarking my suggestions here, but if benchmarking shows that the difference is meaningful because of the reuse of internal objects that we'd be losing, then we could still have a cleaner single entry point through Authorizations, but we would have to do it differently to allow evaluation of multiple Authorizations from a single evaluator without using Evaluator itself as an entry point.
   
   For example:
   
   ```java
   // using an intermediate obj something like AuthorizationsSet
   Authorizations.of(auths1).and(Authorizations.of(auths2).evaluator();
   Authorizations.of(auths1).or(Authorizations.of(auths2).evaluator();
   // final obj is a new evaluator, that takes elements of the first, but updated to account for the additional authorizations to evalute
   Authorizations.of(auths1).evalutor().and(Authorizations.of(auths2));
   Authorizations.of(auths1).evalutor().or(Authorizations.of(auths2));
   // explicit use of an authorizations set
   AuthorizationsSet.of(auths1, auths2).evaluateForAll();
   AuthorizationsSet.of(auths1, auths2).evaluateForAny();
   ```
   
   Each of these constructions could be implemented to keep the reuse optimizations, but without needing Evaluator as a separate API entry point.
   
   @dlmarion [wrote](#issuecomment-1944311859):
   > I don't think it would be this simple, there is some escape-handling that is occurring in the AccessEvaluatorImpl constructors.
   
   I'm not sure I understand this comment or how it relates to what I'm proposing. I think that the internal escape-handling implementation would be unaffected by anything I've suggested here.


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Consider removing AccessEvaluator as an API or improving its entry points [accumulo-access]

Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on issue #56:
URL: https://github.com/apache/accumulo-access/issues/56#issuecomment-2237548646

   > @ctubbsii the changes in #71 move a bit closer to some the things mentioned in this PR. From a performance perspective one thing I learned from #71 is that you probably only want to convert the expression to a byte array (from a string) once when there are multiple evaluators.
   
   I like some of the improvements there. I'm not sure it addresses everything I had an interest in improving. I'll have to revisit this in more detail now that those changes are merged.


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org