static UINT32 hash ( const BSONObj &query, const BSONObj &orderBy, const BSONObj &hint ) { return ossHash ( query.objdata(), query.objsize() ) ^ ossHash ( orderBy.objdata(), orderBy.objsize() ) ^ ossHash ( hint.objdata(), hint.objsize() ) ; }
int ixmBucketManager::_processData(BSONObj &record, dmsRecordID &recordID, unsigned int &hashNum, ixmEleHash &eleHash, unsigned int &random) { int rc = EDB_OK; BSONElement element = record.getField(IXM_KEY_FIELDNAME); // check if _id exists and correct if(element.eoo()|| (element.type() != NumberInt && element.type() != String)) { rc = EDB_INVALIDARG; PD_LOG(PDERROR, "record must be with _id"); goto error; } // hash _id hashNum = ossHash(element.value(), element.valuesize()); random = hashNum % IXM_HASH_MAP_SIZE; eleHash.data = element.rawdata(); eleHash.recordID = recordID; done: return rc; error: goto done; }
UINT32 ossHashFileName ( const CHAR *fileName ) { const CHAR *pathSep = OSS_FILE_SEP ; const CHAR *pFileName = ossStrrchr ( fileName, pathSep[0] ) ; if ( !pFileName ) pFileName = fileName ; else pFileName++ ; return ossHash ( pFileName, (INT32)ossStrlen ( pFileName ) ) ; }
void set( const bson::OID *oid, UINT32 sequence, UINT32 offset, UINT32 dataLen, const CHAR *data ) { _oid = oid ; _sequence = sequence ; _offset = offset ; _hash = ossHash( ( const BYTE * )_oid->getData(), 12, ( const BYTE * )( &_sequence ), sizeof( _sequence ) ) ; _dataLen = dataLen ; _data = data ; return ; }
size_t operator()( const CHAR *name )const { return ossHash( name ) ; }
void _SDB_DMSCB::releaseCSMutex( const CHAR *pCSName ) { UINT32 pos = ossHash( pCSName ) % DMS_CS_MUTEX_BUCKET_SIZE ; _vecCSMutex[ pos ]->release() ; }