Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new property to define operation #458

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions osbenchmark/workload/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def __init__(self, cfg):
@staticmethod
def prepare_docs(cfg, workload, corpus, preparator):
for document_set in corpus.documents:
if document_set.is_bulk:
if document_set.is_supported_source_format:
data_root = data_dir(cfg, workload.name, corpus.name)
logging.getLogger(__name__).info("Resolved data root directory for document corpus [%s] in workload [%s] "
"to [%s].", corpus.name, workload.name, data_root)
Expand Down Expand Up @@ -581,8 +581,8 @@ def prepare_document_set(self, document_set, data_root):
f"because no base URL is provided.") from None
else:
raise

self.create_file_offset_table(doc_path, document_set.number_of_lines)
if document_set.support_file_offset_table:
self.create_file_offset_table(doc_path, document_set.number_of_lines)

def prepare_bundled_document_set(self, document_set, data_root):
"""
Expand Down Expand Up @@ -1302,7 +1302,7 @@ def _create_corpora(self, corpora_specs, indices, data_streams):
base_url = self._r(doc_spec, "base-url", mandatory=False, default_value=default_base_url)
source_format = self._r(doc_spec, "source-format", mandatory=False, default_value=default_source_format)

if source_format == workload.Documents.SOURCE_FORMAT_BULK:
if source_format in workload.Documents.SUPPORTED_SOURCE_FORMAT:
docs = self._r(doc_spec, "source-file")
if io.is_archive(docs):
document_archive = docs
Expand Down
13 changes: 13 additions & 0 deletions osbenchmark/workload/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ def __eq__(self, other):

class Documents:
SOURCE_FORMAT_BULK = "bulk"
SOURCE_FORMAT_HDF5 = "hdf5"
SOURCE_FORMAT_BIG_ANN = "big-ann"
SUPPORTED_SOURCE_FORMAT = [SOURCE_FORMAT_BULK, SOURCE_FORMAT_HDF5, SOURCE_FORMAT_BIG_ANN]

def __init__(self, source_format, document_file=None, document_archive=None, base_url=None,
includes_action_and_meta_data=False,
Expand Down Expand Up @@ -271,6 +274,16 @@ def number_of_lines(self):
def is_bulk(self):
return self.source_format == Documents.SOURCE_FORMAT_BULK

@property
def support_file_offset_table(self):
# Will support create file offset table only for bulk source formats. In future we can move it to
# a list instead of checking bulk directly
return self.source_format == Documents.SOURCE_FORMAT_BULK

@property
def is_supported_source_format(self):
return self.source_format in Documents.SUPPORTED_SOURCE_FORMAT

def __str__(self):
return "%s documents from %s" % (self.source_format, self.document_file)

Expand Down
Loading