weixin_39940755
2020-12-09 08:19 阅读 1

Missing stat method

The Database object has no method to get a Stat object by providing a Transaction. Those methods exist:


    public Stat stat() { ... }
    public MDB_stat stat(Transaction tx) { ... }

But this one is missing:


    public Stat stat(Transaction tx) { ... }

Because the org.fusesource.lmdbjni.JNI class has a package scope, it seems impossible to write (from another package):


    MDB_stat stat = writeDb.stat(tx);

This method would be useful for getting the stats of a write transaction (in order to be able to be able to prevent MDB_MAP_FULL).

And since this is my first message here: thanks for this wonderful Java library!

该提问来源于开源项目:deephacks/lmdbjni

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • weixin_39802020 weixin_39802020 2020-12-09 08:19

    In order to keep the API consistent, I think that MDB_stat stat(Transaction tx) needs to change to return Stat instead.

    点赞 评论 复制链接分享
  • weixin_39940755 weixin_39940755 2020-12-09 08:19

    I agree. By the way I noticed that it is possible to access the fields of the MDB_stat object like this:

    
    Stat stat = db.stat();
    long l = stat.ms_branch_pages;
    

    ... and those values are not initialized by the constructor of the Stat class (it initializes its own private fields instead). In the end I am wondering if the private fields of the Stat class could simply be removed. If it was the case its methods could simply return the MDB_stat fields (that could remain public since they are final).

    点赞 评论 复制链接分享
  • weixin_39802020 weixin_39802020 2020-12-09 08:19

    Yes, that would be ideal I think.

    点赞 评论 复制链接分享
  • weixin_39940755 weixin_39940755 2020-12-09 08:19

    Thank you!

    点赞 评论 复制链接分享
  • weixin_39802020 weixin_39802020 2020-12-09 08:19

    Thanks for reporting!

    点赞 评论 复制链接分享

相关推荐