public class JVMHashIndex extends Object
IBindingSet
s that supports duplicate solutions and
hit counts. The hit counts are used to detect IBindingSet
s that do
not join for OPTIONAL, MINUS, and related kinds of "negation" joins.
Note: The JVMDistinctBindingSetsOp
does not use this class right now
because it enjoys better concurrency than the JVMHashIndex
. Also see
JVMDistinctFilter
, which is the backing implementation for the
JVMDistinctBindingSetsOp
.
JVMDistinctFilter
Modifier and Type | Class and Description |
---|---|
static class |
JVMHashIndex.Bucket
A group of solutions having the same as-bound values for the join vars.
|
static class |
JVMHashIndex.Key
Wrapper for the keys in the hash table.
|
static class |
JVMHashIndex.SolutionHit
An solution and a hit counter as stored in the
JVMHashIndex . |
Constructor and Description |
---|
JVMHashIndex(IVariable<?>[] keyVars,
boolean indexSolutionsHavingUnboundJoinVars,
Map<JVMHashIndex.Key,JVMHashIndex.Bucket> map) |
Modifier and Type | Method and Description |
---|---|
JVMHashIndex.Key |
add(IBindingSet bset)
Add the solution to the index.
|
boolean |
addDistinct(IBindingSet bset)
Add the solution to the index iff the solution is not already present in
the index.
|
int |
bucketCount()
The #of buckets in the hash index.
|
Iterator<JVMHashIndex.Bucket> |
buckets()
Visit all buckets in the hash index.
|
JVMHashIndex.Bucket |
getBucket(IBindingSet left)
Return the hash
JVMHashIndex.Bucket into which the given solution is mapped. |
JVMHashIndex.Bucket[] |
toArray()
Export the
JVMHashIndex.Bucket s as an array. |
public JVMHashIndex(IVariable<?>[] keyVars, boolean indexSolutionsHavingUnboundJoinVars, Map<JVMHashIndex.Key,JVMHashIndex.Bucket> map)
keyVars
- The variables that are used to form the keys in the hash index
(required, but may be empty). The order of the entries is used
when forming the as-bound keys for the hash table. Duplicate
elements and null elements are not permitted. If no join
variables are specified, then the join will consider the N x M
cross product, filtering for solutions which join. This is
very expensive when compared to a hash join. Whenever possible
you should identify one or more variables which must be bound
for the join and specify those as the join variables.indexSolutionsHavingUnboundJoinVars
- When true
, we allow solutions to be stored in the
hash index that have unbound variables for the
keyVars
. When false
, such solutions are
dropped (they are not added to the index).map
- The backing map. A HashMap
should be faster for insert
and search. A LinkedHashMap
should be faster for
scans. Some join patterns do not require us to use scans, in
which case HashMap
is the clear winner. (For example,
a non-optional hash join against an access path never uses the
iterator over the hash index.)public JVMHashIndex.Key add(IBindingSet bset)
bset
- The IBindingSet
.JVMHashIndex.Key
iff the solution was added to the index and
null
iff the solution was not added (because a
JVMHashIndex.Key
could not be formed for the solution given the
specified keyVars
).public boolean addDistinct(IBindingSet bset)
bset
- The solution.true
iff the index was modified by this operation.public JVMHashIndex.Bucket getBucket(IBindingSet left)
JVMHashIndex.Bucket
into which the given solution is mapped.
Note: The caller must apply an appropriate join constraint in order to correctly reject solutions that (a) violate the join contract; and (b) that are present in the hash bucket due to a hash collection rather than because they have the same bindings for the join variables.
left
- The probe.JVMHashIndex.Bucket
into which the given solution is mapped
-or- null
if there is no such hash bucket.public Iterator<JVMHashIndex.Bucket> buckets()
public int bucketCount()
keyVars
to nevertheless be mapped into the same hash bucket.public JVMHashIndex.Bucket[] toArray()
JVMHashIndex.Bucket
s as an array.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.