├── COPYING ├── ChangeLog ├── Makefile.in ├── README ├── THANKS ├── bros ├── Makefile ├── bdbtest.c ├── cdbtest.c ├── cmpsqltctest.c ├── gdbmtest.c ├── mapreporter ├── maptest.cc ├── ndbmtest.c ├── qdbmtest.c ├── reporter ├── result.xls ├── sdbmtest.c ├── sqltest.c ├── tctest.c └── tdbtest.c ├── configure ├── configure.in ├── doc ├── benchmark.pdf ├── common.css ├── icon16.png ├── index.html ├── index.ja.html ├── logo-ja.png ├── logo.png ├── spex-en.html ├── spex-ja.html ├── tokyoproducts.pdf └── tokyoproducts.ppt ├── example ├── Makefile ├── tcadbex.c ├── tcbdbex.c ├── tcfdbex.c ├── tchdbex.c ├── tctchat.c ├── tctchat.tmpl ├── tctdbex.c ├── tctsearch.c ├── tctsearch.tmpl └── tcutilex.c ├── hogehoge ├── lab ├── calccomp ├── datechange ├── diffcheck ├── htmldoctotsv ├── htmltotsv ├── magic ├── printenv.cgi ├── stepcount ├── stopwatch ├── tabcheck ├── wgettsv └── yearchange ├── man ├── hoge ├── htmltoman ├── tcadb.3 ├── tcamgr.1 ├── tcatest.1 ├── tcbdb.3 ├── tcbmgr.1 ├── tcbmttest.1 ├── tcbtest.1 ├── tcfdb.3 ├── tcfmgr.1 ├── tcfmttest.1 ├── tcftest.1 ├── tchdb.3 ├── tchmgr.1 ├── tchmttest.1 ├── tchtest.1 ├── tclist.3 ├── tcmap.3 ├── tcmdb.3 ├── tcmpool.3 ├── tctdb.3 ├── tctmgr.1 ├── tctmttest.1 ├── tctree.3 ├── tcttest.1 ├── tcucodec.1 ├── tcumttest.1 ├── tcutest.1 ├── tcutil.3 ├── tcxstr.3 └── tokyocabinet.3 ├── md5.c ├── md5.h ├── myconf.c ├── myconf.h ├── tako ├── tcadb.c ├── tcadb.h ├── tcamgr.c ├── tcatest.c ├── tcawmgr.c ├── tcbdb.c ├── tcbdb.h ├── tcbmgr.c ├── tcbmttest.c ├── tcbtest.c ├── tcfdb.c ├── tcfdb.h ├── tcfmgr.c ├── tcfmttest.c ├── tcftest.c ├── tchdb.c ├── tchdb.h ├── tchmgr.c ├── tchmttest.c ├── tchtest.c ├── tctdb.c ├── tctdb.h ├── tctmgr.c ├── tctmttest.c ├── tcttest.c ├── tcucodec.c ├── tcumttest.c ├── tcutest.c ├── tcutil.c ├── tcutil.h ├── tokyocabinet.idl └── tokyocabinet.pc.in /README: -------------------------------------------------------------------------------- 1 | ================================================================ 2 | Tokyo Cabinet: a modern implementation of DBM 3 | Copyright (C) 2006-2009 Mikio Hirabayashi 4 | ================================================================ 5 | 6 | 7 | Please read the following documents with a WWW browser. 8 | How to install Tokyo Cabinet is explained in the specification. 9 | 10 | README - this file 11 | COPYING - license 12 | ChangeLog - history of enhancement 13 | THANKS - list of contributors 14 | doc/index.html - index of documents 15 | 16 | 17 | Contents of the directory tree is below. 18 | 19 | ./ - sources of Tokyo Cabinet 20 | ./doc/ - manuals and specifications 21 | ./man/ - manuals for nroff 22 | ./example/ - sample code of tutorial 23 | ./lab/ - for test and experiment 24 | ./bros/ - for comparison with other database managers 25 | 26 | 27 | Tokyo Cabinet is released under the terms of the GNU Lesser General 28 | Public License. See the file `COPYING' for details. 29 | 30 | Tokyo Cabinet was written by Mikio Hirabayashi. You can contact the 31 | author by e-mail to `mikio@users.sourceforge.net'. 32 | 33 | 34 | Thanks. 35 | 36 | 37 | 38 | == END OF FILE == 39 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | ================================================================ 2 | Thanks to all of the following for their valuable suggestions 3 | or contributions. 4 | ================================================================ 5 | 6 | 7 | mixi Inc. and its developers 8 | - allowing me to develop and publish Tokyo Cabinet as business work 9 | 10 | 11 | 12 | == END OF FILE == 13 | -------------------------------------------------------------------------------- /bros/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for writing tests of DBM brothers 2 | 3 | 4 | 5 | #================================================================ 6 | # Setting variables 7 | #================================================================ 8 | 9 | 10 | # Generic settings 11 | SHELL = /bin/sh 12 | 13 | # Targets 14 | MYBINS = tctest qdbmtest ndbmtest sdbmtest gdbmtest tdbtest cdbtest bdbtest \ 15 | maptest sqltest cmpsqltctest 16 | 17 | 18 | 19 | #================================================================ 20 | # Suffix rules 21 | #================================================================ 22 | 23 | 24 | .SUFFIXES : 25 | 26 | 27 | 28 | #================================================================ 29 | # Actions 30 | #================================================================ 31 | 32 | 33 | mesg : 34 | @echo "Here are writing tests of DBM brothers." 1>&2 35 | @echo "select a target of {all clean $(MYBINS)}." 1>&2 36 | 37 | 38 | all : $(MYBINS) 39 | 40 | 41 | clean : 42 | rm -rf $(MYBINS) *.o *.exe a.out casket* *~ 43 | 44 | 45 | distclean : clean 46 | 47 | 48 | 49 | #================================================================ 50 | # Building binaries 51 | #================================================================ 52 | 53 | 54 | tctest : tctest.c 55 | LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):.:.." ; PATH="$(PATH):.:.." ; \ 56 | export LD_LIBRARY_PATH PATH ; ldflags=`tcucodec conf -l` ; \ 57 | [ -z "$$ldflags" ] && \ 58 | ldflags="-L/usr/local/lib -ltokyocabinet -lz -lpthread -lm -lc" ; \ 59 | gcc -I.. -I/usr/local/include -D_GNU_SOURCE=1 \ 60 | -Wall -ansi -pedantic -O3 -o $@ tctest.c \ 61 | -static -L. -L.. $$ldflags 62 | 63 | 64 | qdbmtest : qdbmtest.c 65 | gcc -I.. -I/usr/local/include -D_GNU_SOURCE=1 \ 66 | -Wall -ansi -pedantic -O3 -o $@ qdbmtest.c \ 67 | -static -L.. -L/usr/local/lib -lqdbm -lz -lc 68 | 69 | 70 | ndbmtest : ndbmtest.c 71 | gcc -I/usr/local/include -D_GNU_SOURCE=1 \ 72 | -Wall -ansi -pedantic -O3 -o $@ ndbmtest.c \ 73 | -static -L/usr/local/lib -lndbm -lc 74 | 75 | 76 | sdbmtest : sdbmtest.c 77 | gcc -I/usr/local/include -D_GNU_SOURCE=1 \ 78 | -Wall -ansi -pedantic -O3 -o $@ sdbmtest.c \ 79 | -static -L/usr/local/lib -lsdbm -lc 80 | 81 | 82 | gdbmtest : gdbmtest.c 83 | gcc -I/usr/local/include -D_GNU_SOURCE=1 \ 84 | -Wall -ansi -pedantic -O3 -o $@ gdbmtest.c \ 85 | -static -L/usr/local/lib -lgdbm -lc 86 | 87 | 88 | tdbtest : tdbtest.c 89 | gcc -I/usr/local/include -D_GNU_SOURCE=1 \ 90 | -Wall -ansi -pedantic -O3 -o $@ tdbtest.c \ 91 | -static -L/usr/local/lib -ltdb -lc 92 | 93 | 94 | cdbtest : cdbtest.c 95 | gcc -I/usr/local/include -D_GNU_SOURCE=1 \ 96 | -Wall -ansi -pedantic -O3 -o $@ cdbtest.c \ 97 | -static -L/usr/local/lib -lcdb -lc 98 | 99 | 100 | bdbtest : bdbtest.c 101 | gcc -I/usr/local/bdb/include -D_GNU_SOURCE=1 \ 102 | -Wall -O3 -o $@ bdbtest.c \ 103 | -static -L/usr/local/bdb/lib -ldb -lpthread -lc 104 | 105 | 106 | maptest : maptest.cc 107 | LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):.:.." ; PATH="$(PATH):.:.." ; \ 108 | export LD_LIBRARY_PATH PATH ; ldflags=`tcucodec conf -l` ; \ 109 | [ -z "$$ldflags" ] && \ 110 | ldflags="-L/usr/local/lib -ltokyocabinet -lz -lpthread -lm -lc" ; \ 111 | g++ -I.. -I/usr/local/include -D_GNU_SOURCE=1 \ 112 | -Wall -ansi -pedantic -O3 -o $@ maptest.cc \ 113 | -static -L. -L.. -lstdc++ $$ldflags 114 | 115 | 116 | sqltest : sqltest.c 117 | gcc -I/usr/local/include -D_GNU_SOURCE=1 \ 118 | -Wall -O3 -o $@ sqltest.c \ 119 | -static -L/usr/local/lib -lsqlite3 -lpthread -ldl -lc 120 | 121 | 122 | cmpsqltctest : cmpsqltctest.c 123 | LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):.:.." ; PATH="$(PATH):.:.." ; \ 124 | export LD_LIBRARY_PATH PATH ; ldflags=`tcucodec conf -l` ; \ 125 | [ -z "$$ldflags" ] && \ 126 | ldflags="-L/usr/local/lib -ltokyocabinet -lz -lpthread -lm -lc" ; \ 127 | gcc -std=c99 -I.. -I/usr/local/include -D_GNU_SOURCE=1 \ 128 | -Wall -pedantic -O3 -o $@ cmpsqltctest.c \ 129 | -static -L. -L.. -lsqlite3 -lpthread -ldl $$ldflags 130 | 131 | 132 | 133 | # END OF FILE 134 | -------------------------------------------------------------------------------- /bros/cdbtest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #undef TRUE 12 | #define TRUE 1 /* boolean true */ 13 | #undef FALSE 14 | #define FALSE 0 /* boolean false */ 15 | 16 | #define RECBUFSIZ 32 /* buffer for records */ 17 | 18 | 19 | /* global variables */ 20 | const char *progname; /* program name */ 21 | int showprgr; /* whether to show progression */ 22 | 23 | 24 | /* function prototypes */ 25 | int main(int argc, char **argv); 26 | void usage(void); 27 | int runwrite(int argc, char **argv); 28 | int runread(int argc, char **argv); 29 | int dowrite(char *name, int rnum); 30 | int doread(char *name, int rnum); 31 | 32 | 33 | /* main routine */ 34 | int main(int argc, char **argv){ 35 | int rv; 36 | progname = argv[0]; 37 | showprgr = TRUE; 38 | if(getenv("HIDEPRGR")) showprgr = FALSE; 39 | if(argc < 2) usage(); 40 | rv = 0; 41 | if(!strcmp(argv[1], "write")){ 42 | rv = runwrite(argc, argv); 43 | } else if(!strcmp(argv[1], "read")){ 44 | rv = runread(argc, argv); 45 | } else { 46 | usage(); 47 | } 48 | return rv; 49 | } 50 | 51 | 52 | /* print the usage and exit */ 53 | void usage(void){ 54 | fprintf(stderr, "%s: test cases for Constant Database\n", progname); 55 | fprintf(stderr, "\n"); 56 | fprintf(stderr, "usage:\n"); 57 | fprintf(stderr, " %s write name rnum\n", progname); 58 | fprintf(stderr, " %s read name rnum\n", progname); 59 | fprintf(stderr, "\n"); 60 | exit(1); 61 | } 62 | 63 | 64 | /* parse arguments of write command */ 65 | int runwrite(int argc, char **argv){ 66 | char *name, *rstr; 67 | int i, rnum, rv; 68 | name = NULL; 69 | rstr = NULL; 70 | rnum = 0; 71 | for(i = 2; i < argc; i++){ 72 | if(!name && argv[i][0] == '-'){ 73 | usage(); 74 | } else if(!name){ 75 | name = argv[i]; 76 | } else if(!rstr){ 77 | rstr = argv[i]; 78 | } else { 79 | usage(); 80 | } 81 | } 82 | if(!name || !rstr) usage(); 83 | rnum = atoi(rstr); 84 | if(rnum < 1) usage(); 85 | rv = dowrite(name, rnum); 86 | return rv; 87 | } 88 | 89 | 90 | /* parse arguments of read command */ 91 | int runread(int argc, char **argv){ 92 | char *name, *rstr; 93 | int i, rnum, rv; 94 | name = NULL; 95 | rstr = NULL; 96 | rnum = 0; 97 | for(i = 2; i < argc; i++){ 98 | if(!name && argv[i][0] == '-'){ 99 | usage(); 100 | } else if(!name){ 101 | name = argv[i]; 102 | } else if(!rstr){ 103 | rstr = argv[i]; 104 | } else { 105 | usage(); 106 | } 107 | } 108 | if(!name || !rstr) usage(); 109 | rnum = atoi(rstr); 110 | if(rnum < 1) usage(); 111 | rv = doread(name, rnum); 112 | return rv; 113 | } 114 | 115 | 116 | /* perform write command */ 117 | int dowrite(char *name, int rnum){ 118 | struct cdb_make cdb; 119 | int i, fd, err, len; 120 | char buf[32]; 121 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 122 | /* open a database */ 123 | if((fd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1){ 124 | perror("open"); 125 | return 1; 126 | } 127 | if(cdb_make_start(&cdb, fd) == -1){ 128 | perror("cdb_make_start"); 129 | close(fd); 130 | return 1; 131 | } 132 | err = FALSE; 133 | /* loop for each record */ 134 | for(i = 1; i <= rnum; i++){ 135 | /* store a record */ 136 | len = sprintf(buf, "%08d", i); 137 | if(cdb_make_add(&cdb, buf, len, buf, len) == -1){ 138 | perror("cdb_add"); 139 | err = TRUE; 140 | break; 141 | } 142 | /* print progression */ 143 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 144 | putchar('.'); 145 | fflush(stdout); 146 | if(i == rnum || i % (rnum / 10) == 0){ 147 | printf(" (%08d)\n", i); 148 | fflush(stdout); 149 | } 150 | } 151 | } 152 | /* close the database */ 153 | if(cdb_make_finish(&cdb) == -1){ 154 | perror("cdb_make_finish"); 155 | close(fd); 156 | return 1; 157 | } 158 | if(close(fd) == -1){ 159 | perror("close"); 160 | return 1; 161 | } 162 | if(showprgr && !err) printf("ok\n\n"); 163 | return err ? 1 : 0; 164 | } 165 | 166 | 167 | /* perform read command */ 168 | int doread(char *name, int rnum){ 169 | struct cdb cdb; 170 | int i, fd, err, len; 171 | char buf[RECBUFSIZ], *val; 172 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 173 | /* open a database */ 174 | if((fd = open(name, O_RDONLY, 0644)) == -1){ 175 | perror("open"); 176 | return 1; 177 | } 178 | cdb_init(&cdb, fd); 179 | err = FALSE; 180 | /* loop for each record */ 181 | for(i = 1; i <= rnum; i++){ 182 | /* retrieve a record */ 183 | len = sprintf(buf, "%08d", i); 184 | if(cdb_find(&cdb, buf, len) == 0){ 185 | perror("cdb_find"); 186 | err = TRUE; 187 | break; 188 | } 189 | len = cdb_datalen(&cdb); 190 | if(!(val = malloc(len + 1))){ 191 | perror("malloc"); 192 | err = TRUE; 193 | break; 194 | } 195 | cdb_read(&cdb, val, len, cdb_datapos(&cdb)); 196 | free(val); 197 | /* print progression */ 198 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 199 | putchar('.'); 200 | fflush(stdout); 201 | if(i == rnum || i % (rnum / 10) == 0){ 202 | printf(" (%08d)\n", i); 203 | fflush(stdout); 204 | } 205 | } 206 | } 207 | /* close the database */ 208 | cdb_free(&cdb); 209 | if(close(fd) == -1){ 210 | perror("close"); 211 | return 1; 212 | } 213 | if(showprgr && !err) printf("ok\n\n"); 214 | return err ? 1 : 0; 215 | } 216 | 217 | 218 | 219 | /* END OF FILE */ 220 | -------------------------------------------------------------------------------- /bros/cmpsqltctest.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************************* 2 | * Comparison test of SQLite and Tokyo Cabinet 3 | *************************************************************************************************/ 4 | 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #define SQLFILE "casket.sql" 16 | #define TCTFILE "casket.tct" 17 | #define SQLBUFSIZ 1024 18 | #define SAMPLENUM 10 19 | #define RECORDNUM 1000000 20 | 21 | 22 | /* function prototypes */ 23 | int main(int argc, char **argv); 24 | static void test_sqlite(void); 25 | static void test_tctdb(void); 26 | static int myrand(void); 27 | static int callback(void *opq, int argc, char **argv, char **colname); 28 | 29 | 30 | /* main routine */ 31 | int main(int argc, char **argv){ 32 | test_sqlite(); 33 | test_tctdb(); 34 | return 0; 35 | } 36 | 37 | 38 | /* perform SQLite test */ 39 | static void test_sqlite(void){ 40 | double sum = 0.0; 41 | for(int i = 1; i <= SAMPLENUM; i++){ 42 | unlink(SQLFILE); 43 | sync(); sync(); 44 | printf("SQLite write sample:%d ... ", i); 45 | fflush(stdout); 46 | double stime = tctime(); 47 | sqlite3 *db; 48 | if(sqlite3_open(SQLFILE, &db) != 0) assert(!__LINE__); 49 | char sql[SQLBUFSIZ], *errmsg; 50 | sprintf(sql, "CREATE TABLE tbl ( k TEXT PRIMARY KEY, a TEXT, b INTEGER," 51 | " c TEXT, d INTEGER );"); 52 | if(sqlite3_exec(db, sql, callback, 0, &errmsg) != SQLITE_OK) assert(!__LINE__); 53 | sprintf(sql, "CREATE INDEX tbl_s ON tbl ( a );"); 54 | if(sqlite3_exec(db, sql, callback, 0, &errmsg) != SQLITE_OK) assert(!__LINE__); 55 | sprintf(sql, "CREATE INDEX tbl_n ON tbl ( b );"); 56 | if(sqlite3_exec(db, sql, callback, 0, &errmsg) != SQLITE_OK) assert(!__LINE__); 57 | sprintf(sql, "PRAGMA cache_size = %d;", RECORDNUM); 58 | if(sqlite3_exec(db, sql, callback, 0, &errmsg) != SQLITE_OK) assert(!__LINE__); 59 | sprintf(sql, "BEGIN TRANSACTION;"); 60 | if(sqlite3_exec(db, sql, callback, 0, &errmsg) != SQLITE_OK) assert(!__LINE__); 61 | for(int j = 1; j <= RECORDNUM; j++){ 62 | sprintf(sql, "INSERT INTO tbl VALUES ( '%08d', '%08d', %d, '%08d', %d );", 63 | j, j, myrand() % RECORDNUM, myrand() % RECORDNUM, j); 64 | if(sqlite3_exec(db, sql, callback, 0, &errmsg) != SQLITE_OK) assert(!__LINE__); 65 | } 66 | sprintf(sql, "END TRANSACTION;"); 67 | if(sqlite3_exec(db, sql, callback, 0, &errmsg) != SQLITE_OK) assert(!__LINE__); 68 | sqlite3_close(db); 69 | double etime = tctime() - stime; 70 | printf("%.6f\n", etime); 71 | sum += etime; 72 | } 73 | printf("SQLite write average: %.6f\n", sum / SAMPLENUM); 74 | sum = 0.0; 75 | for(int i = 1; i <= SAMPLENUM; i++){ 76 | sync(); sync(); 77 | printf("SQLite read sample:%d ... ", i); 78 | fflush(stdout); 79 | double stime = tctime(); 80 | sqlite3 *db; 81 | if(sqlite3_open(SQLFILE, &db) != 0) assert(!__LINE__); 82 | char sql[SQLBUFSIZ], *errmsg; 83 | sprintf(sql, "PRAGMA cache_size = %d;", RECORDNUM); 84 | if(sqlite3_exec(db, sql, callback, 0, &errmsg) != SQLITE_OK) assert(!__LINE__); 85 | for(int j = 1; j <= RECORDNUM; j++){ 86 | sprintf(sql, "SELECT * FROM tbl WHERE a = '%08d';", myrand() % RECORDNUM + 1); 87 | if(sqlite3_exec(db, sql, callback, 0, &errmsg) != SQLITE_OK) assert(!__LINE__); 88 | } 89 | sqlite3_close(db); 90 | double etime = tctime() - stime; 91 | printf("%.6f\n", etime); 92 | sum += etime; 93 | } 94 | printf("SQLite read average: %.6f\n", sum / SAMPLENUM); 95 | } 96 | 97 | 98 | /* perform TCHDB test */ 99 | static void test_tctdb(void){ 100 | double sum = 0.0; 101 | for(int i = 1; i <= SAMPLENUM; i++){ 102 | unlink(TCTFILE); 103 | sync(); sync(); 104 | printf("TCTDB write sample:%d ... ", i); 105 | fflush(stdout); 106 | double stime = tctime(); 107 | TCTDB *tdb = tctdbnew(); 108 | if(!tctdbtune(tdb, RECORDNUM * 2, -1, -1, 0)) assert(!__LINE__); 109 | if(!tctdbsetcache(tdb, 0, RECORDNUM, RECORDNUM)) assert(!__LINE__); 110 | if(!tctdbopen(tdb, TCTFILE, TDBOWRITER | TDBOCREAT | TDBOTRUNC)) assert(!__LINE__); 111 | if(!tctdbsetindex(tdb, "a", TDBITLEXICAL)) assert(!__LINE__); 112 | if(!tctdbsetindex(tdb, "b", TDBITDECIMAL)) assert(!__LINE__); 113 | if(!tctdbtranbegin(tdb)) assert(!__LINE__); 114 | char buf[SQLBUFSIZ]; 115 | int size; 116 | for(int j = 1; j <= RECORDNUM; j++){ 117 | TCMAP *cols = tcmapnew2(7); 118 | size = sprintf(buf, "%08d", j); 119 | tcmapput(cols, "a", 1, buf, size); 120 | size = sprintf(buf, "%d", myrand() % RECORDNUM); 121 | tcmapput(cols, "b", 1, buf, size); 122 | size = sprintf(buf, "%08d", myrand() % RECORDNUM); 123 | tcmapput(cols, "c", 1, buf, size); 124 | size = sprintf(buf, "%d", j); 125 | tcmapput(cols, "d", 1, buf, size); 126 | size = sprintf(buf, "%08d", j); 127 | if(!tctdbput(tdb, buf, size, cols)) assert(!__LINE__); 128 | tcmapdel(cols); 129 | } 130 | if(!tctdbtrancommit(tdb)) assert(!__LINE__); 131 | if(!tctdbclose(tdb)) assert(!__LINE__); 132 | tctdbdel(tdb); 133 | double etime = tctime() - stime; 134 | printf("%.6f\n", etime); 135 | sum += etime; 136 | } 137 | printf("TCTDB write average: %.6f\n", sum / SAMPLENUM); 138 | sum = 0.0; 139 | for(int i = 1; i <= SAMPLENUM; i++){ 140 | sync(); sync(); 141 | printf("TCTDB read sample:%d ... ", i); 142 | fflush(stdout); 143 | double stime = tctime(); 144 | TCTDB *tdb = tctdbnew(); 145 | if(!tctdbsetcache(tdb, 0, RECORDNUM, RECORDNUM)) assert(!__LINE__); 146 | if(!tctdbopen(tdb, TCTFILE, TDBOREADER)) assert(!__LINE__); 147 | char buf[SQLBUFSIZ]; 148 | for(int j = 1; j <= RECORDNUM; j++){ 149 | TDBQRY *qry = tctdbqrynew(tdb); 150 | sprintf(buf, "%08d", myrand() % RECORDNUM + 1); 151 | tctdbqryaddcond(qry, "a", TDBQCSTREQ, buf); 152 | TCLIST *res = tctdbqrysearch(qry); 153 | for(int k = 0; k < tclistnum(res); k++){ 154 | int ksiz; 155 | const char *kbuf = tclistval(res, k, &ksiz); 156 | TCMAP *cols = tctdbget(tdb, kbuf, ksiz); 157 | if(!cols) assert(!__LINE__); 158 | tcmapdel(cols); 159 | } 160 | tclistdel(res); 161 | tctdbqrydel(qry); 162 | } 163 | if(!tctdbclose(tdb)) assert(!__LINE__); 164 | double etime = tctime() - stime; 165 | printf("%.6f\n", etime); 166 | sum += etime; 167 | } 168 | printf("TCTDB read average: %.6f\n", sum / SAMPLENUM); 169 | } 170 | 171 | 172 | /* generate a random number */ 173 | static int myrand(void){ 174 | static int cnt = 0; 175 | return (lrand48() + cnt++) & 0x7FFFFFFF; 176 | } 177 | 178 | 179 | /* iterator of SQLite */ 180 | static int callback(void *opq, int argc, char **argv, char **colname){ 181 | return 0; 182 | } 183 | 184 | 185 | 186 | /* END OF FILE */ 187 | -------------------------------------------------------------------------------- /bros/gdbmtest.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************************* 2 | * Writing test of GNU Database Manager 3 | *************************************************************************************************/ 4 | 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #undef TRUE 12 | #define TRUE 1 /* boolean true */ 13 | #undef FALSE 14 | #define FALSE 0 /* boolean false */ 15 | 16 | #define RECBUFSIZ 32 /* buffer for records */ 17 | #define CACHESIZE 16 /* cache size */ 18 | 19 | 20 | /* global variables */ 21 | const char *progname; /* program name */ 22 | int showprgr; /* whether to show progression */ 23 | 24 | 25 | /* function prototypes */ 26 | int main(int argc, char **argv); 27 | void usage(void); 28 | int runwrite(int argc, char **argv); 29 | int runread(int argc, char **argv); 30 | int dowrite(char *name, int rnum); 31 | int doread(char *name, int rnum); 32 | 33 | 34 | /* main routine */ 35 | int main(int argc, char **argv){ 36 | int rv; 37 | progname = argv[0]; 38 | showprgr = TRUE; 39 | if(getenv("HIDEPRGR")) showprgr = FALSE; 40 | if(argc < 2) usage(); 41 | rv = 0; 42 | if(!strcmp(argv[1], "write")){ 43 | rv = runwrite(argc, argv); 44 | } else if(!strcmp(argv[1], "read")){ 45 | rv = runread(argc, argv); 46 | } else { 47 | usage(); 48 | } 49 | return rv; 50 | } 51 | 52 | 53 | /* print the usage and exit */ 54 | void usage(void){ 55 | fprintf(stderr, "%s: test cases for GNU Database Manager\n", progname); 56 | fprintf(stderr, "\n"); 57 | fprintf(stderr, "usage:\n"); 58 | fprintf(stderr, " %s write name rnum\n", progname); 59 | fprintf(stderr, " %s read name rnum\n", progname); 60 | fprintf(stderr, "\n"); 61 | exit(1); 62 | } 63 | 64 | 65 | /* parse arguments of write command */ 66 | int runwrite(int argc, char **argv){ 67 | char *name, *rstr; 68 | int i, rnum, rv; 69 | name = NULL; 70 | rstr = NULL; 71 | rnum = 0; 72 | for(i = 2; i < argc; i++){ 73 | if(!name && argv[i][0] == '-'){ 74 | usage(); 75 | } else if(!name){ 76 | name = argv[i]; 77 | } else if(!rstr){ 78 | rstr = argv[i]; 79 | } else { 80 | usage(); 81 | } 82 | } 83 | if(!name || !rstr) usage(); 84 | rnum = atoi(rstr); 85 | if(rnum < 1) usage(); 86 | rv = dowrite(name, rnum); 87 | return rv; 88 | } 89 | 90 | 91 | /* parse arguments of read command */ 92 | int runread(int argc, char **argv){ 93 | char *name, *rstr; 94 | int i, rnum, rv; 95 | name = NULL; 96 | rstr = NULL; 97 | rnum = 0; 98 | for(i = 2; i < argc; i++){ 99 | if(!name && argv[i][0] == '-'){ 100 | usage(); 101 | } else if(!name){ 102 | name = argv[i]; 103 | } else if(!rstr){ 104 | rstr = argv[i]; 105 | } else { 106 | usage(); 107 | } 108 | } 109 | if(!name || !rstr) usage(); 110 | rnum = atoi(rstr); 111 | if(rnum < 1) usage(); 112 | rv = doread(name, rnum); 113 | return rv; 114 | } 115 | 116 | 117 | /* perform write command */ 118 | int dowrite(char *name, int rnum){ 119 | GDBM_FILE dbf; 120 | datum key, content; 121 | int i, err, optval, len; 122 | char buf[RECBUFSIZ]; 123 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 124 | /* open a database */ 125 | if(!(dbf = gdbm_open(name, 0, GDBM_NEWDB, 00644, NULL))){ 126 | fprintf(stderr, "gdbm_open failed\n"); 127 | return 1; 128 | } 129 | optval = CACHESIZE; 130 | if(gdbm_setopt(dbf, GDBM_CACHESIZE, &optval, sizeof(int)) != 0){ 131 | fprintf(stderr, "gdbm_setopt failed\n"); 132 | gdbm_close(dbf); 133 | return 1; 134 | } 135 | err = FALSE; 136 | /* loop for each record */ 137 | for(i = 1; i <= rnum; i++){ 138 | len = sprintf(buf, "%08d", i); 139 | key.dptr = buf; 140 | key.dsize = len; 141 | content.dptr = buf; 142 | content.dsize = len; 143 | /* store a record */ 144 | if(gdbm_store(dbf, key, content, GDBM_REPLACE) != 0){ 145 | fprintf(stderr, "gdbm_store failed\n"); 146 | err = TRUE; 147 | break; 148 | } 149 | /* print progression */ 150 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 151 | putchar('.'); 152 | fflush(stdout); 153 | if(i == rnum || i % (rnum / 10) == 0){ 154 | printf(" (%08d)\n", i); 155 | fflush(stdout); 156 | } 157 | } 158 | } 159 | /* close the database */ 160 | gdbm_close(dbf); 161 | if(showprgr && !err) printf("ok\n\n"); 162 | return err ? 1 : 0; 163 | } 164 | 165 | 166 | /* perform read command */ 167 | int doread(char *name, int rnum){ 168 | GDBM_FILE dbf; 169 | datum key, content; 170 | int i, err, optval, len; 171 | char buf[RECBUFSIZ]; 172 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 173 | /* open a database */ 174 | if(!(dbf = gdbm_open(name, 0, GDBM_READER, 00644, NULL))){ 175 | fprintf(stderr, "gdbm_open failed\n"); 176 | return 1; 177 | } 178 | optval = CACHESIZE; 179 | if(gdbm_setopt(dbf, GDBM_CACHESIZE, &optval, sizeof(int)) != 0){ 180 | fprintf(stderr, "gdbm_setopt failed\n"); 181 | gdbm_close(dbf); 182 | return 1; 183 | } 184 | err = FALSE; 185 | /* loop for each record */ 186 | for(i = 1; i <= rnum; i++){ 187 | /* retrieve a record */ 188 | len = sprintf(buf, "%08d", i); 189 | key.dptr = buf; 190 | key.dsize = len; 191 | content = gdbm_fetch(dbf, key); 192 | if(!content.dptr){ 193 | fprintf(stderr, "gdbm_fetch failed\n"); 194 | err = TRUE; 195 | break; 196 | } 197 | free(content.dptr); 198 | /* print progression */ 199 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 200 | putchar('.'); 201 | fflush(stdout); 202 | if(i == rnum || i % (rnum / 10) == 0){ 203 | printf(" (%08d)\n", i); 204 | fflush(stdout); 205 | } 206 | } 207 | } 208 | /* close the database */ 209 | gdbm_close(dbf); 210 | if(showprgr && !err) printf("ok\n\n"); 211 | return err ? 1 : 0; 212 | } 213 | 214 | 215 | 216 | /* END OF FILE */ 217 | -------------------------------------------------------------------------------- /bros/mapreporter: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | #================================================================ 4 | # mapreporter 5 | # Measure elapsed time of map utilities 6 | #================================================================ 7 | 8 | use strict; 9 | use warnings; 10 | use Time::HiRes qw(gettimeofday); 11 | 12 | use constant { 13 | RECNUM => 1000000, 14 | TESTCOUNT => 20, 15 | REMOVETOP => 2, 16 | REMOVEBOTTOM => 8, 17 | }; 18 | 19 | my @commands = ( 20 | "./maptest tcmap " . RECNUM, 21 | "./maptest tctree " . RECNUM, 22 | "./maptest stlmap " . RECNUM, 23 | "./maptest stlmmap " . RECNUM, 24 | "./maptest stlset " . RECNUM, 25 | "./maptest gnuhash " . RECNUM, 26 | "./maptest ggldh " . RECNUM, 27 | "./maptest gglsh " . RECNUM, 28 | "./maptest tcmap -rd " . RECNUM, 29 | "./maptest tctree -rd " . RECNUM, 30 | "./maptest stlmap -rd " . RECNUM, 31 | "./maptest stlmmap -rd " . RECNUM, 32 | "./maptest stlset -rd " . RECNUM, 33 | "./maptest gnuhash -rd " . RECNUM, 34 | "./maptest ggldh -rd " . RECNUM, 35 | "./maptest gglsh -rd " . RECNUM, 36 | ); 37 | 38 | my @table; 39 | foreach my $command (@commands){ 40 | system("sync ; sync"); 41 | my @result; 42 | for(my $i = 0; $i < TESTCOUNT; $i++){ 43 | my $stime = gettimeofday(); 44 | system("$command >/dev/null 2>&1"); 45 | $stime = gettimeofday() - $stime; 46 | printf("%s\t%d\t%0.5f\n", $command, $i + 1, $stime); 47 | push(@result, $stime); 48 | } 49 | @result = sort { $a <=> $b } @result; 50 | for(my $i = 0; $i < REMOVETOP; $i++){ 51 | shift(@result); 52 | } 53 | for(my $i = 0; $i < REMOVEBOTTOM; $i++){ 54 | pop(@result); 55 | } 56 | my $sum = 0; 57 | foreach my $result (@result){ 58 | $sum += $result; 59 | } 60 | my $avg = $sum / scalar(@result); 61 | push(@table, [$command, $avg]); 62 | } 63 | 64 | printf("\n\nRESULT\n"); 65 | foreach my $row (@table){ 66 | printf("%s\t%0.5f\n", $$row[0], $$row[1]); 67 | } 68 | printf("\n"); 69 | 70 | 71 | 72 | # END OF FILE 73 | -------------------------------------------------------------------------------- /bros/ndbmtest.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************************* 2 | * Writing test of New Database Manager 3 | *************************************************************************************************/ 4 | 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #undef TRUE 14 | #define TRUE 1 /* boolean true */ 15 | #undef FALSE 16 | #define FALSE 0 /* boolean false */ 17 | 18 | #define RECBUFSIZ 32 /* buffer for records */ 19 | 20 | 21 | /* global variables */ 22 | const char *progname; /* program name */ 23 | int showprgr; /* whether to show progression */ 24 | 25 | 26 | /* function prototypes */ 27 | int main(int argc, char **argv); 28 | void usage(void); 29 | int runwrite(int argc, char **argv); 30 | int runread(int argc, char **argv); 31 | int dowrite(char *name, int rnum); 32 | int doread(char *name, int rnum); 33 | 34 | 35 | /* main routine */ 36 | int main(int argc, char **argv){ 37 | int rv; 38 | progname = argv[0]; 39 | showprgr = TRUE; 40 | if(getenv("HIDEPRGR")) showprgr = FALSE; 41 | if(argc < 2) usage(); 42 | rv = 0; 43 | if(!strcmp(argv[1], "write")){ 44 | rv = runwrite(argc, argv); 45 | } else if(!strcmp(argv[1], "read")){ 46 | rv = runread(argc, argv); 47 | } else { 48 | usage(); 49 | } 50 | return rv; 51 | } 52 | 53 | 54 | /* print the usage and exit */ 55 | void usage(void){ 56 | fprintf(stderr, "%s: test cases for New Database Manager\n", progname); 57 | fprintf(stderr, "\n"); 58 | fprintf(stderr, "usage:\n"); 59 | fprintf(stderr, " %s write name rnum\n", progname); 60 | fprintf(stderr, " %s read name rnum\n", progname); 61 | fprintf(stderr, "\n"); 62 | exit(1); 63 | } 64 | 65 | 66 | /* parse arguments of write command */ 67 | int runwrite(int argc, char **argv){ 68 | char *name, *rstr; 69 | int i, rnum, rv; 70 | name = NULL; 71 | rstr = NULL; 72 | rnum = 0; 73 | for(i = 2; i < argc; i++){ 74 | if(!name && argv[i][0] == '-'){ 75 | usage(); 76 | } else if(!name){ 77 | name = argv[i]; 78 | } else if(!rstr){ 79 | rstr = argv[i]; 80 | } else { 81 | usage(); 82 | } 83 | } 84 | if(!name || !rstr) usage(); 85 | rnum = atoi(rstr); 86 | if(rnum < 1) usage(); 87 | rv = dowrite(name, rnum); 88 | return rv; 89 | } 90 | 91 | 92 | /* parse arguments of read command */ 93 | int runread(int argc, char **argv){ 94 | char *name, *rstr; 95 | int i, rnum, rv; 96 | name = NULL; 97 | rstr = NULL; 98 | rnum = 0; 99 | for(i = 2; i < argc; i++){ 100 | if(!name && argv[i][0] == '-'){ 101 | usage(); 102 | } else if(!name){ 103 | name = argv[i]; 104 | } else if(!rstr){ 105 | rstr = argv[i]; 106 | } else { 107 | usage(); 108 | } 109 | } 110 | if(!name || !rstr) usage(); 111 | rnum = atoi(rstr); 112 | if(rnum < 1) usage(); 113 | rv = doread(name, rnum); 114 | return rv; 115 | } 116 | 117 | 118 | /* perform write command */ 119 | int dowrite(char *name, int rnum){ 120 | DBM *db; 121 | datum key, content; 122 | int i, err, len; 123 | char buf[RECBUFSIZ]; 124 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 125 | /* open a database */ 126 | if(!(db = dbm_open(name, O_RDWR | O_CREAT | O_TRUNC, 00644))){ 127 | fprintf(stderr, "dbm_open failed\n"); 128 | return 1; 129 | } 130 | err = FALSE; 131 | /* loop for each record */ 132 | for(i = 1; i <= rnum; i++){ 133 | len = sprintf(buf, "%08d", i); 134 | key.dptr = buf; 135 | key.dsize = len; 136 | content.dptr = buf; 137 | content.dsize = len; 138 | /* store a record */ 139 | if(dbm_store(db, key, content, DBM_REPLACE) < 0){ 140 | fprintf(stderr, "dbm_store failed\n"); 141 | err = TRUE; 142 | break; 143 | } 144 | /* print progression */ 145 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 146 | putchar('.'); 147 | fflush(stdout); 148 | if(i == rnum || i % (rnum / 10) == 0){ 149 | printf(" (%08d)\n", i); 150 | fflush(stdout); 151 | } 152 | } 153 | } 154 | /* close the database */ 155 | dbm_close(db); 156 | if(showprgr && !err) printf("ok\n\n"); 157 | return err ? 1 : 0; 158 | } 159 | 160 | 161 | /* perform read command */ 162 | int doread(char *name, int rnum){ 163 | DBM *db; 164 | datum key, content; 165 | int i, err, len; 166 | char buf[RECBUFSIZ]; 167 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 168 | /* open a database */ 169 | if(!(db = dbm_open(name, O_RDONLY, 00644))){ 170 | fprintf(stderr, "dbm_open failed\n"); 171 | return 1; 172 | } 173 | err = FALSE; 174 | /* loop for each record */ 175 | for(i = 1; i <= rnum; i++){ 176 | /* retrieve a record */ 177 | len = sprintf(buf, "%08d", i); 178 | key.dptr = buf; 179 | key.dsize = len; 180 | content = dbm_fetch(db, key); 181 | if(!content.dptr){ 182 | fprintf(stderr, "dbm_fetch failed\n"); 183 | err = TRUE; 184 | break; 185 | } 186 | /* print progression */ 187 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 188 | putchar('.'); 189 | fflush(stdout); 190 | if(i == rnum || i % (rnum / 10) == 0){ 191 | printf(" (%08d)\n", i); 192 | fflush(stdout); 193 | } 194 | } 195 | } 196 | /* close the database */ 197 | dbm_close(db); 198 | if(showprgr && !err) printf("ok\n\n"); 199 | return err ? 1 : 0; 200 | } 201 | 202 | 203 | 204 | /* END OF FILE */ 205 | -------------------------------------------------------------------------------- /bros/qdbmtest.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************************* 2 | * Writing test of Quick Database Manager 3 | *************************************************************************************************/ 4 | 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #undef TRUE 14 | #define TRUE 1 /* boolean true */ 15 | #undef FALSE 16 | #define FALSE 0 /* boolean false */ 17 | 18 | #define RECBUFSIZ 32 /* buffer for records */ 19 | 20 | 21 | /* global variables */ 22 | const char *progname; /* program name */ 23 | int showprgr; /* whether to show progression */ 24 | 25 | 26 | /* function prototypes */ 27 | int main(int argc, char **argv); 28 | void usage(void); 29 | int runwrite(int argc, char **argv); 30 | int runread(int argc, char **argv); 31 | int runbtwrite(int argc, char **argv); 32 | int runbtread(int argc, char **argv); 33 | int myrand(void); 34 | int dowrite(char *name, int rnum); 35 | int doread(char *name, int rnum); 36 | int dobtwrite(char *name, int rnum, int rnd); 37 | int dobtread(char *name, int rnum, int rnd); 38 | 39 | 40 | /* main routine */ 41 | int main(int argc, char **argv){ 42 | int rv; 43 | progname = argv[0]; 44 | showprgr = TRUE; 45 | if(getenv("HIDEPRGR")) showprgr = FALSE; 46 | srand48(1978); 47 | if(argc < 2) usage(); 48 | rv = 0; 49 | if(!strcmp(argv[1], "write")){ 50 | rv = runwrite(argc, argv); 51 | } else if(!strcmp(argv[1], "read")){ 52 | rv = runread(argc, argv); 53 | } else if(!strcmp(argv[1], "btwrite")){ 54 | rv = runbtwrite(argc, argv); 55 | } else if(!strcmp(argv[1], "btread")){ 56 | rv = runbtread(argc, argv); 57 | } else { 58 | usage(); 59 | } 60 | return rv; 61 | } 62 | 63 | 64 | /* print the usage and exit */ 65 | void usage(void){ 66 | fprintf(stderr, "%s: test cases for Quick Database Manager\n", progname); 67 | fprintf(stderr, "\n"); 68 | fprintf(stderr, "usage:\n"); 69 | fprintf(stderr, " %s write name rnum\n", progname); 70 | fprintf(stderr, " %s read name rnum\n", progname); 71 | fprintf(stderr, " %s btwrite [-rnd] name rnum\n", progname); 72 | fprintf(stderr, " %s btread [-rnd] name rnum\n", progname); 73 | fprintf(stderr, "\n"); 74 | exit(1); 75 | } 76 | 77 | 78 | /* parse arguments of write command */ 79 | int runwrite(int argc, char **argv){ 80 | char *name, *rstr; 81 | int i, rnum, rv; 82 | name = NULL; 83 | rstr = NULL; 84 | rnum = 0; 85 | for(i = 2; i < argc; i++){ 86 | if(!name && argv[i][0] == '-'){ 87 | usage(); 88 | } else if(!name){ 89 | name = argv[i]; 90 | } else if(!rstr){ 91 | rstr = argv[i]; 92 | } else { 93 | usage(); 94 | } 95 | } 96 | if(!name || !rstr) usage(); 97 | rnum = atoi(rstr); 98 | if(rnum < 1) usage(); 99 | rv = dowrite(name, rnum); 100 | return rv; 101 | } 102 | 103 | 104 | /* parse arguments of read command */ 105 | int runread(int argc, char **argv){ 106 | char *name, *rstr; 107 | int i, rnum, rv; 108 | name = NULL; 109 | rstr = NULL; 110 | rnum = 0; 111 | for(i = 2; i < argc; i++){ 112 | if(!name && argv[i][0] == '-'){ 113 | usage(); 114 | } else if(!name){ 115 | name = argv[i]; 116 | } else if(!rstr){ 117 | rstr = argv[i]; 118 | } else { 119 | usage(); 120 | } 121 | } 122 | if(!name || !rstr) usage(); 123 | rnum = atoi(rstr); 124 | if(rnum < 1) usage(); 125 | rv = doread(name, rnum); 126 | return rv; 127 | } 128 | 129 | 130 | /* parse arguments of btwrite command */ 131 | int runbtwrite(int argc, char **argv){ 132 | char *name, *rstr; 133 | int i, rnum, rnd, rv; 134 | name = NULL; 135 | rstr = NULL; 136 | rnum = 0; 137 | rnd = FALSE; 138 | for(i = 2; i < argc; i++){ 139 | if(!name && argv[i][0] == '-'){ 140 | if(!name && !strcmp(argv[i], "-rnd")){ 141 | rnd = TRUE; 142 | } else { 143 | usage(); 144 | } 145 | } else if(!name){ 146 | name = argv[i]; 147 | } else if(!rstr){ 148 | rstr = argv[i]; 149 | } else { 150 | usage(); 151 | } 152 | } 153 | if(!name || !rstr) usage(); 154 | rnum = atoi(rstr); 155 | if(rnum < 1) usage(); 156 | rv = dobtwrite(name, rnum, rnd); 157 | return rv; 158 | } 159 | 160 | 161 | /* parse arguments of btread command */ 162 | int runbtread(int argc, char **argv){ 163 | char *name, *rstr; 164 | int i, rnum, rnd, rv; 165 | name = NULL; 166 | rstr = NULL; 167 | rnum = 0; 168 | rnd = FALSE; 169 | for(i = 2; i < argc; i++){ 170 | if(!name && argv[i][0] == '-'){ 171 | if(!name && !strcmp(argv[i], "-rnd")){ 172 | rnd = TRUE; 173 | } else { 174 | usage(); 175 | } 176 | } else if(!name){ 177 | name = argv[i]; 178 | } else if(!rstr){ 179 | rstr = argv[i]; 180 | } else { 181 | usage(); 182 | } 183 | } 184 | if(!name || !rstr) usage(); 185 | rnum = atoi(rstr); 186 | if(rnum < 1) usage(); 187 | rv = dobtread(name, rnum, rnd); 188 | return rv; 189 | } 190 | 191 | 192 | /* pseudo random number generator */ 193 | int myrand(void){ 194 | static int cnt = 0; 195 | return (lrand48() + cnt++) & 0x7FFFFFFF; 196 | } 197 | 198 | 199 | /* perform write command */ 200 | int dowrite(char *name, int rnum){ 201 | DEPOT *depot; 202 | int i, err, len; 203 | char buf[RECBUFSIZ]; 204 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 205 | /* open a database */ 206 | if(!(depot = dpopen(name, DP_OWRITER | DP_OCREAT | DP_OTRUNC, rnum * 3))){ 207 | fprintf(stderr, "dpopen failed\n"); 208 | return 1; 209 | } 210 | err = FALSE; 211 | /* loop for each record */ 212 | for(i = 1; i <= rnum; i++){ 213 | /* store a record */ 214 | len = sprintf(buf, "%08d", i); 215 | if(!dpput(depot, buf, len, buf, len, DP_DOVER)){ 216 | fprintf(stderr, "dpput failed\n"); 217 | err = TRUE; 218 | break; 219 | } 220 | /* print progression */ 221 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 222 | putchar('.'); 223 | fflush(stdout); 224 | if(i == rnum || i % (rnum / 10) == 0){ 225 | printf(" (%08d)\n", i); 226 | fflush(stdout); 227 | } 228 | } 229 | } 230 | /* close the database */ 231 | if(!dpclose(depot)){ 232 | fprintf(stderr, "dpclose failed\n"); 233 | return 1; 234 | } 235 | if(showprgr && !err) printf("ok\n\n"); 236 | return err ? 1 : 0; 237 | } 238 | 239 | 240 | /* perform read command */ 241 | int doread(char *name, int rnum){ 242 | DEPOT *depot; 243 | int i, err, len; 244 | char buf[RECBUFSIZ], vbuf[RECBUFSIZ]; 245 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 246 | /* open a database */ 247 | if(!(depot = dpopen(name, DP_OREADER, -1))){ 248 | fprintf(stderr, "dpopen failed\n"); 249 | return 1; 250 | } 251 | err = FALSE; 252 | /* loop for each record */ 253 | for(i = 1; i <= rnum; i++){ 254 | /* store a record */ 255 | len = sprintf(buf, "%08d", i); 256 | if(dpgetwb(depot, buf, len, 0, RECBUFSIZ, vbuf) == -1){ 257 | fprintf(stderr, "dpget failed\n"); 258 | err = TRUE; 259 | break; 260 | } 261 | /* print progression */ 262 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 263 | putchar('.'); 264 | fflush(stdout); 265 | if(i == rnum || i % (rnum / 10) == 0){ 266 | printf(" (%08d)\n", i); 267 | fflush(stdout); 268 | } 269 | } 270 | } 271 | /* close the database */ 272 | if(!dpclose(depot)){ 273 | fprintf(stderr, "dpclose failed\n"); 274 | return 1; 275 | } 276 | if(showprgr && !err) printf("ok\n\n"); 277 | return err ? 1 : 0; 278 | } 279 | 280 | 281 | /* perform btwrite command */ 282 | int dobtwrite(char *name, int rnum, int rnd){ 283 | VILLA *villa; 284 | int i, err, len; 285 | char buf[RECBUFSIZ]; 286 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 287 | /* open a database */ 288 | if(!(villa = vlopen(name, VL_OWRITER | VL_OCREAT | VL_OTRUNC, VL_CMPLEX))){ 289 | fprintf(stderr, "vlopen failed\n"); 290 | return 1; 291 | } 292 | if(rnd){ 293 | vlsettuning(villa, 77, 256, rnum / 77, -1); 294 | } else { 295 | vlsettuning(villa, 101, 256, 16, 16); 296 | } 297 | err = FALSE; 298 | /* loop for each record */ 299 | for(i = 1; i <= rnum; i++){ 300 | /* store a record */ 301 | len = sprintf(buf, "%08d", rnd ? myrand() % rnum + 1 : i); 302 | if(!vlput(villa, buf, len, buf, len, VL_DOVER)){ 303 | fprintf(stderr, "vlput failed\n"); 304 | err = TRUE; 305 | break; 306 | } 307 | /* print progression */ 308 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 309 | putchar('.'); 310 | fflush(stdout); 311 | if(i == rnum || i % (rnum / 10) == 0){ 312 | printf(" (%08d)\n", i); 313 | fflush(stdout); 314 | } 315 | } 316 | } 317 | /* close the database */ 318 | if(!vlclose(villa)){ 319 | fprintf(stderr, "vlclose failed\n"); 320 | return 1; 321 | } 322 | if(showprgr && !err) printf("ok\n\n"); 323 | return err ? 1 : 0; 324 | } 325 | 326 | 327 | /* perform btread command */ 328 | int dobtread(char *name, int rnum, int rnd){ 329 | VILLA *villa; 330 | int i, err, len; 331 | const char *val; 332 | char buf[RECBUFSIZ]; 333 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 334 | /* open a database */ 335 | if(!(villa = vlopen(name, VL_OREADER, VL_CMPLEX))){ 336 | fprintf(stderr, "vlopen failed\n"); 337 | return 1; 338 | } 339 | if(rnd){ 340 | vlsettuning(villa, 37, 200, rnum / 45, 512); 341 | } else { 342 | vlsettuning(villa, 101, 256, 16, 16); 343 | } 344 | err = FALSE; 345 | /* loop for each record */ 346 | for(i = 1; i <= rnum; i++){ 347 | /* store a record */ 348 | len = sprintf(buf, "%08d", rnd ? myrand() % rnum + 1 : i); 349 | if(!(val = vlgetcache(villa, buf, len, NULL))){ 350 | fprintf(stderr, "vlget failed\n"); 351 | err = TRUE; 352 | break; 353 | } 354 | /* print progression */ 355 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 356 | putchar('.'); 357 | fflush(stdout); 358 | if(i == rnum || i % (rnum / 10) == 0){ 359 | printf(" (%08d)\n", i); 360 | fflush(stdout); 361 | } 362 | } 363 | } 364 | /* close the database */ 365 | if(!vlclose(villa)){ 366 | fprintf(stderr, "vlclose failed\n"); 367 | return 1; 368 | } 369 | if(showprgr && !err) printf("ok\n\n"); 370 | return err ? 1 : 0; 371 | } 372 | 373 | 374 | 375 | /* END OF FILE */ 376 | -------------------------------------------------------------------------------- /bros/reporter: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | #================================================================ 4 | # reporter 5 | # Measure elapsed time and database size of DBM brothers 6 | #================================================================ 7 | 8 | use strict; 9 | use warnings; 10 | use Time::HiRes qw(gettimeofday); 11 | 12 | use constant { 13 | RECNUM => 1000000, 14 | TESTCOUNT => 20, 15 | REMOVETOP => 2, 16 | REMOVEBOTTOM => 8, 17 | }; 18 | 19 | my @commands = ( 20 | './tctest write casket.tch ' . RECNUM, 21 | './tctest read casket.tch ' . RECNUM, 22 | './qdbmtest write casket.qdbh ' . RECNUM, 23 | './qdbmtest read casket.qdbh ' . RECNUM, 24 | './ndbmtest write casket.ndbh ' . RECNUM, 25 | './ndbmtest read casket.ndbh ' . RECNUM, 26 | './sdbmtest write casket.sdbh ' . RECNUM, 27 | './sdbmtest read casket.sdbh ' . RECNUM, 28 | './gdbmtest write casket.gdbh ' . RECNUM, 29 | './gdbmtest read casket.gdbh ' . RECNUM, 30 | './tdbtest write casket.tdbh ' . RECNUM, 31 | './tdbtest read casket.tdbh ' . RECNUM, 32 | './cdbtest write casket.cdbh ' . RECNUM, 33 | './cdbtest read casket.cdbh ' . RECNUM, 34 | './bdbtest write casket.bdbh ' . RECNUM, 35 | './bdbtest read casket.bdbh ' . RECNUM, 36 | './tctest btwrite casket.tcb ' . RECNUM, 37 | './tctest btread casket.tcb ' . RECNUM, 38 | './tctest btwrite -rnd casket.tcb_r ' . RECNUM, 39 | './tctest btread -rnd casket.tcb_r ' . RECNUM, 40 | './qdbmtest btwrite casket.qdbb ' . RECNUM, 41 | './qdbmtest btread casket.qdbb ' . RECNUM, 42 | './qdbmtest btwrite -rnd casket.qdbb_r ' . RECNUM, 43 | './qdbmtest btread -rnd casket.qdbb_r ' . RECNUM, 44 | './bdbtest btwrite casket.bdbb ' . RECNUM, 45 | './bdbtest btread casket.bdbb ' . RECNUM, 46 | './bdbtest btwrite -rnd casket.bdbb_r ' . RECNUM, 47 | './bdbtest btread -rnd casket.bdbb_r ' . RECNUM, 48 | './tctest flwrite casket.tcf ' . RECNUM, 49 | './tctest flread casket.tcf ' . RECNUM, 50 | ); 51 | 52 | my @names = ( 53 | 'casket.tch', 54 | 'casket.qdbh', 55 | 'casket.ndbh', 56 | 'casket.sdbh', 57 | 'casket.gdbh', 58 | 'casket.tdbh', 59 | 'casket.cdbh', 60 | 'casket.bdbh', 61 | 'casket.tcb', 62 | 'casket.tcb_r', 63 | 'casket.qdbb', 64 | 'casket.qdbb_r', 65 | 'casket.bdbb', 66 | 'casket.bdbb_r', 67 | 'casket.tcf', 68 | ); 69 | 70 | foreach my $name (@names){ 71 | my @paths = glob("$name*"); 72 | foreach my $path (@paths){ 73 | unlink($path); 74 | } 75 | } 76 | 77 | my @table; 78 | foreach my $command (@commands){ 79 | system('sync ; sync'); 80 | $ENV{'HIDEPRGR'} = 1; 81 | my @result; 82 | for(my $i = 0; $i < TESTCOUNT; $i++){ 83 | my $stime = gettimeofday(); 84 | system("$command >/dev/null 2>&1"); 85 | $stime = gettimeofday() - $stime; 86 | printf("%s\t%d\t%0.5f\n", $command, $i + 1, $stime); 87 | push(@result, $stime); 88 | } 89 | @result = sort { $a <=> $b } @result; 90 | for(my $i = 0; $i < REMOVETOP; $i++){ 91 | shift(@result); 92 | } 93 | for(my $i = 0; $i < REMOVEBOTTOM; $i++){ 94 | pop(@result); 95 | } 96 | my $sum = 0; 97 | foreach my $result (@result){ 98 | $sum += $result; 99 | } 100 | my $avg = $sum / scalar(@result); 101 | push(@table, [$command, $avg]); 102 | } 103 | 104 | printf("\n\nRESULT\n\n"); 105 | foreach my $row (@table){ 106 | printf("%s\t%0.5f\n", $$row[0], $$row[1]); 107 | } 108 | printf("\n"); 109 | 110 | my @sizes; 111 | foreach my $name (@names){ 112 | my @paths = glob("$name*"); 113 | my $sum = 0; 114 | foreach my $path (@paths){ 115 | my @sbuf = stat($path); 116 | $sum += $sbuf[7]; 117 | } 118 | printf("%s\t%s\n", $name, $sum); 119 | push(@sizes, $sum); 120 | } 121 | printf("\n"); 122 | 123 | printf("%s,%.5f,%.5f,%d\n", "TC", $table[0][1], $table[1][1], $sizes[0]); 124 | printf("%s,%.5f,%.5f,%d\n", "QDBM", $table[2][1], $table[3][1], $sizes[1]); 125 | printf("%s,%.5f,%.5f,%d\n", "NDBM", $table[4][1], $table[5][1], $sizes[2]); 126 | printf("%s,%.5f,%.5f,%d\n", "SDBM", $table[6][1], $table[7][1], $sizes[3]); 127 | printf("%s,%.5f,%.5f,%d\n", "GDBM", $table[8][1], $table[9][1], $sizes[4]); 128 | printf("%s,%.5f,%.5f,%d\n", "TDB", $table[10][1], $table[11][1], $sizes[5]); 129 | printf("%s,%.5f,%.5f,%d\n", "CDB", $table[12][1], $table[13][1], $sizes[6]); 130 | printf("%s,%.5f,%.5f,%d\n", "BDB", $table[14][1], $table[15][1], $sizes[7]); 131 | printf("%s,%.5f,%.5f,%d\n", "TC-BT-ASC", $table[16][1], $table[17][1], $sizes[8]); 132 | printf("%s,%.5f,%.5f,%d\n", "TC-BT-RND", $table[18][1], $table[19][1], $sizes[9]); 133 | printf("%s,%.5f,%.5f,%d\n", "QDBM-BT-ASC", $table[20][1], $table[21][1], $sizes[10]); 134 | printf("%s,%.5f,%.5f,%d\n", "QDBM-BT-RND", $table[22][1], $table[23][1], $sizes[11]); 135 | printf("%s,%.5f,%.5f,%d\n", "BDB-BT-ASC", $table[24][1], $table[25][1], $sizes[12]); 136 | printf("%s,%.5f,%.5f,%d\n", "BDB-BT-RND", $table[26][1], $table[27][1], $sizes[13]); 137 | printf("%s,%.5f,%.5f,%d\n", "TC-FIXED", $table[28][1], $table[29][1], $sizes[14]); 138 | 139 | 140 | 141 | # END OF FILE 142 | -------------------------------------------------------------------------------- /bros/result.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clement/tokyo-cabinet/5cb3d3fc93b04b0738298727255ac1b9ba29920f/bros/result.xls -------------------------------------------------------------------------------- /bros/sdbmtest.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************************* 2 | * Writing test of Substitute Database Manager 3 | *************************************************************************************************/ 4 | 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #undef TRUE 14 | #define TRUE 1 /* boolean true */ 15 | #undef FALSE 16 | #define FALSE 0 /* boolean false */ 17 | 18 | #define RECBUFSIZ 32 /* buffer for records */ 19 | 20 | 21 | /* global variables */ 22 | const char *progname; /* program name */ 23 | int showprgr; /* whether to show progression */ 24 | 25 | 26 | /* function prototypes */ 27 | int main(int argc, char **argv); 28 | void usage(void); 29 | int runwrite(int argc, char **argv); 30 | int runread(int argc, char **argv); 31 | int dowrite(char *name, int rnum); 32 | int doread(char *name, int rnum); 33 | 34 | 35 | /* main routine */ 36 | int main(int argc, char **argv){ 37 | int rv; 38 | progname = argv[0]; 39 | showprgr = TRUE; 40 | if(getenv("HIDEPRGR")) showprgr = FALSE; 41 | if(argc < 2) usage(); 42 | rv = 0; 43 | if(!strcmp(argv[1], "write")){ 44 | rv = runwrite(argc, argv); 45 | } else if(!strcmp(argv[1], "read")){ 46 | rv = runread(argc, argv); 47 | } else { 48 | usage(); 49 | } 50 | return rv; 51 | } 52 | 53 | 54 | /* print the usage and exit */ 55 | void usage(void){ 56 | fprintf(stderr, "%s: test cases for Substitute Database Manager\n", progname); 57 | fprintf(stderr, "\n"); 58 | fprintf(stderr, "usage:\n"); 59 | fprintf(stderr, " %s write name rnum\n", progname); 60 | fprintf(stderr, " %s read name rnum\n", progname); 61 | fprintf(stderr, "\n"); 62 | exit(1); 63 | } 64 | 65 | 66 | /* parse arguments of write command */ 67 | int runwrite(int argc, char **argv){ 68 | char *name, *rstr; 69 | int i, rnum, rv; 70 | name = NULL; 71 | rstr = NULL; 72 | rnum = 0; 73 | for(i = 2; i < argc; i++){ 74 | if(!name && argv[i][0] == '-'){ 75 | usage(); 76 | } else if(!name){ 77 | name = argv[i]; 78 | } else if(!rstr){ 79 | rstr = argv[i]; 80 | } else { 81 | usage(); 82 | } 83 | } 84 | if(!name || !rstr) usage(); 85 | rnum = atoi(rstr); 86 | if(rnum < 1) usage(); 87 | rv = dowrite(name, rnum); 88 | return rv; 89 | } 90 | 91 | 92 | /* parse arguments of read command */ 93 | int runread(int argc, char **argv){ 94 | char *name, *rstr; 95 | int i, rnum, rv; 96 | name = NULL; 97 | rstr = NULL; 98 | rnum = 0; 99 | for(i = 2; i < argc; i++){ 100 | if(!name && argv[i][0] == '-'){ 101 | usage(); 102 | } else if(!name){ 103 | name = argv[i]; 104 | } else if(!rstr){ 105 | rstr = argv[i]; 106 | } else { 107 | usage(); 108 | } 109 | } 110 | if(!name || !rstr) usage(); 111 | rnum = atoi(rstr); 112 | if(rnum < 1) usage(); 113 | rv = doread(name, rnum); 114 | return rv; 115 | } 116 | 117 | 118 | /* perform write command */ 119 | int dowrite(char *name, int rnum){ 120 | DBM *db; 121 | datum key, val; 122 | int i, err, len; 123 | char buf[RECBUFSIZ]; 124 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 125 | /* open a database */ 126 | if(!(db = dbm_open(name, O_RDWR | O_CREAT | O_TRUNC, 00644))){ 127 | fprintf(stderr, "dbm_open failed\n"); 128 | return 1; 129 | } 130 | err = FALSE; 131 | /* loop for each record */ 132 | for(i = 1; i <= rnum; i++){ 133 | len = sprintf(buf, "%08d", i); 134 | key.dptr = buf; 135 | key.dsize = len; 136 | val.dptr = buf; 137 | val.dsize = len; 138 | /* store a record */ 139 | if(dbm_store(db, key, val, DBM_REPLACE) < 0){ 140 | fprintf(stderr, "dbm_store failed\n"); 141 | err = TRUE; 142 | break; 143 | } 144 | /* print progression */ 145 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 146 | putchar('.'); 147 | fflush(stdout); 148 | if(i == rnum || i % (rnum / 10) == 0){ 149 | printf(" (%08d)\n", i); 150 | fflush(stdout); 151 | } 152 | } 153 | } 154 | /* close the database */ 155 | dbm_close(db); 156 | if(showprgr && !err) printf("ok\n\n"); 157 | return err ? 1 : 0; 158 | } 159 | 160 | 161 | /* perform read command */ 162 | int doread(char *name, int rnum){ 163 | DBM *db; 164 | datum key, val; 165 | int i, err, len; 166 | char buf[RECBUFSIZ]; 167 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 168 | /* open a database */ 169 | if(!(db = dbm_open(name, O_RDONLY, 00644))){ 170 | fprintf(stderr, "dbm_open failed\n"); 171 | return 1; 172 | } 173 | err = FALSE; 174 | /* loop for each record */ 175 | for(i = 1; i <= rnum; i++){ 176 | /* retrieve a record */ 177 | len = sprintf(buf, "%08d", i); 178 | key.dptr = buf; 179 | key.dsize = len; 180 | val = dbm_fetch(db, key); 181 | if(!val.dptr){ 182 | fprintf(stderr, "dbm_fetch failed\n"); 183 | err = TRUE; 184 | break; 185 | } 186 | /* print progression */ 187 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 188 | putchar('.'); 189 | fflush(stdout); 190 | if(i == rnum || i % (rnum / 10) == 0){ 191 | printf(" (%08d)\n", i); 192 | fflush(stdout); 193 | } 194 | } 195 | } 196 | /* close the database */ 197 | dbm_close(db); 198 | if(showprgr && !err) printf("ok\n\n"); 199 | return err ? 1 : 0; 200 | } 201 | 202 | 203 | 204 | /* END OF FILE */ 205 | -------------------------------------------------------------------------------- /bros/tdbtest.c: -------------------------------------------------------------------------------- 1 | /************************************************************************************************* 2 | * Writing test of Trivial Database 3 | *************************************************************************************************/ 4 | 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #undef TRUE 14 | #define TRUE 1 /* boolean true */ 15 | #undef FALSE 16 | #define FALSE 0 /* boolean false */ 17 | 18 | #define RECBUFSIZ 32 /* buffer for records */ 19 | 20 | 21 | /* global variables */ 22 | const char *progname; /* program name */ 23 | int showprgr; /* whether to show progression */ 24 | 25 | 26 | /* function prototypes */ 27 | int main(int argc, char **argv); 28 | void usage(void); 29 | int runwrite(int argc, char **argv); 30 | int runread(int argc, char **argv); 31 | int dowrite(char *name, int rnum); 32 | int doread(char *name, int rnum); 33 | 34 | 35 | /* main routine */ 36 | int main(int argc, char **argv){ 37 | int rv; 38 | progname = argv[0]; 39 | showprgr = TRUE; 40 | if(getenv("HIDEPRGR")) showprgr = FALSE; 41 | if(argc < 2) usage(); 42 | rv = 0; 43 | if(!strcmp(argv[1], "write")){ 44 | rv = runwrite(argc, argv); 45 | } else if(!strcmp(argv[1], "read")){ 46 | rv = runread(argc, argv); 47 | } else { 48 | usage(); 49 | } 50 | return rv; 51 | } 52 | 53 | 54 | /* print the usage and exit */ 55 | void usage(void){ 56 | fprintf(stderr, "%s: test cases for Trivial Database\n", progname); 57 | fprintf(stderr, "\n"); 58 | fprintf(stderr, "usage:\n"); 59 | fprintf(stderr, " %s write name rnum\n", progname); 60 | fprintf(stderr, " %s read name rnum\n", progname); 61 | fprintf(stderr, "\n"); 62 | exit(1); 63 | } 64 | 65 | 66 | /* parse arguments of write command */ 67 | int runwrite(int argc, char **argv){ 68 | char *name, *rstr; 69 | int i, rnum, rv; 70 | name = NULL; 71 | rstr = NULL; 72 | rnum = 0; 73 | for(i = 2; i < argc; i++){ 74 | if(!name && argv[i][0] == '-'){ 75 | usage(); 76 | } else if(!name){ 77 | name = argv[i]; 78 | } else if(!rstr){ 79 | rstr = argv[i]; 80 | } else { 81 | usage(); 82 | } 83 | } 84 | if(!name || !rstr) usage(); 85 | rnum = atoi(rstr); 86 | if(rnum < 1) usage(); 87 | rv = dowrite(name, rnum); 88 | return rv; 89 | } 90 | 91 | 92 | /* parse arguments of read command */ 93 | int runread(int argc, char **argv){ 94 | char *name, *rstr; 95 | int i, rnum, rv; 96 | name = NULL; 97 | rstr = NULL; 98 | rnum = 0; 99 | for(i = 2; i < argc; i++){ 100 | if(!name && argv[i][0] == '-'){ 101 | usage(); 102 | } else if(!name){ 103 | name = argv[i]; 104 | } else if(!rstr){ 105 | rstr = argv[i]; 106 | } else { 107 | usage(); 108 | } 109 | } 110 | if(!name || !rstr) usage(); 111 | rnum = atoi(rstr); 112 | if(rnum < 1) usage(); 113 | rv = doread(name, rnum); 114 | return rv; 115 | } 116 | 117 | 118 | /* perform write command */ 119 | int dowrite(char *name, int rnum){ 120 | TDB_CONTEXT *tdb; 121 | TDB_DATA key, record; 122 | int i, err, len; 123 | char buf[RECBUFSIZ]; 124 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 125 | /* open a database */ 126 | if(!(tdb = tdb_open(name, rnum * 2, 0, O_RDWR | O_CREAT | O_TRUNC, 00644))){ 127 | fprintf(stderr, "tdb_open failed\n"); 128 | return 1; 129 | } 130 | err = FALSE; 131 | /* loop for each record */ 132 | for(i = 1; i <= rnum; i++){ 133 | len = sprintf(buf, "%08d", i); 134 | key.dptr = (unsigned char *)buf; 135 | key.dsize = len; 136 | record.dptr = (unsigned char *)buf; 137 | record.dsize = len; 138 | /* store a record */ 139 | if(tdb_store(tdb, key, record, TDB_REPLACE) != 0){ 140 | fprintf(stderr, "tdb_store failed\n"); 141 | err = TRUE; 142 | break; 143 | } 144 | /* print progression */ 145 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 146 | putchar('.'); 147 | fflush(stdout); 148 | if(i == rnum || i % (rnum / 10) == 0){ 149 | printf(" (%08d)\n", i); 150 | fflush(stdout); 151 | } 152 | } 153 | } 154 | /* close the database */ 155 | tdb_close(tdb); 156 | if(showprgr && !err) printf("ok\n\n"); 157 | return err ? 1 : 0; 158 | } 159 | 160 | 161 | /* perform read command */ 162 | int doread(char *name, int rnum){ 163 | TDB_CONTEXT *tdb; 164 | TDB_DATA key, record; 165 | int i, err, len; 166 | char buf[RECBUFSIZ]; 167 | if(showprgr) printf("\n name=%s rnum=%d\n\n", name, rnum); 168 | /* open a database */ 169 | if(!(tdb = tdb_open(name, rnum * 2, 0, O_RDONLY, 00644))){ 170 | fprintf(stderr, "tdb_open failed\n"); 171 | return 1; 172 | } 173 | err = FALSE; 174 | /* loop for each record */ 175 | for(i = 1; i <= rnum; i++){ 176 | len = sprintf(buf, "%08d", i); 177 | key.dptr = (unsigned char *)buf; 178 | key.dsize = len; 179 | /* retrieve a record */ 180 | record = tdb_fetch(tdb, key); 181 | if(!record.dptr){ 182 | fprintf(stderr, "tdb_fetch failed\n"); 183 | err = TRUE; 184 | break; 185 | } 186 | free(record.dptr); 187 | /* print progression */ 188 | if(showprgr && rnum > 250 && i % (rnum / 250) == 0){ 189 | putchar('.'); 190 | fflush(stdout); 191 | if(i == rnum || i % (rnum / 10) == 0){ 192 | printf(" (%08d)\n", i); 193 | fflush(stdout); 194 | } 195 | } 196 | } 197 | /* close the database */ 198 | tdb_close(tdb); 199 | if(showprgr && !err) printf("ok\n\n"); 200 | return err ? 1 : 0; 201 | } 202 | 203 | 204 | 205 | /* END OF FILE */ 206 | -------------------------------------------------------------------------------- /configure.in: -------------------------------------------------------------------------------- 1 | # Source of configuration for Tokyo Cabinet 2 | 3 | 4 | 5 | #================================================================ 6 | # Generic Settings 7 | #================================================================ 8 | 9 | # Package name 10 | AC_INIT(tokyocabinet, 1.4.30) 11 | 12 | # Package information 13 | MYLIBVER=8 14 | MYLIBREV=21 15 | MYFORMATVER="1.0" 16 | 17 | # Targets 18 | MYHEADERFILES="tcutil.h tchdb.h tcbdb.h tcfdb.h tctdb.h tcadb.h" 19 | MYLIBRARYFILES="libtokyocabinet.a" 20 | MYLIBOBJFILES="tcutil.o tchdb.o tcbdb.o tcfdb.o tctdb.o tcadb.o myconf.o md5.o" 21 | MYCOMMANDFILES="tcutest tcumttest tcucodec tchtest tchmttest tchmgr" 22 | MYCOMMANDFILES="$MYCOMMANDFILES tcbtest tcbmttest tcbmgr tcftest tcfmttest tcfmgr" 23 | MYCOMMANDFILES="$MYCOMMANDFILES tcttest tctmttest tctmgr tcatest tcamgr" 24 | MYCGIFILES="tcawmgr.cgi" 25 | MYMAN1FILES="tcutest.1 tcumttest.1 tcucodec.1 tchtest.1 tchmttest.1 tchmgr.1" 26 | MYMAN1FILES="$MYMAN1FILES tcbtest.1 tcbmttest.1 tcbmgr.1 tcftest.1 tcfmttest.1 tcfmgr.1" 27 | MYMAN1FILES="$MYMAN1FILES tcttest.1 tctmttest.1 tctmgr.1 tcatest.1 tcamgr.1" 28 | MYMAN3FILES="tokyocabinet.3 tcutil.3 tcxstr.3 tclist.3 tcmap.3 tctree.3 tcmdb.3 tcmpool.3" 29 | MYMAN3FILES="$MYMAN3FILES tchdb.3 tcbdb.3 tcfdb.3 tctdb.3 tcadb.3" 30 | MYDOCUMENTFILES="COPYING ChangeLog THANKS doc" 31 | MYPCFILES="tokyocabinet.pc" 32 | 33 | # Building flags 34 | MYCFLAGS="-std=c99 -Wall -fPIC -fsigned-char -O2" 35 | MYCPPFLAGS="-I. -I\$(INCLUDEDIR) -I$HOME/include -I/usr/local/include" 36 | MYCPPFLAGS="$MYCPPFLAGS -DNDEBUG -D_GNU_SOURCE=1 -D_REENTRANT -D__EXTENSIONS__" 37 | MYLDFLAGS="-L. -L\$(LIBDIR) -L$HOME/lib -L/usr/local/lib" 38 | MYCMDLDFLAGS="" 39 | MYRUNPATH="\$(LIBDIR)" 40 | MYLDLIBPATHENV="LD_LIBRARY_PATH" 41 | MYPOSTCMD="true" 42 | 43 | # Building paths 44 | PATH="$PATH:$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin" 45 | PATH="$PATH:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/xpg4/bin:/usr/xpg6/bin:/usr/ucb" 46 | CPATH="$HOME/include:/usr/local/include:$CPATH" 47 | LIBRARY_PATH="$HOME/lib:/usr/local/lib:$LIBRARY_PATH" 48 | LD_LIBRARY_PATH="$HOME/lib:/usr/local/lib:$LD_LIBRARY_PATH" 49 | PKG_CONFIG_PATH="$HOME/lib/pkgconfig:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" 50 | export PATH CPATH LIBRARY_PATH LD_LIBRARY_PATH PKG_CONFIG_PATH 51 | 52 | 53 | 54 | #================================================================ 55 | # Options 56 | #================================================================ 57 | 58 | 59 | # Internal variables 60 | enables="" 61 | 62 | # Debug mode 63 | AC_ARG_ENABLE(debug, 64 | AC_HELP_STRING([--enable-debug], [build for debugging])) 65 | if test "$enable_debug" = "yes" 66 | then 67 | MYCFLAGS="-std=c99 -Wall -fPIC -pedantic -fsigned-char -g -O0" 68 | MYCPPFLAGS="$MYCPPFLAGS -UNDEBUG" 69 | MYCMDLDFLAGS="$MYCMDLDFLAGS -static" 70 | enables="$enables (debug)" 71 | fi 72 | 73 | # Developping mode 74 | AC_ARG_ENABLE(devel, 75 | AC_HELP_STRING([--enable-devel], [build for development])) 76 | if test "$enable_devel" = "yes" 77 | then 78 | MYCFLAGS="-std=c99 -Wall -fPIC -pedantic -fsigned-char -g -O2 -pipe" 79 | MYCPPFLAGS="$MYCPPFLAGS -UNDEBUG" 80 | enables="$enables (devel)" 81 | fi 82 | 83 | # Profiling mode 84 | AC_ARG_ENABLE(profile, 85 | AC_HELP_STRING([--enable-profile], [build for profiling])) 86 | if test "$enable_profile" = "yes" 87 | then 88 | MYCFLAGS="-std=c99 -Wall -fPIC -pedantic -fsigned-char -g -pg -O2 -pipe" 89 | enables="$enables (profile)" 90 | fi 91 | 92 | # Static mode 93 | AC_ARG_ENABLE(static, 94 | AC_HELP_STRING([--enable-static], [build by static linking])) 95 | if test "$enable_static" = "yes" 96 | then 97 | MYCMDLDFLAGS="$MYCMDLDFLAGS -static" 98 | enables="$enables (static)" 99 | fi 100 | 101 | # Fastest mode 102 | AC_ARG_ENABLE(fastest, 103 | AC_HELP_STRING([--enable-fastest], [build for fastest run])) 104 | if test "$enable_fastest" = "yes" 105 | then 106 | MYLIBOBJFILES="tokyocabinet_all.o" 107 | MYCFLAGS="-std=c99 -Wall -fPIC -pedantic -fsigned-char -O3" 108 | MYCFLAGS="$MYCFLAGS -fomit-frame-pointer -fforce-addr -minline-all-stringops" 109 | MYCPPFLAGS="$MYCPPFLAGS -D_MYFASTEST" 110 | enables="$enables (fastest)" 111 | fi 112 | 113 | # 64-bit offset mode 114 | AC_ARG_ENABLE(off64, 115 | AC_HELP_STRING([--enable-off64], [build with 64-bit file offset on 32-bit system])) 116 | if test "$enable_off64" = "yes" 117 | then 118 | MYCPPFLAGS="$MYCPPFLAGS -D_FILE_OFFSET_BITS=64" 119 | enables="$enables (off64)" 120 | fi 121 | 122 | # Swapping byte-orders mode 123 | AC_ARG_ENABLE(swab, 124 | AC_HELP_STRING([--enable-swab], [build for swapping byte-orders])) 125 | if test "$enable_swab" = "yes" 126 | then 127 | MYCPPFLAGS="$MYCPPFLAGS -D_MYSWAB" 128 | enables="$enables (swab)" 129 | fi 130 | 131 | # Micro yield mode 132 | AC_ARG_ENABLE(uyield, 133 | AC_HELP_STRING([--enable-uyield], [build for detecting race conditions])) 134 | if test "$enable_uyield" = "yes" 135 | then 136 | MYCPPFLAGS="$MYCPPFLAGS -D_MYMICROYIELD" 137 | enables="$enables (uyield)" 138 | fi 139 | 140 | # Disable ZLIB compression 141 | AC_ARG_ENABLE(zlib, 142 | AC_HELP_STRING([--disable-zlib], [build without ZLIB compression])) 143 | if test "$enable_zlib" = "no" 144 | then 145 | MYCPPFLAGS="$MYCPPFLAGS -D_MYNOZLIB" 146 | enables="$enables (no-zlib)" 147 | fi 148 | 149 | # Enable BZIP2 compression 150 | AC_ARG_ENABLE(bzip, 151 | AC_HELP_STRING([--disable-bzip], [build without BZIP2 compression])) 152 | if test "$enable_bzip" = "no" 153 | then 154 | MYCPPFLAGS="$MYCPPFLAGS -D_MYNOBZIP" 155 | enables="$enables (no-bzip)" 156 | fi 157 | 158 | # Disable POSIX thread 159 | AC_ARG_ENABLE(pthread, 160 | AC_HELP_STRING([--disable-pthread], [build without POSIX thread support])) 161 | if test "$enable_pthread" = "no" 162 | then 163 | MYCPPFLAGS="$MYCPPFLAGS -D_MYNOPTHREAD" 164 | enables="$enables (no-pthread)" 165 | fi 166 | 167 | # Disable shared object 168 | AC_ARG_ENABLE(shared, 169 | AC_HELP_STRING([--disable-shared], [avoid to build shared libraries])) 170 | if test "$enable_shared" = "no" 171 | then 172 | enables="$enables (no-shared)" 173 | fi 174 | 175 | # Enable custom codec functions of LZMA 176 | AC_ARG_ENABLE(exlzma, 177 | AC_HELP_STRING([--disable-exlzma], [build with the custom codec of LZMA])) 178 | if test "$enable_exlzma" = "yes" 179 | then 180 | MYCPPFLAGS="$MYCPPFLAGS -D_MYEXLZMA" 181 | enables="$enables (exlzma)" 182 | fi 183 | 184 | # Enable custom codec functions of LZO 185 | AC_ARG_ENABLE(exlzo, 186 | AC_HELP_STRING([--disable-exlzo], [build with the custom codec of LZO])) 187 | if test "$enable_exlzo" = "yes" 188 | then 189 | MYCPPFLAGS="$MYCPPFLAGS -D_MYEXLZO" 190 | enables="$enables (exlzo)" 191 | fi 192 | 193 | # Specify the installation path of ZLIB 194 | AC_ARG_WITH(zlib, 195 | AC_HELP_STRING([--with-zlib=DIR], [search DIR/include and DIR/lib for ZLIB])) 196 | if test -n "$with_zlib" 197 | then 198 | MYCPPFLAGS="$MYCPPFLAGS -I$with_zlib/include" 199 | MYLDFLAGS="$MYLDFLAGS -L$with_zlib/lib" 200 | CPATH="$CPATH:$with_zlib/include" 201 | LIBRARY_PATH="$LIBRARY_PATH:$with_zlib/lib" 202 | LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$with_zlib/lib" 203 | fi 204 | 205 | # Specify the installation path of BZIP2 206 | AC_ARG_WITH(bzip, 207 | AC_HELP_STRING([--with-bzip=DIR], [search DIR/include and DIR/lib for BZIP2])) 208 | if test -n "$with_bzip" 209 | then 210 | MYCPPFLAGS="$MYCPPFLAGS -I$with_bzip/include" 211 | MYLDFLAGS="$MYLDFLAGS -L$with_bzip/lib" 212 | CPATH="$CPATH:$with_bzip/include" 213 | LIBRARY_PATH="$LIBRARY_PATH:$with_bzip/lib" 214 | LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$with_bzip/lib" 215 | fi 216 | 217 | # Messages 218 | printf '#================================================================\n' 219 | printf '# Configuring Tokyo Cabinet version %s%s.\n' "$PACKAGE_VERSION" "$enables" 220 | printf '#================================================================\n' 221 | 222 | 223 | 224 | #================================================================ 225 | # Checking Commands and Libraries 226 | #================================================================ 227 | 228 | # C compiler 229 | AC_PROG_CC 230 | 231 | # Reset variables 232 | if test "$GCC" != "yes" 233 | then 234 | AC_MSG_WARN([another compiler except for GCC was detected]) 235 | MYCFLAGS="" 236 | fi 237 | test -n "$CFLAGS" && MYCFLAGS="$CFLAGS $MYCFLAGS" 238 | test -n "$CPPFLAGS" && MYCPPFLAGS="$CPPFLAGS $MYCPPFLAGS" 239 | test -n "$LDFLAGS" && MYLDFLAGS="$LDFLAGS $MYLDFLAGS" 240 | 241 | # Byte order 242 | AC_C_BIGENDIAN(MYCPPFLAGS="$MYCPPFLAGS -D_MYBIGEND") 243 | 244 | # Underlying libraries 245 | AC_CHECK_LIB(c, main) 246 | AC_CHECK_LIB(m, main) 247 | if test "$enable_pthread" != "no" 248 | then 249 | AC_CHECK_LIB(pthread, main) 250 | AC_CHECK_LIB(rt, main) 251 | fi 252 | if test "$enable_zlib" != "no" 253 | then 254 | AC_CHECK_LIB(z, main) 255 | fi 256 | if test "$enable_bzip" != "no" 257 | then 258 | AC_CHECK_LIB(bz2, main) 259 | fi 260 | if test "$enable_exlzma" = "yes" 261 | then 262 | AC_CHECK_LIB(lzma, main) 263 | fi 264 | if test "$enable_exlzo" = "yes" 265 | then 266 | AC_CHECK_LIB(lzo2, main) 267 | fi 268 | AC_CHECK_LIB(tokyocabinet, main, AC_MSG_WARN([old version of Tokyo Cabinet was detected])) 269 | 270 | # Necessary headers 271 | AC_CHECK_HEADER(stdlib.h, true, AC_MSG_ERROR([stdlib.h is required])) 272 | AC_CHECK_HEADER(stdint.h, true, AC_MSG_ERROR([stdint.h is required])) 273 | AC_CHECK_HEADER(unistd.h, true, AC_MSG_ERROR([unistd.h is required])) 274 | AC_CHECK_HEADER(dirent.h, true, AC_MSG_ERROR([dirent.h is required])) 275 | AC_CHECK_HEADER(regex.h, true, AC_MSG_ERROR([regex.h is required])) 276 | AC_CHECK_HEADER(glob.h, true, AC_MSG_ERROR([glob.h is required])) 277 | if test "$enable_pthread" != "no" 278 | then 279 | AC_CHECK_HEADER(pthread.h, true, AC_MSG_ERROR([pthread.h is required])) 280 | fi 281 | if test "$enable_zlib" != "no" 282 | then 283 | AC_CHECK_HEADER(zlib.h, true, AC_MSG_ERROR([zlib.h is required])) 284 | fi 285 | if test "$enable_bzip" != "no" 286 | then 287 | AC_CHECK_HEADER(bzlib.h, true, AC_MSG_ERROR([bzlib.h is required])) 288 | fi 289 | if test "$enable_exlzma" = "yes" 290 | then 291 | AC_CHECK_HEADER(lzmalib.h, true, AC_MSG_ERROR([lzmalib.h is required])) 292 | fi 293 | if test "$enable_exlzo" = "yes" 294 | then 295 | AC_CHECK_HEADER(lzo/lzo1x.h, true, AC_MSG_ERROR([lzo/lzo1x.h is required])) 296 | fi 297 | 298 | # Shared libraries 299 | if test "$enable_shared" != "no" && test "$enable_profile" != "yes" 300 | then 301 | if uname | grep Darwin >/dev/null 302 | then 303 | MYLIBRARYFILES="$MYLIBRARYFILES libtokyocabinet.$MYLIBVER.$MYLIBREV.0.dylib" 304 | MYLIBRARYFILES="$MYLIBRARYFILES libtokyocabinet.$MYLIBVER.dylib" 305 | MYLIBRARYFILES="$MYLIBRARYFILES libtokyocabinet.dylib" 306 | MYLDLIBPATHENV="DYLD_LIBRARY_PATH" 307 | else 308 | MYLIBRARYFILES="$MYLIBRARYFILES libtokyocabinet.so.$MYLIBVER.$MYLIBREV.0" 309 | MYLIBRARYFILES="$MYLIBRARYFILES libtokyocabinet.so.$MYLIBVER" 310 | MYLIBRARYFILES="$MYLIBRARYFILES libtokyocabinet.so" 311 | fi 312 | fi 313 | 314 | 315 | 316 | #================================================================ 317 | # Generic Settings 318 | #================================================================ 319 | 320 | # Export variables 321 | AC_SUBST(MYLIBVER) 322 | AC_SUBST(MYLIBREV) 323 | AC_SUBST(MYFORMATVER) 324 | AC_SUBST(MYHEADERFILES) 325 | AC_SUBST(MYLIBRARYFILES) 326 | AC_SUBST(MYLIBOBJFILES) 327 | AC_SUBST(MYCOMMANDFILES) 328 | AC_SUBST(MYCGIFILES) 329 | AC_SUBST(MYMAN1FILES) 330 | AC_SUBST(MYMAN3FILES) 331 | AC_SUBST(MYDOCUMENTFILES) 332 | AC_SUBST(MYPCFILES) 333 | AC_SUBST(MYCFLAGS) 334 | AC_SUBST(MYCPPFLAGS) 335 | AC_SUBST(MYLDFLAGS) 336 | AC_SUBST(MYCMDLDFLAGS) 337 | AC_SUBST(MYRUNPATH) 338 | AC_SUBST(MYLDLIBPATHENV) 339 | AC_SUBST(MYPOSTCMD) 340 | 341 | # Targets 342 | AC_OUTPUT(Makefile tokyocabinet.pc) 343 | 344 | # Messages 345 | printf '#================================================================\n' 346 | printf '# Ready to make.\n' 347 | printf '#================================================================\n' 348 | 349 | 350 | 351 | # END OF FILE 352 | -------------------------------------------------------------------------------- /doc/benchmark.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clement/tokyo-cabinet/5cb3d3fc93b04b0738298727255ac1b9ba29920f/doc/benchmark.pdf -------------------------------------------------------------------------------- /doc/common.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Style Sheets commonly used by documents of Tokyo Cabinet 3 | */ 4 | 5 | html { 6 | margin: 0em 0em; 7 | padding: 0em 0em; 8 | background: #eeeeee none; 9 | } 10 | body { 11 | margin: 1em 2em; 12 | padding: 0em 0em; 13 | background: #eeeeee none; 14 | color: #111111; 15 | } 16 | 17 | hr { 18 | margin: 2.5em 0em 1.5em 0em; 19 | height: 1px; 20 | border: none; 21 | background: #999999 none; 22 | color: #999999; 23 | } 24 | 25 | h1,h2,h3,h4,h5,h6 { 26 | font-weight: bold; 27 | } 28 | h1 { 29 | margin: 1.0em 0em 1.3em 0em; 30 | padding: 0em 0em; 31 | font-size: 180%; 32 | color: #000000; 33 | } 34 | h2 { 35 | margin: 1.0em 0em 1.0em 0.2em; 36 | padding: 0.5em 0.5em; 37 | width: 60%; 38 | border-left: solid 0.6em #445555; 39 | border-bottom: solid 1px #bbbbbb; 40 | font-size: 150%; 41 | color: #000011; 42 | } 43 | h3 { 44 | margin: 0.8em 0em 0.5em 0.2em; 45 | padding: 0em 0em; 46 | font-size: 120%; 47 | color: #001111; 48 | } 49 | 50 | p { 51 | margin: 0.8em 0em; 52 | line-height: 140%; 53 | text-indent: 0.8em; 54 | } 55 | 56 | div,pre,table { 57 | margin: 0.8em 1.5em; 58 | } 59 | 60 | div.note,div.navi { 61 | text-align: right; 62 | margin: 0em 0.5em; 63 | color: #333333; 64 | } 65 | span.void { 66 | color: #888888; 67 | } 68 | 69 | div.logo { 70 | text-align: center; 71 | margin: 3em 0em; 72 | } 73 | div.logo img { 74 | border: inset 2px #ccccdd; 75 | } 76 | div.illust { 77 | margin: 1em 0em; 78 | text-align: center; 79 | } 80 | div.illust img { 81 | border: solid 1px #ccccdd; 82 | } 83 | 84 | pre { 85 | padding: 0.2em; 86 | background-color: #ddddee; 87 | border: 1px solid #bbbbcc; 88 | font-size: 95%; 89 | } 90 | 91 | li,dt,dd { 92 | line-height: 130%; 93 | } 94 | dt { 95 | margin-left: 1.2em; 96 | } 97 | dd { 98 | margin-left: 2.5em; 99 | text-indent: -0.3em; 100 | } 101 | dl.api { 102 | margin-top: -0.2em; 103 | } 104 | dl.api dd { 105 | margin-left: 3.0em; 106 | font-size: 95%; 107 | color: #333333; 108 | } 109 | ul { 110 | margin: 0.5em 2.0em; 111 | padding: 0em; 112 | } 113 | ul.options { 114 | list-style-type: none; 115 | margin: 0.5em 1.5em; 116 | font-size: 95%; 117 | color: #333333; 118 | } 119 | ul ul { 120 | margin-top: 0em; 121 | margin-bottom: 0em; 122 | } 123 | 124 | table { 125 | border-collapse: collapse; 126 | } 127 | td { 128 | text-align: left; 129 | vertical-align: top; 130 | padding: 0.1em 0.5em; 131 | border: solid 1px #aaaabb; 132 | font-size: 95%; 133 | } 134 | td.label { 135 | border: none; 136 | font-size: 80%; 137 | color: #333333; 138 | } 139 | td.number { 140 | text-align: right; 141 | } 142 | 143 | a { 144 | color: #0022aa; 145 | text-decoration: none; 146 | } 147 | a:hover,a:focus { 148 | color: #0033ee; 149 | text-decoration: underline; 150 | } 151 | code,kbd { 152 | font-style: normal; 153 | font-weight: bold; 154 | font-size: 100%; 155 | color: #001111; 156 | } 157 | var { 158 | padding: 0em 0.15em 0em 0em; 159 | font-style: italic; 160 | color: #001122; 161 | } 162 | 163 | @media print { 164 | html,body { 165 | margin: 0em 0em; 166 | background-color: #ffffff; 167 | color: #000000; 168 | } 169 | h1 { 170 | padding: 8em 0em 0.5em 0em; 171 | text-align: center; 172 | } 173 | h2 { 174 | page-break-before: always; 175 | } 176 | div.note { 177 | text-align: center; 178 | } 179 | div.navi,div.logo { 180 | display: none; 181 | } 182 | hr { 183 | display: none; 184 | } 185 | pre { 186 | margin: 0.8em 0.8em; 187 | background-color: #ffffff; 188 | border: 1px solid #aaaaaa; 189 | font-size: 90%; 190 | } 191 | a,code,kbd { 192 | color: #000000; 193 | text-decoration: none; 194 | } 195 | h1,h2,h3 { 196 | font-family: sans-serif; 197 | } 198 | p,div,li,dt,dd { 199 | font-family: serif; 200 | } 201 | pre,code,kbd { 202 | font-family: monospace; 203 | } 204 | dd { 205 | font-size: 90%; 206 | } 207 | } 208 | 209 | 210 | 211 | /* END OF FILE */ 212 | -------------------------------------------------------------------------------- /doc/icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clement/tokyo-cabinet/5cb3d3fc93b04b0738298727255ac1b9ba29920f/doc/icon16.png -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Tokyo Cabinet: a modern implementation of DBM 21 | 61 | 62 | 63 | 64 | 65 |

Tokyo Cabinet: a modern implementation of DBM

66 | 67 |
Copyright (C) 2006-2009 Mikio Hirabayashi
68 |
Last Update: Sun, 21 Jun 2009 22:14:52 +0900
69 | 70 | 71 | 72 | 73 |
74 | 75 |

Overview

76 | 77 |

Tokyo Cabinet is a library of routines for managing a database. The database is a simple data file containing records, each is a pair of a key and a value. Every key and value is serial bytes with variable length. Both binary data and character string can be used as a key and a value. There is neither concept of data tables nor data types. Records are organized in hash table, B+ tree, or fixed-length array.

78 | 79 |

Tokyo Cabinet is developed as the successor of GDBM and QDBM on the following purposes. They are achieved and Tokyo Cabinet replaces conventional DBM products.

80 | 81 |
    82 |
  • improves space efficiency : smaller size of database file.
  • 83 |
  • improves time efficiency : faster processing speed.
  • 84 |
  • improves parallelism : higher performance in multi-thread environment.
  • 85 |
  • improves usability : simplified API.
  • 86 |
  • improves robustness : database file is not corrupted even under catastrophic situation.
  • 87 |
  • supports 64-bit architecture : enormous memory space and database file are available.
  • 88 |
89 | 90 |

Tokyo Cabinet is written in the C language, and provided as API of C, Perl, Ruby, Java, and Lua. Tokyo Cabinet is available on platforms which have API conforming to C99 and POSIX. Tokyo Cabinet is a free software licensed under the GNU Lesser General Public License.

91 | 92 |
93 | 94 |

Documents

95 | 96 |

The following are documents of Tokyo Cabinet. They are contained also in the source package.

97 | 98 | 101 | 102 | 108 | 109 | 116 | 117 | 121 | 122 |
123 | 124 |

Packages

125 | 126 |

The following are the source packages of Tokyo Cabinet. As for binary packages, see the site of each distributor.

127 | 128 | 132 | 133 | 139 | 140 | 147 | 148 | 151 | 152 |
153 | 154 |

Information

155 | 156 |

Tokyo Cabinet was written and is maintained by Mikio Hirabayashi. You can contact the author by e-mail to `mikio@users.sourceforge.net'.

157 | 158 |

The project page on SourceForge.net is `http://sourceforge.net/projects/tokyocabinet/'. Update of this project is announced on Freshmeat.net at `http://freshmeat.net/projects/tokyocabinet/'.

159 | 160 |
161 | 162 | 163 | 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /doc/index.ja.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | データベースマネージャ Tokyo Cabinet 21 | 102 | 103 | 104 | 105 | 106 |

Tokyo Cabinet: DBMの現代的な壱実装

107 | 108 |
Copyright (C) 2006-2009 Mikio Hirabayashi
109 |
Last Update: Sun, 21 Jun 2009 22:14:52 +0900
110 | 111 | 112 | 113 | 114 |
115 | 116 |

概要

117 | 118 |

Tokyo Cabinetはデータベースを扱うルーチン群のライブラリです。データベースといっても単純なもので、キーと値のペアからなるレコード群を格納したデータファイルです。キーと値は任意の長さを持つ一連のバイト列であり、文字列でもバイナリでも扱うことができます。テーブルやデータ型の概念はありません。レコードはハッシュ表かB+木か固定長配列で編成されます。

119 | 120 |

Tokyo CabinetはGDBMやQDBMの後継として次の点を目標として開発されました。これらの目標は達成されており、Tokyo Cabinetは従来のDBMを置き換える製品だと言えます。

121 | 122 |
    123 |
  • 空間効率の向上 : データベースファイルがより小さい
  • 124 |
  • 時間効率の向上 : 処理がより高速である
  • 125 |
  • 並列性の向上 : マルチスレッド環境での同時実行性能の向上
  • 126 |
  • 利便性の向上 : APIがより単純である
  • 127 |
  • 堅牢性の向上 : 不慮の事態でもデータベースファイルが壊れにくい
  • 128 |
  • 64ビット対応 : 巨大なメモリ空間とデータベースファイルを扱える
  • 129 |
130 | 131 |

Tokyo CabinetはC言語で記述され、CとPerlとRubyとJavaとLuaのAPIとして提供されます。Tokyo CabinetはC99およびPOSIX準拠のAPIを備えるプラットフォームで利用できます。Tokyo CabinetはGNU Lesser General Public Licenseに基づくフリーソフトウェアです。

132 | 133 |
134 | 135 |

文書

136 | 137 |

以下の文書を読んでください。ソースパッケージにも同じものが含まれています。

138 | 139 | 142 | 143 | 149 | 150 | 157 | 158 | 162 | 163 |
164 | 165 |

ダウンロード

166 | 167 |

以下のソースパッケージをダウンロードしてください。バイナリパッケージについては、各ディストリビュータのサイトをご覧ください。

168 | 169 | 173 | 174 | 180 | 181 | 188 | 189 | 192 | 193 |
194 | 195 |

その他の情報

196 | 197 |

Tokyo Cabinetは平林幹雄が作成しました。作者と連絡をとるには、`mikio@users.sourceforge.net' 宛に電子メールを送ってください。

198 | 199 |

SourceForge.netにおけるプロジェクトページは `http://sourceforge.net/projects/tokyocabinet/' にあります。Freshmeatにおける更新情報は `http://freshmeat.net/projects/tokyocabinet/' から参照できます。

200 | 201 |
202 | 203 | 204 | 205 | 206 | 207 | 208 | -------------------------------------------------------------------------------- /doc/logo-ja.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clement/tokyo-cabinet/5cb3d3fc93b04b0738298727255ac1b9ba29920f/doc/logo-ja.png -------------------------------------------------------------------------------- /doc/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clement/tokyo-cabinet/5cb3d3fc93b04b0738298727255ac1b9ba29920f/doc/logo.png -------------------------------------------------------------------------------- /doc/tokyoproducts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clement/tokyo-cabinet/5cb3d3fc93b04b0738298727255ac1b9ba29920f/doc/tokyoproducts.pdf -------------------------------------------------------------------------------- /doc/tokyoproducts.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clement/tokyo-cabinet/5cb3d3fc93b04b0738298727255ac1b9ba29920f/doc/tokyoproducts.ppt -------------------------------------------------------------------------------- /example/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for sample programs of Tokyo Cabinet 2 | 3 | 4 | 5 | #================================================================ 6 | # Setting Variables 7 | #================================================================ 8 | 9 | 10 | # Generic settings 11 | SHELL = /bin/sh 12 | 13 | # Targets 14 | MYBINS = tcutilex tchdbex tcbdbex tcfdbex tctdbex tcadbex tctchat.cgi tctsearch.cgi 15 | 16 | # Building binaries 17 | CC = gcc 18 | CFLAGS = -ansi -Wall -pedantic -I. -I.. 19 | C99FLAGS = -std=c99 -Wall -pedantic -I. -I.. 20 | LDFLAGS = 21 | LIBS = -L. -L.. -ltokyocabinet -lz -lbz2 -lpthread -lm -lc 22 | LDENV = LD_RUN_PATH=/lib:/usr/lib:$(HOME)/lib:/usr/local/lib:.:.. 23 | 24 | 25 | 26 | #================================================================ 27 | # Suffix rules 28 | #================================================================ 29 | 30 | 31 | .SUFFIXES : 32 | .SUFFIXES : .c .o 33 | 34 | .c.o : 35 | $(CC) -c $(CFLAGS) $< 36 | 37 | 38 | 39 | #================================================================ 40 | # Actions 41 | #================================================================ 42 | 43 | 44 | all : $(MYBINS) 45 | 46 | 47 | clean : 48 | rm -rf $(MYBINS) *.exe *.o a.out check.out gmon.out leak.log casket* *.tct *.idx.* *~ 49 | 50 | 51 | static : 52 | make LDFLAGS="$(LDFLAGS) -static" 53 | 54 | 55 | .PHONY : all clean static tctchat.tct tctsearch.tct 56 | 57 | 58 | 59 | #================================================================ 60 | # Building binaries 61 | #================================================================ 62 | 63 | 64 | tcutilex : tcutilex.o 65 | $(LDENV) $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBS) 66 | 67 | 68 | tchdbex : tchdbex.o 69 | $(LDENV) $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBS) 70 | 71 | 72 | tcbdbex : tcbdbex.o 73 | $(LDENV) $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBS) 74 | 75 | 76 | tcfdbex : tcfdbex.o 77 | $(LDENV) $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBS) 78 | 79 | 80 | tctdbex : tctdbex.o 81 | $(LDENV) $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBS) 82 | 83 | 84 | tcadbex : tcadbex.o 85 | $(LDENV) $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBS) 86 | 87 | 88 | tctchat.cgi : tctchat.c 89 | $(LDENV) $(CC) $(C99FLAGS) -o $@ $< $(LDFLAGS) $(LIBS) 90 | 91 | 92 | tctsearch.cgi : tctsearch.c 93 | $(LDENV) $(CC) $(C99FLAGS) -o $@ $< $(LDFLAGS) $(LIBS) 94 | 95 | 96 | tctchat.tct : 97 | rm -rf tctchat.tct* 98 | LD_LIBRARY_PATH=/usr/local/lib:.:.. ../tctmgr create tctchat.tct 99 | LD_LIBRARY_PATH=/usr/local/lib:.:.. ../tctmgr setindex -it qgram tctchat.tct "t" 100 | chmod 666 tctchat.tct* 101 | 102 | 103 | tctsearch.tct : 104 | rm -rf tctsearch.tct* 105 | LD_LIBRARY_PATH=/usr/local/lib:.:.. ../tctmgr create tctsearch.tct 106 | LD_LIBRARY_PATH=/usr/local/lib:.:.. ../tctmgr setindex -it qgram tctsearch.tct "text" 107 | LD_LIBRARY_PATH=/usr/local/lib:.:.. ../tctmgr setindex -it qgram tctsearch.tct "title" 108 | ../lab/htmldoctotsv -t .. | \ 109 | LD_LIBRARY_PATH=/usr/local/lib:.:.. ../tctmgr importtsv tctsearch.tct 110 | 111 | 112 | 113 | # END OF FILE 114 | -------------------------------------------------------------------------------- /example/tcadbex.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char **argv){ 8 | TCADB *adb; 9 | char *key, *value; 10 | 11 | /* create the object */ 12 | adb = tcadbnew(); 13 | 14 | /* open the database */ 15 | if(!tcadbopen(adb, "casket.tch")){ 16 | fprintf(stderr, "open error\n"); 17 | } 18 | 19 | /* store records */ 20 | if(!tcadbput2(adb, "foo", "hop") || 21 | !tcadbput2(adb, "bar", "step") || 22 | !tcadbput2(adb, "baz", "jump")){ 23 | fprintf(stderr, "put error\n"); 24 | } 25 | 26 | /* retrieve records */ 27 | value = tcadbget2(adb, "foo"); 28 | if(value){ 29 | printf("%s\n", value); 30 | free(value); 31 | } else { 32 | fprintf(stderr, "get error\n"); 33 | } 34 | 35 | /* traverse records */ 36 | tcadbiterinit(adb); 37 | while((key = tcadbiternext2(adb)) != NULL){ 38 | value = tcadbget2(adb, key); 39 | if(value){ 40 | printf("%s:%s\n", key, value); 41 | free(value); 42 | } 43 | free(key); 44 | } 45 | 46 | /* close the database */ 47 | if(!tcadbclose(adb)){ 48 | fprintf(stderr, "close error\n"); 49 | } 50 | 51 | /* delete the object */ 52 | tcadbdel(adb); 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /example/tcbdbex.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char **argv){ 8 | TCBDB *bdb; 9 | BDBCUR *cur; 10 | int ecode; 11 | char *key, *value; 12 | 13 | /* create the object */ 14 | bdb = tcbdbnew(); 15 | 16 | /* open the database */ 17 | if(!tcbdbopen(bdb, "casket.tcb", BDBOWRITER | BDBOCREAT)){ 18 | ecode = tcbdbecode(bdb); 19 | fprintf(stderr, "open error: %s\n", tcbdberrmsg(ecode)); 20 | } 21 | 22 | /* store records */ 23 | if(!tcbdbput2(bdb, "foo", "hop") || 24 | !tcbdbput2(bdb, "bar", "step") || 25 | !tcbdbput2(bdb, "baz", "jump")){ 26 | ecode = tcbdbecode(bdb); 27 | fprintf(stderr, "put error: %s\n", tcbdberrmsg(ecode)); 28 | } 29 | 30 | /* retrieve records */ 31 | value = tcbdbget2(bdb, "foo"); 32 | if(value){ 33 | printf("%s\n", value); 34 | free(value); 35 | } else { 36 | ecode = tcbdbecode(bdb); 37 | fprintf(stderr, "get error: %s\n", tcbdberrmsg(ecode)); 38 | } 39 | 40 | /* traverse records */ 41 | cur = tcbdbcurnew(bdb); 42 | tcbdbcurfirst(cur); 43 | while((key = tcbdbcurkey2(cur)) != NULL){ 44 | value = tcbdbcurval2(cur); 45 | if(value){ 46 | printf("%s:%s\n", key, value); 47 | free(value); 48 | } 49 | free(key); 50 | tcbdbcurnext(cur); 51 | } 52 | tcbdbcurdel(cur); 53 | 54 | /* close the database */ 55 | if(!tcbdbclose(bdb)){ 56 | ecode = tcbdbecode(bdb); 57 | fprintf(stderr, "close error: %s\n", tcbdberrmsg(ecode)); 58 | } 59 | 60 | /* delete the object */ 61 | tcbdbdel(bdb); 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /example/tcfdbex.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char **argv){ 8 | TCFDB *fdb; 9 | int ecode; 10 | char *key, *value; 11 | 12 | /* create the object */ 13 | fdb = tcfdbnew(); 14 | 15 | /* open the database */ 16 | if(!tcfdbopen(fdb, "casket.tcf", FDBOWRITER | FDBOCREAT)){ 17 | ecode = tcfdbecode(fdb); 18 | fprintf(stderr, "open error: %s\n", tcfdberrmsg(ecode)); 19 | } 20 | 21 | /* store records */ 22 | if(!tcfdbput3(fdb, "1", "one") || 23 | !tcfdbput3(fdb, "12", "twelve") || 24 | !tcfdbput3(fdb, "144", "one forty four")){ 25 | ecode = tcfdbecode(fdb); 26 | fprintf(stderr, "put error: %s\n", tcfdberrmsg(ecode)); 27 | } 28 | 29 | /* retrieve records */ 30 | value = tcfdbget3(fdb, "1"); 31 | if(value){ 32 | printf("%s\n", value); 33 | free(value); 34 | } else { 35 | ecode = tcfdbecode(fdb); 36 | fprintf(stderr, "get error: %s\n", tcfdberrmsg(ecode)); 37 | } 38 | 39 | /* traverse records */ 40 | tcfdbiterinit(fdb); 41 | while((key = tcfdbiternext3(fdb)) != NULL){ 42 | value = tcfdbget3(fdb, key); 43 | if(value){ 44 | printf("%s:%s\n", key, value); 45 | free(value); 46 | } 47 | free(key); 48 | } 49 | 50 | /* close the database */ 51 | if(!tcfdbclose(fdb)){ 52 | ecode = tcfdbecode(fdb); 53 | fprintf(stderr, "close error: %s\n", tcfdberrmsg(ecode)); 54 | } 55 | 56 | /* delete the object */ 57 | tcfdbdel(fdb); 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /example/tchdbex.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char **argv){ 8 | TCHDB *hdb; 9 | int ecode; 10 | char *key, *value; 11 | 12 | /* create the object */ 13 | hdb = tchdbnew(); 14 | 15 | /* open the database */ 16 | if(!tchdbopen(hdb, "casket.tch", HDBOWRITER | HDBOCREAT)){ 17 | ecode = tchdbecode(hdb); 18 | fprintf(stderr, "open error: %s\n", tchdberrmsg(ecode)); 19 | } 20 | 21 | /* store records */ 22 | if(!tchdbput2(hdb, "foo", "hop") || 23 | !tchdbput2(hdb, "bar", "step") || 24 | !tchdbput2(hdb, "baz", "jump")){ 25 | ecode = tchdbecode(hdb); 26 | fprintf(stderr, "put error: %s\n", tchdberrmsg(ecode)); 27 | } 28 | 29 | /* retrieve records */ 30 | value = tchdbget2(hdb, "foo"); 31 | if(value){ 32 | printf("%s\n", value); 33 | free(value); 34 | } else { 35 | ecode = tchdbecode(hdb); 36 | fprintf(stderr, "get error: %s\n", tchdberrmsg(ecode)); 37 | } 38 | 39 | /* traverse records */ 40 | tchdbiterinit(hdb); 41 | while((key = tchdbiternext2(hdb)) != NULL){ 42 | value = tchdbget2(hdb, key); 43 | if(value){ 44 | printf("%s:%s\n", key, value); 45 | free(value); 46 | } 47 | free(key); 48 | } 49 | 50 | /* close the database */ 51 | if(!tchdbclose(hdb)){ 52 | ecode = tchdbecode(hdb); 53 | fprintf(stderr, "close error: %s\n", tchdberrmsg(ecode)); 54 | } 55 | 56 | /* delete the object */ 57 | tchdbdel(hdb); 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /example/tctchat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* function prototypes */ 10 | int main(int argc, char **argv); 11 | static void proc(TCTMPL *tmpl, TCMPOOL *mpool); 12 | 13 | /* main routine */ 14 | int main(int argc, char **argv){ 15 | TCTMPL *tmpl = tctmplnew(); 16 | tctmplload2(tmpl, "tctchat.tmpl"); 17 | TCMPOOL *mpool = tcmpoolnew(); 18 | proc(tmpl, mpool); 19 | tcmpooldel(mpool); 20 | tctmpldel(tmpl); 21 | return 0; 22 | } 23 | 24 | /* process each session */ 25 | static void proc(TCTMPL *tmpl, TCMPOOL *mpool){ 26 | TCMAP *params = tcmpoolmapnew(mpool); 27 | char *query = getenv("QUERY_STRING"); 28 | const char *rp = getenv("CONTENT_LENGTH"); 29 | if(rp){ 30 | int clen = tclmin(tcatoi(rp), 1024 * 1024); 31 | query = tcmpoolmalloc(mpool, clen + 1); 32 | fread(query, 1, clen, stdin); 33 | query[clen] = '\0'; 34 | } 35 | if(query) tcwwwformdecode(query, params); 36 | const char *type = tcstrskipspc(tcmapget4(params, "type", "")); 37 | const char *author = tcstrskipspc(tcmapget4(params, "author", "")); 38 | const char *text = tcstrskipspc(tcmapget4(params, "text", "")); 39 | const char *search = tcstrskipspc(tcmapget4(params, "search", "")); 40 | int page = tcatoi(tcmapget4(params, "page", "1")); 41 | const char *dbpath = tctmplconf(tmpl, "dbpath"); 42 | if(!dbpath) dbpath = "tctchat.tct"; 43 | TCLIST *msgs = tcmpoollistnew(mpool); 44 | TCTDB *tdb = tcmpoolpush(mpool, tctdbnew(), (void (*)(void *))tctdbdel); 45 | rp = getenv("REQUEST_METHOD"); 46 | if(rp && !strcmp(rp, "POST") && *author != '\0' && *text != '\0' && 47 | strlen(author) <= 32 && strlen(text) <= 1024){ 48 | if(!tctdbopen(tdb, dbpath, TDBOWRITER | TDBOCREAT)) 49 | tclistprintf(msgs, "The database could not be opened (%s).", tctdberrmsg(tctdbecode(tdb))); 50 | tctdbsetindex(tdb, "", TDBITDECIMAL | TDBITKEEP); 51 | char pkbuf[64]; 52 | int pksiz = sprintf(pkbuf, "%.0f", tctime() * 1000); 53 | TCMAP *cols = tcmpoolmapnew(mpool); 54 | tcmapput2(cols, "a", author); 55 | tcmapput2(cols, "t", text); 56 | tctdbtranbegin(tdb); 57 | if(!tctdbputkeep(tdb, pkbuf, pksiz, cols)) tclistprintf(msgs, "The message is ignored."); 58 | tctdbtrancommit(tdb); 59 | } else { 60 | if(!tctdbopen(tdb, dbpath, TDBOREADER)) 61 | tclistprintf(msgs, "The database could not be opened (%s).", tctdberrmsg(tctdbecode(tdb))); 62 | } 63 | TCLIST *logs = tcmpoollistnew(mpool); 64 | TDBQRY *qry = tcmpoolpush(mpool, tctdbqrynew(tdb), (void (*)(void *))tctdbqrydel); 65 | if(*search != '\0') tctdbqryaddcond(qry, "t", TDBQCFTSEX, search); 66 | tctdbqrysetorder(qry, "", TDBQONUMDESC); 67 | tctdbqrysetlimit(qry, 16, page > 0 ? (page - 1) * 16 : 0); 68 | TCLIST *res = tcmpoolpushlist(mpool, tctdbqrysearch(qry)); 69 | int rnum = tclistnum(res); 70 | for(int i = rnum - 1; i >= 0; i--){ 71 | int pksiz; 72 | const char *pkbuf = tclistval(res, i, &pksiz); 73 | TCMAP *cols = tcmpoolpushmap(mpool, tctdbget(tdb, pkbuf, pksiz)); 74 | if(cols){ 75 | tcmapprintf(cols, "pk", "%s", pkbuf); 76 | char date[64]; 77 | tcdatestrwww(tcatoi(pkbuf) / 1000, INT_MAX, date); 78 | tcmapput2(cols, "d", date); 79 | const char *astr = tcmapget4(cols, "a", ""); 80 | tcmapprintf(cols, "c", "c%02u", tcgetcrc(astr, strlen(astr)) % 12 + 1); 81 | tclistpushmap(logs, cols); 82 | } 83 | } 84 | TCMAP *vars = tcmpoolmapnew(mpool); 85 | if(tclistnum(msgs) > 0) tcmapputlist(vars, "msgs", msgs); 86 | if(tclistnum(logs) > 0) tcmapputlist(vars, "logs", logs); 87 | tcmapprintf(vars, "author", "%s", author); 88 | tcmapprintf(vars, "search", "%s", search); 89 | if(page > 1) tcmapprintf(vars, "prev", "%d", page - 1); 90 | if(rnum >= 16 && tctdbrnum(tdb) > page * 16) tcmapprintf(vars, "next", "%d", page + 1); 91 | char *str = tcmpoolpushptr(mpool, tctmpldump(tmpl, vars)); 92 | printf("Content-Type: %s\r\n", !strcmp(type, "xml") ? "application/xml" : 93 | !strcmp(type, "xhtml") ? "application/xhtml+xml" : "text/html; charset=UTF-8"); 94 | printf("Cache-Control: no-cache\r\n"); 95 | printf("\r\n"); 96 | fwrite(str, 1, strlen(str), stdout); 97 | } 98 | -------------------------------------------------------------------------------- /example/tctchat.tmpl: -------------------------------------------------------------------------------- 1 | [% CONF dbpath "tctchat.tct" \%] 2 | [% CONF url "tctchat.cgi" \%] 3 | [% CONF title "A Tiny Chat System by Tokyo Cabinet" \%] 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | [%title ENC XML%] 16 | 53 | 103 | 104 | 105 | 106 |
107 |
108 | 109 | 110 |
111 |
112 |

[%title ENC XML%]

113 | [% FOREACH msgs msg \%] 114 |
[%msg ENC XML%]
115 | [% END \%] 116 |
117 |
118 | [% IF prev %]PREV[% ELSE %]PREV[% END %] 119 | [% IF next %]NEXT[% ELSE %]NEXT[% END %] 120 |
121 |
122 | [% FOREACH logs log \%] 123 |
124 | [%log.d ENC XML%] 125 | [%log.a ENC XML%] 126 | [%log.t ENC XML%] 127 |
128 | [% END \%] 129 |
130 |
131 |
132 |
133 | 134 | 135 | 136 |
137 |
138 |
139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /example/tctdbex.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char **argv){ 8 | TCTDB *tdb; 9 | int ecode, pksiz, i, rsiz; 10 | char pkbuf[256]; 11 | const char *rbuf, *name; 12 | TCMAP *cols; 13 | TDBQRY *qry; 14 | TCLIST *res; 15 | 16 | /* create the object */ 17 | tdb = tctdbnew(); 18 | 19 | /* open the database */ 20 | if(!tctdbopen(tdb, "casket.tct", TDBOWRITER | TDBOCREAT)){ 21 | ecode = tctdbecode(tdb); 22 | fprintf(stderr, "open error: %s\n", tctdberrmsg(ecode)); 23 | } 24 | 25 | /* store a record */ 26 | pksiz = sprintf(pkbuf, "%ld", (long)tctdbgenuid(tdb)); 27 | cols = tcmapnew3("name", "mikio", "age", "30", "lang", "ja,en,c", NULL); 28 | if(!tctdbput(tdb, pkbuf, pksiz, cols)){ 29 | ecode = tctdbecode(tdb); 30 | fprintf(stderr, "put error: %s\n", tctdberrmsg(ecode)); 31 | } 32 | tcmapdel(cols); 33 | 34 | /* store a record in a naive way */ 35 | pksiz = sprintf(pkbuf, "12345"); 36 | cols = tcmapnew(); 37 | tcmapput2(cols, "name", "falcon"); 38 | tcmapput2(cols, "age", "31"); 39 | tcmapput2(cols, "lang", "ja"); 40 | if(!tctdbput(tdb, pkbuf, pksiz, cols)){ 41 | ecode = tctdbecode(tdb); 42 | fprintf(stderr, "put error: %s\n", tctdberrmsg(ecode)); 43 | } 44 | tcmapdel(cols); 45 | 46 | /* store a record with a TSV string */ 47 | if(!tctdbput3(tdb, "abcde", "name\tjoker\tage\t19\tlang\ten,es")){ 48 | ecode = tctdbecode(tdb); 49 | fprintf(stderr, "put error: %s\n", tctdberrmsg(ecode)); 50 | } 51 | 52 | /* search for records */ 53 | qry = tctdbqrynew(tdb); 54 | tctdbqryaddcond(qry, "age", TDBQCNUMGE, "20"); 55 | tctdbqryaddcond(qry, "lang", TDBQCSTROR, "ja,en"); 56 | tctdbqrysetorder(qry, "name", TDBQOSTRASC); 57 | tctdbqrysetlimit(qry, 10, 0); 58 | res = tctdbqrysearch(qry); 59 | for(i = 0; i < tclistnum(res); i++){ 60 | rbuf = tclistval(res, i, &rsiz); 61 | cols = tctdbget(tdb, rbuf, rsiz); 62 | if(cols){ 63 | printf("%s", rbuf); 64 | tcmapiterinit(cols); 65 | while((name = tcmapiternext2(cols)) != NULL){ 66 | printf("\t%s\t%s", name, tcmapget2(cols, name)); 67 | } 68 | printf("\n"); 69 | tcmapdel(cols); 70 | } 71 | } 72 | tclistdel(res); 73 | tctdbqrydel(qry); 74 | 75 | /* close the database */ 76 | if(!tctdbclose(tdb)){ 77 | ecode = tctdbecode(tdb); 78 | fprintf(stderr, "close error: %s\n", tctdberrmsg(ecode)); 79 | } 80 | 81 | /* delete the object */ 82 | tctdbdel(tdb); 83 | 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /example/tctsearch.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* function prototypes */ 10 | int main(int argc, char **argv); 11 | static void proc(TCTMPL *tmpl, TCMPOOL *mpool); 12 | 13 | /* main routine */ 14 | int main(int argc, char **argv){ 15 | TCTMPL *tmpl = tctmplnew(); 16 | tctmplload2(tmpl, "tctsearch.tmpl"); 17 | TCMPOOL *mpool = tcmpoolnew(); 18 | proc(tmpl, mpool); 19 | tcmpooldel(mpool); 20 | tctmpldel(tmpl); 21 | return 0; 22 | } 23 | 24 | /* process each session */ 25 | static void proc(TCTMPL *tmpl, TCMPOOL *mpool){ 26 | TCMAP *params = tcmpoolmapnew(mpool); 27 | char *query = getenv("QUERY_STRING"); 28 | if(query) tcwwwformdecode(query, params); 29 | char *expr = tcmpoolpushptr(mpool, tcstrdup(tcmapget4(params, "expr", ""))); 30 | expr = tcstrsqzspc(tcstrutfnorm(expr, TCUNSPACE)); 31 | int page = tclmax(tcatoi(tcmapget4(params, "page", "1")), 1); 32 | const char *dbpath = tctmplconf(tmpl, "dbpath"); 33 | if(!dbpath) dbpath = "tctsearch.tct"; 34 | const char *replace = tctmplconf(tmpl, "replace"); 35 | const char *rbef = replace; 36 | const char *raft = rbef ? strchr(rbef, ' ') : NULL; 37 | if(raft){ 38 | rbef = tcmpoolpushptr(mpool, tcmemdup(rbef, raft - rbef)); 39 | raft++; 40 | } 41 | TCMAP *vars = tcmpoolmapnew(mpool); 42 | if(*expr != '\0'){ 43 | TCTDB *tdb = tcmpoolpush(mpool, tctdbnew(), (void (*)(void *))tctdbdel); 44 | tctdbopen(tdb, dbpath, TDBOREADER); 45 | TDBQRY *qrys[2]; 46 | for(int i = 0; i < 2; i++){ 47 | qrys[i] = tcmpoolpush(mpool, tctdbqrynew(tdb), (void (*)(void *))tctdbqrydel); 48 | tctdbqrysetorder(qrys[i], "title", TDBQOSTRASC); 49 | } 50 | tctdbqryaddcond(qrys[0], "title", TDBQCFTSEX, expr); 51 | tctdbqryaddcond(qrys[1], "body", TDBQCFTSEX, expr); 52 | double stime = tctime(); 53 | TCLIST *res = tcmpoolpushlist(mpool, tctdbmetasearch(qrys, 2, TDBMSUNION)); 54 | int rnum = tclistnum(res); 55 | TCLIST *docs = tcmpoollistnew(mpool); 56 | for(int i = (page - 1) * 10; i < rnum && i < page * 10; i++){ 57 | int pksiz; 58 | const char *pkbuf = tclistval(res, i, &pksiz); 59 | TCMAP *cols = tcmpoolpushmap(mpool, tctdbget(tdb, pkbuf, pksiz)); 60 | if(cols){ 61 | tcmapputkeep2(cols, "title", "(no title)"); 62 | TCXSTR *snip = tcmpoolxstrnew(mpool); 63 | TCLIST *kwic = tctdbqrykwic(qrys[1], cols, NULL, 30, TCKWMUTAB | TCKWNOOVER | TCKWPULEAD); 64 | tcmpoolpushlist(mpool, kwic); 65 | for(int j = 0; j < tclistnum(kwic) && tcxstrsize(snip) < 400; j++){ 66 | if(j > 0) tcxstrcat2(snip, " ... "); 67 | tcxstrcat2(snip, ""); 68 | tcxstrcat2(snip, tcmpoolpushptr(mpool, tcxmlescape(tclistval2(kwic, j)))); 69 | tcxstrcat2(snip, ""); 70 | } 71 | tcxstrcat2(snip, " ..."); 72 | char *hlstr = tcregexreplace(tcxstrptr(snip), "\t([^\t]*)\t", "\\1"); 73 | tcmapput2(cols, "snippet", tcmpoolpushptr(mpool, hlstr)); 74 | const char *url = tcmapget4(cols, "url", "/"); 75 | url = tcmpoolpushptr(mpool, tcregexreplace(url, "*^[a-z]+://", "")); 76 | if(rbef) url = tcmpoolpushptr(mpool, tcregexreplace(url, rbef, raft ? raft : "")); 77 | if(url) tcmapprintf(cols, "url", "%s", url); 78 | tclistpushmap(docs, cols); 79 | } 80 | } 81 | tcmapprintf(vars, "etime", "%.3f", tctime() - stime); 82 | tcmapprintf(vars, "min", "%d", (page - 1) * 10 + 1); 83 | tcmapprintf(vars, "max", "%d", page * 10); 84 | tcmapprintf(vars, "expr", "%s", expr); 85 | tcmapprintf(vars, "hitnum", "%d", rnum); 86 | if(tclistnum(docs) > 0) tcmapputlist(vars, "docs", docs); 87 | if(page > 1) tcmapprintf(vars, "prev", "%d", page - 1); 88 | if(rnum > page * 10) tcmapprintf(vars, "next", "%d", page + 1); 89 | } 90 | char *str = tcmpoolpushptr(mpool, tctmpldump(tmpl, vars)); 91 | printf("Content-Type: text/html; charset=UTF-8\r\n"); 92 | printf("Cache-Control: no-cache\r\n"); 93 | printf("\r\n"); 94 | fwrite(str, 1, strlen(str), stdout); 95 | } 96 | -------------------------------------------------------------------------------- /example/tctsearch.tmpl: -------------------------------------------------------------------------------- 1 | [% CONF dbpath "tctsearch.tct" \%] 2 | [% CONF replace "/home/mikio/public_html localhost" \%] 3 | [% CONF url "tctsearch.cgi" \%] 4 | [% CONF title "A Tiny Search System by Tokyo Cabinet" \%] 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | [%title ENC XML%] 17 | 45 | 51 | 52 | 53 | 54 | [% IF expr NOT \%] 55 |

[%title ENC XML%]

56 |
57 |
58 | 59 | 60 |
61 |
62 | [% END \%] 63 | [% IF expr \%] 64 |
65 |
66 | 67 | 68 |
69 |
70 |

Results [%min%] - [%max%] of about [%hitnum%] for [%expr ENC XML%]. ([%etime%] seconds)

71 | [% IF docs \%] 72 | 95 | [% FOREACH docs doc \%] 96 |
97 |

[%doc.title ENC XML%]

98 |
[%doc.snippet%]
99 |
[%doc.url%]
100 |
101 | [% END \%] 102 |
103 | [% IF prev %]Prev[% ELSE %]Prev[% END %] 104 | [% IF next %]Next[% ELSE %]Next[% END %] 105 |
106 |
107 |
108 | 109 | 110 |
111 |
112 | [% ELSE \%] 113 |

No pages containing all your search terms were found.

114 | [% END \%] 115 | [% END \%] 116 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /example/tcutilex.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char **argv){ 8 | 9 | { /* example to use an extensible string object */ 10 | TCXSTR *xstr; 11 | /* create the object */ 12 | xstr = tcxstrnew(); 13 | /* concatenate strings */ 14 | tcxstrcat2(xstr, "hop"); 15 | tcxstrcat2(xstr, "step"); 16 | tcxstrcat2(xstr, "jump"); 17 | /* print the size and the content */ 18 | printf("%d:%s\n", tcxstrsize(xstr), (char *)tcxstrptr(xstr)); 19 | /* delete the object */ 20 | tcxstrdel(xstr); 21 | } 22 | 23 | { /* example to use a list object */ 24 | TCLIST *list; 25 | int i; 26 | /* create the object */ 27 | list = tclistnew(); 28 | /* add strings to the tail */ 29 | tclistpush2(list, "hop"); 30 | tclistpush2(list, "step"); 31 | tclistpush2(list, "jump"); 32 | /* print all elements */ 33 | for(i = 0; i < tclistnum(list); i++){ 34 | printf("%d:%s\n", i, tclistval2(list, i)); 35 | } 36 | /* delete the object */ 37 | tclistdel(list); 38 | } 39 | 40 | { /* example to use a map object */ 41 | TCMAP *map; 42 | const char *key; 43 | /* create the object */ 44 | map = tcmapnew(); 45 | /* add records */ 46 | tcmapput2(map, "foo", "hop"); 47 | tcmapput2(map, "bar", "step"); 48 | tcmapput2(map, "baz", "jump"); 49 | /* print all records */ 50 | tcmapiterinit(map); 51 | while((key = tcmapiternext2(map)) != NULL){ 52 | printf("%s:%s\n", key, tcmapget2(map, key)); 53 | } 54 | /* delete the object */ 55 | tcmapdel(map); 56 | } 57 | 58 | { /* example to use a tree object */ 59 | TCTREE *tree; 60 | const char *key; 61 | /* create the object */ 62 | tree = tctreenew(); 63 | /* add records */ 64 | tctreeput2(tree, "foo", "hop"); 65 | tctreeput2(tree, "bar", "step"); 66 | tctreeput2(tree, "baz", "jump"); 67 | /* print all records */ 68 | tctreeiterinit(tree); 69 | while((key = tctreeiternext2(tree)) != NULL){ 70 | printf("%s:%s\n", key, tctreeget2(tree, key)); 71 | } 72 | /* delete the object */ 73 | tctreedel(tree); 74 | } 75 | 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /hogehoge: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clement/tokyo-cabinet/5cb3d3fc93b04b0738298727255ac1b9ba29920f/hogehoge -------------------------------------------------------------------------------- /lab/calccomp: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | #================================================================ 4 | # calccomp 5 | # Measure elapsed time and database size of compression algos 6 | #================================================================ 7 | 8 | use strict; 9 | use warnings; 10 | use Time::HiRes qw(gettimeofday); 11 | 12 | use constant { 13 | WORDFILE => '/usr/share/dict/words', 14 | TSVFILE => 'words.tsv', 15 | NULLFILE => '/dev/null', 16 | BNUM => 262144, 17 | LCNUM => 8192, 18 | TESTCOUNT => 20, 19 | REMOVETOP => 2, 20 | REMOVEBOTTOM => 8, 21 | }; 22 | 23 | open(IN, '<' . WORDFILE) or die(WORDFILE . ' could not be opened'); 24 | open(OUT, '>' . TSVFILE) or die(TSVFILE . ' could not be opened'); 25 | while(defined(my $word = )){ 26 | $word =~ s/[\t\r\n]//g; 27 | next if(length($word) < 1); 28 | printf OUT ("%s\t%d\n", $word, int(rand(10000))); 29 | } 30 | close(OUT); 31 | close(IN); 32 | 33 | my @commands = ( 34 | './tchmgr create casket-hash ' . BNUM . ' ; ./tchmgr importtsv casket-hash ' . TSVFILE, 35 | './tchmgr list casket-hash >' . NULLFILE, 36 | './tcbmgr create casket-btree ' . LCNUM . ' ; ./tcbmgr importtsv casket-btree ' . TSVFILE, 37 | './tcbmgr list casket-btree >' . NULLFILE, 38 | './tcbmgr create -td casket-bt-td ' . LCNUM . ' ; ./tcbmgr importtsv casket-bt-td ' . TSVFILE, 39 | './tcbmgr list casket-bt-td >' . NULLFILE, 40 | './tcbmgr create -tb casket-bt-tb ' . LCNUM . ' ; ./tcbmgr importtsv casket-bt-tb ' . TSVFILE, 41 | './tcbmgr list casket-bt-tb >' . NULLFILE, 42 | './tcbmgr create -tt casket-bt-tt ' . LCNUM . ' ; ./tcbmgr importtsv casket-bt-tt ' . TSVFILE, 43 | './tcbmgr list casket-bt-tt >' . NULLFILE, 44 | './tcbmgr create -tx casket-bt-tx ' . LCNUM . ' ; ./tcbmgr importtsv casket-bt-tx ' . TSVFILE, 45 | './tcbmgr list casket-bt-tx >' . NULLFILE, 46 | ); 47 | 48 | my @names = ( 49 | 'casket-hash', 50 | 'casket-btree', 51 | 'casket-bt-td', 52 | 'casket-bt-tb', 53 | 'casket-bt-tt', 54 | 'casket-bt-tx', 55 | ); 56 | 57 | foreach my $name (@names){ 58 | my @paths = glob("$name*"); 59 | foreach my $path (@paths){ 60 | unlink($path); 61 | } 62 | } 63 | 64 | my @table; 65 | foreach my $command (@commands){ 66 | system('sync ; sync'); 67 | $ENV{'HIDEPRGR'} = 1; 68 | my @result; 69 | for(my $i = 0; $i < TESTCOUNT; $i++){ 70 | my $stime = gettimeofday(); 71 | system("$command >/dev/null 2>&1"); 72 | $stime = gettimeofday() - $stime; 73 | printf("%s\t%d\t%0.5f\n", $command, $i + 1, $stime); 74 | push(@result, $stime); 75 | } 76 | @result = sort { $a <=> $b } @result; 77 | for(my $i = 0; $i < REMOVETOP; $i++){ 78 | shift(@result); 79 | } 80 | for(my $i = 0; $i < REMOVEBOTTOM; $i++){ 81 | pop(@result); 82 | } 83 | my $sum = 0; 84 | foreach my $result (@result){ 85 | $sum += $result; 86 | } 87 | my $avg = $sum / scalar(@result); 88 | push(@table, [$command, $avg]); 89 | } 90 | 91 | printf("\n\nRESULT\n\n"); 92 | foreach my $row (@table){ 93 | printf("%s\t%0.5f\n", $$row[0], $$row[1]); 94 | } 95 | printf("\n"); 96 | 97 | my @sizes; 98 | foreach my $name (@names){ 99 | my @sbuf = stat($name); 100 | my $size = $sbuf[7]; 101 | printf("%s\t%s\n", $name, $size); 102 | push(@sizes, $size); 103 | } 104 | my @sbuf = stat(TSVFILE); 105 | my $size = $sbuf[7]; 106 | printf("\n"); 107 | 108 | printf("%s,%.5f,%.5f,%d\n", "ORIGINAL", 0, 0, $size); 109 | printf("%s,%.5f,%.5f,%d\n", "HASH", $table[0][1], $table[1][1], $sizes[0]); 110 | printf("%s,%.5f,%.5f,%d\n", "BTREE", $table[2][1], $table[3][1], $sizes[1]); 111 | printf("%s,%.5f,%.5f,%d\n", "BTREE-DEFLATE", $table[4][1], $table[5][1], $sizes[2]); 112 | printf("%s,%.5f,%.5f,%d\n", "BTREE-BZIP2", $table[6][1], $table[7][1], $sizes[3]); 113 | printf("%s,%.5f,%.5f,%d\n", "BTREE-TCBS", $table[8][1], $table[9][1], $sizes[4]); 114 | printf("%s,%.5f,%.5f,%d\n", "BTREE-EXCODEC", $table[10][1], $table[11][1], $sizes[5]); 115 | 116 | 117 | 118 | # END OF FILE 119 | -------------------------------------------------------------------------------- /lab/datechange: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | #================================================================ 4 | # datechange 5 | # Replace date expressions 6 | #================================================================ 7 | 8 | 9 | # set variables 10 | LANG=C 11 | LC_ALL=C 12 | export LANG LC_ALL 13 | year=`date '+%Y'` 14 | date=`date '+%Y-%m-%d'` 15 | fulldate=`date -R` 16 | regexsrc='\.(h|c|cc|cpp|cxx|java|pl|pm|pod|rb|rd|lua)$' 17 | regexman='\.[0-9]$' 18 | regexhtml='\.html$' 19 | 20 | 21 | # edit source files 22 | find . -type f | egrep "$regexsrc" | 23 | while read file 24 | do 25 | echo "$file" 26 | sed "/opyright/ s/\\(20[0-9][0-9]\\)-\\(20[0-9][0-9]\\)/\\1-$year/" "$file" > "$file.tmp" 27 | mv -f "$file.tmp" "$file" 28 | done 29 | 30 | 31 | # edit manual files 32 | find . -type f | egrep "$regexman" | 33 | while read file 34 | do 35 | echo "$file" 36 | sed "/\\.TH/ s/\\(20[0-9][0-9]\\)-\\([0-9][0-9]\\)-\\([0-9][0-9]\\)/$date/" "$file" > "$file.tmp" 37 | mv -f "$file.tmp" "$file" 38 | done 39 | 40 | 41 | # edit HTML files 42 | find . -type f | egrep "$regexhtml" | 43 | while read file 44 | do 45 | echo "$file" 46 | sed -e "/opyright/ s/\\(20[0-9][0-9]\\)-\\(20[0-9][0-9]\\)/\\1-$year/" -e "/
/ s/Last Update: *\\([A-Z][a-z][a-z], [0-9][0-9] [A-Z][a-z][a-z] 20[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] +[0-9][0-9]*\\)/Last Update: $fulldate/" "$file" > "$file.tmp" 47 | mv -f "$file.tmp" "$file" 48 | done 49 | 50 | 51 | # exit normally 52 | exit 0 53 | 54 | 55 | 56 | # END OF FILE 57 | -------------------------------------------------------------------------------- /lab/diffcheck: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | #================================================================ 4 | # diffcheck 5 | # List files different from ones of another version 6 | #================================================================ 7 | 8 | 9 | # set variables 10 | LANG=C 11 | LC_ALL=C 12 | export LANG LC_ALL 13 | regex='\.(h|c|cc|cpp|cxx|java|pl|pm|pod|rb|rd|lua|[1-9]|html|txt)$' 14 | 15 | 16 | # check arguments 17 | if [ $# != 1 ] 18 | then 19 | printf 'diffcheck: usage: diffcheck directory_of_oldversion\n' 1>&2 20 | exit 1 21 | fi 22 | 23 | 24 | # diff files 25 | find . -type f | egrep $regex | 26 | while read file 27 | do 28 | old=`printf '%s\n' "$file" | sed 's/^\.\///'` 29 | printf 'Checking %s and %s ... ' "$file" "$1/$old" 30 | res=`diff -q "$file" "$1/$old"` 31 | if [ -z "$res" ] 32 | then 33 | printf 'same\n' 34 | else 35 | printf '### !!! DIFFERENT !!! ###\n' 36 | fi 37 | done 38 | 39 | 40 | # exit normally 41 | exit 0 42 | 43 | 44 | 45 | # END OF FILE 46 | -------------------------------------------------------------------------------- /lab/htmldoctotsv: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | #================================================================ 4 | # htmldoctotsv 5 | # Generate TSV data from HTML documents 6 | #================================================================ 7 | 8 | use strict; 9 | use warnings; 10 | use Encode; 11 | use Cwd 'realpath'; 12 | 13 | my $path = '.'; 14 | my $mode_table = 0; 15 | my $mode_hex = 0; 16 | 17 | for(my $i = 0; $i < scalar(@ARGV); $i++){ 18 | my $arg = $ARGV[$i]; 19 | if($arg =~ /^-/){ 20 | if($arg eq '-t'){ 21 | $mode_table = 1; 22 | } elsif($arg eq '-x'){ 23 | $mode_hex = 1; 24 | } 25 | } else { 26 | $path = $arg; 27 | } 28 | } 29 | 30 | sub trimhtml { 31 | my $text = shift; 32 | $text =~ s/<[^>]*>/ /g; 33 | $text =~ s/<//g; 35 | $text =~ s/"/"/g; 36 | $text =~ s/ / /g; 37 | $text =~ s/&/\&/g; 38 | $text =~ s/\s+/ /g; 39 | $text =~ s/^ *//; 40 | $text =~ s/ *$//; 41 | return $text; 42 | } 43 | 44 | $ENV{LANG} = "C"; 45 | $ENV{LC_ALL} = "C"; 46 | open(my $lfh, "find $path -type f -iregex '.*\.html?' -print | sort |") || die("could not open"); 47 | my $id = 0; 48 | while(defined($path = <$lfh>)){ 49 | chomp($path); 50 | $path = realpath($path); 51 | next if(!defined($path)); 52 | my @stat = stat($path); 53 | next if(scalar(@stat) < 10); 54 | my $mtime = $stat[9]; 55 | open(my $ifh, "<$path") || next; 56 | my $encname = "UTF-8"; 57 | my @lines; 58 | while(defined(my $line = <$ifh>)){ 59 | push(@lines, $line); 60 | if($line =~ / 0); 65 | } 66 | } 67 | my $text = join('', @lines); 68 | $text = encode("UTF-8", decode($encname, $text)) if($encname ne "UTF-8"); 69 | $text =~ s///is; 70 | my $title = ""; 71 | if($text =~ /]*>[^<]*<\/title>/i){ 72 | $title = $text; 73 | $title =~ s/.*]*>([^<]*)<\/title>.*/$1/is; 74 | $title = trimhtml($title); 75 | } 76 | $text =~ s/.*]*>(.*)<\/body>.*/$1/is; 77 | $text =~ s/]*>.*?<\/style>//is; 78 | $text =~ s/]*>.*?<\/script>//is; 79 | $text = trimhtml($text); 80 | next if(length($title) < 1 && length($text) < 1); 81 | $id++; 82 | my $key = $mode_hex ? sprintf("%X", $id) : $id; 83 | if($mode_table){ 84 | printf("%s", $key); 85 | printf("\tpath\t%s", $path); 86 | printf("\tsize\t%s", length($text)); 87 | printf("\tmtime\t%s", $mtime); 88 | printf("\ttitle\t%s", $title) if(length($title) > 0); 89 | printf("\ttext\t%s", $text); 90 | printf("\n"); 91 | } else { 92 | $text = $title . " " . $text if(length($title) > 0); 93 | printf("%s\t%s\n", $key, $text); 94 | } 95 | close($ifh); 96 | } 97 | close($lfh); 98 | 99 | 100 | 101 | # END OF FILE 102 | -------------------------------------------------------------------------------- /lab/htmltotsv: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | #================================================================ 4 | # htmldoctotsv 5 | # Generate TSV data from HTML documents 6 | #================================================================ 7 | 8 | use strict; 9 | use warnings; 10 | use Encode; 11 | use Cwd 'realpath'; 12 | 13 | my $path = '.'; 14 | my $mode_kv = 0; 15 | my $mode_hex = 0; 16 | 17 | for(my $i = 0; $i < scalar(@ARGV); $i++){ 18 | my $arg = $ARGV[$i]; 19 | if($arg =~ /^-/){ 20 | if($arg eq '-kv'){ 21 | $mode_kv = 1; 22 | } elsif($arg eq '-x'){ 23 | $mode_hex = 1; 24 | } 25 | } else { 26 | $path = $arg; 27 | } 28 | } 29 | 30 | sub trimhtml { 31 | my $text = shift; 32 | $text =~ s/<[^>]*>/ /g; 33 | $text =~ s/<//g; 35 | $text =~ s/"/"/g; 36 | $text =~ s/ / /g; 37 | $text =~ s/&/\&/g; 38 | $text =~ s/\s+/ /g; 39 | $text =~ s/^ *//; 40 | $text =~ s/ *$//; 41 | return $text; 42 | } 43 | 44 | $ENV{LANG} = "C"; 45 | $ENV{LC_ALL} = "C"; 46 | open(my $lfh, "find $path -type f -iregex '.*\.html?' -print | sort |") || die("could not open"); 47 | my $id = 0; 48 | while(defined($path = <$lfh>)){ 49 | chomp($path); 50 | $path = realpath($path); 51 | next if(!defined($path)); 52 | my @stat = stat($path); 53 | next if(scalar(@stat) < 10); 54 | my $mtime = $stat[9]; 55 | open(my $ifh, "<$path") || next; 56 | my $encname = "UTF-8"; 57 | my @lines; 58 | while(defined(my $line = <$ifh>)){ 59 | push(@lines, $line); 60 | if($line =~ / 0); 65 | } 66 | } 67 | my $text = join('', @lines); 68 | $text = encode("UTF-8", decode($encname, $text)) if($encname ne "UTF-8"); 69 | $text =~ s///is; 70 | my $title = ""; 71 | if($text =~ /]*>[^<]*<\/title>/i){ 72 | $title = $text; 73 | $title =~ s/.*]*>([^<]*)<\/title>.*/$1/is; 74 | $title = trimhtml($title); 75 | } 76 | $text =~ s/.*]*>(.*)<\/body>.*/$1/is; 77 | $text =~ s/]*>.*?<\/style>//is; 78 | $text =~ s/]*>.*?<\/script>//is; 79 | $text = trimhtml($text); 80 | next if(length($title) < 1 && length($text) < 1); 81 | $id++; 82 | my $key = $mode_hex ? sprintf("%X", $id) : $id; 83 | printf STDERR ("%d: saving: %s\n", $id, $path); 84 | if($mode_kv){ 85 | $text = $title . " " . $text if(length($title) > 0); 86 | printf("%s\t%s\n", $key, $text); 87 | } else { 88 | printf("%s", $key); 89 | printf("\turl\t%s", $path); 90 | printf("\tsize\t%s", length($text)); 91 | printf("\tmtime\t%s", $mtime); 92 | printf("\ttitle\t%s", $title) if(length($title) > 0); 93 | printf("\tbody\t%s", $text); 94 | printf("\n"); 95 | } 96 | close($ifh); 97 | } 98 | close($lfh); 99 | 100 | 101 | 102 | # END OF FILE 103 | -------------------------------------------------------------------------------- /lab/magic: -------------------------------------------------------------------------------- 1 | # Tokyo Cabinet magic data 2 | 0 string ToKyO\ CaBiNeT\n Tokyo Cabinet 3 | >14 string x \b (%s) 4 | >32 byte 0 \b, Hash 5 | >32 byte 1 \b, B+ tree 6 | >32 byte 2 \b, Fixed-length 7 | >32 byte 3 \b, Table 8 | >33 byte &1 \b, [open] 9 | >33 byte &2 \b, [fatal] 10 | >34 byte x \b, apow=%d 11 | >35 byte x \b, fpow=%d 12 | >36 byte &1 \b, [large] 13 | >36 byte &2 \b, [deflate] 14 | >36 byte &4 \b, [bzip] 15 | >36 byte &8 \b, [tcbs] 16 | >36 byte &16 \b, [excodec] 17 | >40 lelong x \b, bnum=%d 18 | >48 lelong x \b, rnum=%d 19 | >56 lelong x \b, fsiz=%d 20 | -------------------------------------------------------------------------------- /lab/printenv.cgi: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | #================================================================ 4 | # printenv.cgi 5 | # Print CGI environment variables 6 | #================================================================ 7 | 8 | 9 | # set variables 10 | LANG=C 11 | LC_ALL=C 12 | export LANG LC_ALL 13 | 14 | 15 | # output the result 16 | printf 'Content-Type: text/plain\r\n' 17 | printf '\r\n' 18 | 19 | printenv | sort 20 | 21 | 22 | # exit normally 23 | exit 0 24 | 25 | 26 | 27 | # END OF FILE 28 | -------------------------------------------------------------------------------- /lab/stepcount: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | #================================================================ 4 | # stepcount 5 | # Find files including dispensable tab characters 6 | #================================================================ 7 | 8 | 9 | # set variables 10 | LANG=C 11 | LC_ALL=C 12 | export LANG LC_ALL 13 | regex='(\.h|\.c|\.cc|\.java|\.pl|\.pm|\.xs|\.rb|\.js)$' 14 | 15 | 16 | # count steps 17 | files=`find . -type f | egrep $regex` 18 | wc -l $files | sort -n 19 | 20 | 21 | # exit normally 22 | exit 0 23 | 24 | 25 | 26 | # END OF FILE 27 | -------------------------------------------------------------------------------- /lab/stopwatch: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | #================================================================ 4 | # stopwatch 5 | # Measure elapsed time of some test commands. 6 | #================================================================ 7 | 8 | use strict; 9 | use warnings; 10 | use Time::HiRes qw(gettimeofday); 11 | 12 | use constant { 13 | TESTCOUNT => 20, 14 | REMOVETOP => 2, 15 | REMOVEBOTTOM => 8, 16 | }; 17 | 18 | my @commands = ( 19 | "./tchtest write casket 1000000 1000000", 20 | "./tchtest read casket", 21 | "./tchtest rcat casket 1000000", 22 | "./tcbtest write casket 1000000", 23 | "./tcbtest read casket", 24 | "./tcbtest rcat -lc 256 -nc 128 casket 100000", 25 | ); 26 | 27 | my @table; 28 | foreach my $command (@commands){ 29 | system("sync ; sync"); 30 | my @result; 31 | for(my $i = 0; $i < TESTCOUNT; $i++){ 32 | my $stime = gettimeofday(); 33 | system("$command >/dev/null 2>&1"); 34 | $stime = gettimeofday() - $stime; 35 | printf("%s\t%d\t%0.5f\n", $command, $i + 1, $stime); 36 | push(@result, $stime); 37 | } 38 | @result = sort { $a <=> $b } @result; 39 | for(my $i = 0; $i < REMOVETOP; $i++){ 40 | shift(@result); 41 | } 42 | for(my $i = 0; $i < REMOVEBOTTOM; $i++){ 43 | pop(@result); 44 | } 45 | my $sum = 0; 46 | foreach my $result (@result){ 47 | $sum += $result; 48 | } 49 | my $avg = $sum / scalar(@result); 50 | push(@table, [$command, $avg]); 51 | } 52 | 53 | printf("\n\nRESULT\n"); 54 | foreach my $row (@table){ 55 | printf("%s\t%0.5f\n", $$row[0], $$row[1]); 56 | } 57 | printf("\n"); 58 | 59 | 60 | 61 | # END OF FILE 62 | -------------------------------------------------------------------------------- /lab/tabcheck: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | #================================================================ 4 | # tabcheck 5 | # Find files including dispensable tab and space characters 6 | #================================================================ 7 | 8 | 9 | # set variables 10 | LANG=C 11 | LC_ALL=C 12 | export LANG LC_ALL 13 | regex='\.(h|c|cc|cpp|cxx|java|pl|pm|pod|rb|rd|lua)$' 14 | tabcode=`printf '\t'` 15 | 16 | 17 | # find tab 18 | find . -type f | egrep $regex | 19 | while read file 20 | do 21 | printf 'Checking %s ... ' $file 22 | err=0 23 | if grep "$tabcode" $file > /dev/null 24 | then 25 | printf '### !!! TAB FOUND !!! ###' 26 | err=1 27 | fi 28 | if grep ' $' $file > /dev/null 29 | then 30 | printf '### !!! TAILING SPACE FOUND !!! ###' 31 | err=1 32 | fi 33 | [ "$err" = 0 ] && printf 'ok' 34 | printf '\n' 35 | done 36 | 37 | 38 | # exit normally 39 | exit 0 40 | 41 | 42 | 43 | # END OF FILE 44 | -------------------------------------------------------------------------------- /lab/wgettsv: -------------------------------------------------------------------------------- 1 | #! /usr/bin/ruby -w 2 | 3 | #================================================================ 4 | # wgettsv 5 | # Collect WWW resources and generate TSV data 6 | #================================================================ 7 | 8 | require 'open-uri' 9 | require 'iconv' 10 | require 'kconv' 11 | require 'date' 12 | require 'time' 13 | require 'cgi' 14 | 15 | def main 16 | seeds = [] 17 | hist = {} 18 | filters = [] 19 | max = 1 << 30 20 | lim = 1 << 20 21 | wait = 0 22 | ndf = false 23 | i = 0 24 | while i < ARGV.length 25 | if seeds.length < 1 && ARGV[i] =~ /^-/ 26 | if ARGV[i] == '-allow' 27 | usage if (i += 1) >= ARGV.length 28 | regex = Regexp::new(ARGV[i]) 29 | filters.push([true, regex]) if regex 30 | elsif ARGV[i] == '-deny' 31 | usage if (i += 1) >= ARGV.length 32 | regex = Regexp::new(ARGV[i]) 33 | filters.push([false, regex]) if regex 34 | elsif ARGV[i] == '-max' 35 | usage if (i += 1) >= ARGV.length 36 | max = ARGV[i].to_i 37 | elsif ARGV[i] == '-lim' 38 | usage if (i += 1) >= ARGV.length 39 | lim = ARGV[i].to_i 40 | elsif ARGV[i] == '-wait' 41 | usage if (i += 1) >= ARGV.length 42 | wait = ARGV[i].to_f 43 | elsif ARGV[i] == '-ndf' 44 | ndf = true 45 | else 46 | usage 47 | end 48 | else 49 | if ARGV[i] =~ /^http:\/\//i 50 | seeds.push(ARGV[i]) 51 | hist[ARGV[i]] = true 52 | else 53 | usage 54 | end 55 | end 56 | i += 1 57 | end 58 | usage if seeds.length < 1 59 | if !ndf 60 | filters.push([false, /\.(txt|text|asc|c|cc|cxx|cpp|h|hxx|hpp|in)$/i]) 61 | filters.push([false, /\.(css|js|csv|tsv|log|md5|crc|conf|ini|inf|lnk|sys|tmp|bak)$/i]) 62 | filters.push([false, /\.(xml|xsl|xslt|rdf|rss|dtd|sgml|sgm)$/i]) 63 | filters.push([false, /\.(pgp|sig|cer|csr|pem|key|b64|uu|uue|[0-9])$/i]) 64 | filters.push([false, /\.(rtf|pdf|ps|eps|ai|doc|xls|ppt|sxw|sxc|sxi|xdw|jtd|oas|swf)$/i]) 65 | filters.push([false, /\.(zip|tar|tgz|gz|bz2|tbz2|z|lha|lzh)?$/i]) 66 | filters.push([false, /\.(7z|lzo|lzma|cpio|shar|cab|rar|sit|ace|hqx)?$/i]) 67 | filters.push([false, /\.(bin|o|a|so|exe|dll|lib|obj|ocx|class|jar|war)?$/i]) 68 | filters.push([false, /\.(rpm|deb|qdb|qdb|dbx|dbf|dat|msi|bat|com|iso)?$/i]) 69 | filters.push([false, /\.(png|gif|jpg|jpeg|tif|tiff|bmp|ico|pbm|pgm|ppm|xbm|xpm|dvi)$/i]) 70 | filters.push([false, /\.(au|snd|mid|midi|kar|smf|mp2|mp3|m3u|wav|wma|wmp|asx|at3|aif)$/i]) 71 | filters.push([false, /\.(mpg|mpeg|qt|mov|avi|wmv|wvx|asf|ram|rm)$/i]) 72 | filters.push([false, /\.(tch|tdb|tdf|tct)$/i]) 73 | filters.push([false, /\.idx\./i]) 74 | filters.push([false, /(core|casket|Makefile|README|NEWS|COPYING|LISENCE)($|\/)/i]) 75 | end 76 | return proc(seeds, hist, filters, max, lim, wait) ? 0 : 1 77 | end 78 | 79 | def usage 80 | STDERR.printf("%s: collect WWW resources and generate TSV data\n", $progname) 81 | STDERR.printf("\n") 82 | STDERR.printf("usage:\n") 83 | STDERR.printf(" %s [-allow regex] [-deny regex] [-max num] [-lim num] [-wait num]" + 84 | " url ...\n", $progname) 85 | STDERR.printf("\n") 86 | exit(1) 87 | end 88 | 89 | def proc(seeds, hist, filters, max, lim, wait) 90 | cnt = 0 91 | while (url = seeds.shift) && cnt < max 92 | STDERR.printf("%d: getting: %s\n", cnt + 1, url) 93 | begin 94 | opts = {} 95 | OpenURI.open_uri(url, 0, 0, opts) do |sio| 96 | baseuri = sio.base_uri 97 | if baseuri && baseuri.to_s != url 98 | url = baseuri.to_s 99 | hist[url] = true 100 | end 101 | size = sio.size 102 | raise "invalid size" if size > lim || size < 3 103 | type = sio.content_type 104 | type = "text/plain" if !type 105 | str = sio.read 106 | head = str[0,2048] 107 | if (head[0] == 0xfe && head[1] == 0xff) || (head[0] == 0xff && head[1] == 0xfe) 108 | str = Kconv::kconv(str, Kconv::UTF8, Kconv::UTF16) 109 | charset = "UTF-8" 110 | elsif str.include?(0) 111 | raise "binary data" 112 | end 113 | raise "not HTML" if type != "text/html" && head !~ / 0 122 | if charset !~ /^UTF-?8$/i 123 | begin 124 | nstr = Iconv.conv("UTF-8", charset, str) 125 | str = nstr if nstr && nstr.length > 0 126 | rescue 127 | str = str.toutf8 128 | end 129 | end 130 | else 131 | str = str.toutf8 132 | end 133 | body = str.gsub(/.*]*>/im, "") 134 | body = body.gsub(/<\/body>.*/im, "") 135 | body = htmltotext(body) 136 | if str =~ /]*>[^<]*<\/title>/im 137 | title = str.gsub(/.*]*>([^<]*)<\/title>.*/im, '\1') 138 | title = htmltotext(title) 139 | end 140 | title = "" if !title 141 | title = title[0,128] if title.length > 128 142 | mtime = sio.last_modified 143 | if mtime 144 | mtime = Time::parse(mtime.to_s).to_i 145 | else 146 | mtime = 0 147 | end 148 | printf("%d", cnt + 1) 149 | printf("\turl\t%s", url) 150 | printf("\tsize\t%s", size) if size > 0 151 | printf("\tmtime\t%s", mtime) if mtime > 0 152 | printf("\ttitle\t%s", title) if title.length > 0 153 | printf("\tbody\t%s", body) if body.length > 0 154 | printf("\n") 155 | str.gsub(/]*>/im) do |tag| 156 | if tag =~ /href=["']?[^"'>]+["']?/ 157 | href = tag.gsub(/.*href=["']?([^"'>]+)["']?.*/, '\1') 158 | href = URI::join(url, href).to_s 159 | href = href.gsub(/#.*/, "") 160 | if !hist[href] && checkurl(href, filters) 161 | seeds.push(href) 162 | hist[href] = true 163 | end 164 | end 165 | end 166 | end 167 | cnt += 1 168 | rescue 169 | STDERR.printf("%d: failed: %s: %s\n", cnt + 1, url, $!) 170 | end 171 | sleep(wait) if wait > 0 172 | end 173 | return 0 174 | end 175 | 176 | def htmltotext(str) 177 | str = str.gsub(/]*>.*?<\/style>/im, " ") 178 | str = str.gsub(/]*>.*?<\/script>/im, " ") 179 | str = str.gsub(/<\/?(p|br|div|h1|h2|h3|h4|h5|h6|ul|ol|dl|li|dd|dt|td|th|pre)[^>]*>/im, " ") 180 | str = str.gsub(/<[^>]*>/, "") 181 | str = str.gsub(/&(nbsp|#160|#0160|#xa0|#x00a0);/i, " ") 182 | hexrx = Regexp::new("^&#x[0-9a-zA-Z]+;") 183 | decrx = Regexp::new("^&#[0-9]+;") 184 | str = str.gsub(/&#?[A-Za-z0-9]+;/) do |pat| 185 | case pat 186 | when "<" 187 | pat = '<' 188 | when ">" 189 | pat = '>' 190 | when """ 191 | pat = '"' 192 | when "'" 193 | pat = "'" 194 | when " " 195 | pat = " " 196 | else 197 | begin 198 | if pat =~ hexrx 199 | pat = [ pat.gsub(/&#x([A-Za-z0-9]+);/i, '\1').hex ].pack("n") 200 | pat = Iconv.conv("UTF-8", "UTF-16BE", pat) 201 | elsif pat =~ decrx 202 | pat = [ pat.gsub(/&#([A-Za-z0-9]+);/i, '\1').to_i ].pack("n") 203 | pat = Iconv.conv("UTF-8", "UTF-16BE", pat) 204 | else 205 | pat = " " 206 | end 207 | rescue 208 | pat = "" 209 | end 210 | end 211 | pat 212 | end 213 | str = str.gsub(/[\x00-\x20]/, " ") 214 | str = str.gsub(/\xe3\x80\x80/, " ") 215 | str = str.gsub(/ +/, " ") 216 | str = str.gsub(/^ */, "") 217 | str = str.gsub(/ *$/, "") 218 | return str 219 | end 220 | 221 | def checkurl(url, filters) 222 | return false if url !~ /^http:\/\//i; 223 | return true if filters.length < 1 224 | ok = !filters[0][0] 225 | filters.each do |filter| 226 | ok = filter[0] if url =~ filter[1] 227 | end 228 | return ok 229 | end 230 | 231 | STDOUT.sync = true 232 | $progname = $0.dup 233 | $progname.gsub!(/.*\//, "") 234 | srand 235 | exit(main) 236 | -------------------------------------------------------------------------------- /lab/yearchange: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | #================================================================ 4 | # yearchange 5 | # Replace year expressions 6 | #================================================================ 7 | 8 | 9 | # set variables 10 | year=`date '+%Y'` 11 | regex='(\.h|\.c|\.cc|\.cpp|\.cxx|\.java|\.pl|\.pm|\.pod|\.rb|\.rd|\.lua)$' 12 | 13 | 14 | # replace year expressions 15 | find . -type f | egrep "$regex" | 16 | while read file 17 | do 18 | echo "$file" 19 | sed "s/\\(20[0-9][0-9]\\)-\\(20[0-9][0-9]\\)/\\1-$year/g" "$file" > "$file.tmp" 20 | mv -f "$file.tmp" "$file" 21 | done 22 | 23 | 24 | # exit normally 25 | exit 0 26 | 27 | 28 | 29 | # END OF FILE 30 | -------------------------------------------------------------------------------- /man/htmltoman: -------------------------------------------------------------------------------- 1 | #! /usr/bin/awk -f 2 | 3 | function strip(text){ 4 | gsub("^ *<[a-zA-Z0-9]*[^>]*>", "", text) 5 | gsub(" *$", "", text) 6 | return text 7 | } 8 | 9 | function unescape(text){ 10 | gsub("<", "<", text) 11 | gsub(">", ">", text) 12 | gsub(""", "\"", text) 13 | gsub("&", "\\&", text) 14 | gsub("-", "\\-", text) 15 | return text 16 | } 17 | 18 | BEGIN { 19 | date = strftime("%Y-%m-%d") 20 | printf(".TH \"%s\" %d \"%s\" \"%s\" \"%s\"\n\n", "INTRO", 3, date, "Man Page", "Tokyo Cabinet") 21 | } 22 | 23 | / *]*>.*<\/h[1-3]> *$/ { 24 | text = $0 25 | text = strip(text) 26 | text = unescape(text) 27 | text = toupper(text) 28 | printf("\n") 29 | printf(".SH %s\n", text) 30 | } 31 | 32 | / *

]*>.*<\/p> *$/ { 33 | text = $0 34 | text = strip(text) 35 | text = gensub("]*>([^<]*)", "\\\\fB\\1\\\\fR", "g", text) 36 | text = gensub("]*>([^<]*)", "\\\\fI\\1\\\\fR", "g", text) 37 | gsub("<[^>]*>", "", text) 38 | text = unescape(text) 39 | printf(".PP\n") 40 | printf("%s\n", text) 41 | } 42 | 43 | / *

]*> *$/ { 44 | printf(".PP\n") 45 | printf(".RS\n") 46 | } 47 | / *<\/dl> *$/ { 48 | printf(".RE\n") 49 | } 50 | / *
]*>.*<\/dt> *$/ { 51 | text = $0 52 | text = strip(text) 53 | text = gensub("]*>([^<]*)", "\\\\fI\\1\\\\fB", "g", text) 54 | gsub("<[^>]*>", "", text) 55 | gsub("[\\||\\[|\\]]", "\\fR&\\fB", text) 56 | text = unescape(text) 57 | printf(".br\n") 58 | printf("\\fB%s\\fR\n", text) 59 | } 60 | / *
]*>.*<\/dd> *$/ { 61 | text = $0 62 | text = strip(text) 63 | text = gensub("]*>([^<]*)", "\\\\fB\\1\\\\fR", "g", text) 64 | text = gensub("]*>([^<]*)", "\\\\fI\\1\\\\fR", "g", text) 65 | gsub("<[^>]*>", "", text) 66 | text = unescape(text) 67 | printf(".RS\n") 68 | printf("%s\n", text) 69 | printf(".RE\n") 70 | } 71 | 72 | / *
    ]*> *$/ { 73 | printf(".PP\n") 74 | printf(".RS\n") 75 | } 76 | / *<\/ul> *$/ { 77 | printf(".RE\n") 78 | } 79 | / *
  • ]*>.*<\/li> *$/ { 80 | text = $0 81 | text = strip(text) 82 | text = gensub("]*>(.*)", "\\\\fB\\1\\\\fR", "g", text) 83 | text = gensub("]*>([^<]*)", "\\\\fI\\1\\\\fR", "g", text) 84 | gsub("<[^>]*>", "", text) 85 | text = unescape(text) 86 | printf("%s\n", text) 87 | printf(".br\n") 88 | } 89 | 90 | END { 91 | printf("\n") 92 | printf(".SH SEE ALSO\n") 93 | printf(".PP\n") 94 | printf(".BR tcutil (3),\n") 95 | printf(".BR tchdb (3),\n") 96 | printf(".BR tcbdb (3)\n") 97 | printf(".BR tcfdb (3)\n") 98 | printf(".PP\n") 99 | printf("Please see\n") 100 | printf(".I http://tokyocabinet.sourceforge.net/spex-en.html\n") 101 | printf("for detail.\n") 102 | } 103 | -------------------------------------------------------------------------------- /man/tcamgr.1: -------------------------------------------------------------------------------- 1 | .TH "TCATEST" 3 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcamgr \- the command line utility of the abstract database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtcamgr\fR' is a utility for test and debugging of the abstract database API and its applications. `\fIname\fR' specifies the name of a database. `\fIkey\fR' specifies the key of a record. `\fIvalue\fR' specifies the value of a record. `\fIparams\fR' specifies the tuning parameters. `\fIfunc\fR' specifies the name of a function. `\fIarg\fR' specifies the arguments of the function. `\fIdest\fR' specifies the path of the destination file. 9 | .PP 10 | .RS 11 | .br 12 | \fBtcamgr create \fIname\fB\fR 13 | .RS 14 | Create a database file. 15 | .RE 16 | .br 17 | \fBtcamgr inform \fIname\fB\fR 18 | .RS 19 | Print miscellaneous information to the standard output. 20 | .RE 21 | .br 22 | \fBtcamgr put \fR[\fB\-sx\fR]\fB \fR[\fB\-sep \fIchr\fB\fR]\fB \fR[\fB\-dk\fR|\fB\-dc\fR|\fB\-dai\fR|\fB\-dad\fR]\fB \fIname\fB \fIkey\fB \fIvalue\fB\fR 23 | .RS 24 | Store a record. 25 | .RE 26 | .br 27 | \fBtcamgr out \fR[\fB\-sx\fR]\fB \fR[\fB\-sep \fIchr\fB\fR]\fB \fIname\fB \fIkey\fB\fR 28 | .RS 29 | Remove a record. 30 | .RE 31 | .br 32 | \fBtcamgr get \fR[\fB\-sx\fR]\fB \fR[\fB\-sep \fIchr\fB\fR]\fB \fR[\fB\-px\fR]\fB \fR[\fB\-pz\fR]\fB \fIname\fB \fIkey\fB\fR 33 | .RS 34 | Print the value of a record. 35 | .RE 36 | .br 37 | \fBtcamgr list \fR[\fB\-sep \fIchr\fB\fR]\fB \fR[\fB\-m \fInum\fB\fR]\fB \fR[\fB\-pv\fR]\fB \fR[\fB\-px\fR]\fB \fR[\fB\-fm \fIstr\fB\fR]\fB \fIname\fB\fR 38 | .RS 39 | Print keys of all records, separated by line feeds. 40 | .RE 41 | .br 42 | \fBtcamgr optimize \fIname\fB \fIparams\fB\fR 43 | .RS 44 | Optimize a database file. 45 | .RE 46 | .br 47 | \fBtcamgr misc \fR[\fB\-sx\fR]\fB \fR[\fB\-sep \fIchr\fB\fR]\fB \fR[\fB\-px\fR]\fB \fIname\fB \fIfunc\fB \fR[\fB\fIarg\fB...\fR]\fB\fR 48 | .RS 49 | Call a versatile function for miscellaneous operations. 50 | .RE 51 | .br 52 | \fBtcamgr map \fR[\fB\-fm \fIstr\fB\fR]\fB \fIname\fB \fIdest\fB\fR 53 | .RS 54 | Map records into another B+ tree database. 55 | .RE 56 | .br 57 | \fBtcamgr version\fR 58 | .RS 59 | Print the version information of Tokyo Cabinet. 60 | .RE 61 | .RE 62 | .PP 63 | Options feature the following. 64 | .PP 65 | .RS 66 | \fB\-sx\fR : the input data is evaluated as a hexadecimal data string. 67 | .br 68 | \fB\-sep \fIchr\fR\fR : specify the separator of the input data. 69 | .br 70 | \fB\-dk\fR : use the function `tcadbputkeep' instead of `tcadbput'. 71 | .br 72 | \fB\-dc\fR : use the function `tcadbputcat' instead of `tcadbput'. 73 | .br 74 | \fB\-dai\fR : use the function `tcadbaddint' instead of `tcadbput'. 75 | .br 76 | \fB\-dad\fR : use the function `tcadbadddouble' instead of `tcadbput'. 77 | .br 78 | \fB\-px\fR : the output data is converted into a hexadecimal data string. 79 | .br 80 | \fB\-pz\fR : do not append line feed at the end of the output. 81 | .br 82 | \fB\-m \fInum\fR\fR : specify the maximum number of the output. 83 | .br 84 | \fB\-pv\fR : print values of records also. 85 | .br 86 | \fB\-fm \fIstr\fR\fR : specify the prefix of keys. 87 | .br 88 | .RE 89 | .PP 90 | This command returns 0 on success, another on failure. 91 | 92 | .SH SEE ALSO 93 | .PP 94 | .BR tcatest (1), 95 | .BR tcadb (3), 96 | .BR tokyocabinet (3) 97 | -------------------------------------------------------------------------------- /man/tcatest.1: -------------------------------------------------------------------------------- 1 | .TH "TCATEST" 3 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcatest \- test cases of the abstract database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtcatest\fR' is a utility for facility test and performance test. This command is used in the following format. `\fIname\fR' specifies the database name. `\fIrnum\fR' specifies the number of iterations. `\fItnum\fR' specifies the number of transactions. 9 | .PP 10 | .RS 11 | .br 12 | \fBtcatest write \fIname\fB \fIrnum\fB\fR 13 | .RS 14 | Store records with keys of 8 bytes. They change as `00000001', `00000002'... 15 | .RE 16 | .br 17 | \fBtcatest read \fIname\fB\fR 18 | .RS 19 | Retrieve all records of the database above. 20 | .RE 21 | .br 22 | \fBtcatest remove \fIname\fB\fR 23 | .RS 24 | Remove all records of the database above. 25 | .RE 26 | .br 27 | \fBtcatest rcat \fIname\fB \fIrnum\fB\fR 28 | .RS 29 | Store records with partway duplicated keys using concatenate mode. 30 | .RE 31 | .br 32 | \fBtcatest misc \fIname\fB \fIrnum\fB\fR 33 | .RS 34 | Perform miscellaneous test of various operations. 35 | .RE 36 | .br 37 | \fBtcatest wicked \fIname\fB \fIrnum\fB\fR 38 | .RS 39 | Perform updating operations of list and map selected at random. 40 | .RE 41 | .br 42 | \fBtcatest compare \fIname\fB \fItnum\fB \fIrnum\fB\fR 43 | .RS 44 | Perform comparison test of database schema. 45 | .RE 46 | .RE 47 | .PP 48 | This command returns 0 on success, another on failure. 49 | 50 | .SH SEE ALSO 51 | .PP 52 | .BR tcamgr (1), 53 | .BR tcadb (3), 54 | .BR tokyocabinet (3) 55 | -------------------------------------------------------------------------------- /man/tcbmgr.1: -------------------------------------------------------------------------------- 1 | .TH "TCBMGR" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcbmgr \- the command line utility of the B+ tree database API 5 | 6 | .SH DESCRIPTION 7 | The command `\fBtcbmgr\fR' is a utility for test and debugging of the B+ tree database API and its applications. `\fIpath\fR' specifies the path of a database file. `\fIlmemb\fR' specifies the number of members in each leaf page. `\fInmemb\fR' specifies the number of members in each non\-leaf page. `\fIbnum\fR' specifies the number of buckets. `\fIapow\fR' specifies the power of the alignment. `\fIfpow\fR' specifies the power of the free block pool. `\fIkey\fR' specifies the key of a record. `\fIvalue\fR' specifies the value of a record. `\fIfile\fR' specifies the input file. 8 | .PP 9 | .RS 10 | .br 11 | \fBtcbmgr create \fR[\fB\-cd\fR|\fB\-ci\fR|\fB\-cj\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fIpath\fB \fR[\fB\fIlmemb\fB \fR[\fB\fInmemb\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR 12 | .RS 13 | Create a database file. 14 | .RE 15 | .br 16 | \fBtcbmgr inform \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB\fR 17 | .RS 18 | Print miscellaneous information to the standard output. 19 | .RE 20 | .br 21 | \fBtcbmgr put \fR[\fB\-cd\fR|\fB\-ci\fR|\fB\-cj\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fR[\fB\-dk\fR|\fB\-dc\fR|\fB\-dd\fR|\fB\-db\fR|\fB\-dai\fR|\fB\-dad\fR]\fB \fIpath\fB \fIkey\fB \fIvalue\fB\fR 22 | .RS 23 | Store a record. 24 | .RE 25 | .br 26 | \fBtcbmgr out \fR[\fB\-cd\fR|\fB\-ci\fR|\fB\-cj\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fIpath\fB \fIkey\fB\fR 27 | .RS 28 | Remove a record. 29 | .RE 30 | .br 31 | \fBtcbmgr get \fR[\fB\-cd\fR|\fB\-ci\fR|\fB\-cj\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fR[\fB\-px\fR]\fB \fR[\fB\-pz\fR]\fB \fIpath\fB \fIkey\fB\fR 32 | .RS 33 | Print the value of a record. 34 | .RE 35 | .br 36 | \fBtcbmgr list \fR[\fB\-cd\fR|\fB\-ci\fR|\fB\-cj\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-m \fInum\fB\fR]\fB \fR[\fB\-bk\fR]\fB \fR[\fB\-pv\fR]\fB \fR[\fB\-px\fR]\fB \fR[\fB\-j \fIstr\fB\fR]\fB \fR[\fB\-rb \fIbkey\fB \fIekey\fB\fR]\fB \fR[\fB\-fm \fIstr\fB\fR]\fB \fIpath\fB\fR 37 | .RS 38 | Print keys of all records, separated by line feeds. 39 | .RE 40 | .br 41 | \fBtcbmgr optimize \fR[\fB\-cd\fR|\fB\-ci\fR|\fB\-cj\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-tz\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-df\fR]\fB \fIpath\fB \fR[\fB\fIlmemb\fB \fR[\fB\fInmemb\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR 42 | .RS 43 | Optimize a database file. 44 | .RE 45 | .br 46 | \fBtcbmgr importtsv \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sc\fR]\fB \fIpath\fB \fR[\fB\fIfile\fB\fR]\fB\fR 47 | .RS 48 | Store records of TSV in each line of a file. 49 | .RE 50 | .br 51 | \fBtcbmgr version\fR 52 | .RS 53 | Print the version information of Tokyo Cabinet. 54 | .RE 55 | .RE 56 | .PP 57 | Options feature the following. 58 | .PP 59 | .RS 60 | \fB\-cd\fR : use the comparison function `tccmpdecimal'. 61 | .br 62 | \fB\-ci\fR : use the comparison function `tccmpint32'. 63 | .br 64 | \fB\-cj\fR : use the comparison function `tccmpint64'. 65 | .br 66 | \fB\-tl\fR : enable the option `BDBTLARGE'. 67 | .br 68 | \fB\-td\fR : enable the option `BDBTDEFLATE'. 69 | .br 70 | \fB\-tb\fR : enable the option `BDBTBZIP'. 71 | .br 72 | \fB\-tt\fR : enable the option `BDBTTCBS'. 73 | .br 74 | \fB\-tx\fR : enable the option `BDBTEXCODEC'. 75 | .br 76 | \fB\-nl\fR : enable the option `BDBNOLCK'. 77 | .br 78 | \fB\-nb\fR : enable the option `BDBLCKNB'. 79 | .br 80 | \fB\-sx\fR : the input data is evaluated as a hexadecimal data string. 81 | .br 82 | \fB\-dk\fR : use the function `tcbdbputkeep' instead of `tcbdbput'. 83 | .br 84 | \fB\-dc\fR : use the function `tcbdbputcat' instead of `tcbdbput'. 85 | .br 86 | \fB\-dd\fR : use the function `tcbdbputdup' instead of `tcbdbput'. 87 | .br 88 | \fB\-db\fR : use the function `tcbdbputdupback' instead of `tcbdbput'. 89 | .br 90 | \fB\-dai\fR : use the function `tcbdbaddint' instead of `tcbdbput'. 91 | .br 92 | \fB\-dad\fR : use the function `tcbdbadddouble' instead of `tcbdbput'. 93 | .br 94 | \fB\-px\fR : the output data is converted into a hexadecimal data string. 95 | .br 96 | \fB\-pz\fR : do not append line feed at the end of the output. 97 | .br 98 | \fB\-m \fInum\fR\fR : specify the maximum number of the output. 99 | .br 100 | \fB\-bk\fR : perform backword scanning. 101 | .br 102 | \fB\-pv\fR : print values of records also. 103 | .br 104 | \fB\-j \fIstr\fR\fR : specify the key where the cursor jump to. 105 | .br 106 | \fB\-rb \fIbkey\fR \fIekey\fR\fR : specify the range of keys. 107 | .br 108 | \fB\-fm \fIstr\fR\fR : specify the prefix of keys. 109 | .br 110 | \fB\-tz\fR : enable the option `UINT8_MAX'. 111 | .br 112 | \fB\-df\fR : perform defragmentation only. 113 | .br 114 | \fB\-sc\fR : normalize keys as lower cases. 115 | .br 116 | .RE 117 | .PP 118 | This command returns 0 on success, another on failure. 119 | 120 | .SH SEE ALSO 121 | .PP 122 | .BR tcbtest (1), 123 | .BR tcbmttest (1), 124 | .BR tcbdb (3), 125 | .BR tokyocabinet (3) 126 | -------------------------------------------------------------------------------- /man/tcbmttest.1: -------------------------------------------------------------------------------- 1 | .TH "TCBMTTEST" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcbmttest \- test cases of the B+ tree database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtcbmttest\fR' is a utility for facility test and performance test. This command is used in the following format. `\fIpath\fR' specifies the path of a database file. `\fItnum\fR' specifies the number of running threads. `\fIrnum\fR' specifies the number of iterations. `\fIlmemb\fR' specifies the number of members in each leaf page. `\fInmemb\fR' specifies the number of members in each non\-leaf page. `\fIbnum\fR' specifies the number of buckets. `\fIapow\fR' specifies the power of the alignment. `\fIfpow\fR' specifies the power of the free block pool. 9 | .PP 10 | .RS 11 | .br 12 | \fBtcbmttest write \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIlmemb\fB \fR[\fB\fInmemb\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR 13 | .RS 14 | Store records with keys of 8 bytes. They change as `00000001', `00000002'... 15 | .RE 16 | .br 17 | \fBtcbmttest read \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-wb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB\fR 18 | .RS 19 | Retrieve all records of the database above. 20 | .RE 21 | .br 22 | \fBtcbmttest remove \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB\fR 23 | .RS 24 | Remove all records of the database above. 25 | .RE 26 | .br 27 | \fBtcbmttest wicked \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-nc\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB\fR 28 | .RS 29 | Perform updating operations selected at random. 30 | .RE 31 | .br 32 | \fBtcbmttest typical \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-nc\fR]\fB \fR[\fB\-rr \fInum\fB\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIlmemb\fB \fR[\fB\fInmemb\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR 33 | .RS 34 | Perform typical operations selected at random. 35 | .RE 36 | .br 37 | \fBtcbmttest race \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIlmemb\fB \fR[\fB\fInmemb\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR 38 | .RS 39 | Perform race condition test. 40 | .RE 41 | .RE 42 | .PP 43 | Options feature the following. 44 | .PP 45 | .RS 46 | \fB\-tl\fR : enable the option `BDBTLARGE'. 47 | .br 48 | \fB\-td\fR : enable the option `BDBTDEFLATE'. 49 | .br 50 | \fB\-tb\fR : enable the option `BDBTBZIP'. 51 | .br 52 | \fB\-tt\fR : enable the option `BDBTTCBS'. 53 | .br 54 | \fB\-tx\fR : enable the option `BDBTEXCODEC'. 55 | .br 56 | \fB\-xm \fInum\fR\fR : specify the size of the extra mapped memory. 57 | .br 58 | \fB\-df \fInum\fR\fR : specify the unit step number of auto defragmentation. 59 | .br 60 | \fB\-nl\fR : enable the option `BDBNOLCK'. 61 | .br 62 | \fB\-nb\fR : enable the option `BDBLCKNB'. 63 | .br 64 | \fB\-rnd\fR : select keys at random. 65 | .br 66 | \fB\-wb\fR : use the function `tchdbget3' instead of `tchdbget'. 67 | .br 68 | \fB\-nc\fR : omit the comparison test. 69 | .br 70 | \fB\-rr \fInum\fR\fR : specify the ratio of reading operation by percentage. 71 | .br 72 | .RE 73 | .PP 74 | This command returns 0 on success, another on failure. 75 | 76 | .SH SEE ALSO 77 | .PP 78 | .BR tcbtest (1), 79 | .BR tcbmgr (1), 80 | .BR tcbdb (3), 81 | .BR tokyocabinet (3) 82 | -------------------------------------------------------------------------------- /man/tcbtest.1: -------------------------------------------------------------------------------- 1 | .TH "TCBTEST" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcbtest \- test cases of the B+ tree database API 5 | 6 | .SH DESCRIPTION 7 | The command `\fBtcbtest\fR' is a utility for facility test and performance test. This command is used in the following format. `\fIpath\fR' specifies the path of a database file. `\fIrnum\fR' specifies the number of iterations. `\fIlmemb\fR' specifies the number of members in each leaf page. `\fInmemb\fR' specifies the number of members in each non\-leaf page. `\fIbnum\fR' specifies the number of buckets. `\fIapow\fR' specifies the power of the alignment. `\fIfpow\fR' specifies the power of the free block pool. 8 | .PP 9 | .RS 10 | .br 11 | \fBtcbtest write \fR[\fB\-mt\fR]\fB \fR[\fB\-cd\fR|\fB\-ci\fR|\fB\-cj\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-ls \fInum\fB\fR]\fB \fR[\fB\-ca \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fIrnum\fB \fR[\fB\fIlmemb\fB \fR[\fB\fInmemb\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR 12 | .RS 13 | Store records with keys of 8 bytes. They change as `00000001', `00000002'... 14 | .RE 15 | .br 16 | \fBtcbtest read \fR[\fB\-mt\fR]\fB \fR[\fB\-cd\fR|\fB\-ci\fR|\fB\-cj\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-wb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB\fR 17 | .RS 18 | Retrieve all records of the database above. 19 | .RE 20 | .br 21 | \fBtcbtest remove \fR[\fB\-mt\fR]\fB \fR[\fB\-cd\fR|\fB\-ci\fR|\fB\-cj\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB\fR 22 | .RS 23 | Remove all records of the database above. 24 | .RE 25 | .br 26 | \fBtcbtest rcat \fR[\fB\-mt\fR]\fB \fR[\fB\-cd\fR|\fB\-ci\fR|\fB\-cj\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-ls \fInum\fB\fR]\fB \fR[\fB\-ca \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-pn \fInum\fB\fR]\fB \fR[\fB\-dai\fR|\fB\-dad\fR|\fB\-rl\fR|\fB\-ru\fR]\fB \fIpath\fB \fIrnum\fB \fR[\fB\fIlmemb\fB \fR[\fB\fInmemb\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR 27 | .RS 28 | Store records with partway duplicated keys using concatenate mode. 29 | .RE 30 | .br 31 | \fBtcbtest queue \fR[\fB\-mt\fR]\fB \fR[\fB\-cd\fR|\fB\-ci\fR|\fB\-cj\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-ls \fInum\fB\fR]\fB \fR[\fB\-ca \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fIrnum\fB \fR[\fB\fIlmemb\fB \fR[\fB\fInmemb\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR]\fB\fR 32 | .RS 33 | Perform queueing and dequeueing. 34 | .RE 35 | .br 36 | \fBtcbtest misc \fR[\fB\-mt\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fIrnum\fB\fR 37 | .RS 38 | Perform miscellaneous test of various operations. 39 | .RE 40 | .br 41 | \fBtcbtest wicked \fR[\fB\-mt\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fIrnum\fB\fR 42 | .RS 43 | Perform updating operations selected at random. 44 | .RE 45 | .RE 46 | .PP 47 | Options feature the following. 48 | .PP 49 | .RS 50 | \fB\-mt\fR : call the function `tchdbsetmutex'. 51 | .br 52 | \fB\-cd\fR : use the comparison function `tccmpdecimal'. 53 | .br 54 | \fB\-ci\fR : use the comparison function `tccmpint32'. 55 | .br 56 | \fB\-cj\fR : use the comparison function `tccmpint64'. 57 | .br 58 | \fB\-tl\fR : enable the option `BDBTLARGE'. 59 | .br 60 | \fB\-td\fR : enable the option `BDBTDEFLATE'. 61 | .br 62 | \fB\-tb\fR : enable the option `BDBTBZIP'. 63 | .br 64 | \fB\-tt\fR : enable the option `BDBTTCBS'. 65 | .br 66 | \fB\-tx\fR : enable the option `BDBTEXCODEC'. 67 | .br 68 | \fB\-lc \fInum\fR\fR : specify the number of cached leaf pages. 69 | .br 70 | \fB\-nc \fInum\fR\fR : specify the number of cached non\-leaf pages. 71 | .br 72 | \fB\-xm \fInum\fR\fR : specify the size of the extra mapped memory. 73 | .br 74 | \fB\-df \fInum\fR\fR : specify the unit step number of auto defragmentation. 75 | .br 76 | \fB\-ls \fInum\fR\fR : specify the maximum size of each leaf page. 77 | .br 78 | \fB\-ca \fInum\fR\fR : specify the capacity number of records. 79 | .br 80 | \fB\-nl\fR : enable the option `BDBNOLCK'. 81 | .br 82 | \fB\-nb\fR : enable the option `BDBLCKNB'. 83 | .br 84 | \fB\-rnd\fR : select keys at random. 85 | .br 86 | \fB\-wb\fR : use the function `tcbdbget3' instead of `tcbdbget'. 87 | .br 88 | \fB\-pn \fInum\fR\fR : specify the number of patterns. 89 | .br 90 | \fB\-dai\fR : use the function `tcbdbaddint' instead of `tcbdbputcat'. 91 | .br 92 | \fB\-dad\fR : use the function `tcbdbadddouble' instead of `tcbdbputcat'. 93 | .br 94 | \fB\-rl\fR : set the length of values at random. 95 | .br 96 | \fB\-ru\fR : select update operations at random. 97 | .br 98 | .RE 99 | .PP 100 | This command returns 0 on success, another on failure. 101 | 102 | .SH SEE ALSO 103 | .PP 104 | .BR tcbmttest (1), 105 | .BR tcbmgr (1), 106 | .BR tcbdb (3), 107 | .BR tokyocabinet (3) 108 | -------------------------------------------------------------------------------- /man/tcfmgr.1: -------------------------------------------------------------------------------- 1 | .TH "TCFMGR" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcfmgr \- the command line utility of the fixed-length database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtcfmgr\fR' is a utility for test and debugging of the fixed\-length database API and its applications. `\fIpath\fR' specifies the path of a database file. `\fIwidth\fR' specifies the width of the value of each record. `\fIlimsiz\fR' specifies the limit size of the database file. `\fIkey\fR' specifies the key of a record. `\fIvalue\fR' specifies the value of a record. `\fIfile\fR' specifies the input file. 9 | .PP 10 | .RS 11 | .br 12 | \fBtcfmgr create \fIpath\fB \fR[\fB\fIwidth\fB \fR[\fB\fIlimsiz\fB\fR]\fB\fR]\fB\fR 13 | .RS 14 | Create a database file. 15 | .RE 16 | .br 17 | \fBtcfmgr inform \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB\fR 18 | .RS 19 | Print miscellaneous information to the standard output. 20 | .RE 21 | .br 22 | \fBtcfmgr put \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fR[\fB\-dk\fR|\fB\-dc\fR|\fB\-dai\fR|\fB\-dad\fR]\fB \fIpath\fB \fIkey\fB \fIvalue\fB\fR 23 | .RS 24 | Store a record. 25 | .RE 26 | .br 27 | \fBtcfmgr out \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fIpath\fB \fIkey\fB\fR 28 | .RS 29 | Remove a record. 30 | .RE 31 | .br 32 | \fBtcfmgr get \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fR[\fB\-px\fR]\fB \fR[\fB\-pz\fR]\fB \fIpath\fB \fIkey\fB\fR 33 | .RS 34 | Print the value of a record. 35 | .RE 36 | .br 37 | \fBtcfmgr list \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-m \fInum\fB\fR]\fB \fR[\fB\-pv\fR]\fB \fR[\fB\-px\fR]\fB \fR[\fB\-rb \fIlkey\fB \fIukey\fB\fR]\fB \fR[\fB\-ri \fIstr\fB\fR]\fB \fIpath\fB\fR 38 | .RS 39 | Print keys of all records, separated by line feeds. 40 | .RE 41 | .br 42 | \fBtcfmgr optimize \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fR[\fB\fIwidth\fB \fR[\fB\fIlimsiz\fB\fR]\fB\fR]\fB\fR 43 | .RS 44 | Optimize a database file. 45 | .RE 46 | .br 47 | \fBtcfmgr importtsv \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sc\fR]\fB \fIpath\fB \fR[\fB\fIfile\fB\fR]\fB\fR 48 | .RS 49 | Store records of TSV in each line of a file. 50 | .RE 51 | .br 52 | \fBtcfmgr version\fR 53 | .RS 54 | Print the version information of Tokyo Cabinet. 55 | .RE 56 | .RE 57 | .PP 58 | Options feature the following. 59 | .PP 60 | .RS 61 | \fB\-nl\fR : enable the option `FDBNOLCK'. 62 | .br 63 | \fB\-nb\fR : enable the option `FDBLCKNB'. 64 | .br 65 | \fB\-sx\fR : the input data is evaluated as a hexadecimal data string. 66 | .br 67 | \fB\-dk\fR : use the function `tcfdbputkeep' instead of `tcfdbput'. 68 | .br 69 | \fB\-dc\fR : use the function `tcfdbputcat' instead of `tcfdbput'. 70 | .br 71 | \fB\-dai\fR : use the function `tcfdbaddint' instead of `tcfdbput'. 72 | .br 73 | \fB\-dad\fR : use the function `tcfdbadddouble' instead of `tcfdbput'. 74 | .br 75 | \fB\-px\fR : the output data is converted into a hexadecimal data string. 76 | .br 77 | \fB\-pz\fR : do not append line feed at the end of the output. 78 | .br 79 | \fB\-m \fInum\fR\fR : specify the maximum number of the output. 80 | .br 81 | \fB\-pv\fR : print values of records also. 82 | .br 83 | \fB\-rb \fIlkey\fR \fIukey\fR\fR : specify the range of keys. 84 | .br 85 | \fB\-ri \fIstr\fR\fR : specify the interval notation of keys. 86 | .br 87 | \fB\-sc\fR : normalize keys as lower cases. 88 | .br 89 | .RE 90 | .PP 91 | This command returns 0 on success, another on failure. 92 | 93 | .SH SEE ALSO 94 | .PP 95 | .BR tcftest (1), 96 | .BR tcfmttest (1), 97 | .BR tcfdb (3), 98 | .BR tokyocabinet (3) 99 | -------------------------------------------------------------------------------- /man/tcfmttest.1: -------------------------------------------------------------------------------- 1 | .TH "TCFMTTEST" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcfmttest \- test cases of the fixed-length database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtcfmttest\fR' is a utility for facility test under multi\-thread situation. This command is used in the following format. `\fIpath\fR' specifies the path of a database file. `\fItnum\fR' specifies the number of running threads. `\fIrnum\fR' specifies the number of iterations. `\fIwidth\fR' specifies the width of the value of each record. `\fIlimsiz\fR' specifies the limit size of the database file. 9 | .PP 10 | .RS 11 | .br 12 | \fBtcfmttest write \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIwidth\fB \fR[\fB\fIlimsiz\fB\fR]\fB\fR]\fB\fR 13 | .RS 14 | Store records with keys of 8 bytes. They change as `00000001', `00000002'... 15 | .RE 16 | .br 17 | \fBtcfmttest read \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-wb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB\fR 18 | .RS 19 | Retrieve all records of the database above. 20 | .RE 21 | .br 22 | \fBtcfmttest remove \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB\fR 23 | .RS 24 | Remove all records of the database above. 25 | .RE 26 | .br 27 | \fBtcfmttest wicked \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-nc\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB\fR 28 | .RS 29 | Perform updating operations selected at random. 30 | .RE 31 | .br 32 | \fBtcfmttest typical \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-nc\fR]\fB \fR[\fB\-rr \fInum\fB\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIwidth\fB \fR[\fB\fIlimsiz\fB\fR]\fB\fR]\fB\fR 33 | .RS 34 | Perform typical operations selected at random. 35 | .RE 36 | .RE 37 | .PP 38 | Options feature the following. 39 | .PP 40 | .RS 41 | \fB\-nl\fR : enable the option `FDBNOLCK'. 42 | .br 43 | \fB\-nb\fR : enable the option `FDBLCKNB'. 44 | .br 45 | \fB\-rnd\fR : select keys at random. 46 | .br 47 | \fB\-wb\fR : use the function `tcfdbget4' instead of `tcfdbget2'. 48 | .br 49 | \fB\-nc\fR : omit the comparison test. 50 | .br 51 | \fB\-rr\fR \fInum\fR : specifiy the ratio of reading operation by percentage. 52 | .br 53 | .RE 54 | .PP 55 | This command returns 0 on success, another on failure. 56 | 57 | .SH SEE ALSO 58 | .PP 59 | .BR tcftest (1), 60 | .BR tcfmgr (1), 61 | .BR tcfdb (3), 62 | .BR tokyocabinet (3) 63 | -------------------------------------------------------------------------------- /man/tcftest.1: -------------------------------------------------------------------------------- 1 | .TH "TCFTEST" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcftest \- test cases of the fixed-length database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtcftest\fR' is a utility for facility test and performance test. This command is used in the following format. `\fIpath\fR' specifies the path of a database file. `\fIrnum\fR' specifies the number of iterations. `\fIwidth\fR' specifies the width of the value of each record. `\fIlimsiz\fR' specifies the limit size of the database file. 9 | .PP 10 | .RS 11 | .br 12 | \fBtcftest write \fR[\fB\-mt\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fIrnum\fB \fR[\fB\fIwidth\fB \fR[\fB\fIlimsiz\fB\fR]\fB\fR]\fB\fR 13 | .RS 14 | Store records with keys of 8 bytes. They change as `00000001', `00000002'... 15 | .RE 16 | .br 17 | \fBtcftest read \fR[\fB\-mt\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-wb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB\fR 18 | .RS 19 | Retrieve all records of the database above. 20 | .RE 21 | .br 22 | \fBtcftest remove \fR[\fB\-mt\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB\fR 23 | .RS 24 | Remove all records of the database above. 25 | .RE 26 | .br 27 | \fBtcftest rcat \fR[\fB\-mt\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-pn \fInum\fB\fR]\fB \fR[\fB\-dai\fR|\fB\-dad\fR|\fB\-rl\fR]\fB \fIpath\fB \fIrnum\fB \fR[\fB\fIlimsiz\fB\fR]\fB\fR]\fB\fR 28 | .RS 29 | Store records with partway duplicated keys using concatenate mode. 30 | .RE 31 | .br 32 | \fBtcftest misc \fR[\fB\-mt\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fIrnum\fB\fR 33 | .RS 34 | Perform miscellaneous test of various operations. 35 | .RE 36 | .br 37 | \fBtcftest wicked \fR[\fB\-mt\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fIrnum\fB\fR 38 | .RS 39 | Perform updating operations selected at random. 40 | .RE 41 | .RE 42 | .PP 43 | Options feature the following. 44 | .PP 45 | .RS 46 | \fB\-mt\fR : call the function `tcfdbsetmutex'. 47 | .br 48 | \fB\-nl\fR : enable the option `FDBNOLCK'. 49 | .br 50 | \fB\-nb\fR : enable the option `FDBLCKNB'. 51 | .br 52 | \fB\-rnd\fR : select keys at random. 53 | .br 54 | \fB\-wb\fR : use the function `tcfdbget4' instead of `tcfdbget2'. 55 | .br 56 | \fB\-pn \fInum\fR\fR : specify the number of patterns. 57 | .br 58 | \fB\-dai\fR : use the function `tcfdbaddint' instead of `tcfdbputcat'. 59 | .br 60 | \fB\-dad\fR : use the function `tcfdbadddouble' instead of `tcfdbputcat'. 61 | .br 62 | \fB\-rl\fR : set the length of values at random. 63 | .br 64 | .RE 65 | .PP 66 | This command returns 0 on success, another on failure. 67 | 68 | .SH SEE ALSO 69 | .PP 70 | .BR tcfmttest (1), 71 | .BR tcfmgr (1), 72 | .BR tcfdb (3), 73 | .BR tokyocabinet (3) 74 | -------------------------------------------------------------------------------- /man/tchmgr.1: -------------------------------------------------------------------------------- 1 | .TH "TCHMGR" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tchmgr \- the command line utility of the hash database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtchmgr\fR' is a utility for test and debugging of the hash database API and its applications. `\fIpath\fR' specifies the path of a database file. `\fIbnum\fR' specifies the number of buckets. `\fIapow\fR' specifies the power of the alignment. `\fIfpow\fR' specifies the power of the free block pool. `\fIkey\fR' specifies the key of a record. `\fIvalue\fR' specifies the value of a record. `\fIfile\fR' specifies the input file. 9 | .PP 10 | .RS 11 | .br 12 | \fBtchmgr create \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fIpath\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR 13 | .RS 14 | Create a database file. 15 | .RE 16 | .br 17 | \fBtchmgr inform \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB\fR 18 | .RS 19 | Print miscellaneous information to the standard output. 20 | .RE 21 | .br 22 | \fBtchmgr put \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fR[\fB\-dk\fR|\fB\-dc\fR|\fB\-dai\fR|\fB\-dad\fR]\fB \fIpath\fB \fIkey\fB \fIvalue\fB\fR 23 | .RS 24 | Store a record. 25 | .RE 26 | .br 27 | \fBtchmgr out \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fIpath\fB \fIkey\fB\fR 28 | .RS 29 | Remove a record. 30 | .RE 31 | .br 32 | \fBtchmgr get \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fR[\fB\-px\fR]\fB \fR[\fB\-pz\fR]\fB \fIpath\fB \fIkey\fB\fR 33 | .RS 34 | Print the value of a record. 35 | .RE 36 | .br 37 | \fBtchmgr list \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-m \fInum\fB\fR]\fB \fR[\fB\-pv\fR]\fB \fR[\fB\-px\fR]\fB \fR[\fB\-fm \fIstr\fB\fR]\fB \fIpath\fB\fR 38 | .RS 39 | Print keys of all records, separated by line feeds. 40 | .RE 41 | .br 42 | \fBtchmgr optimize \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-tz\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-df\fR]\fB \fIpath\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR 43 | .RS 44 | Optimize a database file. 45 | .RE 46 | .br 47 | \fBtchmgr importtsv \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sc\fR]\fB \fIpath\fB \fR[\fB\fIfile\fB\fR]\fB\fR 48 | .RS 49 | Store records of TSV in each line of a file. 50 | .RE 51 | .br 52 | \fBtchmgr version\fR 53 | .RS 54 | Print the version information of Tokyo Cabinet. 55 | .RE 56 | .RE 57 | .PP 58 | Options feature the following. 59 | .PP 60 | .RS 61 | \fB\-tl\fR : enable the option `HDBTLARGE'. 62 | .br 63 | \fB\-td\fR : enable the option `HDBTDEFLATE'. 64 | .br 65 | \fB\-tb\fR : enable the option `HDBTBZIP'. 66 | .br 67 | \fB\-tt\fR : enable the option `HDBTTCBS'. 68 | .br 69 | \fB\-tx\fR : enable the option `HDBTEXCODEC'. 70 | .br 71 | \fB\-nl\fR : enable the option `HDBNOLCK'. 72 | .br 73 | \fB\-nb\fR : enable the option `HDBLCKNB'. 74 | .br 75 | \fB\-sx\fR : the input data is evaluated as a hexadecimal data string. 76 | .br 77 | \fB\-dk\fR : use the function `tchdbputkeep' instead of `tchdbput'. 78 | .br 79 | \fB\-dc\fR : use the function `tchdbputcat' instead of `tchdbput'. 80 | .br 81 | \fB\-dai\fR : use the function `tchdbaddint' instead of `tchdbput'. 82 | .br 83 | \fB\-dad\fR : use the function `tchdbadddouble' instead of `tchdbput'. 84 | .br 85 | \fB\-px\fR : the output data is converted into a hexadecimal data string. 86 | .br 87 | \fB\-pz\fR : do not append line feed at the end of the output. 88 | .br 89 | \fB\-m \fInum\fR\fR : specify the maximum number of the output. 90 | .br 91 | \fB\-pv\fR : print values of records also. 92 | .br 93 | \fB\-fm \fIstr\fR\fR : specify the prefix of keys. 94 | .br 95 | \fB\-tz\fR : enable the option `UINT8_MAX'. 96 | .br 97 | \fB\-df\fR : perform defragmentation only. 98 | .br 99 | \fB\-sc\fR : normalize keys as lower cases. 100 | .br 101 | .RE 102 | .PP 103 | This command returns 0 on success, another on failure. 104 | 105 | .SH SEE ALSO 106 | .PP 107 | .BR tchtest (1), 108 | .BR tchmttest (1), 109 | .BR tchdb (3), 110 | .BR tokyocabinet (3) 111 | -------------------------------------------------------------------------------- /man/tchmttest.1: -------------------------------------------------------------------------------- 1 | .TH "TCHMTTEST" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tchmttest \- test cases of the hash database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtchmttest\fR' is a utility for facility test under multi\-thread situation. This command is used in the following format. `\fIpath\fR' specifies the path of a database file. `\fItnum\fR' specifies the number of running threads. `\fIrnum\fR' specifies the number of iterations. `\fIbnum\fR' specifies the number of buckets. `\fIapow\fR' specifies the power of the alignment. `\fIfpow\fR' specifies the power of the free block pool. 9 | .PP 10 | .RS 11 | .br 12 | \fBtchmttest write \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-as\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR 13 | .RS 14 | Store records with keys of 8 bytes. They change as `00000001', `00000002'... 15 | .RE 16 | .br 17 | \fBtchmttest read \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-wb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB\fR 18 | .RS 19 | Retrieve all records of the database above. 20 | .RE 21 | .br 22 | \fBtchmttest remove \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB\fR 23 | .RS 24 | Remove all records of the database above. 25 | .RE 26 | .br 27 | \fBtchmttest wicked \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-nc\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB\fR 28 | .RS 29 | Perform updating operations selected at random. 30 | .RE 31 | .br 32 | \fBtchmttest typical \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-nc\fR]\fB \fR[\fB\-rr \fInum\fB\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR 33 | .RS 34 | Perform typical operations selected at random. 35 | .RE 36 | .br 37 | \fBtchmttest race \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR 38 | .RS 39 | Perform race condition test. 40 | .RE 41 | .RE 42 | .PP 43 | Options feature the following. 44 | .PP 45 | .RS 46 | \fB\-tl\fR : enable the option `HDBTLARGE'. 47 | .br 48 | \fB\-td\fR : enable the option `HDBTDEFLATE'. 49 | .br 50 | \fB\-tb\fR : enable the option `HDBTBZIP'. 51 | .br 52 | \fB\-tt\fR : enable the option `HDBTTCBS'. 53 | .br 54 | \fB\-tx\fR : enable the option `HDBTEXCODEC'. 55 | .br 56 | \fB\-rc \fInum\fR\fR : specify the number of cached records. 57 | .br 58 | \fB\-xm \fInum\fR\fR : specify the size of the extra mapped memory. 59 | .br 60 | \fB\-df \fInum\fR\fR : specify the unit step number of auto defragmentation. 61 | .br 62 | \fB\-nl\fR : enable the option `HDBNOLCK'. 63 | .br 64 | \fB\-nb\fR : enable the option `HDBLCKNB'. 65 | .br 66 | \fB\-as\fR : use the function `tchdbputasync' instead of `tchdbput'. 67 | .br 68 | \fB\-rnd\fR : select keys at random. 69 | .br 70 | \fB\-wb\fR : use the function `tchdbget3' instead of `tchdbget'. 71 | .br 72 | \fB\-nc\fR : omit the comparison test. 73 | .br 74 | \fB\-rr \fInum\fR\fR : specify the ratio of reading operation by percentage. 75 | .br 76 | .RE 77 | .PP 78 | This command returns 0 on success, another on failure. 79 | 80 | .SH SEE ALSO 81 | .PP 82 | .BR tchtest (1), 83 | .BR tchmgr (1), 84 | .BR tchdb (3), 85 | .BR tokyocabinet (3) 86 | -------------------------------------------------------------------------------- /man/tchtest.1: -------------------------------------------------------------------------------- 1 | .TH "TCHTEST" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tchtest \- test cases of the hash database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | To use the hash database API easily, the commands `\fBtchtest\fR', `\fBtchmttest\fR', and `\fBtchmgr\fR' are provided. 9 | .PP 10 | The command `\fBtchtest\fR' is a utility for facility test and performance test. This command is used in the following format. `\fIpath\fR' specifies the path of a database file. `\fIrnum\fR' specifies the number of iterations. `\fIbnum\fR' specifies the number of buckets. `\fIapow\fR' specifies the power of the alignment. `\fIfpow\fR' specifies the power of the free block pool. 11 | .PP 12 | .RS 13 | .br 14 | \fBtchtest write \fR[\fB\-mt\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-as\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fIrnum\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR 15 | .RS 16 | Store records with keys of 8 bytes. They change as `00000001', `00000002'... 17 | .RE 18 | .br 19 | \fBtchtest read \fR[\fB\-mt\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-wb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB\fR 20 | .RS 21 | Retrieve all records of the database above. 22 | .RE 23 | .br 24 | \fBtchtest remove \fR[\fB\-mt\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB\fR 25 | .RS 26 | Remove all records of the database above. 27 | .RE 28 | .br 29 | \fBtchtest rcat \fR[\fB\-mt\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-pn \fInum\fB\fR]\fB \fR[\fB\-dai\fR|\fB\-dad\fR|\fB\-rl\fR|\fB\-ru\fR]\fB \fIpath\fB \fIrnum\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR 30 | .RS 31 | Store records with partway duplicated keys using concatenate mode. 32 | .RE 33 | .br 34 | \fBtchtest misc \fR[\fB\-mt\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fIrnum\fB\fR 35 | .RS 36 | Perform miscellaneous test of various operations. 37 | .RE 38 | .br 39 | \fBtchtest wicked \fR[\fB\-mt\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fIrnum\fB\fR 40 | .RS 41 | Perform updating operations selected at random. 42 | .RE 43 | .RE 44 | .PP 45 | Options feature the following. 46 | .PP 47 | .RS 48 | \fB\-mt\fR : call the function `tchdbsetmutex'. 49 | .br 50 | \fB\-tl\fR : enable the option `HDBTLARGE'. 51 | .br 52 | \fB\-td\fR : enable the option `HDBTDEFLATE'. 53 | .br 54 | \fB\-tb\fR : enable the option `HDBTBZIP'. 55 | .br 56 | \fB\-tt\fR : enable the option `HDBTTCBS'. 57 | .br 58 | \fB\-tx\fR : enable the option `HDBTEXCODEC'. 59 | .br 60 | \fB\-rc \fInum\fR\fR : specify the number of cached records. 61 | .br 62 | \fB\-xm \fInum\fR\fR : specify the size of the extra mapped memory. 63 | .br 64 | \fB\-df \fInum\fR\fR : specify the unit step number of auto defragmentation. 65 | .br 66 | \fB\-nl\fR : enable the option `HDBNOLCK'. 67 | .br 68 | \fB\-nb\fR : enable the option `HDBLCKNB'. 69 | .br 70 | \fB\-as\fR : use the function `tchdbputasync' instead of `tchdbput'. 71 | .br 72 | \fB\-rnd\fR : select keys at random. 73 | .br 74 | \fB\-wb\fR : use the function `tchdbget3' instead of `tchdbget'. 75 | .br 76 | \fB\-pn \fInum\fR\fR : specify the number of patterns. 77 | .br 78 | \fB\-dai\fR : use the function `tchdbaddint' instead of `tchdbputcat'. 79 | .br 80 | \fB\-dad\fR : use the function `tchdbadddouble' instead of `tchdbputcat'. 81 | .br 82 | \fB\-rl\fR : set the length of values at random. 83 | .br 84 | \fB\-ru\fR : select update operations at random. 85 | .br 86 | .RE 87 | .PP 88 | This command returns 0 on success, another on failure. 89 | 90 | .SH SEE ALSO 91 | .PP 92 | .BR tchmttest (1), 93 | .BR tchmgr (1), 94 | .BR tchdb (3), 95 | .BR tokyocabinet (3) 96 | -------------------------------------------------------------------------------- /man/tclist.3: -------------------------------------------------------------------------------- 1 | .so man3/tcutil.3 2 | -------------------------------------------------------------------------------- /man/tcmap.3: -------------------------------------------------------------------------------- 1 | .so man3/tcutil.3 2 | -------------------------------------------------------------------------------- /man/tcmdb.3: -------------------------------------------------------------------------------- 1 | .so man3/tcutil.3 2 | -------------------------------------------------------------------------------- /man/tcmpool.3: -------------------------------------------------------------------------------- 1 | .so man3/tcutil.3 2 | -------------------------------------------------------------------------------- /man/tctmgr.1: -------------------------------------------------------------------------------- 1 | .TH "TCTMGR" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tctmgr \- the command line utility of the table database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtctmgr\fR' is a utility for test and debugging of the table database API and its applications. `\fIpath\fR' specifies the path of a database file. `\fIbnum\fR' specifies the number of buckets. `\fIapow\fR' specifies the power of the alignment. `\fIfpow\fR' specifies the power of the free block pool. `\fIpkey\fR' specifies the primary key of a record. `\fIcols\fR' specifies the names and the values of a record alternately. `\fIname\fR' specifies the name of a column. `\fIop\fR' specifies an operator. `\fIexpr\fR' specifies the condition expression. `\fIfile\fR' specifies the input file. 9 | .PP 10 | .RS 11 | .br 12 | \fBtctmgr create \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fIpath\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR 13 | .RS 14 | Create a database file. 15 | .RE 16 | .br 17 | \fBtctmgr inform \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB\fR 18 | .RS 19 | Print miscellaneous information to the standard output. 20 | .RE 21 | .br 22 | \fBtctmgr put \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fR[\fB\-dk\fR|\fB\-dc\fR|\fB\-dai\fR|\fB\-dad\fR]\fB \fIpath\fB \fIpkey\fB \fR[\fB\fIcols\fB ...\fR]\fB\fR 23 | .RS 24 | Store a record. 25 | .RE 26 | .br 27 | \fBtctmgr out \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fIpath\fB \fIpkey\fB\fR 28 | .RS 29 | Remove a record. 30 | .RE 31 | .br 32 | \fBtctmgr get \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sx\fR]\fB \fR[\fB\-px\fR]\fB \fR[\fB\-pz\fR]\fB \fIpath\fB \fIpkey\fB\fR 33 | .RS 34 | Print the value of a record. 35 | .RE 36 | .br 37 | \fBtctmgr list \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-m \fInum\fB\fR]\fB \fR[\fB\-pv\fR]\fB \fR[\fB\-px\fR]\fB \fR[\fB\-fm \fIstr\fB\fR]\fB \fIpath\fB\fR 38 | .RS 39 | Print the primary keys of all records, separated by line feeds. 40 | .RE 41 | .br 42 | \fBtctmgr search \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-ord \fIname\fB \fItype\fB\fR]\fB \fR[\fB\-m \fInum\fB\fR]\fB \fR[\fB\-sk \fInum\fB\fR]\fB \fR[\fB\-kw\fR]\fB \fR[\fB\-pv\fR]\fB \fR[\fB\-px\fR]\fB \fR[\fB\-ph\fR]\fB \fR[\fB\-bt \fInum\fB\fR]\fB \fR[\fB\-rm\fR]\fB \fR[\fB\-ms \fItype\fB\fR]\fB \fIpath\fB \fR[\fB\fIname\fB \fIop\fB \fIexpr\fB ...\fR]\fB\fR 43 | .RS 44 | Print records matching conditions, separated by line feeds. 45 | .RE 46 | .br 47 | \fBtctmgr optimize \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-tz\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-df\fR]\fB \fIpath\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR 48 | .RS 49 | Optimize a database file. 50 | .RE 51 | .br 52 | \fBtctmgr setindex \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-it \fItype\fB\fR]\fB \fIpath\fB \fIname\fB\fR 53 | .RS 54 | Set the index of a column. 55 | .RE 56 | .br 57 | \fBtctmgr importtsv \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-sc\fR]\fB \fIpath\fB \fR[\fB\fIfile\fB\fR]\fB\fR 58 | .RS 59 | Store records of TSV in each line of a file. 60 | .RE 61 | .br 62 | \fBtctmgr version\fR 63 | .RS 64 | Print the version information of Tokyo Cabinet. 65 | .RE 66 | .RE 67 | .PP 68 | Options feature the following. 69 | .PP 70 | .RS 71 | \fB\-tl\fR : enable the option `TDBTLARGE'. 72 | .br 73 | \fB\-td\fR : enable the option `TDBTDEFLATE'. 74 | .br 75 | \fB\-tb\fR : enable the option `TDBTBZIP'. 76 | .br 77 | \fB\-tt\fR : enable the option `TDBTTCBS'. 78 | .br 79 | \fB\-tx\fR : enable the option `TDBTEXCODEC'. 80 | .br 81 | \fB\-nl\fR : enable the option `TDBNOLCK'. 82 | .br 83 | \fB\-nb\fR : enable the option `TDBLCKNB'. 84 | .br 85 | \fB\-sx\fR : the input data is evaluated as a hexadecimal data string. 86 | .br 87 | \fB\-dk\fR : use the function `tctdbputkeep' instead of `tctdbput'. 88 | .br 89 | \fB\-dc\fR : use the function `tctdbputcat' instead of `tctdbput'. 90 | .br 91 | \fB\-dai\fR : use the function `tctdbaddint' instead of `tctdbput'. 92 | .br 93 | \fB\-dad\fR : use the function `tctdbadddouble' instead of `tctdbput'. 94 | .br 95 | \fB\-px\fR : the output data is converted into a hexadecimal data string. 96 | .br 97 | \fB\-pz\fR : do not append line feed at the end of the output. 98 | .br 99 | \fB\-m \fInum\fR\fR : specify the maximum number of the output. 100 | .br 101 | \fB\-pv\fR : print values of records also. 102 | .br 103 | \fB\-fm \fIstr\fR\fR : specify the prefix of keys. 104 | .br 105 | \fB\-ord \fIname\fR \fItype\fR\fR : specify the order of the result. 106 | .br 107 | \fB\-sk \fInum\fR\fR : specify the number of skipped records. 108 | .br 109 | \fB\-kw\fR : print KWIC string. 110 | .br 111 | \fB\-ph\fR : print hint information also. 112 | .br 113 | \fB\-bt\fR : specify the number of benchmark tests. 114 | .br 115 | \fB\-rm\fR : remove every record in the result. 116 | .br 117 | \fB\-ms \fItype\fR\fR : specify the set operation of meta search. 118 | .br 119 | \fB\-tz\fR : enable the option `UINT8_MAX'. 120 | .br 121 | \fB\-df\fR : perform defragmentation only. 122 | .br 123 | \fB\-it \fItype\fR\fR : specify the index type among "lexical", "decimal", "token", "qgram", and "void". 124 | .br 125 | \fB\-cd\fR : create the number index instead of the string index. 126 | .br 127 | \fB\-cv\fR : remove the existing index. 128 | .br 129 | \fB\-sc\fR : normalize keys as lower cases. 130 | .br 131 | .RE 132 | .PP 133 | The operator of the `search' subcommand is one of "STREQ", "STRINC", "STRBW", "STREW", "STRAND", "STROR", "STROREQ", "STRRX", "NUMEQ", "NUMGT", "NUMGE", "NUMLT", "NUMLE", "NUMBT", "NUMOREQ", "FTSPH", "FTSAND", "FTSOR", and "FTSEX". If "~" preposes each operator, the logical meaning is reversed. If "+" preposes each operator, no index is used for the operator. The type of the `\-ord' option is one of "STRASC", "STRDESC", "NUMASC", and "NUMDESC". The type of the `\-ms' option is one of "UNION", "ISECT", and "DIFF". This command returns 0 on success, another on failure. 134 | 135 | .SH SEE ALSO 136 | .PP 137 | .BR tcttest (1), 138 | .BR tctmttest (1), 139 | .BR tctdb (3), 140 | .BR tokyocabinet (3) 141 | -------------------------------------------------------------------------------- /man/tctmttest.1: -------------------------------------------------------------------------------- 1 | .TH "TCTMTTEST" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tctmttest \- test cases of the table database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtctmttest\fR' is a utility for facility test under multi\-thread situation. This command is used in the following format. `\fIpath\fR' specifies the path of a database file. `\fItnum\fR' specifies the number of running threads. `\fIrnum\fR' specifies the number of iterations. `\fIbnum\fR' specifies the number of buckets. `\fIapow\fR' specifies the power of the alignment. `\fIfpow\fR' specifies the power of the free block pool. 9 | .PP 10 | .RS 11 | .br 12 | \fBtctmttest write \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-ip\fR]\fB \fR[\fB\-is\fR]\fB \fR[\fB\-in\fR]\fB \fR[\fB\-it\fR]\fB \fR[\fB\-if\fR]\fB \fR[\fB\-ix\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR 13 | .RS 14 | Store records with columns "str", "num", "type", and "flag". 15 | .RE 16 | .br 17 | \fBtctmttest read \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB\fR 18 | .RS 19 | Retrieve all records of the database above. 20 | .RE 21 | .br 22 | \fBtctmttest remove \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fItnum\fB\fR 23 | .RS 24 | Remove all records of the database above. 25 | .RE 26 | .br 27 | \fBtctmttest wicked \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB\fR 28 | .RS 29 | Perform updating operations selected at random. 30 | .RE 31 | .br 32 | \fBtctmttest typical \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rr \fInum\fB\fR]\fB \fIpath\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR 33 | .RS 34 | Perform typical operations selected at random. 35 | .RE 36 | .RE 37 | .PP 38 | Options feature the following. 39 | .PP 40 | .RS 41 | \fB\-tl\fR : enable the option `TDBTLARGE'. 42 | .br 43 | \fB\-td\fR : enable the option `TDBTDEFLATE'. 44 | .br 45 | \fB\-tb\fR : enable the option `TDBTBZIP'. 46 | .br 47 | \fB\-tt\fR : enable the option `TDBTTCBS'. 48 | .br 49 | \fB\-tx\fR : enable the option `TDBTEXCODEC'. 50 | .br 51 | \fB\-rc \fInum\fR\fR : specify the number of cached records. 52 | .br 53 | \fB\-lc \fInum\fR\fR : specify the number of cached leaf pages. 54 | .br 55 | \fB\-nc \fInum\fR\fR : specify the number of cached non\-leaf pages. 56 | .br 57 | \fB\-xm \fInum\fR\fR : specify the size of the extra mapped memory. 58 | .br 59 | \fB\-df \fInum\fR\fR : specify the unit step number of auto defragmentation. 60 | .br 61 | \fB\-ip\fR : create the number index for the primary key. 62 | .br 63 | \fB\-is\fR : create the string index for the column "str". 64 | .br 65 | \fB\-in\fR : create the number index for the column "num". 66 | .br 67 | \fB\-it\fR : create the string index for the column "type". 68 | .br 69 | \fB\-if\fR : create the token inverted index for the column "flag". 70 | .br 71 | \fB\-ix\fR : create the q\-gram inverted index for the column "text". 72 | .br 73 | \fB\-nl\fR : enable the option `TDBNOLCK'. 74 | .br 75 | \fB\-nb\fR : enable the option `TDBLCKNB'. 76 | .br 77 | \fB\-rnd\fR : select keys at random. 78 | .br 79 | \fB\-nc\fR : omit the comparison test. 80 | .br 81 | \fB\-rr \fInum\fR\fR : specify the ratio of reading operation by percentage. 82 | .br 83 | .RE 84 | .PP 85 | This command returns 0 on success, another on failure. 86 | 87 | .SH SEE ALSO 88 | .PP 89 | .BR tcttest (1), 90 | .BR tctmgr (1), 91 | .BR tctdb (3), 92 | .BR tokyocabinet (3) 93 | -------------------------------------------------------------------------------- /man/tctree.3: -------------------------------------------------------------------------------- 1 | .so man3/tcutil.3 2 | -------------------------------------------------------------------------------- /man/tcttest.1: -------------------------------------------------------------------------------- 1 | .TH "TCTTEST" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcttest \- test cases of the table database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtcttest\fR' is a utility for facility test and performance test. This command is used in the following format. `\fIpath\fR' specifies the path of a database file. `\fIrnum\fR' specifies the number of iterations. `\fIbnum\fR' specifies the number of buckets. `\fIapow\fR' specifies the power of the alignment. `\fIfpow\fR' specifies the power of the free block pool. 9 | .PP 10 | .RS 11 | .br 12 | \fBtcttest write \fR[\fB\-mt\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-ip\fR]\fB \fR[\fB\-is\fR]\fB \fR[\fB\-in\fR]\fB \fR[\fB\-it\fR]\fB \fR[\fB\-if\fR]\fB \fR[\fB\-ix\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB \fIrnum\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR 13 | .RS 14 | Store records with columns "str", "num", "type", and "flag". 15 | .RE 16 | .br 17 | \fBtcttest read \fR[\fB\-mt\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB\fR 18 | .RS 19 | Retrieve all records of the database above. 20 | .RE 21 | .br 22 | \fBtcttest remove \fR[\fB\-mt\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-rnd\fR]\fB \fIpath\fB\fR 23 | .RS 24 | Remove all records of the database above. 25 | .RE 26 | .br 27 | \fBtcttest rcat \fR[\fB\-mt\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-rc \fInum\fB\fR]\fB \fR[\fB\-lc \fInum\fB\fR]\fB \fR[\fB\-nc \fInum\fB\fR]\fB \fR[\fB\-xm \fInum\fB\fR]\fB \fR[\fB\-df \fInum\fB\fR]\fB \fR[\fB\-ip\fR]\fB \fR[\fB\-is\fR]\fB \fR[\fB\-in\fR]\fB \fR[\fB\-it\fR]\fB \fR[\fB\-if\fR]\fB \fR[\fB\-ix\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fR[\fB\-pn \fInum\fB\fR]\fB \fR[\fB\-dai\fR|\fB\-dad\fR|\fB\-rl\fR|\fB\-ru\fR]\fB \fIpath\fB \fIrnum\fB \fR[\fB\fIbnum\fB \fR[\fB\fIapow\fB \fR[\fB\fIfpow\fB\fR]\fB\fR]\fB\fR]\fB\fR 28 | .RS 29 | Store records with partway duplicated keys using concatenate mode. 30 | .RE 31 | .br 32 | \fBtcttest misc \fR[\fB\-mt\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fIrnum\fB\fR 33 | .RS 34 | Perform miscellaneous test of various operations. 35 | .RE 36 | .br 37 | \fBtcttest wicked \fR[\fB\-mt\fR]\fB \fR[\fB\-tl\fR]\fB \fR[\fB\-td\fR|\fB\-tb\fR|\fB\-tt\fR|\fB\-tx\fR]\fB \fR[\fB\-nl\fR|\fB\-nb\fR]\fB \fIpath\fB \fIrnum\fB\fR 38 | .RS 39 | Perform updating operations selected at random. 40 | .RE 41 | .RE 42 | .PP 43 | Options feature the following. 44 | .PP 45 | .RS 46 | \fB\-mt\fR : call the function `tctdbsetmutex'. 47 | .br 48 | \fB\-tl\fR : enable the option `TDBTLARGE'. 49 | .br 50 | \fB\-td\fR : enable the option `TDBTDEFLATE'. 51 | .br 52 | \fB\-tb\fR : enable the option `TDBTBZIP'. 53 | .br 54 | \fB\-tt\fR : enable the option `TDBTTCBS'. 55 | .br 56 | \fB\-tx\fR : enable the option `TDBTEXCODEC'. 57 | .br 58 | \fB\-rc \fInum\fR\fR : specify the number of cached records. 59 | .br 60 | \fB\-lc \fInum\fR\fR : specify the number of cached leaf pages. 61 | .br 62 | \fB\-nc \fInum\fR\fR : specify the number of cached non\-leaf pages. 63 | .br 64 | \fB\-xm \fInum\fR\fR : specify the size of the extra mapped memory. 65 | .br 66 | \fB\-df \fInum\fR\fR : specify the unit step number of auto defragmentation. 67 | .br 68 | \fB\-ip\fR : create the number index for the primary key. 69 | .br 70 | \fB\-is\fR : create the string index for the column "str". 71 | .br 72 | \fB\-in\fR : create the number index for the column "num". 73 | .br 74 | \fB\-it\fR : create the string index for the column "type". 75 | .br 76 | \fB\-if\fR : create the token inverted index for the column "flag". 77 | .br 78 | \fB\-ix\fR : create the q\-gram inverted index for the column "text". 79 | .br 80 | \fB\-nl\fR : enable the option `TDBNOLCK'. 81 | .br 82 | \fB\-nb\fR : enable the option `TDBLCKNB'. 83 | .br 84 | \fB\-rnd\fR : select keys at random. 85 | .br 86 | \fB\-pn \fInum\fR\fR : specify the number of patterns. 87 | .br 88 | \fB\-dai\fR : use the function `tctdbaddint' instead of `tctdbputcat'. 89 | .br 90 | \fB\-dad\fR : use the function `tctdbadddouble' instead of `tctdbputcat'. 91 | .br 92 | \fB\-rl\fR : set the length of values at random. 93 | .br 94 | \fB\-ru\fR : select update operations at random. 95 | .br 96 | .RE 97 | .PP 98 | This command returns 0 on success, another on failure. 99 | 100 | .SH SEE ALSO 101 | .PP 102 | .BR tctmttest (1), 103 | .BR tctmgr (1), 104 | .BR tctdb (3), 105 | .BR tokyocabinet (3) 106 | -------------------------------------------------------------------------------- /man/tcucodec.1: -------------------------------------------------------------------------------- 1 | .TH "TCUCODEC" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcucodec \- popular encoders and decoders 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtcucodec\fR' is a tool to use encoding and decoding features. This command is used in the following format. `\fIfile\fR' specifies a input file. If it is omitted, the standard input is read. 9 | .PP 10 | .RS 11 | .br 12 | \fBtcucodec url \fR[\fB\-d\fR]\fB \fR[\fB\-br\fR]\fB \fR[\fB\-rs \fIbase\fB\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 13 | .RS 14 | Perform URL encoding and its decoding. 15 | .RE 16 | .br 17 | \fBtcucodec base \fR[\fB\-d\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 18 | .RS 19 | Perform Base64 encoding and its decoding. 20 | .RE 21 | .br 22 | \fBtcucodec quote \fR[\fB\-d\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 23 | .RS 24 | Perform quoted\-printable encoding and its decoding. 25 | .RE 26 | .br 27 | \fBtcucodec mime \fR[\fB\-d\fR]\fB \fR[\fB\-en \fIname\fB\fR]\fB \fR[\fB\-q\fR]\fB \fR[\fB\-on\fR]\fB \fR[\fB\-hd\fR]\fB \fR[\fB\-bd\fR]\fB \fR[\fB\-part \fInum\fB\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 28 | .RS 29 | Perform MIME encoding and its decoding. 30 | .RE 31 | .br 32 | \fBtcucodec hex \fR[\fB\-d\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 33 | .RS 34 | Perform hexadecimal encoding and its decoding. 35 | .RE 36 | .br 37 | \fBtcucodec pack \fR[\fB\-d\fR]\fB \fR[\fB\-bwt\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 38 | .RS 39 | Perform Packbits encoding and its decoding. 40 | .RE 41 | .br 42 | \fBtcucodec tcbs \fR[\fB\-d\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 43 | .RS 44 | Perform TCBS encoding and its decoding. 45 | .RE 46 | .br 47 | \fBtcucodec zlib \fR[\fB\-d\fR]\fB \fR[\fB\-gz\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 48 | .RS 49 | Perform ZLIB encoding and its decoding. 50 | .RE 51 | .br 52 | \fBtcucodec bzip \fR[\fB\-d\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 53 | .RS 54 | Perform BZIP2 encoding and its decoding. 55 | .RE 56 | .br 57 | \fBtcucodec xml \fR[\fB\-d\fR]\fB \fR[\fB\-br\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 58 | .RS 59 | Process XML. By default, escape meta characters. 60 | .RE 61 | .br 62 | \fBtcucodec cstr \fR[\fB\-d\fR]\fB \fR[\fB\-js\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 63 | .RS 64 | Perform C\-string escaping and its unescaping. 65 | .RE 66 | .br 67 | \fBtcucodec ucs \fR[\fB\-d\fR]\fB \fR[\fB\-un\fR]\fB \fR[\fB\-kw \fIstr\fB\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 68 | .RS 69 | Convert UTF\-8 string into UCS\-2 array. 70 | .RE 71 | .br 72 | \fBtcucodec hash \fR[\fB\-crc\fR]\fB \fR[\fB\-ch \fInum\fB\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 73 | .RS 74 | Calculate the hash value. By default, use MD5 function. 75 | .RE 76 | .br 77 | \fBtcucodec date \fR[\fB\-ds \fIstr\fB\fR]\fB \fR[\fB\-jl \fInum\fB\fR]\fB \fR[\fB\-wf\fR]\fB \fR[\fB\-rf\fR]\fB\fR 78 | .RS 79 | Process date string. By default, print the current UNIX time. 80 | .RE 81 | .br 82 | \fBtcucodec tmpl \fR[\fB\-var \fIname\fB \fIvalue\fB\fR]\fB \fR[\fB\fIfile\fB\fR]\fB\fR 83 | .RS 84 | Perform template serialization. 85 | .RE 86 | .br 87 | \fBtcucodec conf \fR[\fB\-v\fR|\fB\-i\fR|\fB\-l\fR|\fB\-p\fR]\fB\fR 88 | .RS 89 | Print some configurations. 90 | .RE 91 | .RE 92 | .PP 93 | Options feature the following. 94 | .PP 95 | .RS 96 | \fB\-d\fR : perform decoding (unescaping), not encoding (escaping). 97 | .br 98 | \fB\-br\fR : break up URL or XML into elements. 99 | .br 100 | \fB\-rs \fIbase\fR\fR : specify the base URL and resolve the relative URL. 101 | .br 102 | \fB\-en \fIname\fR\fR : specify the input encoding, which is UTF\-8 by default. 103 | .br 104 | \fB\-q\fR : use quoted\-printable encoding, which is Base64 by default. 105 | .br 106 | \fB\-on\fR : output the charset name when decoding. 107 | .br 108 | \fB\-bd\fR : perform MIME parsing and output the body. 109 | .br 110 | \fB\-hd\fR : perform MIME parsing and output the headers. 111 | .br 112 | \fB\-part \fInum\fR\fR : perform MIME parsing and output the specified part. 113 | .br 114 | \fB\-bwt\fR : convert by BWT as preprocessing. 115 | .br 116 | \fB\-gz\fR : use GZIP format. 117 | .br 118 | \fB\-crc\fR : use CRC32 function. 119 | .br 120 | \fB\-js\fR : use JSON compatible format. 121 | .br 122 | \fB\-un\fR : perform UCS normalization. 123 | .br 124 | \fB\-kw \fIstr\fR\fR : generate KWIC string. 125 | .br 126 | \fB\-ch \fInum\fR\fR : use consistent hashing function. 127 | .br 128 | \fB\-ds \fIstr\fR\fR : specify the time. 129 | .br 130 | \fB\-jl \fInum\fR\fR : specify the jet lag. 131 | .br 132 | \fB\-wf\fR : format the output in W3CDTF. 133 | .br 134 | \fB\-rf\fR : format the output in RFC 1123 format. 135 | .br 136 | \fB\-var \fIname\fR \fIvalue\fR\fR : specify a template variable. 137 | .br 138 | \fB\-v\fR : show the version number of Tokyo Cabinet. 139 | .br 140 | \fB\-i\fR : show options to include the headers of Tokyo Cabinet. 141 | .br 142 | \fB\-l\fR : show options to link the library of Tokyo Cabinet. 143 | .br 144 | \fB\-p\fR : show the directory path of the commands of Tokyo Cabinet. 145 | .br 146 | .RE 147 | .PP 148 | This command returns 0 on success, another on failure. 149 | 150 | .SH SEE ALSO 151 | .PP 152 | .BR tcutest (1), 153 | .BR tcumttest (1), 154 | .BR tcutil (3), 155 | .BR tokyocabinet (3) 156 | -------------------------------------------------------------------------------- /man/tcumttest.1: -------------------------------------------------------------------------------- 1 | .TH "TCUMTTEST" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcutest \- test cases of the on-memory database API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtcumttest\fR' is a utility for facility test under multi\-thread situation. This command is used in the following format. `\fIrnum\fR' specifies the number of iterations. `\fIbnum\fR' specifies the number of buckets. 9 | .PP 10 | .RS 11 | .br 12 | \fBtcumttest combo \fR[\fB\-rnd\fR]\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIbnum\fB\fR]\fB\fR 13 | .RS 14 | Peform storing, retrieving, and removing in turn. 15 | .RE 16 | .br 17 | \fBtcumttest typical \fR[\fB\-nc\fR]\fB \fR[\fB\-rr \fInum\fB\fR]\fB \fItnum\fB \fIrnum\fB \fR[\fB\fIbnum\fB\fR]\fB\fR 18 | .RS 19 | Perform typical operations selected at random. 20 | .RE 21 | .RE 22 | .PP 23 | Options feature the following. 24 | .PP 25 | .RS 26 | \fB\-rnd\fR : select keys at random. 27 | .br 28 | \fB\-nc\fR : omit the comparison test. 29 | .br 30 | \-rr \fInum\fR : specifiy the ratio of reading operation by percentage. 31 | .br 32 | .RE 33 | .PP 34 | This command returns 0 on success, another on failure. 35 | 36 | .SH SEE ALSO 37 | .PP 38 | .BR tcutest (1), 39 | .BR tcucodec (1), 40 | .BR tcutil (3), 41 | .BR tokyocabinet (3) 42 | -------------------------------------------------------------------------------- /man/tcutest.1: -------------------------------------------------------------------------------- 1 | .TH "TCUTEST" 1 "2009-06-21" "Man Page" "Tokyo Cabinet" 2 | 3 | .SH NAME 4 | tcutest \- test cases of the utility API 5 | 6 | .SH DESCRIPTION 7 | .PP 8 | The command `\fBtcutest\fR' is a utility for facility test and performance test. This command is used in the following format. `\fIrnum\fR' specifies the number of iterations. `\fIanum\fR' specifies the initial number of elements of array. `\fIbnum\fR' specifies the number of buckets. 9 | .PP 10 | .RS 11 | .br 12 | \fBtcutest xstr \fIrnum\fB\fR 13 | .RS 14 | Perform test of extensible string. 15 | .RE 16 | .br 17 | \fBtcutest list \fR[\fB\-rd\fR]\fB \fIrnum\fB \fR[\fB\fIanum\fB\fR]\fB\fR 18 | .RS 19 | Perform test of array list. 20 | .RE 21 | .br 22 | \fBtcutest map \fR[\fB\-rd\fR]\fB \fR[\fB\-tr\fR]\fB \fR[\fB\-rnd\fR]\fB \fR[\fB\-dk\fR|\fB\-dc\fR|\fB\-dai\fR|\fB\-dad\fR|\fB\-dpr\fR]\fB \fIrnum\fB \fR[\fB\fIbnum\fB\fR]\fB\fR 23 | .RS 24 | Perform test of hash map. 25 | .RE 26 | .br 27 | \fBtcutest tree \fR[\fB\-rd\fR]\fB \fR[\fB\-tr\fR]\fB \fR[\fB\-rnd\fR]\fB \fR[\fB\-dk\fR|\fB\-dc\fR|\fB\-dai\fR|\fB\-dad\fR|\fB\-dpr\fR]\fB \fIrnum\fB\fR 28 | .RS 29 | Perform test of ordered tree. 30 | .RE 31 | .br 32 | \fBtcutest mdb \fR[\fB\-rd\fR]\fB \fR[\fB\-tr\fR]\fB \fR[\fB\-rnd\fR]\fB \fR[\fB\-dk\fR|\fB\-dc\fR|\fB\-dai\fR|\fB\-dad\fR|\fB\-dpr\fR]\fB \fIrnum\fB \fR[\fB\fIbnum\fB\fR]\fB\fR 33 | .RS 34 | Perform test of on\-memory hash database. 35 | .RE 36 | .br 37 | \fBtcutest ndb \fR[\fB\-rd\fR]\fB \fR[\fB\-tr\fR]\fB \fR[\fB\-rnd\fR]\fB \fR[\fB\-dk\fR|\fB\-dc\fR|\fB\-dai\fR|\fB\-dad\fR|\fB\-dpr\fR]\fB \fIrnum\fB\fR 38 | .RS 39 | Perform test of on\-memory tree database. 40 | .RE 41 | .br 42 | \fBtcutest misc \fIrnum\fB\fR 43 | .RS 44 | Perform test of miscellaneous routines. 45 | .RE 46 | .br 47 | \fBtcutest wicked \fIrnum\fB\fR 48 | .RS 49 | Perform updating operations of list and map selected at random. 50 | .RE 51 | .RE 52 | .PP 53 | Options feature the following. 54 | .PP 55 | .RS 56 | \fB\-rd\fR : perform the reading test also. 57 | .br 58 | \fB\-tr\fR : perform the iterator test also. 59 | .br 60 | \fB\-rnd\fR : select keys at random. 61 | .br 62 | \fB\-dk\fR : use the function `tcxxxputkeep' instead of `tcxxxput'. 63 | .br 64 | \fB\-dc\fR : use the function `tcxxxputcat' instead of `tcxxxput'. 65 | .br 66 | \fB\-dai\fR : use the function `tcxxxaddint' instead of `tcxxxput'. 67 | .br 68 | \fB\-dad\fR : use the function `tcxxxadddouble' instead of `tcxxxput'. 69 | .br 70 | \fB\-dpr\fR : use the function `tcxxxputproc' instead of `tcxxxput'. 71 | .br 72 | .RE 73 | .PP 74 | This command returns 0 on success, another on failure. 75 | 76 | .SH SEE ALSO 77 | .PP 78 | .BR tcumttest (1), 79 | .BR tcucodec (1), 80 | .BR tcutil (3), 81 | .BR tokyocabinet (3) 82 | -------------------------------------------------------------------------------- /man/tcxstr.3: -------------------------------------------------------------------------------- 1 | .so man3/tcutil.3 2 | -------------------------------------------------------------------------------- /md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 3. This notice may not be removed or altered from any source distribution. 19 | 20 | L. Peter Deutsch 21 | ghost@aladdin.com 22 | 23 | */ 24 | /* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */ 25 | /* 26 | Independent implementation of MD5 (RFC 1321). 27 | 28 | This code implements the MD5 Algorithm defined in RFC 1321, whose 29 | text is available at 30 | http://www.ietf.org/rfc/rfc1321.txt 31 | The code is derived from the text of the RFC, including the test suite 32 | (section A.5) but excluding the rest of Appendix A. It does not include 33 | any code or documentation that is identified in the RFC as being 34 | copyrighted. 35 | 36 | The original and principal author of md5.h is L. Peter Deutsch 37 | . Other authors are noted in the change history 38 | that follows (in reverse chronological order): 39 | 40 | 2002-04-13 lpd Removed support for non-ANSI compilers; removed 41 | references to Ghostscript; clarified derivation from RFC 1321; 42 | now handles byte order either statically or dynamically. 43 | 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. 44 | 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); 45 | added conditionalization for C++ compilation from Martin 46 | Purschke . 47 | 1999-05-03 lpd Original version. 48 | */ 49 | 50 | #ifndef md5_INCLUDED 51 | # define md5_INCLUDED 52 | 53 | /* 54 | * This package supports both compile-time and run-time determination of CPU 55 | * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be 56 | * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is 57 | * defined as non-zero, the code will be compiled to run only on big-endian 58 | * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to 59 | * run on either big- or little-endian CPUs, but will run slightly less 60 | * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined. 61 | */ 62 | 63 | 64 | /* 65 | * hack to avoid conflict of application symbol names 66 | */ 67 | #define md5_init _tc_md5_init 68 | #define md5_append _tc_md5_append 69 | #define md5_finish _tc_md5_finish 70 | 71 | 72 | 73 | typedef unsigned char md5_byte_t; /* 8-bit byte */ 74 | typedef unsigned int md5_word_t; /* 32-bit word */ 75 | 76 | /* Define the state of the MD5 Algorithm. */ 77 | typedef struct md5_state_s { 78 | md5_word_t count[2]; /* message length in bits, lsw first */ 79 | md5_word_t abcd[4]; /* digest buffer */ 80 | md5_byte_t buf[64]; /* accumulate block */ 81 | } md5_state_t; 82 | 83 | #ifdef __cplusplus 84 | extern "C" 85 | { 86 | #endif 87 | 88 | /* Initialize the algorithm. */ 89 | void md5_init(md5_state_t *pms); 90 | 91 | /* Append a string to the message. */ 92 | void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); 93 | 94 | /* Finish the message and return the digest. */ 95 | void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); 96 | 97 | #ifdef __cplusplus 98 | } /* end extern "C" */ 99 | #endif 100 | 101 | #endif /* md5_INCLUDED */ 102 | -------------------------------------------------------------------------------- /tako: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clement/tokyo-cabinet/5cb3d3fc93b04b0738298727255ac1b9ba29920f/tako -------------------------------------------------------------------------------- /tokyocabinet.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | datarootdir = @datarootdir@ 4 | bindir=@bindir@ 5 | libdir=@libdir@ 6 | libexecdir=@libexecdir@ 7 | includedir=@includedir@ 8 | datadir=@datadir@ 9 | 10 | Name: Tokyo Cabinet 11 | Description: a modern implementation of DBM 12 | Version: @PACKAGE_VERSION@ 13 | Libs: -L${libdir} -ltokyocabinet @LIBS@ 14 | Cflags: -I${includedir} 15 | --------------------------------------------------------------------------------