Github user joshelser commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/298#discussion_r211401373
--- 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);
--- End diff --
This, and others, need to use a logger.
---