2014-08-27 15 views

risposta

6

Codewisely, si potrebbe usare db->GetProperty("rocksdb.estimate-num-keys", &num) per ottenere il numero stimato di chiavi memorizzate in un rocksdb.

Un'altra opzione consiste nell'utilizzare lo strumento sst_dump con l'argomento --show_properties per ottenere il numero di voci, sebbene il risultato sia per file. Ad esempio, il seguente comando mostrerà le proprietà di ciascun file SST sotto la directory rocksdb specificato:

sst_dump --file=/tmp/rocksdbtest-691931916/dbbench --show_properties --command=none 

Ed ecco l'output del campione:

Process /tmp/rocksdbtest-691931916/dbbench/000005.sst 
Sst file format: block-based 
Table Properties: 
------------------------------ 
    # data blocks: 845 
    # entries: 27857 
    raw key size: 668568 
    raw average key size: 24.000000 
    raw value size: 2785700 
    raw average value size: 100.000000 
    data block size: 3381885 
    index block size: 28473 
    filter block size: 0 
    (estimated) table size: 3410358 
    filter policy name: N/A 
    # deleted keys: 0 
Process /tmp/rocksdbtest-691931916/dbbench/000008.sst 
Sst file format: block-based 
Table Properties: 
------------------------------ 
    # data blocks: 845 
    # entries: 27880 
    raw key size: 669120 
... 

Combinate con alcuni comandi di shell, si sarà in grado per ottenere il numero totale di voci:

sst_dump --file=/tmp/rocksdbtest-691931916/dbbench --show_properties --command=none | grep entries | cut -c 14- | awk '{x+=$0}END{print "total number of entries: " x}' 

E questo genererà il seguente risultato:

01.235.164,106174 millions
total number of entries: 111507 
Problemi correlati