typedef unsigned short tag;
#define TABLESIZE (1<<16)
-#define NULL_TAG ((tag)-1)
+#define NULL_TAG (-1)
static int false_alarms;
static int tag_hits;
static int matches;
-static int data_transfer;
+static int64 data_transfer;
static int total_false_alarms;
static int total_tag_hits;
static int total_matches;
-static int64 total_data_transfer;
+extern struct stats stats;
struct target {
tag t;
static struct target *targets;
-static tag *tag_table;
+static int *tag_table;
#define gettag2(s1,s2) (((s1) + (s2)) & 0xFFFF)
#define gettag(sum) gettag2((sum)&0xFFFF,(sum)>>16)
int i;
if (!tag_table)
- tag_table = (tag *)malloc(sizeof(tag)*TABLESIZE);
+ tag_table = (int *)malloc(sizeof(tag_table[0])*TABLESIZE);
targets = (struct target *)malloc(sizeof(targets[0])*s->count);
if (!tag_table || !targets)
OFF_T offset,int i)
{
OFF_T n = offset - last_match;
- int j;
+ OFF_T j;
if (verbose > 2 && i >= 0)
rprintf(FINFO,"match at %d last_match=%d j=%d len=%d n=%d\n",
send_token(f,i,buf,last_match,n,i<0?0:s->sums[i].len);
data_transfer += n;
- if (n > 0)
- write_flush(f);
-
- if (i >= 0)
+ if (i >= 0) {
+ stats.matched_data += s->sums[i].len;
n += s->sums[i].len;
+ }
for (j=0;j<n;j+=CHUNK_SIZE) {
int n1 = MIN(CHUNK_SIZE,n-j);
last_match = offset + s->sums[i].len;
else
last_match = offset;
+
+ if (buf)
+ show_progress(last_match, buf->size);
+
+ if (i == -1) end_progress();
}
char sum2[SUM_LENGTH];
uint32 s1, s2, sum;
schar *map;
- extern int do_compression;
if (verbose > 2)
rprintf(FINFO,"hash search b=%d len=%d\n",s->n,(int)len);
if (verbose > 2)
rprintf(FINFO,"done hash search\n");
} else {
+ OFF_T j;
+ /* by doing this in pieces we avoid too many seeks */
+ for (j=0;j<(len-CHUNK_SIZE);j+=CHUNK_SIZE) {
+ int n1 = MIN(CHUNK_SIZE,(len-CHUNK_SIZE)-j);
+ matched(f,s,buf,j+n1,-2);
+ }
matched(f,s,buf,len,-1);
}
total_tag_hits += tag_hits;
total_false_alarms += false_alarms;
total_matches += matches;
- total_data_transfer += data_transfer;
+ stats.literal_data += data_transfer;
}
void match_report(void)
return;
rprintf(FINFO,
- "total: matches=%d tag_hits=%d false_alarms=%d data=%ld\n",
+ "total: matches=%d tag_hits=%d false_alarms=%d data=%.0f\n",
total_matches,total_tag_hits,
- total_false_alarms,(long)total_data_transfer);
+ total_false_alarms,
+ (double)stats.literal_data);
}