mirror of
https://github.com/privacore/open-source-search-engine.git
synced 2025-07-14 02:36:06 -04:00
Marked most Titledb member functions as static
This commit is contained in:
34
Titledb.h
34
Titledb.h
@ -43,7 +43,7 @@ class Titledb {
|
||||
// in the case of a collision we pick a nearby docId that is
|
||||
// different but guaranteed to be in the same group/cluster, so you
|
||||
// can be assured the top 32 bits of the docId will be unchanged
|
||||
uint64_t getProbableDocId ( Url *url , bool mask = true ) {
|
||||
static uint64_t getProbableDocId ( Url *url , bool mask = true ) {
|
||||
uint64_t probableDocId = hash64b(url->getUrl(),0);
|
||||
// Linkdb::getUrlHash() does not mask it
|
||||
if ( mask ) probableDocId = probableDocId & DOCID_MASK;
|
||||
@ -59,14 +59,14 @@ class Titledb {
|
||||
}
|
||||
|
||||
// a different way to do it
|
||||
uint64_t getProbableDocId ( const char *url ) {
|
||||
static uint64_t getProbableDocId ( const char *url ) {
|
||||
Url u;
|
||||
u.set( url );
|
||||
return getProbableDocId ( &u );
|
||||
}
|
||||
|
||||
// a different way to do it
|
||||
uint64_t getProbableDocId(const char *url,const char *dom,int32_t domLen) {
|
||||
static uint64_t getProbableDocId(const char *url,const char *dom,int32_t domLen) {
|
||||
uint64_t probableDocId = hash64b(url,0) &
|
||||
DOCID_MASK;
|
||||
// clear bits 6-13 because we want to put the domain hash there
|
||||
@ -80,31 +80,31 @@ class Titledb {
|
||||
}
|
||||
|
||||
// turn off the last 6 bits
|
||||
uint64_t getFirstProbableDocId ( int64_t d ) {
|
||||
static uint64_t getFirstProbableDocId ( int64_t d ) {
|
||||
return d & 0xffffffffffffffc0LL; }
|
||||
|
||||
// turn on the last 6 bits for the end docId
|
||||
uint64_t getLastProbableDocId ( int64_t d ) {
|
||||
static uint64_t getLastProbableDocId ( int64_t d ) {
|
||||
return d | 0x000000000000003fLL; }
|
||||
|
||||
// . the top NUMDOCIDBITs of "key" are the docId
|
||||
// . we use the top X bits of the keys to partition the records
|
||||
// . using the top bits to partition allows us to keep keys that
|
||||
// are near each other (euclidean metric) in the same partition
|
||||
int64_t getDocIdFromKey ( key96_t *key ) {
|
||||
static int64_t getDocIdFromKey ( key96_t *key ) {
|
||||
uint64_t docId;
|
||||
docId = ((uint64_t)key->n1)<<(NUMDOCIDBITS - 32);
|
||||
docId|= key->n0 >>(64-(NUMDOCIDBITS-32));
|
||||
return docId;
|
||||
}
|
||||
int64_t getDocId ( key96_t *key ) { return getDocIdFromKey(key); }
|
||||
int64_t getDocIdFromKey ( key96_t key ) {
|
||||
static int64_t getDocId ( key96_t *key ) { return getDocIdFromKey(key); }
|
||||
static int64_t getDocIdFromKey ( key96_t key ) {
|
||||
return getDocIdFromKey(&key);}
|
||||
|
||||
uint8_t getDomHash8FromDocId (int64_t d) {
|
||||
static uint8_t getDomHash8FromDocId (int64_t d) {
|
||||
return (d & ~0xffffffffffffc03fULL) >> 6; }
|
||||
|
||||
int64_t getUrlHash48 ( key96_t *k ) {
|
||||
static int64_t getUrlHash48 ( key96_t *k ) {
|
||||
return ((k->n0 >> 10) & 0x0000ffffffffffffLL); }
|
||||
|
||||
// . dptr is a char ptr to the docid
|
||||
@ -114,13 +114,13 @@ class Titledb {
|
||||
// how the docid is parsed out of this key (or see
|
||||
// Indexdb.h)
|
||||
// . return ((*((uint16_t *)dptr)) >> 8) & 0xff; }
|
||||
uint8_t getDomHash8 ( uint8_t *dptr ) { return dptr[1]; }
|
||||
static uint8_t getDomHash8 ( uint8_t *dptr ) { return dptr[1]; }
|
||||
|
||||
// does this key/docId/url have it's titleRec stored locally?
|
||||
bool isLocal ( int64_t docId );
|
||||
bool isLocal ( Url *url ) {
|
||||
static bool isLocal ( int64_t docId );
|
||||
static bool isLocal ( Url *url ) {
|
||||
return isLocal ( getProbableDocId(url) ); }
|
||||
bool isLocal ( key96_t key ) {
|
||||
static bool isLocal ( key96_t key ) {
|
||||
return isLocal (getDocIdFromKey(&key));}
|
||||
|
||||
|
||||
@ -129,12 +129,12 @@ class Titledb {
|
||||
// . make the key of a TitleRec from a docId
|
||||
// . remember to set the low bit so it's not a delete
|
||||
// . hi bits are set in the key
|
||||
key96_t makeKey ( int64_t docId, int64_t uh48, bool isDel );
|
||||
static key96_t makeKey ( int64_t docId, int64_t uh48, bool isDel );
|
||||
|
||||
key96_t makeFirstKey ( int64_t docId ) {
|
||||
static key96_t makeFirstKey ( int64_t docId ) {
|
||||
return makeKey ( docId , 0, true ); }
|
||||
|
||||
key96_t makeLastKey ( int64_t docId ) {
|
||||
static key96_t makeLastKey ( int64_t docId ) {
|
||||
return makeKey ( docId , 0xffffffffffffLL, false ); }
|
||||
|
||||
// . this is an estimate of the number of docs in the WHOLE db network
|
||||
|
Reference in New Issue
Block a user