Skip to content

Refactor to Create typed_list_values module and related library cleanup#182

Merged
avalerio-tkd merged 6 commits into
mainfrom
av_sequncer_decryption_015
Dec 6, 2025
Merged

Refactor to Create typed_list_values module and related library cleanup#182
avalerio-tkd merged 6 commits into
mainfrom
av_sequncer_decryption_015

Conversation

@avalerio-tkd

Copy link
Copy Markdown
Collaborator
  • Refactor to move Type bit-handling to TypedListValues
  • Refined common methods that converted between value bytes and typed list values and centralized in TypedListValues.
  • Cleanup nits of DecodingUtils related to bit shifting and byte slicing.
  • Rewrote ValueBytes encoding so that (1) Parquet specific encoding lives on decoding_utils and (2) TypedListValues logic is on typed_list_values.

- Refined common methods that converted between value bytes and typed list values and centralized in TypedListValues.
- Cleanup nits of DecodingUtils related to bit shifting and byte slicing.
- Rewrote ValueBytes encoding so that (1) Parquet specific encoding lives on decoding_utils and (2) TypedListValues logic is on typed_list_values.
- Refined common methods that converted between value bytes and typed list values and centralized in TypedListValues.
- Cleanup nits of DecodingUtils related to bit shifting and byte slicing.
- Rewrote ValueBytes encoding so that (1) Parquet specific encoding lives on decoding_utils and (2) TypedListValues logic is on typed_list_values.

@argmarco-tkd argmarco-tkd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this refactor. Things are much cleaner now.

Overall everything looks good, but the specifics (logic) inside decoding_utils are a bit unknown to me. Happy to chat if you need an in-depth review of those (but I think the tests help ensure correctness there)

Comment thread CMakeLists.txt

# Bytes utils tests
add_executable(bytes_utils_test src/server/bytes_utils_test.cpp)
add_executable(bytes_utils_test src/common/bytes_utils_test.cpp)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you :)

Comment thread src/common/typed_list_values.cpp Outdated

} // namespace

std::string PrintTypedList(const TypedListValues& list) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: technically this is a "TypedListToString", instead of a "PrintTypedList" (there is no actual printing) :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. In a previous life it was a print, then changed. Thanks for that.

/**
* Type alias for raw value bytes.
*/
using RawValueBytes = std::vector<uint8_t>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love this.

Comment thread src/common/value_encryption_utils.h Outdated
/**
* Simple container for an encrypted payload and its size.
*/
struct EncryptedValue {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would not do the alias thing similar to what happened with RawValueBytes? :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks.

int32_t rep_level_length = std::get<int32_t>(encoding_attribs.at("page_v2_repetition_levels_byte_length"));
total_level_bytes = def_level_length + rep_level_length;
std::cout << "CalculateLevelBytesLength DATA_PAGE_V2: total_level_bytes=" << total_level_bytes << std::endl;
std::cout << "CalculateLevelBytesLength DATA_PAGE_V2: total_level_bytes="

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this is meant to be temporary? (same for other printouts in this file) if so, let's add the TODO/link to task to clean up.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Filed #183 and added TODO note.

Comment thread src/server/decoding_utils.cpp Outdated
std::vector<T> DecodeFixedSizeType(const uint8_t* raw_data, size_t raw_size, const char* name) {
if ((raw_size % sizeof(T)) != 0) {
throw InvalidInputException(std::string("Invalid data size for ") + name + " decoding");
static size_t GetFixedElemSizeOrThrow(Type::type datatype, const std::optional<int>& datatype_length) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason this static vs. some of the other utils which have been inlined?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update. Yes, much better as inlined. Thanks.

int fixed_length = datatype_length.value();
if ((bytes.size() % fixed_length) != 0) {

// Variable-length BYTE_ARRAY: parse [4-byte len][bytes...] elements in order.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for clarity - is this how this data type is encoded in parquet?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. This is Parquet specific. Added a comment inline and also to the header file. The next PR will rename the module this to make more explicit that this is specific Parquet encode/decode and move to parquet_utils. But that's next PR.

@argmarco-tkd argmarco-tkd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(no need for a new PR if/when the comments/nits are addressed)

- Switched EncryptedValue to std::vector<uint8_t> in value_encryption_utils.h
@avalerio-tkd

Copy link
Copy Markdown
Collaborator Author

Thanks for the comments. Merging..

@avalerio-tkd
avalerio-tkd merged commit b53b5b9 into main Dec 6, 2025
2 checks passed
@avalerio-tkd
avalerio-tkd deleted the av_sequncer_decryption_015 branch December 6, 2025 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants