X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Flib%2Fgscphftaaux%2Fhfta_runtime_library.cc;h=ccae6e389adba79c592bbe3238ab8ffa60cfdeb9;hb=refs%2Fchanges%2F82%2F3882%2F1;hp=ab94a0137d85cbd7b101787b2b51783f779fc089;hpb=3ff5c433efcaee8b01fbeed90ab848008f2e6278;p=com%2Fgs-lite.git diff --git a/src/lib/gscphftaaux/hfta_runtime_library.cc b/src/lib/gscphftaaux/hfta_runtime_library.cc index ab94a01..ccae6e3 100644 --- a/src/lib/gscphftaaux/hfta_runtime_library.cc +++ b/src/lib/gscphftaaux/hfta_runtime_library.cc @@ -92,6 +92,39 @@ void hfta_vstr_replace(vstring *dst, vstring *src){ hfta_vstr_assign_with_copy(dst,src); } +#define HFTA_VSTR_LHASHFUNC_PRIME 12916008961267169387ull +gs_uint64_t hfta_vstr_long_hashfunc(const vstring *s) { + gs_uint64_t hash_code; + gs_int32_t n_steps; + gs_int32_t substr_len; + gs_int32_t j, k; + gs_uint64_t sub_hash; + gs_sp_t sv; + + sv=(gs_sp_t)(s->offset); + hash_code = 0; + n_steps = s->length / 4; + if(4*n_steps < s->length) n_steps++; + + for (j = 0; j < n_steps; j++) { + if(4*(j+1) < s->length) substr_len = 4; + else substr_len = s->length - 4*j; + + sub_hash = 0; + for(k=0;k<4;k++){ + if(k < substr_len) + sub_hash = (sub_hash << 4) + *sv; + else + sub_hash = (sub_hash << 4); + sv++; + } + + hash_code = (sub_hash + hash_code * HFTA_VSTR_LHASHFUNC_PRIME); + } + + return(hash_code); +} + #define HFTA_VSTR_HASHFUNC_PRIME 2995999 gs_uint32_t hfta_vstr_hashfunc(const vstring *s) { gs_uint32_t hash_code; @@ -101,7 +134,6 @@ gs_uint32_t hfta_vstr_hashfunc(const vstring *s) { gs_uint32_t k, sub_hash; gs_sp_t sv; - sv=(gs_sp_t)(s->offset); hash_code = 0; n_steps = s->length / 4; @@ -126,6 +158,7 @@ gs_uint32_t hfta_vstr_hashfunc(const vstring *s) { return(hash_code); } + // return negative if s1 < s2, 0 if s1==s2, positive if s1>s2 gs_retval_t hfta_vstr_compare(const vstring * s1, const vstring * s2) { gs_int32_t minlen,cmp_ret;