Example #1
0
/* perform inform command */
static int procinform(const char *path, int omode) {
    TCHDB *hdb = tchdbnew();
    if (!INVALIDHANDLE(g_dbgfd)) tchdbsetdbgfd(hdb, g_dbgfd);
    tchdbsetcodecfunc(hdb, _tc_recencode, NULL, _tc_recdecode, NULL);
    if (!tchdbopen(hdb, path, HDBOREADER | omode)) {
        printerr(hdb);
        tchdbdel(hdb);
        return 1;
    }
    bool err = false;
    const char *npath = tchdbpath(hdb);
    if (!npath) npath = "(unknown)";
    printf("path: %s\n", npath);
    const char *type = "(unknown)";
    switch (tchdbtype(hdb)) {
        case TCDBTHASH: type = "hash";
            break;
        case TCDBTBTREE: type = "btree";
            break;
        case TCDBTFIXED: type = "fixed";
            break;
        case TCDBTTABLE: type = "table";
            break;
    }
    printf("database type: %s\n", type);
    uint8_t flags = tchdbflags(hdb);
    printf("additional flags:");
    if (flags & HDBFOPEN) printf(" open");
    if (flags & HDBFFATAL) printf(" fatal");
    printf("\n");
    printf("bucket number: %" PRIu64 "\n", (uint64_t) tchdbbnum(hdb));
#ifndef NDEBUG
    if (hdb->cnt_writerec >= 0)
        printf("used bucket number: %" PRId64 "\n", (int64_t) tchdbbnumused(hdb));
#endif
    printf("alignment: %u\n", tchdbalign(hdb));
    printf("free block pool: %u\n", tchdbfbpmax(hdb));
    printf("inode number: %" PRId64 "\n", (int64_t) tchdbinode(hdb));
    char date[48];
    tcdatestrwww(tchdbmtime(hdb), INT_MAX, date);
    printf("modified time: %s\n", date);
    uint8_t opts = tchdbopts(hdb);
    printf("options:");
    if (opts & HDBTLARGE) printf(" large");
    if (opts & HDBTDEFLATE) printf(" deflate");
    if (opts & HDBTBZIP) printf(" bzip");
    if (opts & HDBTTCBS) printf(" tcbs");
    if (opts & HDBTEXCODEC) printf(" excodec");
    printf("\n");
    printf("record number: %" PRIu64 "\n", (uint64_t) tchdbrnum(hdb));
    printf("file size: %" PRIu64 "\n", (uint64_t) tchdbfsiz(hdb));
    if (!tchdbclose(hdb)) {
        if (!err) printerr(hdb);
        err = true;
    }
    tchdbdel(hdb);
    return err ? 1 : 0;
}
Example #2
0
/* perform inform command */
static int procinform(const char *path, int omode) {
    TCFDB *fdb = tcfdbnew();
    if (!INVALIDHANDLE(g_dbgfd)) tcfdbsetdbgfd(fdb, g_dbgfd);
    if (!tcfdbopen(fdb, path, FDBOREADER | omode)) {
        printerr(fdb);
        tcfdbdel(fdb);
        return 1;
    }
    bool err = false;
    const char *npath = tcfdbpath(fdb);
    if (!npath) npath = "(unknown)";
    printf("path: %s\n", npath);
    const char *type = "(unknown)";
    switch (tcfdbtype(fdb)) {
        case TCDBTHASH: type = "hash";
            break;
        case TCDBTBTREE: type = "btree";
            break;
        case TCDBTFIXED: type = "fixed";
            break;
        case TCDBTTABLE: type = "table";
            break;
    }
    printf("database type: %s\n", type);
    uint8_t flags = tcfdbflags(fdb);
    printf("additional flags:");
    if (flags & FDBFOPEN) printf(" open");
    if (flags & FDBFFATAL) printf(" fatal");
    printf("\n");
    printf("minimum ID number: %" PRIu64 "\n", (uint64_t) tcfdbmin(fdb));
    printf("maximum ID number: %" PRIu64 "\n", (uint64_t) tcfdbmax(fdb));
    printf("width of the value: %u\n", (unsigned int) tcfdbwidth(fdb));
    printf("limit file size: %" PRIu64 "\n", (uint64_t) tcfdblimsiz(fdb));
    printf("limit ID number: %" PRIu64 "\n", (uint64_t) tcfdblimid(fdb));
    printf("inode number: %" PRId64 "\n", (int64_t) tcfdbinode(fdb));
    char date[48];
    tcdatestrwww(tcfdbmtime(fdb), INT_MAX, date);
    printf("modified time: %s\n", date);
    printf("record number: %" PRIu64 "\n", (uint64_t) tcfdbrnum(fdb));
    printf("file size: %" PRIu64 "\n", (uint64_t) tcfdbfsiz(fdb));
    if (!tcfdbclose(fdb)) {
        if (!err) printerr(fdb);
        err = true;
    }
    tcfdbdel(fdb);
    return err ? 1 : 0;
}
Example #3
0
/* perform inform command */
static int procinform(const char *path, int omode) {
    TCBDB *bdb = tcbdbnew();
    if (!INVALIDHANDLE(g_dbgfd)) tcbdbsetdbgfd(bdb, g_dbgfd);
    tcbdbsetcmpfunc(bdb, mycmpfunc, NULL);
    tcbdbsetcodecfunc(bdb, _tc_recencode, NULL, _tc_recdecode, NULL);
    if (!tcbdbopen(bdb, path, BDBOREADER | omode)) {
        printerr(bdb);
        tcbdbdel(bdb);
        return 1;
    }
    bool err = false;
    const char *npath = tcbdbpath(bdb);
    if (!npath) npath = "(unknown)";
    printf("path: %s\n", npath);
    printf("database type: btree\n");
    uint8_t flags = tcbdbflags(bdb);
    printf("additional flags:");
    if (flags & BDBFOPEN) printf(" open");
    if (flags & BDBFFATAL) printf(" fatal");
    printf("\n");
    TCCMP cmp = tcbdbcmpfunc(bdb);
    printf("comparison function: ");
    if (cmp == tccmplexical) {
        printf("lexical");
    } else if (cmp == tccmpdecimal) {
        printf("decimal");
    } else if (cmp == tccmpint32) {
        printf("int32");
    } else if (cmp == tccmpint64) {
        printf("int64");
    } else {
        printf("custom");
    }
    printf("\n");
    printf("max leaf member: %d\n", tcbdblmemb(bdb));
    printf("max node member: %d\n", tcbdbnmemb(bdb));
    printf("leaf number: %" PRIuMAX "\n", (uint64_t) tcbdblnum(bdb));
    printf("node number: %" PRIuMAX "\n", (uint64_t) tcbdbnnum(bdb));
    printf("bucket number: %" PRIuMAX "\n", (uint64_t) tcbdbbnum(bdb));

#ifndef NDEBUG
    if (bdb->hdb->cnt_writerec >= 0)
        printf("used bucket number: %" PRIdMAX "\n", (int64_t) tcbdbbnumused(bdb));
#endif

    printf("alignment: %u\n", tcbdbalign(bdb));
    printf("free block pool: %u\n", tcbdbfbpmax(bdb));
    printf("inode number: %" PRIdMAX "\n", (int64_t) tcbdbinode(bdb));
    char date[48];
    tcdatestrwww(tcbdbmtime(bdb), INT_MAX, date);
    printf("modified time: %s\n", date);
    uint8_t opts = tcbdbopts(bdb);
    printf("options:");
    if (opts & BDBTLARGE) printf(" large");
    if (opts & BDBTDEFLATE) printf(" deflate");
    if (opts & BDBTBZIP) printf(" bzip");
    if (opts & BDBTTCBS) printf(" tcbs");
    if (opts & BDBTEXCODEC) printf(" excodec");
    printf("\n");
    printf("record number: %" PRIuMAX "\n", (uint64_t) tcbdbrnum(bdb));
    printf("file size: %" PRIuMAX "\n", (uint64_t) tcbdbfsiz(bdb));
    if (!tcbdbclose(bdb)) {
        if (!err) printerr(bdb);
        err = true;
    }
    tcbdbdel(bdb);
    return err ? 1 : 0;
}
Example #4
0
/* perform inform command */
static int procinform(const char *path, int omode){
  TCTDB *tdb = tctdbnew();
  if(g_dbgfd != INVALID_HANDLE_VALUE) tctdbsetdbgfd(tdb, g_dbgfd);
  tctdbsetcodecfunc(tdb, _tc_recencode, NULL, _tc_recdecode, NULL);
  if(!tctdbopen(tdb, path, TDBOREADER | omode)){
    printerr(tdb);
    tctdbdel(tdb);
    return 1;
  }
  bool err = false;
  const char *npath = tctdbpath(tdb);
  if(!npath) npath = "(unknown)";
  printf("path: %s\n", npath);
  printf("database type: table\n");
  uint8_t flags = tctdbflags(tdb);
  printf("additional flags:");
  if(flags & TDBFOPEN) printf(" open");
  if(flags & TDBFFATAL) printf(" fatal");
  printf("\n");
  printf("bucket number: %llu\n", (unsigned long long)tctdbbnum(tdb));
  if(tdb->hdb->cnt_writerec >= 0)
    printf("used bucket number: %lld\n", (long long)tctdbbnumused(tdb));
  printf("alignment: %u\n", tctdbalign(tdb));
  printf("free block pool: %u\n", tctdbfbpmax(tdb));
  printf("index number: %d\n", tctdbinum(tdb));
  TDBIDX *idxs = tdb->idxs;
  int inum = tdb->inum;
  for(int i = 0; i < inum; i++){
    TDBIDX *idxp = idxs + i;
    switch(idxp->type){
      case TDBITLEXICAL:
        printf("  name=%s, type=lexical, rnum=%lld, fsiz=%lld\n",
               idxp->name, (long long)tcbdbrnum(idxp->db), (long long)tcbdbfsiz(idxp->db));
        break;
      case TDBITDECIMAL:
        printf("  name=%s, type=decimal, rnum=%lld, fsiz=%lld\n",
               idxp->name, (long long)tcbdbrnum(idxp->db), (long long)tcbdbfsiz(idxp->db));
        break;
      case TDBITTOKEN:
        printf("  name=%s, type=token, rnum=%lld, fsiz=%lld\n",
               idxp->name, (long long)tcbdbrnum(idxp->db), (long long)tcbdbfsiz(idxp->db));
        break;
      case TDBITQGRAM:
        printf("  name=%s, type=qgram, rnum=%lld, fsiz=%lld\n",
               idxp->name, (long long)tcbdbrnum(idxp->db), (long long)tcbdbfsiz(idxp->db));
        break;
    }
  }
  printf("unique ID seed: %lld\n", (long long)tctdbuidseed(tdb));
  printf("inode number: %lld\n", (long long)tctdbinode(tdb));
  char date[48];
  tcdatestrwww(tctdbmtime(tdb), INT_MAX, date);
  printf("modified time: %s\n", date);
  uint8_t opts = tctdbopts(tdb);
  printf("options:");
  if(opts & TDBTLARGE) printf(" large");
  if(opts & TDBTDEFLATE) printf(" deflate");
  if(opts & TDBTBZIP) printf(" bzip");
  if(opts & TDBTTCBS) printf(" tcbs");
  if(opts & TDBTEXCODEC) printf(" excodec");
  printf("\n");
  printf("record number: %llu\n", (unsigned long long)tctdbrnum(tdb));
  printf("file size: %llu\n", (unsigned long long)tctdbfsiz(tdb));
  if(!tctdbclose(tdb)){
    if(!err) printerr(tdb);
    err = true;
  }
  tctdbdel(tdb);
  return err ? 1 : 0;
}