1

ここでは、構造が次のようになるグラフデータベースを作成しようとしています。ノードを追加し続けると、depth of the tree increasing. ここで私が間違っているかもしれないことを提案できますか?

       A:1
     /    \
    B:2   C:3
  /          \
D:4          E:5

    >>> import lmdb
    >>> env = lmdb.open("treedb.lmdb")
    >>> txn = env.begin(write = True)
    >>> txn.stat()
    {'psize': 4096, 'depth': 0, 'branch_pages': 0, 'leaf_pages': 0, 'overflow_pages': 0, 'entries': 0}
    >>> txn.put('root'.encode('utf-8'),json.dumps({'A':1}).encode('utf-8'))
    True
    >>> txn.stat()
    {'psize': 4096, 'depth': 1, 'branch_pages': 0, 'leaf_pages': 1, 'overflow_pages': 0, 'entries': 1}
    
    >>> txn.put('A'.encode('utf-8'), json.dumps({'A':{'B':2}}).encode('utf-8'))
    True
    >>> txn.stat()
    {'psize': 4096, 'depth': 1, 'branch_pages': 0, 'leaf_pages': 1, 'overflow_pages': 0, 'entries': 2}
    >>>
    >>> txn.put('A'.encode('utf-8'), json.dumps({'A':{'C':3}}).encode('utf-8'))
    True
    >>>
    >>> txn.stat()
    {'psize': 4096, 'depth': 1, 'branch_pages': 0, 'leaf_pages': 1, 'overflow_pages': 0, 'entries': 3}
    >>>
    >>> txn.put('B'.encode('utf-8'), json.dumps({'B':{'D':4}}).encode('utf-8'))
    True
    >>> txn.put('C'.encode('utf-8'), json.dumps({'C':{'E':5}}).encode('utf-8'))
    >>> txn.stat()
{'psize': 4096, 'depth': 1, 'branch_pages': 0, 'leaf_pages': 1, 'overflow_pages': 0, 'entries': 5}
4

1 に答える 1