TokyoCabinet:hdb->close() 处出现分段错误

发布于 2024-08-03 05:59:43 字数 740 浏览 5 评论 0原文

在 TC 哈希数据库中插入大约 800 万条记录后,我陷入了分段错误。插入所有内容后,我关闭数据库,但在代码的这一部分(tchdb.c)中发现了分段错误:

static void tchdbsetflag(TCHDB *hdb, int flag, bool sign){
  assert(hdb);
  char *fp = (char *)hdb->map + HDBFLAGSOFF;
  if(sign){
    *fp |= (uint8_t)flag;  //SEGFAULT HERE!
  } else {
    *fp &= ~(uint8_t)flag;
  }
  hdb->flags = *fp;
}

更具体地说,在注释行处。

数据库是这样打开的:

tchdbopen(hdb, db_file,  HDBOWRITER | HDBOCREAT))

数据库调整为:

tchdbtune(hdb, 25000000, -1, -1, HDBTLARGE);
tchdbsetcache(hdb, 100000);

.tch 文件约为 2GB(2147483647 字节)。有趣的是,只有当我插入大约 800 万条记录时才会发生这种情况。有了两三百万,数据库就可以关闭了。插入 800 万条记录大约需要 3 个小时,因为我从文本文件读取数据。

有什么想法吗?

谢谢

I'm stuck at a Segmentation fault after inserting about 8 million records in a TC Hash Database. After everything is inserted I close the DB but I caught a Segmentation Fault at this part of the code (tchdb.c):

static void tchdbsetflag(TCHDB *hdb, int flag, bool sign){
  assert(hdb);
  char *fp = (char *)hdb->map + HDBFLAGSOFF;
  if(sign){
    *fp |= (uint8_t)flag;  //SEGFAULT HERE!
  } else {
    *fp &= ~(uint8_t)flag;
  }
  hdb->flags = *fp;
}

More especifically at the commented line.

The DB was opened like this:

tchdbopen(hdb, db_file,  HDBOWRITER | HDBOCREAT))

The DB is tunned with:

tchdbtune(hdb, 25000000, -1, -1, HDBTLARGE);
tchdbsetcache(hdb, 100000);

The .tch file is about 2GB (2147483647 bytes). The interesting thing is that it is only happening when I insert around 8 million records. With 2 or 3 millions the DB closes all right. Inserting 8 million records takes around 3 hours because I read data from text files.

Any ideas?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぃ双果 2024-08-10 05:59:43

刚刚解决了问题。
我使用的是 32 位系统,TC 在此类系统中只能处理最大 2GB 的数据库。
解决方案是使用“--enable-off64”选项构建 TC。像这样的事情:

./configure --enable-off64
make
make install

Just solved the problem.
I'm on a 32bits system and TC can only handle databases up to 2GB in such systems.
The solution is building TC with the "--enable-off64" option. Something like this:

./configure --enable-off64
make
make install
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文