C ++ spatialindex库:从/到磁盘加载/存储主内存RTree [英] C++ spatialindex library: loading/storing main memory RTree from/to disk

查看:598
本文介绍了C ++ spatialindex库:从/到磁盘加载/存储主内存RTree的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个主内存R *索引与spatialindex库的帮助下面的方式(DBStream实现bulkLoading的接口)

I have created a main memory R* index with the help of spatialindex library in the following way (DBStream implements the interface for bulkLoading)

// creating a main memory RTree
memStorage = StorageManager::createNewMemoryStorageManager();

size_t capacity = 1024;
bool bWriteThrough = false;
fileInMem = StorageManager
   ::createNewRandomEvictionsBuffer(*memStorage, capacity, bWriteThrough);

DBStream dstream(streets);

tree = RTree::createAndBulkLoadNewRTree(SpatialIndex::RTree::BLM_STR, dstream,
   *fileInMem,
   fillFactor, indexCapacity,
   leafCapacity, dimension, rv, indexIdentifier);

我的数据是只读的,即我只想建树一次,并从每次我使用我的程序从永久存储器重新加载。显然,我可以自己保存和加载memStorage,但是如何从中重新创建RTree?

My data is read-only, i.e., I want to build the tree only once, save it, and reload from persistent storage every time I use my program. Clearly, I can save and load the memStorage myself, but how to recreate the RTree from it?

推荐答案

加载树反正,这里有很少得到,实际上。 STR批量加载所做的就是对数据进行排序。这是 O(n log n)理论上,但如果你有适当的数据排序它实际上将在 O(n)与大多数排序实现。

Since you are bulk-loading the tree anyway, there is little to gain here, actually. All that a STR bulk load does is sort the data. This is O(n log n) theoretically, but if you have the data sorted appropriately it will actually be in O(n) with most sorting implementations.

所以最可能的是,序列化树到一个文件和回来不比每次大量批量加载更便宜。它确实带来了一些灵活性。

So most likely, serializing the tree into a file and back is not much cheaper than bulk-loading it again each time. It does take away some flexibility though.

R树通常用于动态数据IMHO。当然,他们为静态数据工作。但是他们的关键力量(与其他结构相反)是树支持插入时的平衡。

R-Trees in general are meant for dynamic data IMHO. Sure, they do work for static data. But their key strength (opposed to other structures) is that the tree supports balancing on insert.

这篇关于C ++ spatialindex库:从/到磁盘加载/存储主内存RTree的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆