public abstract class MemoryVariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable> extends Object implements VariableTermStore<T,V>
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_PREFIX
Prefix of property keys used by this class.
|
static int |
DEFAULT_SIZE_DEFAULT |
static String |
DEFAULT_SIZE_KEY
The default size in terms of number of variables.
|
static boolean |
SHUFFLE_DEFAULT |
static String |
SHUFFLE_KEY
Shuffle the terms before each return of iterator().
|
Constructor and Description |
---|
MemoryVariableTermStore() |
Modifier and Type | Method and Description |
---|---|
void |
add(GroundRule rule,
T term)
Add a term to the store that was generated from the given ground rule.
|
void |
clear()
Remove any existing terms and prepare for a new set.
|
void |
close()
Close down the term store, it will not be used any more.
|
protected abstract V |
convertAtomToVariable(RandomVariableAtom atom) |
V |
createLocalVariable(RandomVariableAtom atom)
Create a variable local to a specific term.
|
void |
ensureCapacity(int capacity)
Ensure that the underlying stuctures can have the required term capacity.
|
void |
ensureVariableCapacity(int capacity)
Make sure we allocate the right amount of memory for global variables.
|
T |
get(int index) |
int |
getNumVariables() |
int |
getVariableIndex(V variable)
Get the index that matches up to getVariableValues().
|
Iterable<V> |
getVariables() |
float[] |
getVariableValues()
Get the truth values for variabe atoms.
|
boolean |
isLoaded()
Is the term store loaded, and can it give an accurate term and variable count.
|
Iterator<T> |
iterator() |
Iterator<T> |
noWriteIterator()
Get an iterator over the terms in the store that does not write to disk.
|
int |
size() |
void |
syncAtoms()
Ensure that all the variable atoms have the same value as the array returned by getVariableValues().
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public static final String CONFIG_PREFIX
public static final String SHUFFLE_KEY
public static final boolean SHUFFLE_DEFAULT
public static final String DEFAULT_SIZE_KEY
public static final int DEFAULT_SIZE_DEFAULT
public int getVariableIndex(V variable)
VariableTermStore
getVariableIndex
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public float[] getVariableValues()
VariableTermStore
getVariableValues
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void syncAtoms()
VariableTermStore
syncAtoms
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public int getNumVariables()
getNumVariables
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public boolean isLoaded()
VariableTermStore
isLoaded
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public V createLocalVariable(RandomVariableAtom atom)
TermStore
createLocalVariable
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void ensureVariableCapacity(int capacity)
ensureVariableCapacity
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public Iterable<V> getVariables()
getVariables
in interface VariableTermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void add(GroundRule rule, T term)
TermStore
add
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void clear()
TermStore
clear
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void close()
TermStore
close
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public T get(int index)
get
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public int size()
size
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public void ensureCapacity(int capacity)
TermStore
ensureCapacity
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
public Iterator<T> iterator()
iterator
in interface Iterable<T extends ReasonerTerm>
public Iterator<T> noWriteIterator()
TermStore
noWriteIterator
in interface TermStore<T extends ReasonerTerm,V extends ReasonerLocalVariable>
protected abstract V convertAtomToVariable(RandomVariableAtom atom)
Copyright © 2020 University of California, Santa Cruz. All rights reserved.