use of nars.index.util.TermContainerToOpMap in project narchy by automenta.
the class CaffeineIndex2 method get.
@Override
public Termed get(Term x, boolean createIfMissing) {
if (x.volume() > nar.termVolumeMax.intValue())
// quick check to avoid creating a vector for a term that will be invalid anyway
return null;
assert (!(x instanceof Variable)) : "variables should not be stored in index";
Op op = x.op();
TermContainerToOpMap<Termed> v;
if (createIfMissing) {
v = vectors.get(vector(x), k -> {
TermContainerToOpMap<Termed> t = new TermContainerToOpMap<>(k);
Termed p = nar.conceptBuilder.apply(x, null);
if (p != null)
t.compareAndSet(op.id, null, p);
return t;
});
} else {
v = vectors.getIfPresent(vector(x));
}
return v != null ? v.get(op.id) : null;
}
Aggregations