MCPcopy Create free account
hub / github.com/crate/crate / FetchTask

Class FetchTask

server/src/main/java/io/crate/execution/engine/fetch/FetchTask.java:66–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64import io.crate.metadata.doc.DocTableInfo;
65
66public class FetchTask implements Task {
67
68 private final IntObjectHashMap<RefCountedItem<? extends IndexSearcher>> searchers = new IntObjectHashMap<>();
69 private final IntObjectHashMap<SharedShardContext> shardContexts = new IntObjectHashMap<>();
70 private final FetchPhase phase;
71 private final int memoryLimitInBytes;
72 private final String localNodeId;
73 private final SharedShardContexts sharedShardContexts;
74 private final TreeMap<Integer, PartitionName> tableIdents = new TreeMap<>();
75 private final Metadata metadata;
76 private final List<? extends Routing> routings;
77 private final Map<RelationName, Collection<Reference>> toFetch;
78 private final UUID jobId;
79 private final Function<RelationName, DocTableInfo> getTableInfo;
80 private final CompletableFuture<Void> result = new CompletableFuture<>();
81
82
83 @GuardedBy("jobId")
84 private int borrowed = 0;
85
86 @GuardedBy("jobId")
87 private Throwable killed;
88
89 public FetchTask(UUID jobId,
90 FetchPhase phase,
91 int memoryLimitInBytes,
92 String localNodeId,
93 SharedShardContexts sharedShardContexts,
94 Metadata metadata,
95 Function<RelationName, DocTableInfo> getTableInfo,
96 List<? extends Routing> routings) {
97 this.jobId = jobId;
98 this.phase = phase;
99 this.memoryLimitInBytes = memoryLimitInBytes;
100 this.localNodeId = localNodeId;
101 this.sharedShardContexts = sharedShardContexts;
102 this.metadata = metadata;
103 this.routings = routings;
104 this.toFetch = HashMap.newHashMap(phase.tableIndices().size());
105 this.getTableInfo = getTableInfo;
106 this.result.whenComplete((_, _) -> {
107 synchronized (jobId) {
108 for (var cursor : searchers) {
109 cursor.value.close();
110 }
111 searchers.clear();
112 }
113 });
114 }
115
116 /**
117 * From the memory.operation_limit session setting.
118 */
119 public int memoryLimitInBytes() {
120 return memoryLimitInBytes;
121 }
122
123 public Map<RelationName, Collection<Reference>> toFetch() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected