A spatiotemporal keyword query method in a hybrid storage blockchain environment

By building a blockchain model classified by attributes and semantics and an on-chain two-level index structure based on B2F-BKM structure, the blockchain storage model is solved, and the blockchain storage model is inefficient and communication overhead is high in space-time keyword query, achieving efficient space-time keyword query and better user experience.

CN115048377BActive Publication Date: 2025-03-28NORTHEASTERN UNIV CHINA +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210650145.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-10
Publication Date
2025-03-28
Estimated Expiration
2042-06-10

AI Technical Summary

Technical Problem

When conducting spatio-temporal keyword query, the existing blockchain storage model has low query efficiency and high communication overhead, which affects the user experience.

Method used

Design a space-time keyword query method in a hybrid storage blockchain environment, and realize efficient space-time keyword query by building a blockchain model classified by attributes and semantics and a two-level on-chain index structure based on B2F-BKM structure.

Benefits of technology

It improves the efficiency of space-time keyword query in a hybrid storage blockchain environment, reduces unnecessary communication overhead, and provides a better user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115048377B_ABST
    Figure CN115048377B_ABST
Patent Text Reader

Abstract

Aiming at the spatiotemporal keyword query problem of on-chain and off-chain hybrid storage blockchain, the present invention proposes a spatiotemporal keyword query method in a hybrid storage blockchain environment, which relates to the technical field of computer blockchain query. Firstly, in view of the weak query semantics, a blockchain model CSBM classified by attributes and endowed with semantics is constructed, and the attribute types are divided for the transactions in the block and semantics are added. Secondly, in view of the low query efficiency, a B-based 2 The F-BKM structure has an on-chain two-level index structure that can index all blocks and transactions, effectively improving query efficiency. Finally, in view of the large communication overhead, an on-chain and off-chain spatiotemporal keyword query method is designed. By traversing B 2 The F‑BKM structure performs on-chain conditional query, and then performs on-chain and off-chain data connection query based on the connection attribute value, which reduces unnecessary communication overhead compared to traditional query methods; experiments have proved that the index of the present invention has good stability, greatly improves query efficiency and significantly reduces communication overhead.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer blockchain query, and in particular to a spatiotemporal keyword query method in a hybrid storage blockchain environment. Background Art

[0002] In recent years, with the increasing popularity of digital cryptocurrency, its underlying technology, blockchain technology, has become the focus of current social attention. In essence, blockchain can be regarded as a distributed database with the characteristics of decentralization, immutability, traceability, and data transparency, which can well solve the trust problem between multiple participants in scenarios such as supply chain. Spatiotemporal data is a common form of data in fields such as supply chain and Internet of Things. With the application of blockchain in the above scenarios, a large amount of spatiotemporal data is stored on the blockchain. Spatiotemporal keyword query uses time, space and keywords as query conditions to find all information that meets the conditions, which is widely used in the above scenarios.

[0003] The commonly used blockchain storage mode is the on-chain and off-chain hybrid storage mode. The on-chain storage is for multi-party shared operations, while the off-chain storage is for each party's private data. When performing spatiotemporal keyword queries in this mode, it is necessary to return the results of the on-chain and off-chain data connection. Since most of the existing query methods use B+ tree indexes within the block, the query efficiency is low for spatiotemporal keyword queries with multi-dimensional search space. In addition, the existing methods need to read all the data in the off-chain connection table for connection during the query, resulting in a large amount of communication overhead, which affects the user experience. Therefore, it is of great significance to study the spatiotemporal keyword query method in the hybrid storage blockchain environment.

[0004] Taking the real-life scenario as an example, in the supply chain scenario, multiple participants store their production information, logistics information, sales information, etc. openly and transparently on the blockchain for multi-party data sharing and collaborative processing, and the private data of each participant is stored off-chain. When the user sends the spatiotemporal keyword query Q shown in the figure, the transactions on and off the chain that meet the query conditions need to be connected through the connection attributes and returned to the querying user. The existing query method needs to query separately according to the B+ tree index of each attribute column in the block, take the intersection of the query results to obtain all transactions that meet the query conditions, and then read all the data in the off-chain connection table to connect to the blockchain, and finally return the connected results to the querying user. The defects of this query method are mainly in the following three aspects:

[0005] First, query semantics are weak. Although transactions on the blockchain contain multiple attributes, existing blockchain platforms usually store transactions in the form of key-value or semantics. The key-value mode does not support relational queries such as selection and connection, and cannot query transactions based on attribute names; the semantic storage mode requires a separate index to be built for each attribute column, and cannot merge indexes based on attribute types.

[0006] Second, the query efficiency is low. On-chain transactions contain attributes such as time, space, and keywords, which are distributed in each block. Most existing blockchain query methods use B+ tree indexes within blocks to avoid traversing all transactions, but this structure has low query efficiency for spatiotemporal keyword queries with multi-dimensional search space.

[0007] Third, the communication overhead is high. Since the query needs to obtain both on-chain and off-chain data at the same time, the existing method needs to read all the data in the off-chain connection table for connection. When the amount of off-chain data is very large and the results to be connected are few, a lot of unnecessary communication overhead will be generated. Summary of the invention

[0008] In view of the shortcomings of the prior art, the present invention designs a spatiotemporal keyword query method in a hybrid storage blockchain environment.

[0009] A spatiotemporal keyword query method in a hybrid storage blockchain environment, the specific steps are as follows:

[0010] Step 1: Build a blockchain model that is classified by attributes and endowed with semantics, namely CSBM;

[0011] Step 1.1: CSBM contains multiple blocks CS-B classified by attributes and given semantics, CSBM = CS-B1 + CS-B2 + ··· + CS-B n , each CS-B contains two parts: a block header B head and a block body CS-B body classified by attributes and endowed with semantics; CS-B=B head+CS-B body; B head has the same structure as the traditional blockchain block header, including the hash value PrevHash of the previous block that connects the blocks into a chain, the block height Block Height that records the position of the current block on the chain, the timestamp Timestamp that records the block generation time, as well as the mining difficulty Bits and the random number Nonce. The Merkle root Merkle Root in the block header is replaced by the root node BKM-tree Root of the BKM-tree constructed in step 2, which is generated based on the hash value of the transactions in the block; CS-B body contains all the transactions in the block, and these transactions are divided into attribute types and semantics are added;

[0012] Step 1.2: Define Tx T is a transaction in CSBM that is classified by attributes and given semantics. x ={Key=v1,Time={time=v2},Coordinate={longitude=v3,latitude=v4},Keywords={kw1,kw2,···,kw n},Others={oth1,oth2,···,oth n}}, Key is the primary key of the transaction, obtained by calculating the hash value of the transaction, and represented by a hexadecimal string of length 64; Time is the time attribute type, time is the timestamp of the transaction, Coordinate is the spatial attribute type, longitude is the longitude of the transaction, latitude is the latitude of the transaction, v i is the attribute value, Keywords is the keyword attribute type, kw i is the attribute name of a keyword of the transaction; Others is other attribute types, i The names of other attributes of the transaction. Different attribute names are set for different application scenarios and transaction types.

[0013] Step 2: Build based on B 2 The on-chain two-level index structure of the F-BKM structure consists of two parts: 2 F-tree and intra-block BKM-tree complete the indexing of all blocks and transactions;

[0014] Step 2.1: Build a BKM tree in each block to replace the original Merkle tree; in the process of building a new block, extract all transaction space attribute type values ​​and keyword attribute type values ​​in the block; imitate the KD tree structure, divide the area according to the transaction space attribute data, until each area contains only one transaction, the transaction is only stored in the leaf node, and the non-leaf node stores the information related to the data division; then add a Bloom filter field to the KD tree, construct a Bloom filter according to the transaction keyword attribute data, and the Bloom filter of the non-leaf node contains all the keywords of its child nodes; finally, calculate the hash value of each node from the bottom up according to the construction method of the Merkle tree to form a BKM-tree, and record the root node in the block header;

[0015] Step 2.2: Construct a block-to-block B based on the block number, block creation time, and the key in the block. 2 F-tree; obtain new block data, including the block number block-id of the new block, the block creation time timestamp, the bloom filter bloomfilter-bf composed of the keywords in the block, and the address offset of the block in the blockchain file; construct B2 F-tree node, the format of the key in the leaf node is "block-id, timestamp, bf", where block-id comes from the block height BlockHeight located in the block header, timestamp comes from the timestamp Timestamp located in the block header, and bf is the same as the Bloom filter in the root node of the BKM-tree in the block; the pointer in the leaf node records the address offset of the block in the blockchain file; the Bloom filter of the non-leaf node contains all the keywords of its subtree, which is used to filter the pointer to determine whether the node pointed to by the pointer contains the corresponding keyword, and update the B according to the block-id in the B+ tree node insertion method. 2 F-tree;

[0016] Step 2.3: On-chain two-level index structure B 2 The F-BKM structure was completed;

[0017] Step 3: Design a method for querying on-chain and off-chain spatial and temporal keywords; obtain query conditions and use the two-level index structure B on the chain to query the keywords. 2 F-BKM structure, namely B 2 The F-tree and BKM-tree perform on-chain conditional queries and extract the connection attribute values ​​of the queried transactions. Based on the values, they perform on-chain and off-chain connection queries and return the final results.

[0018] Step 3.1: Define the spatiotemporal keyword query in the hybrid storage blockchain environment. It consists of a four-tuple, Q = [[T s ,T e ],S,W,join-attr], where [T s ,T e ] is the time range of the user's query, S is the spatial range of the user's query, W is the keyword data set of the user's query, including several keywords, join-attr is the connection condition in the form of an equation, the left side of the equation is the keyword attribute name that needs to be connected on the chain, and the right side of the equation is the connection keyword attribute name in the off-chain database table;

[0019] Step 3.2: Traverse B based on the time and keyword conditions in query Q 2 F-tree; based on B 2 The "timestamp,bf" part of the key in the F-tree node starts from the root node, selects the branch pointer according to the time condition, and then determines whether the node pointed to by the pointer contains the query keyword W according to the Bloom filter. If it does, continue traversing, otherwise terminate; follow this method until the leaf node, find the node that contains the query keyword W and the time is greater than or equal to 'T s ', less than or equal to 'T e 'All keys and get the location of these blocks through pointers;

[0020] Step 3.3: After querying a specific block, traverse the BKM-tree in the block in turn according to the space and keyword conditions in the query Q; select child nodes from the root node from top to bottom according to the search method of the KD-tree, and determine whether the Bloom filter of the child node contains all the query keywords. If so, traverse the child node; if not, abandon this branch; follow this method until the leaf node, that is, find all transactions in the block that meet the space and keyword conditions; obtain the key data in the leaf node, that is, the hash value Key of the transaction, and then obtain the original data based on the key data. If the time condition is met, add the data to the on-chain result set Onchain-RS;

[0021] Step 3.4: According to the join condition join-attr in the query Q, extract the value of the connection attribute of the original data in Onchain-RS, query the data in the off-chain database table based on the value, and add it to the off-chain result set Offchain-RS; read the data in Offchain-RS and Onchain-RS, connect the on-chain and off-chain data through the connection attribute, and store the result in the result set ResultSet;

[0022] Step 3.5: Return ResultSet, terminate the current calculation and wait for the next call;

[0023] Beneficial technical effects of the present invention:

[0024] The present invention takes into account that when performing spatiotemporal keyword queries on a blockchain based on an on-chain and off-chain hybrid storage mode, the existing methods have low query efficiency and will generate a large amount of unnecessary communication overhead, affecting user experience; therefore, the purpose of the present invention is to propose a spatiotemporal keyword query method in a hybrid storage blockchain environment, which improves query efficiency and reduces communication overhead compared to traditional query methods. The specific beneficial technical effects are:

[0025] 1. The method provided by the present invention processes the spatiotemporal keyword query problem in a hybrid storage blockchain environment based on the blockchain model CSBM that is classified by attributes and endowed with semantics, and can realize efficient spatiotemporal keyword query in a hybrid storage blockchain environment.

[0026] 2. The spatiotemporal keyword query method of the present invention constructs a 2 The on-chain two-level index structure of the F-BKM structure consists of two parts: 2 F-tree and BKM-tree within the block complete the indexing of all blocks and transactions. This structure can quickly locate the block position and find the query transaction, effectively improving the query efficiency.

[0027] 3. The blockchain connection query method for hybrid storage mode provided by the present invention is to traverse B2 The F-BKM structure performs on-chain conditional queries, and then performs on-chain and off-chain data connection queries based on the connection attribute values. Compared with traditional query methods, it avoids unnecessary communication overhead caused by reading all the data in the off-chain connection table, providing users with a better experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 Schematic diagram of a supply chain scenario in a spatiotemporal keyword query method in a hybrid storage blockchain environment according to an embodiment of the present invention; the left side is a blockchain model CSBM classified by attributes and endowed with semantics on the chain, and the right side is an off-chain database;

[0029] Figure 2 A schematic diagram of the structure of a block CS-B classified by attributes and endowed with semantics in a spatiotemporal keyword query method in a hybrid storage blockchain environment according to an embodiment of the present invention;

[0030] Figure 3 Two-level index structure B on the chain in the spatiotemporal keyword query method under the hybrid storage blockchain environment of the embodiment of the present invention 2 Schematic diagram of the overall structure of the F-BKM structure;

[0031] Figure 4 In the spatiotemporal keyword query method under the hybrid storage blockchain environment of the present invention, a two-level index structure B is constructed on the chain 2 F-BKM structure flow chart;

[0032] Figure 5 Flow chart of the on-chain and off-chain spatiotemporal keyword query method in the spatiotemporal keyword query method in the hybrid storage blockchain environment according to an embodiment of the present invention;

[0033] Figure 6 A query process diagram of an example of an on-chain and off-chain spatiotemporal keyword query method in a hybrid storage blockchain environment in an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The present invention will be further described below in conjunction with the accompanying drawings and embodiments;

[0035] This paper aims at the problem of spatiotemporal keyword query in hybrid storage blockchains on and off the chain, and proposes a spatiotemporal keyword query method in a hybrid storage blockchain environment. First, in view of the weak query semantics, a blockchain model (Categorical and Semantic Blockchain Model, CSBM) is constructed by classifying attributes and giving semantics to transactions in the block, dividing attribute types and adding semantics. Secondly, in view of the low query efficiency, a B 2The F-BKM structure has an on-chain two-level index structure, which can index all blocks and transactions, effectively improving query efficiency. Finally, in view of the large communication overhead, a method for on-chain and off-chain spatiotemporal keyword query is designed. 2 The F-BKM structure performs on-chain conditional queries, and then performs on-chain and off-chain data connection queries based on the connection attribute values, which reduces unnecessary communication overhead compared to traditional query methods.

[0036] A spatiotemporal keyword query method in a hybrid storage blockchain environment, the specific steps are as follows:

[0037] Step 1: Construct a Categorical and Semantic Blockchain Model (CSBM) with the following structure: Figure 1 Shown in the left part.

[0038] Step 1.1: CSBM contains multiple blocks (CS-B) classified by attributes and given semantics, CSBM = CS-B1 + CS-B2 + ··· + CS-B n Each CS-B consists of a block header (B head) and a block body (CS-B body) classified by attributes and given semantics. The structure is as follows: Figure 2 As shown. CS-B = B head + CS-B body. B head has the same structure as the traditional blockchain block header, including the hash value PrevHash of the previous block that connects the blocks into a chain, the block height Block Height that records the position of the current block on the chain, the timestamp Timestamp that records the block generation time, and the mining difficulty Bits and random number Nonce. The Merkle root (Merkle Root) in the block header is replaced by the root node (BKM-tree Root) of the BKM-tree constructed in step 2 of the present invention, which is generated based on the hash value of the transaction in the block. The CS-B body contains all the transactions in the block, divides the attribute types for these transactions and adds semantics;

[0039] Step 1.2: Define T x T is a transaction in CSBM that is classified by attributes and given semantics. x ={Key=v1,Time={time=v2},Coordinate={longitude=v3,latitude=v4},Keywords={kw1,kw2,···,kw n},Others={oth1,oth2,···,oth n}}, Key is the primary key of the transaction, obtained by calculating the hash value of the transaction, and represented by a hexadecimal string of length 64; Time is the time attribute type, time is the timestamp of the transaction, Coordinate is the spatial attribute type, longitude is the longitude of the transaction, latitude is the latitude of the transaction, v i is the attribute value, Keywords is the keyword attribute type, kw i is the attribute name of a keyword of the transaction; Others is other attribute types, i The names of other attributes of the transaction. Different attribute names are set for different application scenarios and transaction types;

[0040] In this example, the transaction that records production information has Keywords = {operate, goods, factory}, and the transaction that records logistics information has Keywords = {operate, goods, factory, driver}. Figure 2 Medium Affairs T j+1 For example, the primary key of the transaction is '8C...9B', which records a piece of logistics information: 'At time t2, driver Tom transported goods 2 produced by factory 2 to the location (134.3°E, 42.5°N)';

[0041] Step 2: Build based on B 2 The on-chain two-level index structure of the F-BKM structure is as follows: Figure 3 As shown. The structure consists of two parts: inter-block B 2 F-tree and BKM-tree in the block complete the indexing of all blocks and transactions. The construction process is as follows: Figure 4 As shown, the specific process is as follows:

[0042] Step 2.1: Build a BKM-tree in each block to replace the original Merkle tree. In the process of building a new block, extract the spatial attribute type values ​​and keyword attribute type values ​​of all transactions in the block. Imitate the KD-tree structure and divide the area according to the spatial attribute data of the transaction until each area contains only one transaction. Transactions are only stored in leaf nodes, and non-leaf nodes store information related to data division; then add a Bloom filter field to the KD-tree, and construct a Bloom filter based on the keyword attribute data of the transaction. The Bloom filter of the non-leaf node contains all the keywords of its child nodes; finally, calculate the hash value of each node from bottom to top according to the construction method of the Merkle tree to form a BKM-tree, and record the root node in the block header. The structure is as follows Figure 3 As shown;

[0043] In this example, Figure 3The right side of the figure shows the BKM-tree built for all transactions in block n. For example, the root node contains the hash value of the node, information related to space partitioning, and the Bloom filter. The Bloom filter BF7 contains the keyword data of all transactions in block n. Leaf node P j+1 Recorded transaction T j+1 The spatial information (134.3°E, 42.5°N), keyword information (transport, factory2, goods2, Tom) and Key value (8C…9B) of the node are connected in series and hashed to obtain the hash value of the node.

[0044] Step 2.2: Construct a block-to-block B based on the block number, block creation time, and the key in the block. 2 F-tree. Get the new block data, including the block number (block-id) of the new block, the block creation time (timestamp), the bloom filter (bloomfilter-bf) composed of the keywords in the block, and the address offset of the block in the blockchain file. Construct B 2 F-tree nodes, the format of the key in the leaf node is "block-id, timestamp, bf", where block-id comes from the block height (Block Height) located in the block header, timestamp comes from the timestamp (Timestamp) located in the block header, and bf is the same as the Bloom filter in the root node of the BKM-tree in the block. The pointer in the leaf node records the address offset of the block in the blockchain file. The Bloom filter of the non-leaf node contains all the keywords of its subtree, which is used to filter the pointer to determine whether the node pointed to by the pointer contains the corresponding keyword, and updates the B according to the block-id in the B+ tree node insertion method. 2 F-tree, structured like Figure 3 As shown;

[0045] In this example, Figure 3 Shown is the B constructed for all blocks 2 For example, the root node Bloom filter BF5 contains all the keywords in its subtree Bloom filters BF1 and BF2. The leaf node ((1, ts1, bf1), p1) indicates that the first block was created at time ts1. The keyword data of the transactions in the block constitute the Bloom filter bf1, and p1 points to the location of the block.

[0046] Step 2.3: On-chain two-level index structure B 2 The F-BKM structure was completed;

[0047] Step 3: Design a method for querying on-chain and off-chain spatial and temporal keywords. Obtain query conditions and use the two-level index structure B on the chain. 2F-BKM structure, namely B 2 F-tree and BKM-tree perform on-chain conditional queries and extract the connection attribute value of the queried transaction. Based on the value, on-chain and off-chain connection queries are performed and the final result is returned. The process is as follows: Figure 5 As shown in the example query process Figure 6 As shown, the specific process is as follows:

[0048] Step 3.1: Define the spatiotemporal keyword query in the hybrid storage blockchain environment. It consists of a four-tuple, Q = [[T s ,T e ],S,W,join-attr], where [T s ,T e ] is the time range of the user's query, S is the spatial range of the user's query, W is the keyword data set of the user's query, including several keywords, join-attr is the connection condition in the form of an equation, the left side of the equation is the keyword attribute name that needs to be connected on the chain, and the right side of the equation is the connection keyword attribute name in the off-chain database table;

[0049] In this example, the query Q = [[t7, t9], [S], [goods = goods2, operate = transport], driver = Driver.dname].

[0050] Step 3.2: Traverse B based on the time and keyword conditions in query Q 2 F-tree. Based on B 2 The "timestamp,bf" part of the key in the F-tree node starts from the root node, selects the branch pointer according to the time condition, and then determines whether the node pointed to by the pointer contains the query keyword W according to the Bloom filter. If it does, continue traversing, otherwise terminate; follow this method until the leaf node, find the node that contains the query keyword W and the time is greater than or equal to 'T s ', less than or equal to 'T e 'All keys and get the location of these blocks through pointers;

[0051] In this example, by traversing B 2 The F-tree finds that only the block with block number 9 meets the query time condition and contains all the query keywords, and obtains the location information of the block.

[0052] Step 3.3: After querying the specific block, traverse the BKM-tree located in the block in turn according to the space and keyword conditions in the query Q. Select child nodes from the root node from top to bottom according to the search method of the KD-tree, and determine whether the Bloom filter of the child node contains all the query keywords. If it does, traverse the child node. If not, abandon this branch. Follow this method until the leaf node, that is, find all transactions in the block that meet the space and keyword conditions. Get the key data in the leaf node, that is, the hash value (Key) of the transaction, and then get the original data based on the key data. If the time condition is met, add the data to the on-chain result set (Onchain-RS);

[0053] In this example, node P is obtained by traversing the BKM-tree in block 9. j and P j+1 Meet the spatial and keyword query conditions, and then read node P j and P j+1 The hash value Key stored in j and Key j+1 , find the original data T j and T j+1 And the original data meets the time condition, transaction T j and T j+1 The original data is added to Onchain-RS.

[0054] Step 3.4: According to the join condition join-attr in the query Q, extract the value of the connection attribute of the original data in Onchain-RS, query the data in the off-chain database table based on the value, and add it to the off-chain result set (Offchain-RS). After reading the data in Offchain-RS and Onchain-RS and connecting the on-chain and off-chain data through the connection attribute, the result is stored in the result set ResultSet; in this example, the value of the connection attribute driver Tom and James is obtained according to the original data, and the data about drivers Tom and James is found from the off-chain Driver table, and then the on-chain data is connected with the off-chain data through the connection attribute value to obtain the results R1 and R2, which are stored in the result set ResultSet.

[0055] Step 3.5: Return ResultSet, terminate the current calculation and wait for the next call.

Claims

1. A spatiotemporal keyword query method in a hybrid storage blockchain environment, characterized in that: The specific steps include: Step 1: Build a blockchain model that is classified by attributes and endowed with semantics, namely CSBM; Step 1.1: CSBM contains multiple blocks CS-B classified by attributes and given semantics, CSBM = CS-B1 + CS-B2 + ··· + CS-B n Each CS-B consists of a block header (B head) and a block body (CS-B body) classified by attributes and endowed with semantics; Where CS-B = B head + CS-B body; B head has the same structure as the traditional blockchain block header; the Merkle root in the block header is replaced by the root node BKM-tree Root constructed in step 2, which is generated based on the hash value of the transaction in the block; CS-B body contains all the transactions in the block, and these transactions are divided into attribute types and semantics are added; Step 1.2: Define T x T is a transaction in CSBM that is classified by attributes and given semantics. x ={Key=v1,Time={time=v2},Coordinate={longitude=v3,latitude=v4},Keywords={kw1,kw2,···,kw n },Others={oth1,oth2,···,oth n }}, Key is the primary key of the transaction, obtained by calculating the hash value of the transaction, and represented by a hexadecimal string of length 64; Time is the time attribute type, time is the timestamp of the transaction, Coordinate is the spatial attribute type, longitude is the longitude of the transaction, latitude is the latitude of the transaction, v i is the attribute value, Keywords is the keyword attribute type, kw i is the attribute name of a keyword of the transaction; Others is other attribute types, i is the name of the other attribute of the transaction; Set different attribute names for different application scenarios and transaction types; Step 2: Build based on B 2 The on-chain two-level index structure of the F-BKM structure consists of two parts: 2 F-tree and intra-block BKM-tree complete the indexing of all blocks and transactions; Step 3: Design an on-chain and off-chain spatiotemporal keyword query method; Get the query conditions based on the two-level index structure B on the chain 2 F-BKM structure, namely B 2 The F-tree and BKM-tree perform on-chain conditional queries and extract the connection attribute values ​​of the queried transactions. Based on the values, they perform on-chain and off-chain connection queries and return the final results.

2. According to a method for space-time keyword query in a hybrid storage blockchain environment according to claim 1, it is characterized in that: The B head includes the hash value PrevHash of the previous block that connects the blocks into a chain, the block height Block Height that records the position of the current block on the chain, the timestamp Timestamp that records the block generation time, and the mining difficulty Bits and random number Nonce.

3. According to a method for space-time keyword query in a hybrid storage blockchain environment according to claim 1, it is characterized in that: Step 2 is as follows: Step 2.1: Build a BKM-tree in each block to replace the original Merkle tree; in the process of building a new block, extract all transaction space attribute type values ​​and keyword attribute type values ​​in the block; imitate the KD-tree structure, divide the area according to the transaction space attribute data, until each area contains only one transaction, the transaction is only stored in the leaf node, and the non-leaf node stores the information related to the data division; then add a Bloom filter field to the KD-tree, construct a Bloom filter according to the transaction keyword attribute data, and the Bloom filter of the non-leaf node contains all the keywords of its child nodes; finally, calculate the hash value of each node from the bottom up according to the construction method of the Merkle tree to form a BKM-tree, and record the root node in the block header; Step 2.2: Construct a block-to-block B based on the block number, block creation time, and the key in the block. 2 F-tree; get new block data and construct B 2 F-tree node, the format of the key in the leaf node is "block-id, timestamp, bf", where block-id comes from the block height Block Height located in the block header, timestamp comes from the timestamp Timestamp located in the block header, and bf is the same as the Bloom filter in the root node of the BKM-tree in the block; the pointer in the leaf node records the address offset of the block in the blockchain file; the Bloom filter of the non-leaf node contains all the keywords of its subtree, which is used to filter the pointer to determine whether the node pointed to by the pointer contains the corresponding keyword, and update the B according to the block-id in the B+ tree node insertion method. 2 F-tree; Step 2.3: On-chain two-level index structure B 2 The F-BKM structure was completed.

4. According to a method for space-time keyword query in a hybrid storage blockchain environment according to claim 3, it is characterized in that: The new block data obtained includes the block number block-id of the new block, the block creation time timestamp, the bloom filter bloomfilter-bf composed of the keywords in the block, and the address offset of the block in the blockchain file.

5. According to a method for space-time keyword query in a hybrid storage blockchain environment according to claim 1, it is characterized in that: Step 3 is as follows: Step 3.1: Define the spatiotemporal keyword query in the hybrid storage blockchain environment. It consists of a four-tuple, Q = [[T s ,T e ],S,W,join-attr]; Step 3.2: Traverse B based on the time and keyword conditions in query Q 2 F-tree; based on B 2 The "timestamp,bf" part of the key in the F-tree node starts from the root node, selects the branch pointer according to the time condition, and then determines whether the node pointed to by the pointer contains the query keyword W according to the Bloom filter. If it does, continue traversing, otherwise terminate; continue this method until the leaf node, find the node that contains the query keyword W and the time is greater than or equal to 'T s ', less than or equal to 'T e 'All keys and get the location of these blocks through pointers; Step 3.3: After querying a specific block, traverse the BKM-tree in the block in turn according to the space and keyword conditions in the query Q; select child nodes from the root node from top to bottom according to the search method of the KD-tree, and determine whether the Bloom filter of the child node contains all the query keywords. If so, traverse the child node; if not, abandon this branch; follow this method until the leaf node, that is, find all transactions in the block that meet the space and keyword conditions; obtain the key data in the leaf node, that is, the hash value Key of the transaction, and then obtain the original data based on the key data. If the time condition is met, add the data to the on-chain result set Onchain-RS; Step 3.4: According to the join condition join-attr in the query Q, extract the value of the connection attribute of the original data in Onchain-RS, query the data in the off-chain database table based on the value, and add it to the off-chain result set Offchain-RS; read the data in Offchain-RS and Onchain-RS, connect the on-chain and off-chain data through the connection attribute, and store the result in the result set ResultSet; Step 3.5: Return ResultSet, terminate the current calculation and wait for the next call.

6. According to a method for spatiotemporal keyword query in a hybrid storage blockchain environment according to claim 5, it is characterized in that: In step 3.1 [T s ,T e ] is the time range of the user's query, S is the spatial range of the user's query, W is the keyword data set of the user's query, including several keywords, join-attr is the connection condition in the form of an equation, the left side of the equation is the keyword attribute name that needs to be connected on the chain, and the right side of the equation is the connection keyword attribute name in the off-chain database table.

Citation Information

Patent Citations

  • Data processing method and device of block chain network, cluster node and storage medium

    CN108769150A

  • Efficient data retrieval method based on improved block storage structure

    CN112800065A