Optimize index lookup for 8-byte keys.
More cleanups.
This commit is contained in:
parent
5d6ffd969d
commit
6c5d8d9e18
2 changed files with 14 additions and 6 deletions
|
@ -168,7 +168,7 @@ set_cfg:
|
|||
} else {
|
||||
cfg->intervals = 100 / *pct_interval;
|
||||
cfg->sub_intervals = cfg->intervals;
|
||||
*hash_slots = file_sz / cfg->segment_sz_bytes + 1;
|
||||
*hash_slots = file_sz / cfg->segment_sz_bytes;
|
||||
*hash_slots *= cfg->sub_intervals;
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ int
|
|||
db_segcache_map(archive_config_t *cfg, int tid, uint32_t *blknum, uint64_t *offset, uchar_t **blocks)
|
||||
{
|
||||
uchar_t *mapbuf, *hdr;
|
||||
int fd;
|
||||
int fd, dummy;
|
||||
uint32_t len, adj;
|
||||
uint64_t pos;
|
||||
|
||||
|
@ -364,6 +364,7 @@ db_segcache_map(archive_config_t *cfg, int tid, uint32_t *blknum, uint64_t *offs
|
|||
*blknum = *((uint32_t *)(hdr));
|
||||
*offset = *((uint64_t *)(hdr + 4));
|
||||
*blocks = hdr + SEGCACHE_HDR_SZ;
|
||||
dummy = *(hdr + SEGCACHE_HDR_SZ);
|
||||
|
||||
cfg->seg_fd_r[tid].mapping = mapbuf;
|
||||
cfg->seg_fd_r[tid].len = len + adj;
|
||||
|
@ -436,6 +437,15 @@ db_lookup_insert_s(archive_config_t *cfg, uchar_t *sim_cksum, int interval,
|
|||
pent = &(ent->next);
|
||||
ent = ent->next;
|
||||
}
|
||||
} else if (cfg->similarity_cksum_sz == 8) {
|
||||
while (ent) {
|
||||
if (*((uint64_t *)sim_cksum) == *((uint64_t *)ent->cksum) &&
|
||||
ent->item_offset != item_offset) {
|
||||
return (ent);
|
||||
}
|
||||
pent = &(ent->next);
|
||||
ent = ent->next;
|
||||
}
|
||||
} else {
|
||||
while (ent) {
|
||||
if (mycmp(sim_cksum, ent->cksum, cfg->similarity_cksum_sz) == 0 &&
|
||||
|
|
|
@ -866,16 +866,14 @@ process_blocks:
|
|||
*/
|
||||
sim_ck = ctx->similarity_cksums;
|
||||
sub_i = cfg->sub_intervals;
|
||||
len = length;
|
||||
tgt = seg_heap;
|
||||
increment = cfg->chunk_cksum_sz;
|
||||
if (increment * sub_i > len)
|
||||
sub_i = len / increment;
|
||||
if (increment * sub_i > length)
|
||||
sub_i = length / increment;
|
||||
for (j = 0; j<sub_i; j++) {
|
||||
crc = lzma_crc64(tgt, increment/4, 0);
|
||||
*((uint64_t *)sim_ck) = crc;
|
||||
tgt += increment;
|
||||
len -= increment;
|
||||
sim_ck += cfg->similarity_cksum_sz;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue