Commit e23f74c7 authored by Rusty Russell's avatar Rusty Russell

Handle pre-existing records, wipe_all and repack (ldb users.ldb trace)

parent 1bc7c436
...@@ -35,10 +35,10 @@ ...@@ -35,10 +35,10 @@
struct op_table { struct op_table {
const char *name; const char *name;
enum op_type type; enum op_type type;
void (*enhance_op)(const char *filename, void (*enhance_op)(char *filename[], struct op op[],
struct op op[], unsigned int op_num, char *words[]); unsigned file, unsigned op_num, char *words[]);
}; };
/* maximum key range = 48, duplicates = 0 */ /* maximum key range = 53, duplicates = 0 */
#ifdef __GNUC__ #ifdef __GNUC__
__inline __inline
...@@ -52,32 +52,32 @@ hash_keyword (register const char *str, register unsigned int len) ...@@ -52,32 +52,32 @@ hash_keyword (register const char *str, register unsigned int len)
{ {
static const unsigned char asso_values[] = static const unsigned char asso_values[] =
{ {
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 20, 56, 30, 61, 61, 61, 61, 61, 61, 61, 45, 61, 30,
5, 0, 0, 5, 5, 56, 56, 0, 0, 0, 5, 0, 0, 5, 5, 61, 61, 0, 0, 0,
20, 56, 20, 56, 56, 0, 5, 0, 56, 0, 20, 61, 20, 61, 25, 0, 5, 0, 61, 0,
56, 5, 56, 56, 56, 56, 56, 56, 56, 56, 61, 5, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
56, 56, 56, 56, 56, 56 61, 61, 61, 61, 61, 61
}; };
return len + asso_values[(unsigned char)str[4]] + asso_values[(unsigned char)str[len - 1]]; return len + asso_values[(unsigned char)str[4]] + asso_values[(unsigned char)str[len - 1]];
} }
...@@ -93,11 +93,11 @@ find_keyword (register const char *str, register unsigned int len) ...@@ -93,11 +93,11 @@ find_keyword (register const char *str, register unsigned int len)
{ {
enum enum
{ {
TOTAL_KEYWORDS = 34, TOTAL_KEYWORDS = 35,
MIN_WORD_LENGTH = 8, MIN_WORD_LENGTH = 8,
MAX_WORD_LENGTH = 30, MAX_WORD_LENGTH = 30,
MIN_HASH_VALUE = 8, MIN_HASH_VALUE = 8,
MAX_HASH_VALUE = 55 MAX_HASH_VALUE = 60
}; };
static const struct op_table wordlist[] = static const struct op_table wordlist[] =
...@@ -112,7 +112,7 @@ find_keyword (register const char *str, register unsigned int len) ...@@ -112,7 +112,7 @@ find_keyword (register const char *str, register unsigned int len)
#line 16 "keywords.gperf" #line 16 "keywords.gperf"
{"tdb_lockall", OP_TDB_LOCKALL, op_add_nothing,}, {"tdb_lockall", OP_TDB_LOCKALL, op_add_nothing,},
#line 36 "keywords.gperf" #line 36 "keywords.gperf"
{"tdb_wipe_all", OP_TDB_WIPE_ALL, op_add_nothing,}, {"tdb_wipe_all", OP_TDB_WIPE_ALL, op_add_wipe_all,},
#line 20 "keywords.gperf" #line 20 "keywords.gperf"
{"tdb_unlockall", OP_TDB_UNLOCKALL, op_add_nothing,}, {"tdb_unlockall", OP_TDB_UNLOCKALL, op_add_nothing,},
#line 48 "keywords.gperf" #line 48 "keywords.gperf"
...@@ -153,8 +153,8 @@ find_keyword (register const char *str, register unsigned int len) ...@@ -153,8 +153,8 @@ find_keyword (register const char *str, register unsigned int len)
#line 41 "keywords.gperf" #line 41 "keywords.gperf"
{"tdb_traverse_read_start", OP_TDB_TRAVERSE_READ_START, op_add_traverse_start,}, {"tdb_traverse_read_start", OP_TDB_TRAVERSE_READ_START, op_add_traverse_start,},
{""}, {""},
#line 34 "keywords.gperf" #line 50 "keywords.gperf"
{"tdb_append", OP_TDB_APPEND, op_add_append,}, {"tdb_repack", OP_TDB_REPACK, op_add_nothing,},
#line 47 "keywords.gperf" #line 47 "keywords.gperf"
{"tdb_nextkey", OP_TDB_NEXTKEY, op_add_key_data,}, {"tdb_nextkey", OP_TDB_NEXTKEY, op_add_key_data,},
{""}, {""}, {""}, {""}, {""}, {""},
...@@ -181,7 +181,10 @@ find_keyword (register const char *str, register unsigned int len) ...@@ -181,7 +181,10 @@ find_keyword (register const char *str, register unsigned int len)
{"tdb_chainlock_read", OP_TDB_CHAINLOCK_READ, op_add_chainlock,}, {"tdb_chainlock_read", OP_TDB_CHAINLOCK_READ, op_add_chainlock,},
{""}, {""},
#line 30 "keywords.gperf" #line 30 "keywords.gperf"
{"tdb_chainunlock_read", OP_TDB_CHAINUNLOCK_READ, op_analyze_chainlock,} {"tdb_chainunlock_read", OP_TDB_CHAINUNLOCK_READ, op_analyze_chainlock,},
{""}, {""}, {""}, {""},
#line 34 "keywords.gperf"
{"tdb_append", OP_TDB_APPEND, op_add_append,}
}; };
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
struct op_table { struct op_table {
const char *name; const char *name;
enum op_type type; enum op_type type;
void (*enhance_op)(const char *filename, void (*enhance_op)(char *filename[], struct op op[],
struct op op[], unsigned int op_num, char *words[]); unsigned file, unsigned op_num, char *words[]);
}; };
%define hash-function-name hash_keyword %define hash-function-name hash_keyword
%define lookup-function-name find_keyword %define lookup-function-name find_keyword
...@@ -33,7 +33,7 @@ tdb_exists, OP_TDB_EXISTS, op_add_key_ret, ...@@ -33,7 +33,7 @@ tdb_exists, OP_TDB_EXISTS, op_add_key_ret,
tdb_store, OP_TDB_STORE, op_add_store, tdb_store, OP_TDB_STORE, op_add_store,
tdb_append, OP_TDB_APPEND, op_add_append, tdb_append, OP_TDB_APPEND, op_add_append,
tdb_get_seqnum, OP_TDB_GET_SEQNUM, op_add_seqnum, tdb_get_seqnum, OP_TDB_GET_SEQNUM, op_add_seqnum,
tdb_wipe_all, OP_TDB_WIPE_ALL, op_add_nothing, tdb_wipe_all, OP_TDB_WIPE_ALL, op_add_wipe_all,
tdb_transaction_start, OP_TDB_TRANSACTION_START, op_add_transaction, tdb_transaction_start, OP_TDB_TRANSACTION_START, op_add_transaction,
tdb_transaction_cancel, OP_TDB_TRANSACTION_CANCEL, op_analyze_transaction, tdb_transaction_cancel, OP_TDB_TRANSACTION_CANCEL, op_analyze_transaction,
tdb_transaction_commit, OP_TDB_TRANSACTION_COMMIT, op_analyze_transaction, tdb_transaction_commit, OP_TDB_TRANSACTION_COMMIT, op_analyze_transaction,
...@@ -47,3 +47,4 @@ tdb_firstkey, OP_TDB_FIRSTKEY, op_add_key, ...@@ -47,3 +47,4 @@ tdb_firstkey, OP_TDB_FIRSTKEY, op_add_key,
tdb_nextkey, OP_TDB_NEXTKEY, op_add_key_data, tdb_nextkey, OP_TDB_NEXTKEY, op_add_key_data,
tdb_fetch, OP_TDB_FETCH, op_add_key_data, tdb_fetch, OP_TDB_FETCH, op_add_key_data,
tdb_delete, OP_TDB_DELETE, op_add_key_ret, tdb_delete, OP_TDB_DELETE, op_add_key_ret,
tdb_repack, OP_TDB_REPACK, op_add_nothing,
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment