use of org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry in project bboxdb by jnidzwetzki.
the class Memtable method getAllTuplesInBoundingBox.
@Override
public Iterator<Tuple> getAllTuplesInBoundingBox(final BoundingBox boundingBox) {
assert (usage.get() > 0);
final List<? extends SpatialIndexEntry> matchingKeys = spatialIndex.getEntriesForRegion(boundingBox);
final Iterator<? extends SpatialIndexEntry> keyIterator = matchingKeys.iterator();
return new Iterator<Tuple>() {
@Override
public boolean hasNext() {
return keyIterator.hasNext();
}
@Override
public Tuple next() {
final SpatialIndexEntry entry = keyIterator.next();
final int pos = (int) entry.getValue();
return data[pos];
}
};
}
use of org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry in project bboxdb by jnidzwetzki.
the class Memtable method put.
@Override
public void put(final Tuple value) throws StorageManagerException {
assert (usage.get() > 0);
if (freePos >= maxEntries) {
throw new StorageManagerException("Unable to store a new tuple, all memtable slots are full");
}
data[freePos] = value;
bloomFilter.put(value.getKey());
final SpatialIndexEntry indexEntry = new SpatialIndexEntry(value.getBoundingBox(), freePos);
spatialIndex.insert(indexEntry);
freePos++;
sizeInMemory = sizeInMemory + value.getSize();
if (oldestTupleTimestamp == -1) {
oldestTupleTimestamp = value.getVersionTimestamp();
} else {
oldestTupleTimestamp = Math.min(oldestTupleTimestamp, value.getVersionTimestamp());
}
if (newestTupleTimestamp == -1) {
newestTupleTimestamp = value.getVersionTimestamp();
} else {
newestTupleTimestamp = Math.max(newestTupleTimestamp, value.getVersionTimestamp());
}
}
Aggregations