Forest Data Structure for Blockchain Map Iteration
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing map iteration methods in blockchain systems are computationally intensive and time-consuming, particularly when retrieving all keys or values, as they often require traversing the entire map data structure, leading to bottlenecks and conflicts in concurrent access.
Innovation Solution
The implementation of a forest data structure that stores key-value pairs, comprising multiple trees allowing concurrent access, uses hash functions to distribute keys across storage nodes, reducing I/O complexity and enabling low-latency, high-concurrency map iteration by traversing the forest instead of the map.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If traditional map iteration methods are used to retrieve all keys or values, then the map data structure can be traversed sequentially, but the operation becomes computationally intensive and time-consuming with bottlenecks in concurrent access
Solution Approach 1:
The map data structure is divided into multiple independent trees organized as a forest, where each tree contains a subset of key-value pairs. This segmentation allows concurrent iteration across multiple trees simultaneously, eliminating the sequential bottleneck of traditional single-structure map iteration and significantly improving throughput while reducing latency.
Solution Approach 2:
The patent transitions from a single-dimensional sequential traversal of a traditional map to a multi-dimensional forest structure where iteration can occur across multiple trees in parallel. This dimensional expansion enables concurrent access patterns, allowing multiple threads to iterate through different trees simultaneously, thereby increasing productivity and reducing time loss.
2Ease of operation
If the entire map data structure is traversed to retrieve keys or values, then all data can be accessed, but I/O complexity increases and concurrent access conflicts occur
Solution Approach 1:
By segmenting the map into a forest of multiple independent trees, the patent enables easier concurrent access since different threads can operate on different trees without conflicts. The segmentation reduces operational complexity for concurrent access while the overall forest structure, though more complex than a single map, provides systematic organization that manages this complexity through clear separation of data subsets.
3Speed
If key-value pairs are stored in a traditional map structure, then simple read and write operations are possible, but retrieval of all keys or values requires accessing each pair sequentially
Solution Approach 1:
The forest structure segments key-value pairs across multiple trees, enabling parallel retrieval operations. While individual read/write operations remain simple, the ability to retrieve all keys or values improves speed and productivity because multiple trees can be traversed concurrently, increasing overall system throughput without sacrificing operational simplicity.
Solution Approach 2:
The patent maintains a forest structure that effectively creates an alternative organizational copy of the key-value data. This forest copy enables efficient iteration and retrieval operations without modifying the original map structure, allowing fast retrieval of all keys or values through parallel tree traversal while preserving the simplicity of individual access operations.
Data Source
Figure 1~2
Figure 3~4
Figure 5
AI summary
Disclosed herein are methods, systems, and apparatus, including computer programs encoded on computer storage media, for performing a map iteration by a network node of a blockchain network. One of the methods includes receiving a request to obtain a number of keys included in a map by the network node, the map storing a number of key-value pairs that include the number of keys and a number of values corresponding to the number of keys. The network node maintains data representing a forest that stores the number of keys that are stored in the map. The forest includes a number of trees, each tree includes up to a respective number of storage nodes, and each storage node stores a subset of the number of keys. The network node traverses the forest to retrieve the number of keys stored in the forest, and return the number of keys.