You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by li...@apache.org on 2023/06/19 13:01:36 UTC

[arrow] branch main updated: GH-36151: [Java] Add `volatile` declaration to `keyPosition` in `ParallelSearcher` (#36152)

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

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 9589338ed2 GH-36151: [Java] Add `volatile` declaration to `keyPosition` in `ParallelSearcher` (#36152)
9589338ed2 is described below

commit 9589338ed2565fcfdbd4b58bcb49a27f09741ba6
Author: rtadepalli <10...@users.noreply.github.com>
AuthorDate: Mon Jun 19 09:01:29 2023 -0400

    GH-36151: [Java] Add `volatile` declaration to `keyPosition` in `ParallelSearcher` (#36152)
    
    ### Rationale for this change
    
    Multiple threads can read/write to the `keyPosition` variable. Thus, it should be declared `volatile` so that all threads have a consistent view of the value of this variable.
    
    ### What changes are included in this PR?
    
    This PR just marks an instance member `volatile`.
    
    ### Are these changes tested?
    
    Existing tests should suffice as no functionality is being changed.
    
    ### Are there any user-facing changes?
    
    No, there are no user facing changes. There are no changes to the public API either.
    * Closes: #36151
    
    Authored-by: Ramasai <ra...@gmail.com>
    Signed-off-by: David Li <li...@gmail.com>
---
 .../main/java/org/apache/arrow/algorithm/search/ParallelSearcher.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/algorithm/src/main/java/org/apache/arrow/algorithm/search/ParallelSearcher.java b/java/algorithm/src/main/java/org/apache/arrow/algorithm/search/ParallelSearcher.java
index e93eb2c3de..e62ebdecb1 100644
--- a/java/algorithm/src/main/java/org/apache/arrow/algorithm/search/ParallelSearcher.java
+++ b/java/algorithm/src/main/java/org/apache/arrow/algorithm/search/ParallelSearcher.java
@@ -52,7 +52,7 @@ public class ParallelSearcher<V extends ValueVector> {
   /**
    * The position of the key in the target vector, if any.
    */
-  private int keyPosition = -1;
+  private volatile int keyPosition = -1;
 
   /**
    * Constructs a parallel searcher.