Module: MurmurHash3::Native128
- Includes:
- Alias128
- Defined in:
- lib/murmurhash3/native_murmur.rb,
ext/murmurhash3/murmur3.c
Instance Method Summary collapse
- #murmur3_128_fmix(integer) ⇒ Object
- #murmur3_128_int32_hash(*args) ⇒ Object
- #murmur3_128_int64_hash(*args) ⇒ Object
- #murmur3_128_str_base64digest(*args) ⇒ Object
- #murmur3_128_str_digest(*args) ⇒ Object
- #murmur3_128_str_hash(*args) ⇒ Object
- #murmur3_128_str_hexdigest(*args) ⇒ Object
Methods included from Alias128
Instance Method Details
#murmur3_128_fmix(integer) ⇒ Object
308 309 310 311 312 313 314 315 316 317 318 |
# File 'ext/murmurhash3/murmur3.c', line 308 static VALUE rb_fmix64(VALUE self, VALUE integer) { #if SIZEOF_LONG == 8 uint64_t _int = NUM2ULONG(integer); return ULONG2NUM(fmix64(_int)); #else uint64_t _int = NUM2ULL(integer); return ULL2NUM(fmix64(_int)); #endif } |
#murmur3_128_int32_hash(*args) ⇒ Object
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
# File 'ext/murmurhash3/murmur3.c', line 574 static VALUE rb_murmur3_128_int32_hash(int argc, VALUE* argv, VALUE self) { VALUE ar_result; uint32_t result[4], _int; if (argc == 0 || argc > 2) { rb_raise(rb_eArgError, "accept 1 or 2 arguments: (int32[, seed])"); } _int = NUM2UINT(argv[0]); MurmurHash3_x64_128(&_int, 4, argc == 1 ? 0 : NUM2UINT(argv[1]), result); #if WORDS_BIGENDIAN SWAP_128_BIT(); #endif RETURN_128_BIT(); } |
#murmur3_128_int64_hash(*args) ⇒ Object
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
# File 'ext/murmurhash3/murmur3.c', line 591 static VALUE rb_murmur3_128_int64_hash(int argc, VALUE* argv, VALUE self) { VALUE ar_result; uint32_t result[4]; uint64_t _int; if (argc == 0 || argc > 2) { rb_raise(rb_eArgError, "accept 1 or 2 arguments: (int64[, seed])"); } #if SIZEOF_LONG == 8 _int = NUM2ULONG(argv[0]); #else _int = NUM2ULL(argv[0]); #endif MurmurHash3_x64_128(&_int, 8, argc == 1 ? 0 : NUM2UINT(argv[1]), result); #if WORDS_BIGENDIAN SWAP_128_BIT(); #endif RETURN_128_BIT(); } |
#murmur3_128_str_base64digest(*args) ⇒ Object
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
# File 'ext/murmurhash3/murmur3.c', line 544 static VALUE rb_murmur3_128_str_base64digest(int argc, VALUE *argv, VALUE self) { union { uint32_t result[4]; unsigned char res[18]; } r; char out[24]; int i; rb_murmur3_128_hash(argc, argv, self, r.result); #if WORDS_BIGENDIAN SWAP_128_BIT_BYTE(); #endif r.res[16] = 0; r.res[17] = 0; for(i = 0; i<6; i++) { uint32_t b64 = ((uint32_t)r.res[i*3+0] << 16) | ((uint32_t)r.res[i*3+1] << 8) | (uint32_t)r.res[i*3+2]; out[i*4+0] = base64[(b64 >> 18) & 0x3f]; out[i*4+1] = base64[(b64 >> 12) & 0x3f]; out[i*4+2] = base64[(b64 >> 6) & 0x3f]; out[i*4+3] = base64[(b64 >> 0) & 0x3f]; } out[22] = '='; out[23] = '='; return rb_str_new(out, sizeof(out)); } |
#murmur3_128_str_digest(*args) ⇒ Object
510 511 512 513 514 515 516 517 518 519 520 521 522 |
# File 'ext/murmurhash3/murmur3.c', line 510 static VALUE rb_murmur3_128_str_digest(int argc, VALUE *argv, VALUE self) { union { uint32_t result[4]; char res[16]; } r; rb_murmur3_128_hash(argc, argv, self, r.result); #if WORDS_BIGENDIAN SWAP_128_BIT_BYTE(); #endif return rb_str_new(r.res, sizeof(r.res)); } |
#murmur3_128_str_hash(*args) ⇒ Object
498 499 500 501 502 503 504 505 506 507 508 |
# File 'ext/murmurhash3/murmur3.c', line 498 static VALUE rb_murmur3_128_str_hash(int argc, VALUE* argv, VALUE self) { VALUE ar_result; uint32_t result[4]; rb_murmur3_128_hash(argc, argv, self, result); #if WORDS_BIGENDIAN SWAP_128_BIT(); #endif RETURN_128_BIT(); } |
#murmur3_128_str_hexdigest(*args) ⇒ Object
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'ext/murmurhash3/murmur3.c', line 524 static VALUE rb_murmur3_128_str_hexdigest(int argc, VALUE *argv, VALUE self) { union { uint32_t result[4]; unsigned char res[16]; } r; char out[32]; int i; rb_murmur3_128_hash(argc, argv, self, r.result); #if WORDS_BIGENDIAN SWAP_128_BIT_BYTE(); #endif for(i = 0; i<16; i++) { out[i*2] = hex[r.res[i]*2]; out[i*2+1] = hex[r.res[i]*2+1]; } return rb_str_new(out, sizeof(out)); } |