Skip to content

Conversation

@b41sh
Copy link
Member

@b41sh b41sh commented Mar 5, 2025

This PR introduces implementations of the serde::de::Deserializer and serde::ser::Serializer traits for the RawJsonb struct.

Functionality Added:

  1. Implements serde::de::Deserializer for RawJsonb: Enables deserialization of RawJsonb instances directly from various data sources using Serde's flexible deserialization framework.
  2. Implements serde::ser::Serializer for RawJsonb: Enables serialization of RawJsonb instances into various data formats using Serde's serialization framework.
  3. Refactors Existing Functions: Refactors existing functions that operate on RawJsonb to utilize the new Serde implementations. This involves removing direct manipulation of binary JSONB data and replacing it with calls to Serde's serialization and deserialization APIs, along with underlying API calls.

Benefits:

  1. Abstraction of Underlying JSONB Format: This implementation hides the low-level details of JSONB format encoding and decoding. Higher-level functions can now interact with RawJsonb through Serde's standard interfaces, simplifying code and improving readability. This reduces the need for direct manipulation of the underlying JSONB representation.
  2. Code Simplification and Reduced Redundancy: By leveraging Serde, this change eliminates redundant implementations of serialization and deserialization logic across different parts of the codebase. Functions that work with RawJsonb can now rely on Serde for these tasks, leading to cleaner and more maintainable code.
  3. Reduced Development Complexity: The use of Serde's high-level APIs and the removal of direct binary data manipulation significantly reduces the complexity of developing and maintaining functions that work with RawJsonb. This makes the code easier to understand, debug, and extend.
  4. Enhanced Extensibility: This change significantly improves the extensibility of the RawJsonb implementation. Future work can now easily add support for different JSONB formats (e.g., SQLite, PostgreSQL) by implementing the necessary Serde serialization/deserialization logic without requiring modifications to the core RawJsonb structure or the functions that use it. This promotes a more modular and adaptable design.

fix #73
part of #72 #74

@b41sh b41sh changed the title Refactor: Implements serde::de::Deserializer and serde::ser::Serializer for RawJsonb Refactor: Implements serde trait for RawJsonb Mar 5, 2025
@b41sh b41sh marked this pull request as ready for review March 20, 2025 02:54
@b41sh b41sh merged commit 37d07f0 into databendlabs:main Mar 20, 2025
1 check passed
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.

Refactoring function API interface

2 participants