Aklakan commented on code in PR #2405: URL: https://github.com/apache/jena/pull/2405#discussion_r1713430097
########## jena-arq/src/main/java/org/apache/jena/sparql/engine/join/JoinIndex.java: ########## @@ -0,0 +1,175 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jena.sparql.engine.join; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Set; +import java.util.function.Consumer; + +import org.apache.jena.atlas.iterator.Iter; +import org.apache.jena.sparql.core.Var; +import org.apache.jena.sparql.engine.binding.Binding; +import org.apache.jena.sparql.engine.binding.BindingFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A join index contains information about the indexing of a set of rows w.r.t. a join key. + * <p /> + * Consider a primary index for the join key [?x, ?y, ?z]: + * <p /> + * All rows that bind all three variables will be placed into the {@link #mainTable}. + * + * If there is any data that only binds a sub set of the variables, such as [?x, ?z] or [?y], + * then that data will be placed into respective skew tables. + */ +public class JoinIndex + implements Iterable<Binding> +{ + private static final Logger logger = LoggerFactory.getLogger(JoinIndex.class); + + private JoinKey superJoinKey; + + private BitSet mainJoinKeyBitSet; + private HashProbeTable mainTable; + + /** Skew tables hold rows whose variables are a strict sub set of those of this table. */ + private Map<BitSet, HashProbeTable> skewTables; + + public JoinIndex(JoinKey superJoinKey, JoinKey mainJoinKey, BitSet mainJoinKeyBitSet) { + this.superJoinKey = Objects.requireNonNull(superJoinKey); + this.mainJoinKeyBitSet = mainJoinKeyBitSet; + this.mainTable = new HashProbeTable(mainJoinKey); + } + + public BitSet getMainJoinKeyBitSet() { + return mainJoinKeyBitSet; + } + + public HashProbeTable getMainTable() { + return mainTable; + } + + public Set<BitSet> getSkewKeys() { + return skewTables == null ? Collections.emptySet() : skewTables.keySet(); + } + + /** Return a secondary table for the given key. Returns null if there is none. */ Review Comment: all remaining mentions of 'secondary' should be renamed to 'skew'. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: pr-unsubscr...@jena.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@jena.apache.org For additional commands, e-mail: pr-h...@jena.apache.org