1

我正在使用空间索引(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;

以下是有关已构建树的信息的输出:

    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 

现在我正在尝试加载我保存在磁盘中的内容:

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;

并且树只有一个节点(树的输出是:)

    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

我做错了什么?为什么我不从磁盘加载整个树?

4

2 回答 2

1

您可能没有将更改同步到光盘吗?

另外,通常人们会在磁盘上实现树,而不是在第一次访问时完全读取它。所以在这一点上,它不能报告准确的统计数据。

或者也许你bulkLoadRTree不使用fileInMem.

于 2012-11-08T20:04:43.653 回答
0

必须删除fileInMem,以便将页面进一步发送回磁盘并进一步发送回删除*磁盘。此行需要在删除磁盘之前添加:

delete fileInMem
于 2012-11-22T08:25:44.693 回答