WO2020244239A1 - 一种基于业务标识的索引创建方法、装置及设备 - Google Patents
一种基于业务标识的索引创建方法、装置及设备 Download PDFInfo
- Publication number
- WO2020244239A1 WO2020244239A1 PCT/CN2020/071461 CN2020071461W WO2020244239A1 WO 2020244239 A1 WO2020244239 A1 WO 2020244239A1 CN 2020071461 W CN2020071461 W CN 2020071461W WO 2020244239 A1 WO2020244239 A1 WO 2020244239A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- block
- service
- data record
- record
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
- G06F16/2255—Hash tables
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
Definitions
- the embodiments of this specification relate to the field of information technology, and in particular to an index creation method, device and equipment based on service identification.
- the ledger records the relevant data records that the relevant users need to save.
- the centralized database service provider generally docks with corporate users, and the data records that corporate users need to store often have different business identifiers (which can also be considered business attributes). For example, the source of the data record, the user, the project to which it belongs, and so on.
- the data records under the same business identifier often have different categories. For example, in the traceability process, the same batch of goods has the transit records of the goods passing through different transit points, and different transit points have different urgency for the transportation of the goods. There may be many different sending urgency levels.
- the purpose of the embodiments of the present application is to provide a method for creating an index based on a business identifier in a blockchain ledger, and a more flexible data record query solution.
- An index creation method based on business identification, applied to a centralized database service provider that stores data through a block chain ledger, the method includes:
- each data block contains at least one data record
- each data block contains the hash value of the previous data block and the data record contained in itself Determine the hash value of the own data block
- the block height of the data block increases monotonically based on the sequence of the block time.
- the embodiment of this specification also provides an index creation device based on business identification, which is applied to a centralized database service provider that stores data through a block chain ledger, and the device includes:
- An acquiring module which acquires a business identifier and a business label in a data record, the business identifier is used to uniquely identify the business attribute of the data record, and the business label is used to characterize the category of the data record;
- a determining module to determine the location information of the data record in the ledger, where the location information includes the block height of the data block where the data record is located, and the offset in the data block where the data record is located;
- a writing module to establish the corresponding relationship between the service ID, the service label and the location information, and write the corresponding relationship into the index with the service ID as the main key;
- each data block contains at least one data record
- each data block contains the hash value of the previous data block and the data record contained in itself Determine the hash value of the own data block
- the block height of the data block increases monotonically based on the sequence of the block time.
- the embodiment of this specification also provides a data record query method based on the aforementioned index, which is applied to a centralized database service provider that stores data through a block chain ledger, including:
- the embodiment of this specification also provides a data record query device, which is applied to a centralized database service provider that stores data through a blockchain ledger, including:
- the receiving module receives the query request including the service identification and the service label sent by the client;
- a matching module to perform matching from a pre-created index according to the service ID and service label, and determine the location information corresponding to the service ID and service label in the index table;
- the obtaining module obtains corresponding data records from the ledger according to the location information, and returns the obtained corresponding data records to the client.
- the relevant index about the service identification, the service label and the location information is created, so that when the data is inquired, the corresponding index can be obtained according to the service identification and the service label.
- the location information of the data record is obtained, and the corresponding data record is obtained, which makes the query process more flexible and improves user experience.
- Fig. 1 is a schematic diagram of a process for generating a block chain ledger provided by an embodiment of the specification
- Figure 2 is a schematic diagram of the system architecture involved in an embodiment of the specification
- FIG. 3 is a schematic flowchart of a method for creating an index based on a service identifier provided by an embodiment of this specification
- FIG. 4 is an index creation device based on service identification provided by an embodiment of this specification
- FIG. 5 is a schematic flowchart of a data record query method provided by an embodiment of the specification.
- FIG. 6 is a schematic structural diagram of a data record query device provided by an embodiment of this specification.
- Fig. 7 is a schematic structural diagram of a device for configuring the method of the embodiment of this specification.
- FIG. 2 is a schematic diagram of the system architecture involved in the embodiment of the specification.
- an enterprise organization can face multiple users, and each user can query the database service provider through its corresponding enterprise organization.
- the organization that the database service party connects to is a financial product company
- the data record can be the personal user’s financial management records in the financial product company
- the organization to be connected can be a government department, where the data record is the government department’s Expense details of the managed public project; or, the database service provider is connected to a hospital, and the data record is the patient’s medical record; or the database service provider is connected to a third-party payment agency, and the data record can be an individual user Payment records through the agency, etc.
- Figure 1 is a schematic diagram of the process of generating a block chain ledger provided by the embodiment of this specification, including:
- S101 Receive a data record to be stored, and determine a hash value of each data record, where the data record includes a business identifier and a business tag.
- the data records to be stored here can be various consumption records of individual users of the client, or can be business results, intermediate states, and operation records generated when the application server executes business logic based on user instructions.
- Specific business scenarios can include consumption records, audit logs, supply chains, government supervision records, medical records, and so on.
- the service identifier is used to uniquely identify the service attribute of the data record.
- the service identification can be the patient's user identification (including mobile phone number, ID number, user name, etc.), or a hash value obtained by hashing the user identification;
- the data record is the project overhead flow of an organization (an organization may have multiple project data records stored in the same ledger at the same time)
- the business identifier at this time may be the unique number of the project.
- the business tag further subdivides the category of the data record, and is used to characterize the category of the data record, and is different in granularity from the business identifier.
- business tags such as "serious illness” or “minor illness” and similar tags such as “emergency” or “non-emergency” can be included in the medical records, so that the medical records of the same user can be more detailed. classification;
- business tags such as "large amount” or “small amount” can be added according to the amount of each expenditure, so that data records under the same business ID can be more granular based on the amount Classification.
- the business identifier can clearly indicate the only counterpart of a data record, and the business label can classify the data records under the same business identifier in a more fine-grained manner.
- a user's medical record can use the user's ID card as a business identifier, and contain the business tags "minor illness” and "emergency" at the same time.
- the preset block conditions include: the number of data records to be stored reaches the number threshold, for example, every time one thousand data records are received, a new data block is generated and one thousand data records are written into the block; or , The time interval from the last block formation time reaches the time threshold, for example, every 5 minutes, a new data block is generated, and the data records received within these 5 minutes are written into the block.
- the N here refers to the serial number of the data block.
- the data block is in the form of a block chain, which is arranged sequentially based on the order of the block time, and has a strong timing characteristic.
- the block height of the data block increases monotonically based on the sequence of the block time.
- the block height can be a sequence number, at this time the block height of the Nth data block is N; the block height can also be generated in other ways.
- the data block at this time is the initial data block.
- the current data block (the first data block) can be generated based on the hash value of the previous data block (that is, the N-1th data block). For example, a feasible way is to determine the hash value of each data record to be written in the Nth block, and generate a Merck according to the sequence in the block. In the Er tree, the root hash value of the Merkel tree and the hash value of the previous data block are spliced together, and the hash algorithm is used again to generate the hash value of the current block.
- the specific verification method is to recalculate the hash value of the data record itself and the hash value of the data block in the database, and compare with the locally stored hash value.
- each data block is determined by a hash value, and the hash value of the data block is determined by the content and sequence of the data records in the data block and the hash value of the previous data block.
- the user can initiate verification based on the hash value of the data block at any time. Any modification of the data block (including the modification of the data record content or sequence in the data block) will cause the hash value of the data block calculated during verification and The hash value of the data block is inconsistent when it is generated, which causes the verification to fail, thus realizing the immutability under centralization.
- a segment of data block is designated for continuous integrity verification, or continuous integrity verification starts from the initial data block.
- the verification method is to obtain the hash value of the previous data block, and use the same algorithm as when generating the hash value of the data block, and recalculate its own data based on its own data record and the hash value of the previous data block.
- the hash value of the block is compared with the previously saved hash value to verify consistency.
- these data records usually have strong timing characteristics when they are written into the ledger (that is, the data records that are generally written first are arranged first), but for users, their data records are usually distributed Stored in multiple data blocks. For example, the hospital's medical records of all patients are uploaded sequentially in the order of time. For a user in a hospital, there may be multiple medical records, and the time interval is relatively large. If the hospital or the user needs to select the user's data record from the ledger, or even if the hospital or the user needs It is very inconvenient to find out some specific medical records from the ledger.
- a hospital or a user needs the user's "serious illness" record.
- FIG. 3 is a schematic flowchart of a method for creating an index based on a service identifier provided by an embodiment of this specification. The process specifically includes the following steps:
- S301 Acquire a service identifier and a service label in a data record, where the service identifier is used to uniquely identify a service attribute of the data record, and the service label is used to characterize a category of the data record.
- the specific location of the service identifier and the service label in the data record and the acquisition method may be determined by the database service party and the docking agency through consultation in advance.
- the service ID and service label can be obtained from the specified offset in the data record, or the start position and end of the service ID and service label can be determined by specific characters Location, for example, use "0E” as the starting point of the business identification/business label, and “0F” as the end character of the business identification/business label; or, when the data record provided by the docking organization is unstructured data,
- the docking agency can directly splice the header containing the business identification and business label at the beginning of each data record, and the database server can directly obtain the business identification and business label of each data record from the header.
- S303 Determine location information of the data record in the ledger, where the location information includes the block height of the data block where the data record is located, and the offset in the data block where the data record is located.
- a block-chain ledger is composed of multiple data blocks, and at the same time, a data block usually contains multiple data records. Therefore, in the embodiment of this specification, the location information specifically refers to which data block in the ledger is in when a data record is saved, and the offset or sequence number in the data block.
- the hash value of the data block is a hash value obtained by hash calculation based on the previous block's hash value and its own data record, which can be used to uniquely and clearly identify a data block.
- the block height of the first data block is 0, and the block height is increased by 1 for each additional data block; or, the block time of the data block can be converted into a large monotonic increase Integer data (usually 12 to 15 bits) sequence, as the block height of the data block. Therefore, a data block usually has a clear block height.
- the order of the data records has also been fixed, so the serial number of a data record in the data block is also clear.
- the serial number It can also be used to clarify the location information of the data record in the data block where it is located.
- the offset of the data recorded in the data block can be represented by the address offset or the sequence number.
- the address offset of each data record in the data block can also be used to identify the data records in the data block. Obviously, in the same data block, the address offset of each data record is not the same.
- the position information of a data record can be represented by the following array: (block height, serial number), for example (2, 10) where 2 represents the block height of the data block, and 10 represents the serial number of the data record in the data block;
- the content in the array is (block height, offset), for example (2, 1024), where 2 indicates the block height of the data block, and 1024 indicates the offset in the data block body.
- the specific format of the data block can be customized (for example, the metadata information and remark information contained in the block header of the data block, the block height of the data block is adopted Format, etc.), in different formats, the content of the location information will be different, which does not constitute a limitation to this solution.
- S305 Establish a correspondence relationship between the service ID, service label, and location information, and write the correspondence relationship into an index with the service ID as a primary key.
- the index is an inverted index.
- the primary key is the business identifier contained in the data record.
- the specific writing method is: when the primary key in the index does not contain the business identifier, an index record with the business identifier as the primary key is created in the index table.
- the service tag and location information are written into the index record where the service identifier is located. It should be noted that the writing here is not an overwriting writing, but the location information is added to the value of the index record, and it exists in the index record alongside other location information.
- Table 1 is an exemplary index table provided in the embodiment of this specification.
- the Key is the specific value of the business identifier
- each array in the Value part is the business tag + location information
- the format in the array element is (business tag, location information), such as 1 in (1,2,08) It is the service label
- the 2 in (2,08) is the block height
- 08 is the serial number of the data record in the data block.
- a data record can be uniquely determined by the block height and serial number. It is easy to understand that in the index table, a key can correspond to multiple location information.
- the business identifier and business tag of the data record, as well as the storage location in the ledger are determined, the corresponding relationship is established, and the business identifier is created as the main key
- the inverted index does not need to know the user’s business details. From the index, data records can be counted based on business identifiers, and more fine-grained queries can be made based on business tags, facilitating subsequent query and verification.
- an obtaining method can be created synchronously, that is, when the data record is received, the service ID and service label are directly parsed.
- an index is created synchronously. Another way is that when the data block is written into the ledger, there is no need to create an index immediately, but when the database has free resources, an index is created asynchronously for each data record in the data block newly written to the ledger , In the asynchronous creation mode, it is helpful for the database server to save resources.
- the location information can also be recorded in the ledger according to the data
- the sequence is arranged in order, which is conducive to the user's query and verification.
- the sequence of data records in the ledger can be reflected by the timestamp when the data record is written into the ledger (that is, the block timestamp of the data block), and for data records in the same data block, it can be displayed in the data block The sort of order to reflect one after another.
- the business attributes of the data records and the storage location in the ledger are determined, the corresponding relationship between the two is established, and the business attribute is created as the main key. Sort index, without knowing the user's business details, from the index, you can perform corresponding statistics on data records based on business attributes, as well as subsequent query and verification.
- the embodiment of this specification also provides an index creation device based on service identification, which is applied to a centralized database service provider that stores data through a block chain ledger, as shown in Figure 4, which is an implementation of this specification.
- the service identification-based index creation device provided in the example includes:
- the obtaining module 401 obtains a service identifier and a service label in a data record, where the service identifier is used to uniquely identify the service attribute of the data record, and the service label is used to characterize the type of the data record;
- the determining module 403 determines the location information of the data record in the ledger, where the location information includes the block height of the data block where the data record is located, and the offset in the data block where the data record is located;
- the writing module 405 establishes the corresponding relationship between the service ID, the service label and the location information, and writes the corresponding relationship into the index with the service ID as the primary key;
- each data block contains at least one data record
- each data block contains the hash value of the previous data block and the data record contained in itself Determine the hash value of the own data block
- the block height of the data block increases monotonically based on the sequence of the block time.
- the obtaining module 401 when receiving the data record sent by the user, obtains the service identification and service label in the data record in the data record; For any data record contained in the data block, the service identification and service label are obtained.
- the writing module 405 when the primary key in the index does not contain the business identifier, creates an index record with the business identifier as the primary key in the index table; when the primary key in the index When the service identifier is included, the location information is written into the index record where the service identifier is located.
- the writing module 405 determines the time stamp of the data record; in the same index record, according to the sequence of the time stamp, the position information of the data record is sequentially written into the value of the index record.
- the device further includes a data block generation module 407, which receives the data records to be stored, and determines the hash value of each data record, wherein the data record includes a service identification and a service label;
- each data record to be written in the data block is determined, and the Nth data block containing the hash value of the data block and the data record is generated, which specifically includes:
- the hash value and block height of the initial data block are given based on a preset method; when N>1, according to the data records in the data block to be written and the hash value of the N-1th data block The value determines the hash value of the Nth data block, and generates the Nth data block containing the hash value of the Nth data block and each data record.
- the block height of the data block is monotonous based on the block time sequence Increment.
- the embodiment of this specification also provides a data record query method based on the aforementioned index, which is applied to a centralized database service provider that stores data through a blockchain ledger, as shown in FIG. 5, which is
- the flow diagram of the data record query method provided by the embodiment of this specification includes:
- S501 Receive a query request that includes a service identifier and a service label sent by a client.
- the service identifier "0X123456" is the identity ID of a user. It is easy to understand that the user is more concerned about the data records and data blocks related to the service identification, and other data blocks are not what the user cares about.
- the query request can come from the docking organization or the service user of the docking organization.
- the user can input the query command in the form of Retrieve (0X123456, 1, FULL), where "0X123456" is the business identifier, and 1 is the business tag, which is used to query and obtain the business identifier "0X123456" in the ledger.
- the generated data record of category "1" is used to query and obtain the business identifier "0X123456" in the ledger.
- the query can also include a block height parameter used to specify the data block interval, for example, the user enters a query command, Retrieve (0X123456, 1, 100), used to query the specified service identifier "0X123456" before the block height 100
- the category is "1" data record.
- a segment of data block can also be determined by the height of two data blocks, for example, the user enters a query instruction, Retrieve (0X123456, 2, 200, 1000), which is used to query the specified business identifier 0X123456 in the ledger with a block height of 200 to block height Data records of category "2" between 1000, so as to obtain the data records corresponding to the location information (300,89) and (300,999).
- S503 Perform matching from a pre-created index according to the service identifier and the service label, and determine the location information corresponding to the service identifier and the service label in the index table.
- all VALUEs corresponding to the corresponding primary keys are obtained according to the service identification query, and then the location information that matches the service label input by the user is obtained through matching.
- index table 1 For example, after index table 1 is created, if the user enters the query command Retrieve (0X123456, 1, FULL), the location information can be obtained as (2,08), (2,10). That is, the 8th and 10th data records in the second data block.
- the available location information at this time is (300, 89), (300, 999). That is, the 89th and 999th data records in the 300th data block.
- S505 Obtain corresponding data records from the ledger according to the location information, and return the obtained corresponding data records to the client.
- the service identification and service label are added to the query instruction, and the user avoids obtaining all the data for each query and then traversing and categorizing the relevant data accurately. Query, improve query efficiency.
- the embodiment of this specification also provides a data record query device, which is applied to a centralized database service provider that stores data through a block chain ledger, as shown in FIG. 6, which is the specification
- a schematic structural diagram of a data record query device provided by an embodiment includes:
- the receiving module 601 receives the query request including the service identification and the service label sent by the client;
- the matching module 603 is configured to perform matching from a pre-created index according to the service ID and the service label, and determine the location information corresponding to the service ID and the service label in the index table;
- the obtaining module 605 obtains corresponding data records from the ledger according to the location information, and returns the obtained corresponding data records to the client.
- the embodiments of this specification also provide a computer device, which includes at least a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the index shown in FIG. 3 when the program is executed. Create method.
- the embodiments of this specification also provide a computer device, which includes at least a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the data shown in FIG. 5 when the program is executed. Record the query method.
- FIG. 7 shows a more specific hardware structure diagram of a computing device provided by an embodiment of this specification.
- the device may include a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050.
- the processor 1010, the memory 1020, the input/output interface 1030, and the communication interface 1040 realize the communication connection between each other in the device through the bus 1050.
- the processor 1010 may be implemented in a general-purpose CPU (Central Processing Unit, central processing unit), microprocessor, application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits for execution related Program to implement the technical solutions provided in the embodiments of this specification.
- a general-purpose CPU Central Processing Unit, central processing unit
- microprocessor microprocessor
- application specific integrated circuit Application Specific Integrated Circuit, ASIC
- ASIC Application Specific Integrated Circuit
- the memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory, random access memory), static storage device, dynamic storage device, etc.
- the memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of the present specification are implemented through software or firmware, related program codes are stored in the memory 1020 and called and executed by the processor 1010.
- the input/output interface 1030 is used to connect an input/output module to realize information input and output.
- the input/output/module can be configured in the device as a component (not shown in the figure), or can be connected to the device to provide corresponding functions.
- the input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and an output device may include a display, a speaker, a vibrator, an indicator light, and the like.
- the communication interface 1040 is used to connect a communication module (not shown in the figure) to realize the communication interaction between the device and other devices.
- the communication module can realize communication through wired means (such as USB, network cable, etc.), or through wireless means (such as mobile network, WIFI, Bluetooth, etc.).
- the bus 1050 includes a path to transmit information between various components of the device (for example, the processor 1010, the memory 1020, the input/output interface 1030, and the communication interface 1040).
- the device may also include the necessary equipment for normal operation.
- the above-mentioned device may also include only the components necessary to implement the solutions of the embodiments of the present specification, rather than all the components shown in the figures.
- the embodiment of this specification also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the index creation method shown in FIG. 3 is implemented.
- the embodiment of this specification also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the data record query method shown in FIG. 5 is implemented.
- Computer-readable media include permanent and non-permanent, removable and non-removable media, and information storage can be realized by any method or technology.
- the information can be computer-readable instructions, data structures, program modules, or other data.
- Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, CD-ROM, digital versatile disc (DVD) or other optical storage, Magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media can be used to store information that can be accessed by computing devices. According to the definition in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
- a typical implementation device is a computer.
- the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email receiving and sending device, and a game control A console, a tablet computer, a wearable device, or a combination of any of these devices.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computational Linguistics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
一种基于业务标识的索引创建方法、装置及设备,该方法通过在存储数据时根据业务双方的协定,创建有关业务标识、业务标签和位置信息的有关索引,从而在进行数据查询时,可以根据业务标识和业务标签获取对应的数据记录的位置信息,进而得到相应的数据记录,使得查询过程更为灵活,提高用户体验。
Description
本说明书实施例涉及信息技术领域,尤其涉及一种基于业务标识的索引创建方法、装置及设备。
在中心化的数据库服务方以块链式的账本对外提供服务时,账本中记录了相关用户所需要保存的相关数据记录。
在实际应用中,中心化的数据库服务方一般对接的是企业用户,而企业用户需要进行存储的数据记录往往具有不同的业务标识(也可以认为是业务属性)。例如,数据记录的来源、用户、所属项目等等。在同一业务标识下的数据记录往往也有类别不同,例如,在溯源过程中,同一批次商品在通过不同转运点均有该货物的转运记录,不同的转运点对于该商品的运送紧急程度不同,可能有多种不同的发送紧急级别。
由于在块链式账本中对于同一业务标识的数据记录的存储往往是分散的,在同一业务标识下往往也还同时包含很多不同类别的数据记录,而当前在块链式账本中的查询往往是串行式的查询。基于此,需要一种基于业务标识的索引创建方案。
发明内容
本申请实施例的目的是提供一种在块链式账本中基于业务标识的索引创建方法,以及,更为灵活的数据记录查询方案。
为解决上述技术问题,本申请实施例是这样实现的:
一种基于业务标识的索引创建方法,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,所述方法包括:
获取数据记录中的业务标识和业务标签,所述业务标识用于唯一标识所述数据记录的业务属性,所述业务标签用于表征所述数据记录的类别;
确定所述数据记录在账本中的位置信息,所述位置信息包括数据记录所处的数据块的块高,以及,在所处的数据块中的偏移量;
建立所述业务标识、业务标签和位置信息的对应关系,将所述对应关系写入以所述业务标识为主键的索引;
其中,在所述块链式账本中,除初始数据块以外,每一数据块中包含至少一条数据记录,每一数据块中包含由前一数据块的哈希值和自身所包含的数据记录确定的自身数据块的哈希值,数据块的块高基于成块时间的先后顺序单调递增。
对应的,本说明书实施例还提供一种基于业务标识的索引创建装置,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,所述装置包括:
获取模块,获取数据记录中的业务标识和业务标签,所述业务标识用于唯一标识所述数据记录的业务属性,所述业务标签用于表征所述数据记录的类别;
确定模块,确定所述数据记录在账本中的位置信息,所述位置信息包括数据记录所处的数据块的块高,以及,在所处的数据块中的偏移量;
写入模块,建立所述业务标识、业务标签和位置信息的对应关系,将所述对应关系写入以所述业务标识为主键的索引;
其中,在所述块链式账本中,除初始数据块以外,每一数据块中包含至少一条数据记录,每一数据块中包含由前一数据块的哈希值和自身所包含的数据记录确定的自身数据块的哈希值,数据块的块高基于成块时间的先后顺序单调递增。
另一方面,本说明书实施例还提供一种基于前述索引的数据记录查询方法,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,包括:
接收客户端所发送的包含业务标识和业务标签的查询请求;
根据所述业务标识和业务标签,从预先创建的索引中进行匹配,确定在所述索引表中所述业务标识和业务标签所对应的位置信息;
根据所述位置信息从所述账本中获取对应的数据记录,并返回获取得到的对应的数据记录至客户端。
与另一方面对应的,本说明书实施例还提供一种数据记录查询装置,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,包括:
接收模块,接收客户端所发送的包含业务标识和业务标签的查询请求;
匹配模块,根据所述业务标识和业务标签,从预先创建的索引中进行匹配,确定在所述索引表中所述业务标识和业务标签所对应的位置信息;
获取模块,根据所述位置信息从所述账本中获取对应的数据记录,并返回获取得到的对应的数据记录至客户端。
通过本说明书实施例所提供的方案,在存储数据时根据业务双方的协定,创建有关业务标识、业务标签和位置信息的有关索引,从而在进行数据查询时,可以根据业务标识和业务标签获取对应的数据记录的位置信息,进而得到相应的数据记录,使得查询过程更为灵活,提高用户体验。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本说明书实施例。
此外,本说明书实施例中的任一实施例并不需要达到上述的全部效果。
为了更清楚地说明本说明书实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书实施例中记载的一些实施例,对于本领域普通技术人员来讲,还可以根据这些附图获得其他的附图。
图1为本说明书实施例所提供的一种生成块链式账本的流程示意图;
图2为本说明书实施例所涉及的系统架构示意图;
图3是本说明书实施例提供的一种基于业务标识的索引创建方法的流程示意图;
图4为本说明书实施例所提供的基于业务标识的索引创建装置;
图5为本说明书实施例所提供的数据记录查询方法的流程示意图;
图6是本说明书实施例提供的一种数据记录查询装置的结构示意图;
图7是用于配置本说明书实施例方法的一种设备的结构示意图。
为了使本领域技术人员更好地理解本说明书实施例中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行详细地描述,显然,所描述的实施例仅仅是本说明书的一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员所获得的所有其他实施例,都应当属于保护的范围。
首先对本说明书实施例中所涉及的中心化下的块链式的账本予以说明。在实际应用中,数据库服务方面向的对象常常为各种机构,各机构则可以将它们与第三方用户(包括其它机构或者个人)之间所产生的数据记录在数据库服务方进行存储。如图2所示,图2为本说明书实施例所涉及的系统架构示意图。在该示意图中,一个企业机构可以面向多名用户,而每个用户均可以通过其对应的企业机构向数据库服务提供方进行查询。
例如,数据库服务方对接的机构是某金融产品公司,数据记录可以是个人用户在该金融产品公司的理财记录;或者,对接的机构可以是政府部门,其中的数据记录是政府部门对于该部门所管理的公共项目的开销明细;或者,数据库服务方对接的机构是某个医院,其中的数据记录是病人的病历;或者,数据库服务方对接的机构是第三方支付机构,数据记录可以是个人用户通过该机构的支付记录,等等。
在中心化的数据库服务提供方,块链式的账本通过如下方式生成,如图1所示,图1为本说明书实施例所提供的一种生成块链式账本的流程示意图,包括:
S101,接收待存储的数据记录,确定各数据记录的哈希值,其中,数据记录中包含业务标识和业务标签。
此处的待存储的数据记录,可以是客户端个人用户的各种消费记录,也可以是应用服务器基于用户的指令,在执行业务逻辑时产生的业务结果、中间状态以及操作记录等等。具体的业务场景可以包括消费记录、审计日志、供应链条、政府监管记录、医疗记录等等。
如前所述,基于业务场景的不同,数据记录的内容也会不同。在本说明书实施例中,业务标识用于唯一标识所述数据记录的业务属性。
例如,当数据记录为医疗记录时,其中业务标识可以是病人的用户标识(包括手机号、身份证号、用户名等等),或者对该用户标识进行哈希算法所得到的哈希值;或者,当数据记录为某个机构的项目开销流水时(一个机构可能有多个项目的数据记录同时存储在同一账本中),此时的业务标识可以为项目的唯一编号。
而业务标签则是对于数据记录的类别进行了进一步的细分,用于表征所述数据记录的类别,与业务标识存在粒度上的不同。
例如,对于医疗记录,可以在其中包含“大病”或者“小病”这样的业务标签,以及,“急症”或者“非急症”等等类似标签,以便对于同一用户的医疗记录可以更细致的进行分类;
又例如,对于项目的开销流水记录,可以根据在每一笔支出的额度添加“大金额”或 者“小金额”这样的业务标签,以便对于同一业务标识下的数据记录可以根据金额进行更细粒度的分类。
总而言之,在同一业务场景下,业务标识可以明确的指示出一条数据记录的唯一对应方,而业务标签则可以对于同一业务标识下的数据记录进行更细粒度的分类。
在一条数据记录中,业务标识只有一个,而标签则可以包含多个。例如,一条用户的医疗记录可以使用该用户的身份证作为业务标识,而同时包含业务标签“小病”和“急症”。
S103,当达到预设的成块条件时,确定待写入数据块中的各数据记录,生成包含数据块的哈希值和数据记录的第N个数据块。
所述预设的成块条件包括:待存储的数据记录数量达到数量阈值,例如,每接收到一千条数据记录时,生成一个新数据块,将一千条数据记录写入块中;或者,距离上一次成块时刻的时间间隔达到时间阈值,例如,每隔5分钟,生成一个新数据块,将在这5分钟内接收到的数据记录写入块中。
此处的N指的是数据块的序号,换言之,在本说明书实施例中,数据块是以块链的形式,基于成块时间的顺序先后排列,具有很强的时序特征。其中,数据块的块高基于成块时间的先后顺序单调递增。块高可以是序号,此时第N个数据块的块高即为N;块高也可以其它方式生成。
当N=1时,即此时的数据块为为初始数据块。初始数据块的哈希值和块高基于预设方式给定。例如,初始数据块中不包含数据记录,哈希值则为任一给定的哈希值,块高blknum=0;又例如,初始数据块的生成触发条件与其它数据块的触发条件一致,但是初始数据块的哈希值由对初始数据块中的所有内容取哈希确定。
当N>1时,由于前一数据块的内容和哈希值已经确定,则此时,可以基于前一数据块(即第N-1个数据块)的哈希值生成当前数据块(第N个数据块)的哈希值,例如,一种可行的方式为,确定每一条将要写入第N个块中的数据记录的哈希值,按照在块中的排列顺序,生成一个默克尔树,将默克尔树的根哈希值和前一数据块的哈希值拼接在一起,再次采用哈希算法,生成当前块的哈希值。又例如,还可以按照块中数据记录的顺序进行拼接并取哈希得到整体数据记录的哈希值,拼接前一数据块的哈希值和整体数据记录的哈希值,并对拼接得到的字串进行哈希运算,生成数据块的哈希值。
用户在上传数据成功后,即可以得到对应的数据记录的哈希值以及所处的数据块的 哈希值,并保存,并且可以基于该哈希值发起完整性验证。具体的验证方式即为在数据库中重新计算数据记录自身的哈希值以及所处的数据块的哈希值,与本地所保存的进行对比。
通过前述的数据块的生成方式,每一个数据块通过哈希值确定,数据块的哈希值由数据块中的数据记录的内容、顺序以及前一数据块的哈希值决定。用户可以随时基于数据块的哈希值发起验证,对于数据块中任何内容(包括对于数据块中数据记录内容或者顺序的修改)的修改都会造成在验证时计算得到的数据块的哈希值和数据块生成时的哈希值不一致,而导致验证失败,从而实现了中心化下的不可篡改。
在对于块链式的账本进行验证时,一般而言,即指定一段数据块进行连续的完整性验证,或者从初始数据块开始进行连续的完整性验证。验证的方式即为获取前一数据块的哈希值,并采用与生成数据块的哈希值时的同样算法,根据自身的数据记录和前一数据块的哈希值,重新计算一遍自身数据块的哈希值,并且和之前所保存的哈希值进行对比以验证一致性。
如前所述,这些数据记录在写入账本时通常已经有了较强的时序特征(即一般写在前的数据记录排列在前),但是对于用户而言,其数据记录通常是分散式的存储在多个数据块中的。例如,医院对于所有病人的病历记录按照时间产生的顺序,依次上传。而对于医院的某个用户而言,其病历记录可能有多条,时间间隔又比较大,如果医院或者该用户需要从账本中将该用户的数据记录挑选出来,甚至,如果医院或者该用户需要从账本中将某些特定的病历查找出来在,则非常不方便。
例如,医院或者用户需要该用户的“大病”记录。在这种情形下,则需要根据用户保存的哈希值从账本中遍历查询得到该用户的数据记录,以及,进一步地从数据记录中进一步查询得到“大病”记录。
基于此,本说明书实施例提供一种基于业务标识的索引创建方法,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,可以实现在不必了解对接机构的业务详情时,创建出相关的索引,方便对接机构的业务处理,提高用户体验。如图3所示,图3是本说明书实施例提供的一种基于业务标识的索引创建方法的流程示意图,该流程具体包括如下步骤:
S301,获取数据记录中的业务标识和业务标签,所述业务标识用于唯一标识所述数据记录的业务属性,所述业务标签用于表征所述数据记录的类别。
业务标识和业务标签在数据记录中的具体位置以及获取方式可以是数据库服务方和对接机构事先协商而确定。例如,对接机构所提供的数据记录为标准结构化的数据记录时,业务标识和业务标签可以从数据记录中指定偏移量获取,或者由特定字符确定出业务标识和业务标签起始位置和结束位置,例如,以“0E”作为业务标识/业务标签的起点,以“0F”作为业务标识/业务标签的结束字符;又或者,对接机构所提供的数据记录为非结构化的数据时,在对接机构上传时可以直接在每条数据记录的开头拼接上包含业务标识和业务标签的头部,数据库服务方可以直接从头部获取每条数据记录的业务标识和业务标签。
S303,确定所述数据记录在账本中的位置信息,所述位置信息包括数据记录所处的数据块的块高,以及,在所处的数据块中的偏移量。
如前所述,一个块链式的账本由多个数据块组成,同时,一个数据块中通常包含多个数据记录。因此,在本说明书实施例中,所述的位置信息具体指的是一条数据记录被保存时,处于账本中的哪个数据块上,以及,在该数据块中的偏移量或者排列序号。
在本说明书实施例所提供的数据块中,可以有多种方式用来标识不同的数据块,包括数据块的哈希值或者块高。
数据块的哈希值为根据前一区块哈希值和自身数据记录进行哈希计算而得到的哈希值,可以用于唯一、明确地标识一个数据块。在块链式的账本中,通常第一个数据块其块高为0,以后每增加一个数据块,块高加1;或者,还可以将数据块的成块时间转换为一个大的单调递增整型数据(一般为12至15位)序列,作为数据块的块高。因此,一个数据块通常有一个明确的块高。
同时,在一个已经确定的要写入数据库的数据块,其中数据记录的排序也已经固定,因此一个数据记录在该数据块中的序号也是明确的,在数据记录的长度为固定单位时,序号同样可以用于明确该数据记录在其所处的数据块中的位置信息。换言之,数据记录在数据块中的偏移量可以通过地址偏移量或者序号来表示。
在一个数据块中,由于通常包含了多个数据记录,因此,还可以用各数据记录在该数据块中的地址偏移量来分别标识数据块中的数据记录。显而易见,在同一个数据块中,各数据记录的地址偏移量并不相同。
因此,一个数据记录的位置信息其形式可以是通过如下数组表示:(块高,序号),例如(2,10)其中的2表示数据块块高,10表示数据记录在数据块中的序号;又或者, 数组中的内容为(块高,偏移量),例如(2,1024)其中的2标识数据块块高,1024表示在数据块块体中的偏移量。
当然,由于在本说明书实施例所提供的方式中,数据块的具体格式是可以自定义的(例如,数据块的块头中所包含的元数据信息和备注信息,数据块的块高所采取的形式等等),在不同的格式下,位置信息的内容也会有所不同,这并不构成对本方案的限定。
S305,建立所述业务标识、业务标签和位置信息的对应关系,将所述对应关系写入以所述业务标识为主键的索引。
即,该索引是一个倒排索引。在该索引中,主键是数据记录中所包含的业务标识。具体的写入方式为,当索引中的主键不包含所述业务标识时,在索引表中创建以所述业务标识为主键的索引记录。
当所述索引中的主键包含所述业务标识时,将所述业务标签和位置信息写入所述业务标识所处的索引记录。需要说明的是,此处的写入不是覆盖性的写入,而是将位置信息添加到该索引记录的值中,与其它位置信息并列存在于该索引记录中。
如表1所示,表1为本说明书实施例所提供的一种示例性索引表。其中Key即为业务标识的具体值,Value部分的每个数组即为业务标签+位置信息,数组元素中的格式即为(业务标签,位置信息),如(1,2,08)中的1即为业务标签,(2,08)中的2即为块高,08为数据记录在该数据块中的序号,通过块高和序号即可以唯一的确定一条数据记录。容易理解,在索引表中,一个key可以对应于多个位置信息。
表1
| Key | Value |
| 0X123456 | (1,2,08),(1,2,10),(2,300,89),(2,300,999) |
| 344X0001 | (1,5,01),(2,8,22) |
| …… | …… |
通过本说明书实施例所提供的方案,对于写入账本的数据记录,确定出数据记录的业务标识和业务标签,以及在账本中的存储位置,建立起相应的对应关系,创建以业务标识为主键的倒排索引,不必了解用户的业务详情,从索引中即可以基于业务标识对于数据记录进行相应统计,以及基于业务标签进行更细粒度的查询,便于后续的查询和验证。
在一种实施例中,数据库服务方在获取数据记录中的业务标识和业务标签时,一种 获取方式可以同步创建,即接收到数据记录的时候即直接解析得到业务标识和业务标签,在数据块写入账本时,同步创建索引。另一种方式则为,在数据块写入账本时,并不需要立即创建索引,而是在数据库有空余资源的时候,再针对新写入账本的数据块中的每条数据记录异步创建索引,在异步创建的方式下,有利于数据库服务方节省资源。
在索引表中,由于一个业务标识可以对应于多个位置信息+业务标签(即对应于多个数据记录),在将位置信息写入索引中时,还可以将位置信息按照数据记录在账本中的先后顺序依次进行排列,有利于用户的查询以及验证。数据记录在账本中的先后顺序即可以数据记录被写入账本的时间戳(即数据块的成块时间戳)来体现,以及,对于同一数据块中的数据记录,则可以通过在数据块中的排序先后来体现。
通过本说明书实施例所提供的方案,对于写入账本的数据记录,确定出数据记录的业务属性,以及在账本中的存储位置,建立起二者的对应关系,创建以业务属性为主键的倒排索引,不必了解用户的业务详情,从索引中即可以基于业务属性对于数据记录进行相应统计,以及后续的查询和验证。
对应的,本说明书实施例还提供一种基于业务标识的索引创建装置,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,如图4所示,图4为本说明书实施例所提供的基于业务标识的索引创建装置,所述装置包括:
获取模块401,获取数据记录中的业务标识和业务标签,所述业务标识用于唯一标识所述数据记录的业务属性,所述业务标签用于表征所述数据记录的类别;
确定模块403,确定所述数据记录在账本中的位置信息,所述位置信息包括数据记录所处的数据块的块高,以及,在所处的数据块中的偏移量;
写入模块405,建立所述业务标识、业务标签和位置信息的对应关系,将所述对应关系写入以所述业务标识为主键的索引;
其中,在所述块链式账本中,除初始数据块以外,每一数据块中包含至少一条数据记录,每一数据块中包含由前一数据块的哈希值和自身所包含的数据记录确定的自身数据块的哈希值,数据块的块高基于成块时间的先后顺序单调递增。
进一步地,所述获取模块401,接收到用户所发送的数据记录时,获取数据记录中的数据记录中的业务标识和业务标签;或者,确定账本中的数据块所包含的数据记录,针对所述数据块中所包含的任一数据记录,获取其中的业务标识和业务标签。
进一步地,所述写入模块405,当所述索引中的主键不包含所述业务标识时,在所 述索引表中创建以所述业务标识为主键的索引记录;当所述索引中的主键包含所述业务标识时,将所述位置信息写入所述业务标识所处的索引记录。
进一步地,所述写入模块405,确定数据记录的时间戳;在同一索引记录中按照时间戳的先后顺序,将数据记录的位置信息依序写入索引记录的值。
进一步地,所述装置中还包括数据块生成模块407,接收待存储的数据记录,确定各数据记录的哈希值,其中,数据记录中包含业务标识和业务标签;
当达到预设的成块条件时,确定待写入数据块中的各数据记录,生成包含数据块的哈希值和数据记录的第N个数据块,具体包括:
当N=1时,初始数据块的哈希值和块高基于预设方式给定;当N>1时,根据待写入数据块中的各数据记录和第N-1个数据块的哈希值确定第N个数据块的哈希值,生成包含第N个数据块的哈希值和各数据记录的第N个数据块,其中,数据块的块高基于成块时间的先后顺序单调递增。
在另一方面,本说明书实施例还提供一种基于前述索引的数据记录查询方法,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,如图5所示,图5为本说明书实施例所提供的数据记录查询方法的流程示意图,包括:
S501,接收客户端所发送的包含业务标识和业务标签的查询请求。
假设业务标识“0X123456”为一名用户的身份ID。容易理解,对于而言,用户更关心的是和该业务标识相关的数据记录和数据块,其它的数据块并不是用户所关心的。
此时,查询请求可以来自于对接机构,也可以是来自于对接机构的服务用户。例如,用户输入查询指令的形式可以是,Retrieve(0X123456,1,FULL),其中的,“0X123456”即为业务标识,1即为业务标签,用于查询获取在账本中业务标识“0X123456”所产生的类别为“1”的数据记录。
进一步地,查询时还可以包含用于指定数据块区间的块高参数,例如,用户输入查询指令,Retrieve(0X123456,1,100),用于查询指定的业务标识“0X123456”在块高100之前的类别为“1”数据记录。
以及,还可以由两个数据块高确定一段数据块,例如,用户输入查询指令,Retrieve(0X123456,2,200,1000),用于查询指定的业务标识0X123456在账本中块高200至块高1000之间的类别为“2”的数据记录,从而得到位置信息(300,89),(300,999)所 对应的数据记录。
S503,根据所述业务标识和业务标签,从预先创建的索引中进行匹配,确定在所述索引表中所述业务标识和业务标签所对应的位置信息。
具体而言,首先根据业务标识查询得到相应的主键所对应的所有VALUE,进而,从中匹配得到符合用户输入的业务标签的位置信息。
例如,在索引表1被创建以后,若用户输入查询指令Retrieve(0X123456,1,FULL),即可以得到位置信息为(2,08),(2,10)。即第2个数据块中的第8条和第10条数据记录。
若用户输入的查询指令为Retrieve(0X123456,2,200,1000),此时可得到的位置信息为(300,89),(300,999)。即第300个数据块中的第89条和999条数据记录。
S505,根据所述位置信息从所述账本中获取对应的数据记录,并返回获取得到的对应的数据记录至客户端。
通过本说明书实施例所提供的方案,在查询指令中加入业务标识和业务标签,用户在查询时避免了每次查询获取全部数据再进行遍历分类,可以准确的对相关的数据进行更细粒度的查询,提高了查询效率。
与另一方面对应的,本说明书实施例还提供一种数据记录查询装置,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,如图6所示,图6是本说明书实施例提供的一种数据记录查询装置的结构示意图,包括:
接收模块601,接收客户端所发送的包含业务标识和业务标签的查询请求;
匹配模块603,根据所述业务标识和业务标签,从预先创建的索引中进行匹配,确定在所述索引表中所述业务标识和业务标签所对应的位置信息;
获取模块605,根据所述位置信息从所述账本中获取对应的数据记录,并返回获取得到的对应的数据记录至客户端。
本说明书实施例还提供一种计算机设备,其至少包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,处理器执行所述程序时实现图3所示的索引创建方法。
本说明书实施例还提供一种计算机设备,其至少包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,处理器执行所述程序时实现图5所 示的数据记录查询方法。
图7示出了本说明书实施例所提供的一种更为具体的计算设备硬件结构示意图,该设备可以包括:处理器1010、存储器1020、输入/输出接口1030、通信接口1040和总线1050。其中处理器1010、存储器1020、输入/输出接口1030和通信接口1040通过总线1050实现彼此之间在设备内部的通信连接。
处理器1010可以采用通用的CPU(Central Processing Unit,中央处理器)、微处理器、应用专用集成电路(Application Specific Integrated Circuit,ASIC)、或者一个或多个集成电路等方式实现,用于执行相关程序,以实现本说明书实施例所提供的技术方案。
存储器1020可以采用ROM(Read Only Memory,只读存储器)、RAM(Random Access Memory,随机存取存储器)、静态存储设备,动态存储设备等形式实现。存储器1020可以存储操作系统和其他应用程序,在通过软件或者固件来实现本说明书实施例所提供的技术方案时,相关的程序代码保存在存储器1020中,并由处理器1010来调用执行。
输入/输出接口1030用于连接输入/输出模块,以实现信息输入及输出。输入输出/模块可以作为组件配置在设备中(图中未示出),也可以外接于设备以提供相应功能。其中输入设备可以包括键盘、鼠标、触摸屏、麦克风、各类传感器等,输出设备可以包括显示器、扬声器、振动器、指示灯等。
通信接口1040用于连接通信模块(图中未示出),以实现本设备与其他设备的通信交互。其中通信模块可以通过有线方式(例如USB、网线等)实现通信,也可以通过无线方式(例如移动网络、WIFI、蓝牙等)实现通信。
总线1050包括一通路,在设备的各个组件(例如处理器1010、存储器1020、输入/输出接口1030和通信接口1040)之间传输信息。
需要说明的是,尽管上述设备仅示出了处理器1010、存储器1020、输入/输出接口1030、通信接口1040以及总线1050,但是在具体实施过程中,该设备还可以包括实现正常运行所必需的其他组件。此外,本领域的技术人员可以理解的是,上述设备中也可以仅包含实现本说明书实施例方案所必需的组件,而不必包含图中所示的全部组件。
本说明书实施例还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现图3所示的索引创建方法。
本说明书实施例还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现图5所示的数据记录查询方法。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
通过以上的实施方式的描述可知,本领域的技术人员可以清楚地了解到本说明书实施例可借助软件加必需的通用硬件平台的方式来实现。基于这样的理解,本说明书实施例的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本说明书实施例各个实施例或者实施例的某些部分所述的方法。
上述实施例阐明的系统、方法、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机,计算机的具体形式可以是个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件收发设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任意几种设备的组合。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于方法实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。以上所描述的方法实施例仅仅是示意性的,其中所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,在实施本说明书实施例方案时可以把各模块的功能在同一个或多个软件和/或硬件中实现。也可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。
以上所述仅是本说明书实施例的具体实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本说明书实施例原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本说明书实施例的保护范围。
Claims (14)
- 一种基于业务标识的索引创建方法,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,所述方法包括:获取数据记录中的业务标识和业务标签,所述业务标识用于唯一标识所述数据记录的业务属性,所述业务标签用于表征所述数据记录的类别;确定所述数据记录在账本中的位置信息,所述位置信息包括数据记录所处的数据块的块高,以及,在所处的数据块中的偏移量;建立所述业务标识、业务标签和位置信息的对应关系,将所述对应关系写入以所述业务标识为主键的索引;其中,在所述块链式账本中,除初始数据块以外,每一数据块中包含至少一条数据记录,每一数据块中包含由前一数据块的哈希值和自身所包含的数据记录确定的自身数据块的哈希值,数据块的块高基于成块时间的先后顺序单调递增。
- 如权利要求1所述的方法,获取数据记录中的数据记录中的业务标识和业务标签,包括:接收到用户所发送的数据记录时,获取数据记录中的数据记录中的业务标识和业务标签;或者,确定账本中的数据块所包含的数据记录,针对所述数据块中所包含的任一数据记录,获取其中的业务标识和业务标签。
- 如权利要求1所述的方法,将所述对应关系写入以所述指定标识字段为主键的索引,包括:当所述索引中的主键不包含所述业务标识时,在所述索引表中创建以所述业务标识为主键的索引记录;当所述索引中的主键包含所述业务标识时,将所述位置信息写入所述业务标识所处的索引记录。
- 如权利要求3所述的方法,将所述位置信息写入所述业务标识所处的索引记录,包括:确定数据记录的时间戳;在同一索引记录中按照时间戳的先后顺序,将数据记录的位置信息依序写入索引记录的值。
- 如权利要求1所述的方法,在中心化的数据库服务提供方,数据块通过如下方式预先生成:接收待存储的数据记录,确定各数据记录的哈希值,其中,数据记录中包含业务标识和业务标签;当达到预设的成块条件时,确定待写入数据块中的各数据记录,生成包含数据块的哈希值和数据记录的第N个数据块,具体包括:当N=1时,初始数据块的哈希值和块高基于预设方式给定;当N>1时,根据待写入数据块中的各数据记录和第N-1个数据块的哈希值确定第N个数据块的哈希值,生成包含第N个数据块的哈希值和各数据记录的第N个数据块,其中,数据块的块高基于成块时间的先后顺序单调递增。
- 一种基于业务标识的索引创建装置,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,所述装置包括:获取模块,获取数据记录中的业务标识和业务标签,所述业务标识用于唯一标识所述数据记录的业务属性,所述业务标签用于表征所述数据记录的类别;确定模块,确定所述数据记录在账本中的位置信息,所述位置信息包括数据记录所处的数据块的块高,以及,在所处的数据块中的偏移量;写入模块,建立所述业务标识、业务标签和位置信息的对应关系,将所述对应关系写入以所述业务标识为主键的索引;其中,在所述块链式账本中,除初始数据块以外,每一数据块中包含至少一条数据记录,每一数据块中包含由前一数据块的哈希值和自身所包含的数据记录确定的自身数据块的哈希值,数据块的块高基于成块时间的先后顺序单调递增。
- 如权利要求6所述的装置,所述获取模块,接收到用户所发送的数据记录时,获取数据记录中的数据记录中的业务标识和业务标签;或者,确定账本中的数据块所包含的数据记录,针对所述数据块中所包含的任一数据记录,获取其中的业务标识和业务标签。
- 如权利要求6所述的装置,所述写入模块,当所述索引中的主键不包含所述业务标识时,在所述索引表中创建以所述业务标识为主键的索引记录;当所述索引中的主键包含所述业务标识时,将所述位置信息写入所述业务标识所处的索引记录。
- 如权利要求8所述的装置,所述写入模块,确定数据记录的时间戳;在同一索引记录中按照时间戳的先后顺序,将数据记录的位置信息依序写入索引记录的值。
- 如权利要求6所述的装置,还包括数据块生成模块,接收待存储的数据记录,确定各数据记录的哈希值,其中,数据记录中包含业务标识和业务标签;当达到预设的成块条件时,确定待写入数据块中的各数据记录,生成包含数据块的 哈希值和数据记录的第N个数据块,具体包括:当N=1时,初始数据块的哈希值和块高基于预设方式给定;当N>1时,根据待写入数据块中的各数据记录和第N-1个数据块的哈希值确定第N个数据块的哈希值,生成包含第N个数据块的哈希值和各数据记录的第N个数据块,其中,数据块的块高基于成块时间的先后顺序单调递增。
- 一种基于权利要求1至5任一项所述索引的数据记录查询方法,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,包括:接收客户端所发送的包含业务标识和业务标签的查询请求;根据所述业务标识和业务标签,从预先创建的索引中进行匹配,确定在所述索引表中所述业务标识和业务标签所对应的位置信息;根据所述位置信息从所述账本中获取对应的数据记录,并返回获取得到的对应的数据记录至客户端。
- 一种数据记录查询装置,应用于通过块链式账本存储数据的中心化的数据库服务提供方中,包括:接收模块,接收客户端所发送的包含业务标识和业务标签的查询请求;匹配模块,根据所述业务标识和业务标签,从预先创建的索引中进行匹配,确定在所述索引表中所述业务标识和业务标签所对应的位置信息;获取模块,根据所述位置信息从所述账本中获取对应的数据记录,并返回获取得到的对应的数据记录至客户端。
- 一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述程序时实现如权利要求1至5任一项所述的方法。
- 一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述程序时实现如权利要求11所述的方法。
Priority Applications (3)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| US16/811,502 US10963453B2 (en) | 2019-06-03 | 2020-03-06 | Service identifier-based data indexing |
| US17/215,255 US11106660B2 (en) | 2019-06-03 | 2021-03-29 | Service identifier-based data indexing |
| US17/462,308 US11816099B2 (en) | 2019-06-03 | 2021-08-31 | Service identifier-based data indexing |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910475975.2 | 2019-06-03 | ||
| CN201910475975.2A CN110347674A (zh) | 2019-06-03 | 2019-06-03 | 一种基于业务标识的索引创建方法、装置及设备 |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US16/811,502 Continuation US10963453B2 (en) | 2019-06-03 | 2020-03-06 | Service identifier-based data indexing |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020244239A1 true WO2020244239A1 (zh) | 2020-12-10 |
Family
ID=68181426
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2020/071461 Ceased WO2020244239A1 (zh) | 2019-06-03 | 2020-01-10 | 一种基于业务标识的索引创建方法、装置及设备 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN110347674A (zh) |
| WO (1) | WO2020244239A1 (zh) |
Families Citing this family (13)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110347674A (zh) * | 2019-06-03 | 2019-10-18 | 阿里巴巴集团控股有限公司 | 一种基于业务标识的索引创建方法、装置及设备 |
| US10963453B2 (en) | 2019-06-03 | 2021-03-30 | Advanced New Technologies Co., Ltd. | Service identifier-based data indexing |
| CN114090481A (zh) * | 2020-07-02 | 2022-02-25 | 北京瀚海云星科技有限公司 | 一种发送数据的方法、接收数据的方法及相关装置 |
| CN112328603B (zh) * | 2020-11-17 | 2024-10-18 | 北京沃东天骏信息技术有限公司 | 用户请求处理方法、装置、设备和计算机可读介质 |
| CN112434125A (zh) * | 2020-11-30 | 2021-03-02 | 中国人寿保险股份有限公司 | 索引结构、非结构化数据的检索方法、装置和设备 |
| CN112613917B (zh) * | 2020-12-30 | 2024-09-06 | 平安壹钱包电子商务有限公司 | 基于用户画像的信息推送方法、装置、设备及存储介质 |
| CN113760530A (zh) * | 2021-01-15 | 2021-12-07 | 北京京东拓先科技有限公司 | 请求处理方法、装置、设备、可读存储介质、程序产品 |
| CN112860955B (zh) * | 2021-03-01 | 2022-03-08 | 杨皓淳 | 基于云计算和大数据的业务数据管理系统和方法 |
| CN112883036B (zh) * | 2021-03-05 | 2024-05-28 | 鹏城实验室 | 索引创建方法、装置、存储服务器以及存储介质 |
| CN113051456B (zh) * | 2021-05-11 | 2024-10-29 | 抖音视界有限公司 | 请求处理方法、装置、电子设备和计算机可读介质 |
| CN114153844A (zh) * | 2021-11-23 | 2022-03-08 | 新华三大数据技术有限公司 | 基于索引模板的分表管理方法、装置、设备及存储介质 |
| CN116842002B (zh) * | 2022-03-23 | 2026-03-17 | 北京京东振世信息技术有限公司 | 一种业务数据管理的方法和装置 |
| CN120804152B (zh) * | 2025-09-12 | 2026-02-03 | 昆仑数智科技有限责任公司 | 基于数据库的数据处理方法、装置、设备及存储介质 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107239479A (zh) * | 2017-03-28 | 2017-10-10 | 阿里巴巴集团控股有限公司 | 一种基于区块链的数据存储以及查询的方法及装置 |
| CN107273556A (zh) * | 2017-08-23 | 2017-10-20 | 上海点融信息科技有限责任公司 | 区块链数据索引方法和设备 |
| CN107729383A (zh) * | 2017-09-18 | 2018-02-23 | 联动优势科技有限公司 | 一种索引库生成方法、数据验证方法、装置及平台 |
| CN107943951A (zh) * | 2017-11-24 | 2018-04-20 | 中钞信用卡产业发展有限公司杭州区块链技术研究院 | 一种区块链业务信息的检索方法及系统 |
| US20180268504A1 (en) * | 2017-03-15 | 2018-09-20 | Factom | Indexing Mortgage Documents via Blockchains |
| CN110347674A (zh) * | 2019-06-03 | 2019-10-18 | 阿里巴巴集团控股有限公司 | 一种基于业务标识的索引创建方法、装置及设备 |
Family Cites Families (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103150397B (zh) * | 2013-03-26 | 2016-03-16 | 北京经纬恒润科技有限公司 | 一种数据索引创建方法、数据检索方法和系统 |
| EP3535659B1 (en) * | 2016-11-03 | 2025-09-24 | Visa International Service Association | Systems and methods for creating a universal record |
| CN108197505B (zh) * | 2017-12-29 | 2020-07-17 | 泰康保险集团股份有限公司 | 区块链业务数据处理方法、装置及电子设备 |
| CN109558422A (zh) * | 2018-10-29 | 2019-04-02 | 平安科技(深圳)有限公司 | 基于区块链的驾驶证档案管理方法、装置、计算机设备 |
| CN109669943A (zh) * | 2018-11-30 | 2019-04-23 | 深圳灵图慧视科技有限公司 | 数据存储方法、数据查询方法及装置 |
| CN109508564B (zh) * | 2018-12-20 | 2021-08-13 | 姚前 | 一种基于区块链的数字资产存储系统和方法 |
-
2019
- 2019-06-03 CN CN201910475975.2A patent/CN110347674A/zh active Pending
-
2020
- 2020-01-10 WO PCT/CN2020/071461 patent/WO2020244239A1/zh not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20180268504A1 (en) * | 2017-03-15 | 2018-09-20 | Factom | Indexing Mortgage Documents via Blockchains |
| CN107239479A (zh) * | 2017-03-28 | 2017-10-10 | 阿里巴巴集团控股有限公司 | 一种基于区块链的数据存储以及查询的方法及装置 |
| CN107273556A (zh) * | 2017-08-23 | 2017-10-20 | 上海点融信息科技有限责任公司 | 区块链数据索引方法和设备 |
| CN107729383A (zh) * | 2017-09-18 | 2018-02-23 | 联动优势科技有限公司 | 一种索引库生成方法、数据验证方法、装置及平台 |
| CN107943951A (zh) * | 2017-11-24 | 2018-04-20 | 中钞信用卡产业发展有限公司杭州区块链技术研究院 | 一种区块链业务信息的检索方法及系统 |
| CN110347674A (zh) * | 2019-06-03 | 2019-10-18 | 阿里巴巴集团控股有限公司 | 一种基于业务标识的索引创建方法、装置及设备 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110347674A (zh) | 2019-10-18 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020244239A1 (zh) | 一种基于业务标识的索引创建方法、装置及设备 | |
| WO2021073242A1 (zh) | 索引创建和数据查询方法、装置及设备 | |
| CN110188096B (zh) | 一种数据记录的索引创建方法、装置及设备 | |
| WO2020211569A1 (zh) | 一种数据记录的索引创建方法 | |
| CN110162662B (zh) | 一种块链式账本中数据记录的验证方法、装置及设备 | |
| WO2021017422A1 (zh) | 一种块链式账本中的索引创建方法、装置及设备 | |
| US10990705B2 (en) | Index creation for data records | |
| US11816099B2 (en) | Service identifier-based data indexing | |
| CN110716965A (zh) | 一种块链式账本中的查询方法、装置及设备 | |
| CN110349019B (zh) | 一种块链式账本中的验证方法、装置及设备 | |
| CN110162526A (zh) | 一种块链式账本中数据记录的查询方法、装置及设备 | |
| CN110347679B (zh) | 一种基于收据的数据存储方法、装置及设备 | |
| WO2021093461A1 (zh) | 一种块链式账本中的聚合计算方法、装置及设备 | |
| US11223471B2 (en) | Blockchain-type data storage | |
| WO2021073241A1 (zh) | 一种基于磁盘存储的数据读取方法、装置及设备 | |
| CN110837502A (zh) | 一种块链式账本中的数据存储方法、装置及设备 | |
| CN110362570B (zh) | 一种数据存储方法、装置及设备 | |
| WO2021057127A1 (zh) | 一种基于多条业务属性的数据存储方法、装置及设备 | |
| CN110717196A (zh) | 一种证券交易数据的存储方法、装置及设备 | |
| CN110636042B (zh) | 一种服务端已验证块高的更新方法、装置及设备 | |
| CN111444215A (zh) | 一种块链式账本中的成块方法、装置及设备 | |
| HK40015738A (zh) | 一种基於业务标识的索引创建方法、装置及设备 | |
| CN110347748A (zh) | 一种基于倒排索引的数据验证方法、系统、装置及设备 | |
| CN110874486A (zh) | 一种块链式账本中的数据读取方法、装置及设备 | |
| HK40045819B (zh) | 块链式账本中全局状态的哈希的生成方法、装置及设备 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20819163 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 20819163 Country of ref document: EP Kind code of ref document: A1 |