| 474 | |
| 475 | |
| 476 | static uint64 |
| 477 | BsonHashCompare(bson_iter_t *bsonIterValue, |
| 478 | uint64 (*hash_bytes_func)(const uint8_t *bytes, uint32_t bytesLength, |
| 479 | int64 seed), |
| 480 | uint64 (*hash_combine_func)(uint64 left, uint64 right), |
| 481 | int64 seed, |
| 482 | const char *collationString) |
| 483 | { |
| 484 | check_stack_depth(); |
| 485 | uint64_t hashValue = 0; |
| 486 | while (bson_iter_next(bsonIterValue)) |
| 487 | { |
| 488 | pgbsonelement leftElement; |
| 489 | |
| 490 | BsonIterToPgbsonElement(bsonIterValue, &leftElement); |
| 491 | |
| 492 | /* next compare field name. */ |
| 493 | uint64_t pathHash = hash_bytes_func((uint8_t *) leftElement.path, |
| 494 | leftElement.pathLength, seed); |
| 495 | hashValue = hash_combine_func(hashValue, pathHash); |
| 496 | |
| 497 | uint64_t valueHash = HashBsonValueCompare(&leftElement.bsonValue, hash_bytes_func, |
| 498 | hash_combine_func, seed, |
| 499 | collationString); |
| 500 | hashValue = hash_combine_func(hashValue, valueHash); |
| 501 | } |
| 502 | |
| 503 | return hashValue; |
| 504 | } |
| 505 | |
| 506 | |
| 507 | /* |
no test coverage detected