Skip to content

Commit

Permalink
Minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
TLCFEM committed Oct 20, 2024
1 parent 6cac162 commit 9adfc45
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/msglc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,34 @@ def configure(
"""
This function is used to configure the settings. It accepts any number of keyword arguments.
The function updates the values of the configuration parameters if they are provided in the arguments.
:param small_obj_optimization_threshold:
The threshold (in bytes) for small object optimization.
Objects smaller than this threshold are not indexed.
:param write_buffer_size:
The size (in bytes) for the write buffer.
:param read_buffer_size:
The size (in bytes) for the read buffer.
:param fast_loading:
Flag to enable or disable fast loading.
If enabled, the container will be read in one go, instead of reading each child separately.
:param fast_loading_threshold:
The threshold (0 to 1) for fast loading.
With the fast loading flag turned on, fast loading will be performed if the number of
already read children over the total number of children is smaller than this threshold.
:param trivial_size:
The size (in bytes) considered trivial, around a dozen bytes.
Objects smaller than this size are considered trivial.
For a list of trivial objects, the container will be indexed in a blocked fashion.
:param disable_gc:
Flag to enable or disable garbage collection.
:param simple_repr:
Flag to enable or disable simple representation used in the __repr__ method.
If turned on, __repr__ will not incur any disk I/O.
:param copy_chunk_size:
The size (in bytes) for the copy chunk.
:param magic:
Magic bytes (max length: 30) to set, used to identify the file format version.
"""
if (
isinstance(small_obj_optimization_threshold, int)
Expand Down
15 changes: 15 additions & 0 deletions src/msglc/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,21 @@ def __init__(
unpacker: Unpacker | None = None,
):
"""
It is possible to use a customized unpacker.
Please inherit the `Unpacker` class from the `unpacker.py`.
There are already several unpackers available using different libraries.
.. highlight:: python
.. code-block:: python
class CustomUnpacker(Unpacker):
def decode(self, data: bytes):
# provide the decoding logic
...
with LazyReader("file.msg", unpacker=CustomUnpacker()) as reader:
# read the data
...
:param buffer_or_path: the buffer or path to the file
:param counter: the counter object for tracking the number of bytes read
:param cached: whether to cache the data
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import pytest

from msglc import dump, config
from msglc.generate import (
from generate import (
generate_random_json,
find_all_paths,
goto_path,
Expand Down

0 comments on commit 9adfc45

Please sign in to comment.