简体   繁体   English

(重新)使用spacespaceindex库加载R树

[英](Re)loading the R Tree with spatialindex library

I am bulkloading an R Tree with spatialindex (http://libspatialindex.github.com/) library: 我正在使用spaceindex(http://libspatialindex.github.com/)库批量加载R树:

string baseName = "streets";
size_t capacity = 10 * 1024 * 1024;
bool bWriteThrough = false;
indexIdentifier = 0;

IStorageManager *disk = StorageManager::createNewDiskStorageManager(baseName, 512);
fileInMem = StorageManager
   ::createNewRandomEvictionsBuffer(*disk, capacity, bWriteThrough);

// bulkLoads my tree
bulkLoadRTree();

cout << "tree info:" << endl;
cout << *tree << endl;

delete disk;

The following is output at the info about the built tree: 以下是有关已构建树的信息的输出:

    Dimension: 2 
    Fill factor: 0.7 
    Index capacity: 100 
    Leaf capacity: 100 
    Tight MBRs: enabled 
    Near minimum overlap factor: 32 
    Reinsert factor: 0.3 
    Split distribution factor: 0.4 
    Utilization: 69% 
    Reads: 1 
    Writes: 35980 
    Hits: 0 
    Misses: 0 
    Tree height: 4 
    Number of data: 2482376 
    Number of nodes: 35979 
    Level 0 pages: 35463 
    Level 1 pages: 507 
    Level 2 pages: 8 
    Level 3 pages: 1 
    Splits: 0 
    Adjustments: 0 
    Query results: 0 

now I am trying to load what I have saved in the disk: 现在,我正在尝试加载磁盘中保存的内容:

IStorageManager *ldisk = StorageManager::loadDiskStorageManager(baseName);
SpatialIndex::StorageManager::IBuffer* fileLoadBuffer = StorageManager
    ::createNewRandomEvictionsBuffer(*ldisk, capacity, bWriteThrough);

id_type id = 1;
tree = RTree::loadRTree(*fileLoadBuffer, id);
cout << *tree << endl;

and the tree has only one node (the output of the tree is:) 并且树只有一个节点(树的输出是:)

    Dimension: 2
    Fill factor: 0.7
    Index capacity: 100
    Leaf capacity: 100
    Tight MBRs: enabled
    Near minimum overlap factor: 32
    Reinsert factor: 0.3
    Split distribution factor: 0.4
    Utilization: 0%
    Reads: 0
    Writes: 0
    Hits: 0
    Misses: 0
    Tree height: 1
    Number of data: 0
    Number of nodes: 1
    Level 0 pages: 1
    Splits: 0
    Adjustments: 0
    Query results: 0

What do I do wrong? 我做错了什么? Why don't I load the whole tree from the disk? 为什么不从磁盘加载整个树?

Did you maybe not sync your changes to disc? 您是否可能未将更改同步到光盘?

Plus, usually one would implement the tree on-disk, and not read it completely on the first access. 另外,通常会在磁盘上实现树,而在第一次访问时不会完全读取它。 So at this point, it cannot report accurate statistics. 因此,它目前无法报告准确的统计信息。

Or maybe your bulkLoadRTree does not use fileInMem . 也许您的bulkLoadRTree不使用fileInMem

One has to delete the fileInMem so the pages are further sent back to disk and further sent back to delete *disk. 必须删除fileInMem,以便将页面进一步发送回磁盘,并进一步发送回删除* disk。 This line needs to be added before delete disk: 在删除磁盘之前,需要添加以下行:

delete fileInMem

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM