-
Notifications
You must be signed in to change notification settings - Fork 10
Skip over bad entries in UAL while parsing data #59
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -199,6 +199,27 @@ def __init__(self, table: Table, node: Node): | |
| self._get_tag_field = lru_cache(4096)(self._get_tag_field) | ||
| self._find_tag_field_idx = lru_cache(4096)(self._find_tag_field_idx) | ||
|
|
||
| @property | ||
| def is_empty(self) -> bool: | ||
| """Return whether the record is a tombstone or empty (has no defined column data).""" | ||
| return self._last_fixed_id == 0 and self._last_variable_id == 0 and self._tagged_data_count == 0 | ||
|
|
||
| def matches_schema(self) -> bool: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably this can be a property too? |
||
| """Check if the record column layout is compatible with the table schema. | ||
|
|
||
| A record can have fewer columns than the table defines — missing columns are null. | ||
| A record with more columns most likely is corrupted (or written with another schema) | ||
| and cannot be parsed. | ||
| """ | ||
| num_fixed, num_variable, num_tagged = self.table.column_counts | ||
| return all( | ||
| ( | ||
| self._last_fixed_id <= num_fixed, | ||
| (self._last_variable_id - 127) <= num_variable, | ||
| self._tagged_data_count <= num_tagged, | ||
| ) | ||
| ) | ||
|
Comment on lines
+214
to
+221
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps until we have other places to use it, it can be fine to just inline the logic from |
||
|
|
||
| def get(self, column: Column, raw: bool = False, errors: str | None = "backslashreplace") -> RecordValue: | ||
| """Retrieve the value for the specified column. | ||
|
|
||
|
|
@@ -401,6 +422,8 @@ def _get_tagged(self, column: Column) -> bytes | None: | |
| if not tag_field.is_null: | ||
| offset = self._tagged_data_start | ||
| value = self.data[offset + data_start : offset + data_end] | ||
| else: | ||
| value = None | ||
| else: | ||
| # If the column has a default, use that | ||
| # If not, this defaults to None | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add a
is_validproperty that combines bothis_emptyandmatches_schema?