Search in sources :

Example 26 with SpatialIndexEntry

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];
        }
    };
}
Also used : Iterator(java.util.Iterator) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)

Example 27 with SpatialIndexEntry

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());
    }
}
Also used : StorageManagerException(org.bboxdb.storage.StorageManagerException) SpatialIndexEntry(org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)

Aggregations

SpatialIndexEntry (org.bboxdb.storage.sstable.spatialindex.SpatialIndexEntry)27 Test (org.junit.Test)14 SpatialIndexBuilder (org.bboxdb.storage.sstable.spatialindex.SpatialIndexBuilder)13 RTreeBuilder (org.bboxdb.storage.sstable.spatialindex.rtree.RTreeBuilder)12 BoundingBox (org.bboxdb.commons.math.BoundingBox)8 RandomAccessFile (java.io.RandomAccessFile)6 ArrayList (java.util.ArrayList)6 StorageManagerException (org.bboxdb.storage.StorageManagerException)6 File (java.io.File)5 AbstractRTreeReader (org.bboxdb.storage.sstable.spatialindex.rtree.AbstractRTreeReader)4 List (java.util.List)3 Random (java.util.Random)3 Collectors (java.util.stream.Collectors)3 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 SpatialIndexReader (org.bboxdb.storage.sstable.spatialindex.SpatialIndexReader)2 Assert (org.junit.Assert)2 ByteBuffer (java.nio.ByteBuffer)1 MappedByteBuffer (java.nio.MappedByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1