Github user dbwong commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/298#discussion_r211432802
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java ---
    @@ -494,19 +540,37 @@ public ServerCache execute(HashJoinPlan parent) 
throws SQLException {
                 if (hashExpressions != null) {
                     ResultIterator iterator = plan.iterator();
                     try {
    -                    cache =
    -                            parent.hashClient.addHashCache(ranges, 
iterator,
    -                                plan.getEstimatedSize(), hashExpressions, 
singleValueOnly,
    +                    final byte[] cacheId;
    +                    String queryString = 
plan.getStatement().toString().replaceAll("\\$[0-9]+", "\\$");
    +                    if (usePersistentCache) {
    +                        cacheId = 
Arrays.copyOfRange(digest.digest(queryString.getBytes()), 0, 8);
    +                        boolean disablePersistentCache = 
parent.delegate.getContext().getDisablePersistentCache(Bytes.toLong(cacheId));
    +                        if (!disablePersistentCache) {
    +                            try {
    +                                cache = 
parent.hashClient.createServerCache(cacheId, parent.delegate);
    +                            } catch (IOException e) {
    +                                throw new RuntimeException(e);
    +                            }
    +                        }
    +                    } else {
    +                        cacheId = Bytes.toBytes(RANDOM.nextLong());
    +                    }
    +                    System.out.println("Using cache ID " + 
Hex.encodeHexString(cacheId) + " for " + queryString);
    +                    if (cache == null) {
    --- End diff --
    
    If disablePersistentCache == true this addHashCace is still using the 
cacheId from the query string as opposed to a randomID.  Is this intended?  
Will this affect the future interactions with that cache?


---

Reply via email to