|
26 | 26 | import java.text.DecimalFormat;
|
27 | 27 | import java.text.SimpleDateFormat;
|
28 | 28 | import java.util.*;
|
29 |
| -import java.util.concurrent.ConcurrentHashMap; |
30 | 29 | import java.util.concurrent.Executor;
|
31 | 30 | import java.util.concurrent.atomic.AtomicLong;
|
32 | 31 |
|
@@ -136,7 +135,7 @@ private static class GlobalState {
|
136 | 135 | private TransactionService transactionService;
|
137 | 136 | private SourceHint sourceHint;
|
138 | 137 | private Executor executor = ExecutorUtils.getDirectExecutor();
|
139 |
| - Map<String, ReusableExecution<?>> reusableExecutions; |
| 138 | + Map<Object, List<ReusableExecution<?>>> reusableExecutions; |
140 | 139 | Set<CommandListener> commandListeners = null;
|
141 | 140 | private LRUCache<String, DecimalFormat> decimalFormatCache;
|
142 | 141 | private LRUCache<String, SimpleDateFormat> dateFormatCache;
|
@@ -647,32 +646,43 @@ public void setExecutor(Executor e) {
|
647 | 646 | this.globalState.executor = e;
|
648 | 647 | }
|
649 | 648 |
|
650 |
| - public ReusableExecution<?> getReusableExecution(String nodeId) { |
| 649 | + public ReusableExecution<?> getReusableExecution(Object key) { |
651 | 650 | synchronized (this.globalState) {
|
652 | 651 | if (this.globalState.reusableExecutions == null) {
|
653 | 652 | return null;
|
654 | 653 | }
|
655 |
| - return this.globalState.reusableExecutions.get(nodeId); |
| 654 | + List<ReusableExecution<?>> reusableExecutions = this.globalState.reusableExecutions.get(key); |
| 655 | + if (reusableExecutions != null && !reusableExecutions.isEmpty()) { |
| 656 | + return reusableExecutions.remove(0); |
| 657 | + } |
| 658 | + return null; |
656 | 659 | }
|
657 | 660 | }
|
658 | 661 |
|
659 |
| - public void putReusableExecution(String nodeId, ReusableExecution<?> execution) { |
| 662 | + public void putReusableExecution(Object key, ReusableExecution<?> execution) { |
660 | 663 | synchronized (this.globalState) {
|
661 | 664 | if (this.globalState.reusableExecutions == null) {
|
662 |
| - this.globalState.reusableExecutions = new ConcurrentHashMap<String, ReusableExecution<?>>(); |
| 665 | + this.globalState.reusableExecutions = new HashMap<Object, List<ReusableExecution<?>>>(); |
| 666 | + } |
| 667 | + List<ReusableExecution<?>> reusableExecutions = this.globalState.reusableExecutions.get(key); |
| 668 | + if (reusableExecutions == null) { |
| 669 | + reusableExecutions = new LinkedList<ReusableExecution<?>>(); |
| 670 | + this.globalState.reusableExecutions.put(key, reusableExecutions); |
663 | 671 | }
|
664 |
| - this.globalState.reusableExecutions.put(nodeId, execution); |
| 672 | + reusableExecutions.add(execution); |
665 | 673 | }
|
666 | 674 | }
|
667 | 675 |
|
668 | 676 | public void close() {
|
669 | 677 | synchronized (this.globalState) {
|
670 | 678 | if (this.globalState.reusableExecutions != null) {
|
671 |
| - for (ReusableExecution<?> reusableExecution : this.globalState.reusableExecutions.values()) { |
672 |
| - try { |
673 |
| - reusableExecution.dispose(); |
674 |
| - } catch (Exception e) { |
675 |
| - LogManager.logWarning(LogConstants.CTX_DQP, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30030)); |
| 679 | + for (List<ReusableExecution<?>> reusableExecutions : this.globalState.reusableExecutions.values()) { |
| 680 | + for (ReusableExecution<?> reusableExecution : reusableExecutions) { |
| 681 | + try { |
| 682 | + reusableExecution.dispose(); |
| 683 | + } catch (Exception e) { |
| 684 | + LogManager.logWarning(LogConstants.CTX_DQP, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30030)); |
| 685 | + } |
676 | 686 | }
|
677 | 687 | }
|
678 | 688 | this.globalState.reusableExecutions.clear();
|
|
0 commit comments