Skip to content

Commit

Permalink
Make some document properties extensible (#1163)
Browse files Browse the repository at this point in the history
The `Documents` domain class currently assumes static corpora and thus
populates all properties eagerly via instance fields. There are cases
however when we want to resolve these attributes lazily because the
respective set of documents is generated at a later stage in the
benchmark and we cannot derive these properties upfront. With this
commit we make the relevant properties extensible so they can be
resolved lazily in subclass implementations.
  • Loading branch information
danielmitterdorfer authored Jan 28, 2021
1 parent 8e8c122 commit bbb5ca1
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions esrally/track/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ def __init__(self, source_format, document_file=None, document_archive=None, bas
self.document_archive = document_archive
self.base_url = base_url
self.includes_action_and_meta_data = includes_action_and_meta_data
self.number_of_documents = number_of_documents
self.compressed_size_in_bytes = compressed_size_in_bytes
self.uncompressed_size_in_bytes = uncompressed_size_in_bytes
self._number_of_documents = number_of_documents
self._compressed_size_in_bytes = compressed_size_in_bytes
self._uncompressed_size_in_bytes = uncompressed_size_in_bytes
self.target_index = target_index
self.target_data_stream = target_data_stream
self.target_type = target_type
Expand All @@ -227,6 +227,30 @@ def has_compressed_corpus(self):
def has_uncompressed_corpus(self):
return self.document_file is not None

@property
def number_of_documents(self):
return self._number_of_documents

@number_of_documents.setter
def number_of_documents(self, value):
self._number_of_documents = value

@property
def uncompressed_size_in_bytes(self):
return self._uncompressed_size_in_bytes

@uncompressed_size_in_bytes.setter
def uncompressed_size_in_bytes(self, value):
self._uncompressed_size_in_bytes = value

@property
def compressed_size_in_bytes(self):
return self._compressed_size_in_bytes

@compressed_size_in_bytes.setter
def compressed_size_in_bytes(self, value):
self._compressed_size_in_bytes = value

@property
def number_of_lines(self):
if self.includes_action_and_meta_data:
Expand Down

0 comments on commit bbb5ca1

Please sign in to comment.