use of io.crate.metadata.RelationName in project crate by crate.
the class FilterOnJoinsUtil method moveQueryBelowJoin.
static LogicalPlan moveQueryBelowJoin(Symbol query, LogicalPlan join) {
if (!WhereClause.canMatch(query)) {
return join.replaceSources(List.of(getNewSource(query, join.sources().get(0)), getNewSource(query, join.sources().get(1))));
}
Map<Set<RelationName>, Symbol> splitQuery = QuerySplitter.split(query);
int initialParts = splitQuery.size();
if (splitQuery.size() == 1 && splitQuery.keySet().iterator().next().size() > 1) {
return null;
}
assert join.sources().size() == 2 : "Join operator must only have 2 children, LHS and RHS";
LogicalPlan lhs = join.sources().get(0);
LogicalPlan rhs = join.sources().get(1);
Set<RelationName> leftName = lhs.getRelationNames();
Set<RelationName> rightName = rhs.getRelationNames();
Symbol queryForLhs = splitQuery.remove(leftName);
Symbol queryForRhs = splitQuery.remove(rightName);
LogicalPlan newLhs = getNewSource(queryForLhs, lhs);
LogicalPlan newRhs = getNewSource(queryForRhs, rhs);
LogicalPlan newJoin = join.replaceSources(List.of(newLhs, newRhs));
if (splitQuery.isEmpty()) {
return newJoin;
} else if (initialParts == splitQuery.size()) {
return null;
} else {
return new Filter(newJoin, AndOperator.join(splitQuery.values()));
}
}
use of io.crate.metadata.RelationName in project crate by crate.
the class FetchPhase method writeTo.
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(executionPhaseId);
out.writeVInt(executionNodes.size());
for (String executionNode : executionNodes) {
out.writeString(executionNode);
}
out.writeVInt(bases.size());
for (Map.Entry<String, Integer> entry : bases.entrySet()) {
out.writeString(entry.getKey());
out.writeVInt(entry.getValue());
}
out.writeVInt(fetchRefs.size());
for (Reference ref : fetchRefs) {
Reference.toStream(ref, out);
}
out.writeVInt(tableIndices.size());
for (Map.Entry<RelationName, Collection<String>> entry : tableIndices.entrySet()) {
entry.getKey().writeTo(out);
out.writeVInt(entry.getValue().size());
for (String s : entry.getValue()) {
out.writeString(s);
}
}
}
use of io.crate.metadata.RelationName in project crate by crate.
the class FetchProjection method generateStreamersGroupedByReaderAndNode.
@SuppressWarnings({ "rawtypes" })
public Map<String, ? extends IntObjectMap<Streamer[]>> generateStreamersGroupedByReaderAndNode() {
HashMap<String, IntObjectHashMap<Streamer[]>> streamersByReaderByNode = new HashMap<>();
for (Map.Entry<String, IntSet> entry : nodeReaders.entrySet()) {
IntObjectHashMap<Streamer[]> streamersByReaderId = new IntObjectHashMap<>();
String nodeId = entry.getKey();
streamersByReaderByNode.put(nodeId, streamersByReaderId);
for (IntCursor readerIdCursor : entry.getValue()) {
int readerId = readerIdCursor.value;
String index = readerIndices.floorEntry(readerId).getValue();
RelationName relationName = indicesToIdents.get(index);
FetchSource fetchSource = fetchSources.get(relationName);
if (fetchSource == null) {
continue;
}
streamersByReaderId.put(readerIdCursor.value, Symbols.streamerArray(fetchSource.references()));
}
}
return streamersByReaderByNode;
}
use of io.crate.metadata.RelationName in project crate by crate.
the class FetchProjection method getFetchSourceByReader.
public FetchSource getFetchSourceByReader(int readerId) {
String index = readerIndices.floorEntry(readerId).getValue();
RelationName relationName = indicesToIdents.get(index);
assert relationName != null : "Must have a relationName for readerId=" + readerId;
FetchSource fetchSource = fetchSources.get(relationName);
assert fetchSource != null : "Must have a fetchSource for relationName=" + relationName;
return fetchSource;
}
use of io.crate.metadata.RelationName in project crate by crate.
the class TransportSwapRelationsAction method checkBlock.
@Override
protected ClusterBlockException checkBlock(SwapRelationsRequest request, ClusterState state) {
Set<String> affectedIndices = new HashSet<>();
for (RelationNameSwap swapAction : request.swapActions()) {
affectedIndices.addAll(Arrays.asList(indexNameExpressionResolver.concreteIndexNames(state, IndicesOptions.LENIENT_EXPAND_OPEN, swapAction.source().indexNameOrAlias())));
affectedIndices.addAll(Arrays.asList(indexNameExpressionResolver.concreteIndexNames(state, IndicesOptions.LENIENT_EXPAND_OPEN, swapAction.target().indexNameOrAlias())));
}
for (RelationName dropRelation : request.dropRelations()) {
affectedIndices.addAll(Arrays.asList(indexNameExpressionResolver.concreteIndexNames(state, IndicesOptions.LENIENT_EXPAND_OPEN, dropRelation.indexNameOrAlias())));
}
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, affectedIndices.toArray(new String[0]));
}
Aggregations