Module: Zstd::Dictionary
- Defined in:
- ext/extzstd.c
Class Method Summary collapse
- .add_entropy_tables_from_buffer(dict, dict_capacity, sample) ⇒ Object
- .getid(dict) ⇒ Object
- .train_from_buffer(src, dict_capacity) ⇒ Object
Class Method Details
.add_entropy_tables_from_buffer(dict, dict_capacity, sample) ⇒ Object
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
# File 'ext/extzstd.c', line 459 static VALUE dict_s_add_entropy_tables_from_buffer(VALUE mod, VALUE dict, VALUE dict_capacity, VALUE sample) { /* * ZDICTLIB_API size_t ZDICT_finalizeDictionary(void* dstDictBuffer, size_t maxDictSize, * const void* dictContent, size_t dictContentSize, * const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples, * ZDICT_params_t parameters); */ rb_check_type(dict, RUBY_T_STRING); rb_check_type(sample, RUBY_T_STRING); size_t capa = NUM2SIZET(dict_capacity); (dict, capa); char *destptr = RSTRING_PTR(dict); size_t destlen = RSTRING_LEN(dict); const char *sampleptr = RSTRING_PTR(sample); size_t samplesize = RSTRING_LEN(sample); ZDICT_params_t params = { 0, 0, 0 }; size_t s = ZDICT_finalizeDictionary(destptr, capa, destptr, destlen, sampleptr, &samplesize, 1, params); extzstd_check_error(s); rb_str_set_len(dict, s); return dict; } |
.getid(dict) ⇒ Object
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File 'ext/extzstd.c', line 484 static VALUE dict_s_getid(VALUE mod, VALUE dict) { /* * ZDICTLIB_API unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize); */ rb_check_type(dict, RUBY_T_STRING); const char *p; size_t psize; RSTRING_GETMEM(dict, p, psize); size_t s = ZDICT_getDictID(p, psize); extzstd_check_error(s); return SIZET2NUM(s); } |
.train_from_buffer(src, dict_capacity) ⇒ Object
441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'ext/extzstd.c', line 441 static VALUE dict_s_train_from_buffer(VALUE mod, VALUE src, VALUE dict_capacity) { rb_check_type(src, RUBY_T_STRING); size_t capa = NUM2SIZET(dict_capacity); VALUE dict = rb_str_buf_new(capa); size_t srcsize = RSTRING_LEN(src); const ZDICT_legacy_params_t params = { 0 }; size_t s = ZDICT_trainFromBuffer_legacy(RSTRING_PTR(dict), capa, RSTRING_PTR(src), &srcsize, 1, params); extzstd_check_error(s); rb_str_set_len(dict, s); return dict; } |