public class SolutionSetStatserator extends Object implements ICloseableIterator<IBindingSet[]>
ISolutionSetStats
object from a stream of
solutions. The summary is available from getStats()
once the source
solutions have been fully consumed.
TODO Compute the distinct values for each variable for which we have a
binding, or at least the #of such values and offer a method to obtain the
distinct values which could cache them. We can do the exact #of distinct
values trivially for small solution sets. For very large solution sets this
is more expensive and approximate techniques for obtaining the distinct set
only when it is likely to be small would be appropriate.
Note that this must correctly handle TermId.mockIV(VTE)
s.
Or compute a bloom filter for a statistical summary.
Modifier and Type | Field and Description |
---|---|
protected Set<IVariable<?>> |
currentVars |
protected Map<IVariable<?>,IConstant<?>> |
firstBoundValue
A map from the variable to the first bound value for that variable.
|
protected Set<IVariable<?>> |
notAlwaysBound
The set of variables which are NOT bound in at least one solution (e.g.,
MAYBE bound semantics).
|
protected Set<IVariable<?>> |
notBoundThisSolution |
protected Set<IVariable<?>> |
notConstant
The set of variables which have been proven to not be effective
constants.
|
protected Set<IVariable<?>> |
notMaterialized
The set of variables whose
IVCache association is NOT set is at
least one solution in which the variable is bound. |
protected long |
nsolutions
The #of solutions.
|
protected Set<IVariable<?>> |
usedVars
The set of variables observed across all solutions.
|
Constructor and Description |
---|
SolutionSetStatserator(Iterator<IBindingSet[]> src) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the iterator, releasing any associated resources.
|
protected ISolutionSetStats |
compile()
Compile the statistics collected from the observed solutions.
|
protected void |
filter(IBindingSet[] a)
Compute incremental statistics from an observed chunk of solutions.
|
static ISolutionSetStats |
get(IBindingSet[] bindingSets)
Convenience method.
|
ISolutionSetStats |
getStats()
Return the compiled statistics.
|
boolean |
hasNext() |
IBindingSet[] |
next() |
void |
remove() |
protected long nsolutions
protected final Set<IVariable<?>> usedVars
protected final Set<IVariable<?>> notAlwaysBound
protected final Set<IVariable<?>> notMaterialized
IVCache
association is NOT set is at
least one solution in which the variable is bound.protected final Map<IVariable<?>,IConstant<?>> firstBoundValue
protected final Set<IVariable<?>> notConstant
public SolutionSetStatserator(Iterator<IBindingSet[]> src)
public static ISolutionSetStats get(IBindingSet[] bindingSets)
bindingSets
- The source solutions.protected void filter(IBindingSet[] a)
protected ISolutionSetStats compile()
public ISolutionSetStats getStats()
{@link
- IllegalStateException} if the statistics have not yet been
compiled (they are automatically compiled when the source
iterator has been fully consumed).public void close()
ICloseableIterator
ICloseableIterator.close()
if Iterator.hasNext()
method returns false
to ensure that the iterator is closed
(and its resources release) as soon as it is exhausted.
Note: Implementations that support Iterator.remove()
MUST NOT
eagerly close the iterator when it is exhausted since that would make it
impossible to remove the last visited statement. Instead they MUST wait
for an explicit ICloseableIterator.close()
by the application.
close
in interface ICloseable
close
in interface ICloseableIterator<IBindingSet[]>
public boolean hasNext()
hasNext
in interface Iterator<IBindingSet[]>
public IBindingSet[] next()
next
in interface Iterator<IBindingSet[]>
public void remove()
remove
in interface Iterator<IBindingSet[]>
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.