vcwprefix.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2003-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include "vcwhdr.h"
/* Compute window using block matching.
**
** Written by Kiem-Phong Vo.
*/
struct _pfseg_s
};
struct _pfobj_s
};
struct _pftab_s
};
struct _pffile_s
};
struct _prefix_s
};
/* functions to set and test bits from a Bloom filter */
/* compute the linear congruential hash of a block of data */
#if __STD_C
#else
#endif
{
return key;
}
/* compute hash value of dt given the hash value of (dt-1) */
/* create the structure to search file sf */
#if __STD_C
#else
int srcfile;
#endif
{
{ for(k = 1024; k*2 < n; k *= 2)
;
}
else n = k = blsz = 0;
if(n > 0)
}
return pf;
}
/* make blocks with addresses < maxp searchable */
#if __STD_C
#else
#endif
{
Vchash_t k, r, n;
return 0;
/* construct keys to represent blocks */
return -1;
return -1;
k = PF_HUGE-1;
}
return 0;
}
#if __STD_C
#else
#endif
{
/* merge with last segment if overlapping */
return mn;
}
return 0;
/* creating a new segment */
return -1;
}
return mn;
}
/* parse a string of keys into matchable and unmatched data */
#if __STD_C
#else
ssize_t n;
#endif
{
Pfobj_t *o;
total = 0;
continue;
{ /* find a stretch of approximate matches */
ucnt = 0;
break; /* too many misses */
else ucnt += 1;
}
{ mn = k; /* current best match length */
}
}
if(mn > 0)
break;
}
if(mn <= 0) /* done with search for windows */
break;
return -1;
else total += k; /* good match */
}
return total;
}
/* compute a window to return to application for delta-ing */
#if __STD_C
#else
Vcwmatch_t* wm;
#endif
{
/* absorb left unmatched data if any */
sz = 0;
}
if(sz > 0) /* returning an unmatchable window of data */
return 0;
}
/* absorb any right unmatched block data */
if(sz > 0)
}
/* set window */
return -1;
}
return 1;
}
#if __STD_C
#else
#endif
{
int rv;
return NIL(Vcwmatch_t*);
}
else /* too large, use all source file */
}
return NIL(Vcwmatch_t*);
return wm;
}
target_file: /* returning computed windows in target file */
return NIL(Vcwmatch_t*);
return wm;
}
}
return NIL(Vcwmatch_t*);
}
{ /* compute all keys for this set of data */
}
/* match with source data to parse into segments */
{ /* fail source, try target */
goto target_file;
else return NIL(Vcwmatch_t*);
}
}
return NIL(Vcwmatch_t*);
else
if(rv > 0)
return wm;
}
return wm;
}
else /* try matching this segment with target data */
goto target_file;
else
return wm;
}
}
}
}
/* Event handler */
#if __STD_C
#else
int type;
#endif
{
int rv = -1;
if(type == VCW_OPENING)
{
return -1;
return -1;
/* compute a suitable block size between [MINSIZE,MAXSIZE] */
if(maxsz < PF_MINSIZE)
sz = 0;
else
{ sz = PF_DFLTSIZE;
sz += PF_MINSIZE;
sz -= PF_MINSIZE;
}
if(srcsz > 0)
goto do_closing;
goto do_closing;
}
}
goto do_closing;
goto do_closing;
}
return 0;
}
else if(type == VCW_CLOSING)
{ rv = 0;
}
}
}
return rv;
}
else return 0;
}
{ pfmatch,
"prefix",
"Find windows with matching prefixes.",
"[-version?window::prefix (AT&T Research) 2003-01-01]" USAGE_LICENSE,
};