You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/09/15 10:49:39 UTC

[GitHub] [lucene] shaie opened a new pull request, #11775: Minor refactoring and cleanup to taxonomy index code

shaie opened a new pull request, #11775:
URL: https://github.com/apache/lucene/pull/11775

   ### Description
   
   Aside from some cleanups (typos, improving comments), this PR addresses few issues:
   
   1. `DirTaxoWriter.nextID` is declared `volatile` however this `nextID++` is not a safe-operation. Switched to `AtomicInteger`.
   2. `DirTaxoReader` protected constructor couldn't really be extended since `TaxonomyIndexArrays` is package-private and isn't exported by the module. Therefore I think it's safe to change the constructor to package-private too.
   3. Changed the [Double-Check Lock](https://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html) pattern implementation to assign the `volatile` field to a local variable, so that we do a volatile read only once if the reference isn't null.
   


-- 
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: issues-unsubscribe@lucene.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] shaie merged pull request #11775: Minor refactoring and cleanup to taxonomy index code

Posted by GitBox <gi...@apache.org>.
shaie merged PR #11775:
URL: https://github.com/apache/lucene/pull/11775


-- 
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: issues-unsubscribe@lucene.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] gsmiller commented on a diff in pull request #11775: Minor refactoring and cleanup to taxonomy index code

Posted by GitBox <gi...@apache.org>.
gsmiller commented on code in PR #11775:
URL: https://github.com/apache/lucene/pull/11775#discussion_r975666927


##########
lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FacetLabel.java:
##########
@@ -120,11 +120,10 @@ public int compareTo(FacetLabel other) {
 
   @Override
   public boolean equals(Object obj) {
-    if (!(obj instanceof FacetLabel)) {
+    if (!(obj instanceof FacetLabel other)) {

Review Comment:
   Also, I didn't know you could do a cast inline like this. Cool!



##########
lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FacetLabel.java:
##########
@@ -120,11 +120,10 @@ public int compareTo(FacetLabel other) {
 
   @Override
   public boolean equals(Object obj) {
-    if (!(obj instanceof FacetLabel)) {
+    if (!(obj instanceof FacetLabel other)) {

Review Comment:
   Should we flip this to use `== false` instead of `!` as it seems to be the preferred style in this code base?



-- 
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: issues-unsubscribe@lucene.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] shaie commented on a diff in pull request #11775: Minor refactoring and cleanup to taxonomy index code

Posted by GitBox <gi...@apache.org>.
shaie commented on code in PR #11775:
URL: https://github.com/apache/lucene/pull/11775#discussion_r976038157


##########
lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FacetLabel.java:
##########
@@ -120,11 +120,10 @@ public int compareTo(FacetLabel other) {
 
   @Override
   public boolean equals(Object obj) {
-    if (!(obj instanceof FacetLabel)) {
+    if (!(obj instanceof FacetLabel other)) {

Review Comment:
   I tried doing that, but then the rest of the method complains it doesn't recognize `other`. The pattern variable was introduced in Java 14, so I'll change the code to not using it, which will make it easier to merge to the 9.x branch. If we wanted to use the pattern variable though, we'd need to change the method body to implement equality inside `if (obj instanceof FacetLabel other)` clause.



-- 
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: issues-unsubscribe@lucene.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org