@@ -1139,6 +1139,7 @@ __cold static int chk_db(MDBX_chk_scope_t *const scope, MDBX_dbi dbi, MDBX_chk_t
1139
1139
const size_t maxkeysize = mdbx_env_get_maxkeysize_ex (env , tbl -> flags );
1140
1140
MDBX_val prev_key = {nullptr , 0 }, prev_data = {nullptr , 0 };
1141
1141
MDBX_val key , data ;
1142
+ size_t dups_count = 0 ;
1142
1143
err = mdbx_cursor_get (cursor , & key , & data , MDBX_FIRST );
1143
1144
while (err == MDBX_SUCCESS ) {
1144
1145
err = chk_check_break (scope );
@@ -1162,6 +1163,12 @@ __cold static int chk_db(MDBX_chk_scope_t *const scope, MDBX_dbi dbi, MDBX_chk_t
1162
1163
}
1163
1164
1164
1165
if (prev_key .iov_base ) {
1166
+ if (key .iov_base == prev_key .iov_base )
1167
+ dups_count += 1 ;
1168
+ else {
1169
+ histogram_acc (dups_count , & tbl -> histogram .multival );
1170
+ dups_count = 0 ;
1171
+ }
1165
1172
if (prev_data .iov_base && !bad_data && (tbl -> flags & MDBX_DUPFIXED ) && prev_data .iov_len != data .iov_len ) {
1166
1173
chk_object_issue (scope , "entry" , record_count , "different data length" , "%" PRIuPTR " != %" PRIuPTR ,
1167
1174
prev_data .iov_len , data .iov_len );
@@ -1248,17 +1255,27 @@ __cold static int chk_db(MDBX_chk_scope_t *const scope, MDBX_dbi dbi, MDBX_chk_t
1248
1255
err = mdbx_cursor_get (cursor , & key , & data , MDBX_NEXT );
1249
1256
}
1250
1257
1258
+ if (prev_key .iov_base )
1259
+ histogram_acc (dups_count , & tbl -> histogram .multival );
1260
+
1251
1261
err = (err != MDBX_NOTFOUND ) ? chk_error_rc (scope , err , "mdbx_cursor_get" ) : MDBX_SUCCESS ;
1252
1262
if (err == MDBX_SUCCESS && record_count != db -> items )
1253
1263
chk_scope_issue (scope , "different number of entries %" PRIuSIZE " != %" PRIu64 , record_count , db -> items );
1254
1264
bailout :
1255
1265
if (cursor ) {
1256
1266
if (handler ) {
1257
- if (tbl -> histogram . key_len . count ) {
1267
+ if (record_count ) {
1258
1268
MDBX_chk_line_t * line = chk_line_begin (scope , MDBX_chk_info );
1259
1269
line = histogram_dist (line , & tbl -> histogram .key_len , "key length density" , "0/1" , false);
1260
1270
chk_line_feed (line );
1261
1271
line = histogram_dist (line , & tbl -> histogram .val_len , "value length density" , "0/1" , false);
1272
+ if (tbl -> histogram .multival .amount ) {
1273
+ chk_line_feed (line );
1274
+ line = histogram_dist (line , & tbl -> histogram .multival , "number of multi-values density" , "single" , false);
1275
+ chk_line_feed (line );
1276
+ line = chk_print (line , "number of keys %" PRIuSIZE ", average values per key %.1f" ,
1277
+ tbl -> histogram .multival .count , record_count / (double )tbl -> histogram .multival .count );
1278
+ }
1262
1279
chk_line_end (line );
1263
1280
}
1264
1281
if (scope -> stage == MDBX_chk_maindb )
0 commit comments