CN111858602A - Data reading and updating method and system of block chain - Google Patents
Data reading and updating method and system of block chain Download PDFInfo
- Publication number
- CN111858602A CN111858602A CN202010717510.6A CN202010717510A CN111858602A CN 111858602 A CN111858602 A CN 111858602A CN 202010717510 A CN202010717510 A CN 202010717510A CN 111858602 A CN111858602 A CN 111858602A
- Authority
- CN
- China
- Prior art keywords
- file
- page
- data
- record
- updating
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 28
- 238000013507 mapping Methods 0.000 claims abstract description 11
- 238000004364 calculation method Methods 0.000 claims description 6
- 238000012986 modification Methods 0.000 description 5
- 230000004048 modification Effects 0.000 description 5
- 238000007726 management method Methods 0.000 description 4
- 238000012217 deletion Methods 0.000 description 2
- 230000037430 deletion Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000004075 alteration Effects 0.000 description 1
- 230000015572 biosynthetic process Effects 0.000 description 1
- 238000013523 data management Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/23—Updating
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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
- G06F16/2458—Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
- G06F16/2471—Distributed queries
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Abstract
The invention discloses a data reading and updating method and a data reading and updating system of a block chain, which relate to the technical field of block chains, and the method comprises the following steps: calculating page id according to key (record id) of the updated data needing to be read; calculating a logic file id according to the page id; finding out a physical file id in the disk according to the logical file id and the mapping relation; a data read update operation is performed. Aiming at the characteristics of the block chain, the target position in the disk is quickly found in a mapping mode during data reading and updating, and the data reading and updating performance is greatly improved.
Description
Technical Field
The present invention relates to the field of block chain technology, and in particular, to a method and system for reading and updating data of a block chain.
Background
Currently, the mainstream database storage technologies include an Access database, a MySQL database, a SqlServer database, and an Oracle database, wherein the Access database is released by microsoft, is a database of an associated data management system, and is usually used to develop a Web application. The MySQL database is a database of a small database management system, and the development company is the MySQLAB company in sweden, and MySQL is widely applied to small and medium-sized websites on the Internet. The SqlServer database is characterized by a real client/server system structure and a graphical user interface, so that the database management mode is more intuitive and simpler. The Oracle database is one of the more typical CLIENT/SERVER (CLIENT/Server) or B/S architecture databases.
However, the above database management techniques are not efficient when applied to the blockchain, because the blockchain system does not need to support the deletion operation, and the above database management techniques all support the deletion operation, so that the current storage techniques have many useless designs when applied to the blockchain, resulting in low storage performance.
Disclosure of Invention
The embodiment of the invention provides a data reading and updating method and system of a block chain, which can solve the problems in the prior art.
The invention provides a data reading and updating method of a block chain, wherein data in the block chain is stored in a disk, the disk is divided into a plurality of file files with the same size, the file files are distributed to corresponding services according to needs, a logical file id and a physical file id are respectively obtained after continuous numbering is carried out in the services and the disk, the physical file id and the logical file id have a mapping relation, the file files comprise a plurality of page pages with the same size, and the page pages comprise a plurality of record records with the same size;
the method comprises the following steps:
reading record id of the updated data as required to calculate page id;
calculating a logic file id according to the page id;
finding out a physical file id in the disk according to the logical file id and the mapping relation;
a data read update operation is performed.
The invention also provides a data reading and updating system of the block chain, which comprises:
the page id calculation module is used for reading record id of the updated data according to the requirement and calculating page id;
the file id calculation module is used for calculating a logic file id according to the page id;
the disk position determining module is used for finding out a physical file id in the disk according to the logical file id and the mapping relation; and
and the reading updating execution module is used for executing data reading updating operation.
The invention discloses a data reading and updating method and a data reading and updating system of a block chain, wherein the method comprises the following steps: reading record id of the updated data as required to calculate page id; calculating a logic file id according to the page id; finding out a physical file id in the disk according to the logical file id and the mapping relation; a data read update operation is performed. Aiming at the characteristics of the block chain, the target position in the disk is quickly found in a mapping mode during data reading and updating, and the data reading and updating performance is greatly improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a diagram of a magnetic disk storage structure.
FIG. 2 is a flowchart illustrating a method for reading and updating data of a blockchain according to the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Before describing the data reading and updating method of the present invention, a disk storage structure of a storage system implementing the method will be described.
As shown in fig. 1, the formation of the disk storage structure is as follows:
1. formatting a magnetic disk: each disk is formatted, the disk is divided into a plurality of files (files) with the same size, the files are all in an unallocated state (for example, the disk C in the figure is divided into 7 files), the sizes of the files are the same, and therefore the number of the files is in direct proportion to the disk space.
2. And (3) disk file allocation: and distributing the files to corresponding services according to service requirements. For example, in the figure, the disk D allocates the file0, the file 1 and the file 3 to the a service, allocates the file 2 and the file 4 to the B service and allocates the file 5 to the C service.
A logic file id: within a service (e.g., a, B, C), numbering is continued from 0.
Physical file id: in the disks (such as disk D, disk E and disk F), serial numbers are started from 0, and a plurality of disks are managed through a disk group to map the physical file id and the logical file id. For example, the service a5 file maps to file 4 of disk E.
3. Paging files: the file is divided into pages (pages) according to a fixed size, and the pages are divided into records (records) according to the fixed size.
For example, a file of service A is divided into 10 pages, and one page is divided into 5 records. Therefore, the page id can be directly calculated according to the record id, the logical file id can be directly calculated according to the page id, the disk position can be found according to the mapping relation between the logical file id and the physical file id, and the method is very efficient.
According to the above process, the API interface provided by the present invention is as follows:
template<typename RECORD_TYPE>
ACE_INT32 Update(const ACE_UINT64 nRecordID,RECORD_TYPE&rRecord)
wherein the updating operation corresponding to the API interface is as follows:
const ACE _ UINT64 nRecordID: the record id must be nRecordID that has been append,
RECORD _ TYPE & rRecord: the parameters are data to be stored, the data types are defined by users, and the parameters need to be consistent with the data types in the application operation
template<typename RECORD_TYPE>
ACE_INT32 Read(RECORD_TYPE&rRecord,const ACE_UINT64nRecordID)
The corresponding read operation is:
nRecordID: RECORD id is the nRecordID RECORD _ TYPE & rRecord that must have been apppended: keep consistent with the data structure of the Append operation, otherwise there is a risk of memory out-of-range
The data reading and updating method of the present invention is explained in detail below.
Referring to fig. 2, the block chain data reading and updating method of the present invention includes the following steps:
1. and judging whether the record id needing to read the updated data is legal or not, and if the record id is not written with the data, the reading and updating operation fails.
2. The page id is calculated from the record id.
3. The file id is calculated from the page id.
4. And finding the position of the disk according to the file id and the file type.
5. A data read update operation is performed.
The file comprises a file, a page id/m, a file id/m, wherein the page id is record id/n, the file id is page id/m, n is the number of records in one page, and m is the number of pages in one file.
Based on the same inventive concept, the invention also provides a data reading and updating system of the block chain, and the implementation of the system can refer to the implementation of the method, and repeated details are not repeated. The system comprises:
and the data key validity judging module is used for judging whether the record id needing to read the updated data is legal or not.
And the page id calculating module is used for calculating the page id according to the record id when the record id of the updated data is required to be read is legal.
And the file id calculating module is used for calculating the file id according to the page id.
And the disk position determining module is used for determining the position of the corresponding physical file id according to the file id and the file type.
And the reading updating execution module is used for reading and updating data at the id position of the physical file according to the corresponding offset and length.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.
Claims (8)
1. The data reading and updating method of the block chain is characterized in that data in the block chain is stored in a disk, the disk is divided into a plurality of file files with the same size, the file files are distributed to corresponding services according to needs, a logical file id and a physical file id are obtained after continuous numbering is carried out in the services and the disk respectively, the physical file id and the logical file id have a mapping relation, the file files comprise a plurality of page pages with the same size, and the page pages comprise a plurality of record records with the same size;
the method comprises the following steps:
reading record id of the updated data as required to calculate page id;
calculating a logic file id according to the page id;
finding out a physical file id in the disk according to the logical file id and the mapping relation;
a data read update operation is performed.
2. The method according to claim 1, wherein before calculating the page id, the method further comprises determining whether a record id of the update data to be read is legal, and after determining that the record id of the update data to be read is legal, calculating the page id.
3. The data reading and updating method of the block chain according to claim 1, wherein the page id and the logical file id are respectively obtained by calculating according to the following formula:
page id=record id/n
logical file id is page id/m
Wherein n is the number of records in a page, and m is the number of pages in a file.
4. The method for reading and updating data of a blockchain according to claim 1, wherein after obtaining the physical file id, the data reading and updating operation is performed at the position of the physical file id according to the corresponding offset and length.
5. A data read update system of a blockchain to which the data read update method of a blockchain in claim 1 is applied, characterized in that the system comprises:
the page id calculation module is used for reading record id of the updated data according to the requirement and calculating page id;
the file id calculation module is used for calculating a logic file id according to the page id;
the disk position determining module is used for finding out a physical file id in the disk according to the logical file id and the mapping relation; and
and the reading updating execution module is used for executing data reading updating operation.
6. The data reading and updating system of the block chain according to claim 5, further comprising a data key validity judging module, wherein the data key validity judging module is configured to judge whether a record id of the updated data to be read is legal, and after the data key validity judging module determines that the record id of the updated data to be read is legal, the page id calculating module calculates the page id.
7. The system for reading and updating data of a block chain according to claim 5, wherein the page id calculation module and the file id calculation module calculate the page id and the logical file id by the following formulas, respectively:
page id=record id/n
logical file id is page id/m
Wherein n is the number of records in a page, and m is the number of pages in a file.
8. The system according to claim 5, wherein the read update execution module performs a data read update operation at a physical file id position according to the corresponding offset and length after obtaining the physical file id.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010717510.6A CN111858602B (en) | 2020-07-23 | 2020-07-23 | Data reading and updating method and system of block chain |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010717510.6A CN111858602B (en) | 2020-07-23 | 2020-07-23 | Data reading and updating method and system of block chain |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111858602A true CN111858602A (en) | 2020-10-30 |
CN111858602B CN111858602B (en) | 2023-04-21 |
Family
ID=72949819
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010717510.6A Active CN111858602B (en) | 2020-07-23 | 2020-07-23 | Data reading and updating method and system of block chain |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111858602B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108628942A (en) * | 2018-03-27 | 2018-10-09 | 深圳市网心科技有限公司 | The digital independent and wiring method of block chain node device, distributed data base |
US20190116142A1 (en) * | 2017-10-17 | 2019-04-18 | American Express Travel Related Services Company, Inc. | Messaging balancing and control on blockchain |
CN110011800A (en) * | 2018-11-07 | 2019-07-12 | 阿里巴巴集团控股有限公司 | A kind of block chain method for reading data and device |
-
2020
- 2020-07-23 CN CN202010717510.6A patent/CN111858602B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20190116142A1 (en) * | 2017-10-17 | 2019-04-18 | American Express Travel Related Services Company, Inc. | Messaging balancing and control on blockchain |
CN108628942A (en) * | 2018-03-27 | 2018-10-09 | 深圳市网心科技有限公司 | The digital independent and wiring method of block chain node device, distributed data base |
CN110011800A (en) * | 2018-11-07 | 2019-07-12 | 阿里巴巴集团控股有限公司 | A kind of block chain method for reading data and device |
Also Published As
Publication number | Publication date |
---|---|
CN111858602B (en) | 2023-04-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107273455B (en) | Block chain data access method and device | |
US6668263B1 (en) | Method and system for efficiently searching for free space in a table of a relational database having a clustering index | |
CN110096227B (en) | Data storage method, data processing device, electronic equipment and computer readable medium | |
US8135688B2 (en) | Partition/table allocation on demand | |
CN111125447A (en) | Metadata access method, device and equipment and readable storage medium | |
CN110765076B (en) | Data storage method, device, electronic equipment and storage medium | |
US20040103123A1 (en) | System and method for scaleable multiplexed transactional log recovery | |
CN111324665A (en) | Log playback method and device | |
CN114936188A (en) | Data processing method and device, electronic equipment and storage medium | |
CN111680019A (en) | Data capacity expansion method and device for block chain | |
CN107506466A (en) | A kind of small documents storage method and system | |
US7797290B2 (en) | Database reorganization program and method | |
CN110955658B (en) | Data organization and storage method based on Java intelligent contract | |
CN109542860B (en) | Service data management method based on HDFS and terminal equipment | |
CN111858602B (en) | Data reading and updating method and system of block chain | |
CN110928923A (en) | Data storage method and system based on block chain | |
CN111858603B (en) | Block chain data writing method and system | |
US7949632B2 (en) | Database-rearranging program, database-rearranging method, and database-rearranging apparatus | |
CN115203211A (en) | Unique hash sequence number generation method and system | |
CN105242985B (en) | Data recovery method and device | |
CN109241011B (en) | Virtual machine file processing method and device | |
CN112131226A (en) | Index obtaining method, data query method and related device | |
CN112015672A (en) | Data processing method, device, equipment and storage medium in storage system | |
CN113411395B (en) | Access request routing method, device, computer equipment and storage medium | |
CN115328878B (en) | Log data storage system, method, device and medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
PP01 | Preservation of patent right | ||
PP01 | Preservation of patent right |
Effective date of registration: 20231026 Granted publication date: 20230421 |
|
PD01 | Discharge of preservation of patent | ||
PD01 | Discharge of preservation of patent |
Date of cancellation: 20240307 Granted publication date: 20230421 |