CN111858602B - Data reading and updating method and system of block chain - Google Patents

Data reading and updating method and system of block chain Download PDF

Info

Publication number
CN111858602B
CN111858602B CN202010717510.6A CN202010717510A CN111858602B CN 111858602 B CN111858602 B CN 111858602B CN 202010717510 A CN202010717510 A CN 202010717510A CN 111858602 B CN111858602 B CN 111858602B
Authority
CN
China
Prior art keywords
file
page
data
read
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.)
Active
Application number
CN202010717510.6A
Other languages
Chinese (zh)
Other versions
CN111858602A (en
Inventor
王保春
邓泰生
娄俊凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Yongqi Blockchain Technology Co ltd
Original Assignee
Zhejiang Yongqi Blockchain Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zhejiang Yongqi Blockchain Technology Co ltd filed Critical Zhejiang Yongqi Blockchain Technology Co ltd
Priority to CN202010717510.6A priority Critical patent/CN111858602B/en
Publication of CN111858602A publication Critical patent/CN111858602A/en
Application granted granted Critical
Publication of CN111858602B publication Critical patent/CN111858602B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE 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/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a data reading and updating method and a system of a block chain, which relate to the technical field of block chains, and the method comprises the following steps: the page id is calculated according to key (record id) of the update data which is required to be read; calculating a logical file id according to the page id; finding out the 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 invention can quickly find the target position in the disk in a mapping mode when the data is read and updated, thereby greatly improving the data reading and updating performance.

Description

Data reading and updating method and system of block chain
Technical Field
The present invention relates to the field of blockchain technologies, and in particular, to a method and a system for reading and updating data of a blockchain.
Background
The current mainstream database storage technology includes an Access database, a MySQL database, an sql server database and an Oracle database, wherein the Access database is published by microsoft and is a database of a related data management system, which is usually used for developing Web applications. The MySQL database is a database of a small database management system, and its development company is MySQLAB company in sweden, and MySQL is widely used in small and medium websites on the Internet. The SqlServer database is characterized by a real client/server architecture and is a graphical user interface, so that the database management mode is more visual and simple. The Oracle database is one of the databases of a more typical CLIENT/SERVER (CLIENT/SERVER) or B/S architecture.
However, the above database management techniques are not efficient in the blockchain, because the blockchain system does not need to support the delete operation, and the above database management techniques support the delete operation, so that there are many useless designs when the current storage techniques are applied in the blockchain, resulting in poor storage performance.
Disclosure of Invention
The embodiment of the invention provides a data reading and updating method and system for 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 the need, 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 comprises a plurality of page pages with the same size, and the page comprises a plurality of records record with the same size;
the method comprises the following steps:
the page id is calculated according to the record id of the update data which is required to be read;
calculating a logical file id according to the page id;
finding out the 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 following steps:
the page id calculation module is used for calculating the page id according to the record id of the update data read as required;
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 the physical file id in the disk according to the logical file id and the mapping relation; and
and the reading update execution module is used for executing data reading update operation.
The invention relates to a data reading and updating method and a system of a block chain, wherein the method comprises the following steps: the page id is calculated according to the record id of the update data which is required to be read; calculating a logical file id according to the page id; finding out the 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 invention can quickly find the target position in the disk in a mapping mode when the data is read and updated, thereby greatly improving the data reading and updating performance.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a block diagram of disk storage.
FIG. 2 is a flow chart of a method for updating data read of a blockchain in the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Before describing the data reading and updating method of the present invention, a disk storage structure of a storage system for implementing the method will be described.
As shown in fig. 1, the disk storage structure is formed as follows:
1. disk formatting: each disk is formatted to divide the disk into a number of files of equal size, which are unallocated (e.g., disk C, split into 7 files in the figure), which are of equal size, so that the number of files is proportional to disk space.
2. Disk file allocation: and distributing the files to corresponding services according to service requirements. In the figure, the disk D allocates file 0, file 1, and file 3 to the a service, allocates file 2, and file 4 to the B service, and allocates file 5 to the C service.
Logical file id: within the traffic (e.g., a, B, C), numbering continues from 0.
Physical file id: in the disk (e.g., disk D, disk E, disk F), serial numbers are given from 0, and a mapping is established between the physical file id and the logical file id by disk group management among the plurality of disks. For example, the service A5 file maps to file 4 of disk E.
3. File paging: the file is divided into pages (pages) of a fixed size and pages into records (records) of a fixed size.
For example, the 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, and the disk position can be found according to the mapping relation between the logical file id and the physical file id, so that 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)
the updating operation corresponding to the API interface is as follows:
const ACE_UINT64 nRecordID: the record id is an nrecond that must have been applied,
record_type & rrecor: the parameters are data to be stored, the data types are defined by the user, and the data types are required 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 nRecordID record_type & rRecord which must be already applied: the data structure of the application operation is kept consistent, otherwise the risk of memory out-of-range is caused
The data reading and updating method of the present invention will be described in detail.
Referring to fig. 2, the blockchain data reading and updating method of the present invention includes the steps of:
1. judging whether the record id of the update data to be read is legal or not, and if the record id is not written with the data, failing to read the update operation.
2. And calculating the page id according to the record id.
3. And calculating the file id according to 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.
Wherein, page id=record id/n, file id=page id/m, where 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 blockchain, and the implementation of the system can refer to the implementation of the method, and the repetition is omitted. The system comprises:
and the data key validity judging module is used for judging whether the record id of the update data to be read is legal or not.
The page id calculation module is used for calculating the page id according to the record id when the record id of the update data to be read is legal.
And the file id calculation 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 update execution module is used for carrying out data reading update operation at the physical file id position 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. It is therefore intended that the following claims be interpreted as including the 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 modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.

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 requirements, logical file ids and physical file ids are respectively obtained after continuous numbering is carried out in the services and the disk, the physical file ids and the logical file ids 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 records record with the same size;
the method comprises the following steps:
the page id is calculated according to the record id of the update data which is required to be read;
calculating a logical file id according to the page id;
finding out the 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 of claim 1, wherein before calculating the page id, the method further comprises determining whether a record id for which update data needs to be read is legal, and after determining that the record id for which update data needs to be read is legal, calculating the page id.
3. The method for updating the data read of the blockchain of claim 1, wherein the page id and the logical file id are obtained by the following calculation:
page id=record id/n
logical file id=page id/m
Where n is the number of records in a page, and m is the number of pages in a file.
4. The method for updating and reading data of a blockchain of claim 1, wherein after obtaining the physical file id, performing a data reading and updating operation at the physical file id according to the corresponding offset and length.
5. A data read update system for a blockchain employing the data read update method for a blockchain of claim 1, the system comprising:
the page id calculation module is used for calculating the page id according to the record id of the update data read as required;
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 the physical file id in the disk according to the logical file id and the mapping relation; and
and the reading update execution module is used for executing data reading update operation.
6. The system of claim 5, further comprising a data key validity determination module, wherein the data key validity determination module is configured to determine whether a record id for which update data needs to be read is valid, and the page id calculation module calculates a page id after the data key validity determination module determines that the record id for which update data needs to be read is valid.
7. The blockchain data reading and updating system of 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=page id/m
Where n is the number of records in a page, and m is the number of pages in a file.
8. The system of claim 5, wherein the read update execution module performs the data read update operation at the physical file id location based on the corresponding offset and length after the physical file id is obtained.
CN202010717510.6A 2020-07-23 2020-07-23 Data reading and updating method and system of block chain Active CN111858602B (en)

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 CN111858602A (en) 2020-10-30
CN111858602B true 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 (2)

* Cited by examiner, † Cited by third party
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
CN110011800A (en) * 2018-11-07 2019-07-12 阿里巴巴集团控股有限公司 A kind of block chain method for reading data and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10567320B2 (en) * 2017-10-17 2020-02-18 American Express Travel Related Services Company, Inc. Messaging balancing and control on blockchain

Patent Citations (2)

* Cited by examiner, † Cited by third party
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
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
CN111858602A (en) 2020-10-30

Similar Documents

Publication Publication Date Title
CN107026881B (en) Method, device and system for processing service data
US8135688B2 (en) Partition/table allocation on demand
CN104794123A (en) Method and device for establishing NoSQL database index for semi-structured data
US20100312749A1 (en) Scalable lookup service for distributed database
CN110765076B (en) Data storage method, device, electronic equipment and storage medium
US10552460B2 (en) Sensor data management apparatus, sensor data management method, and computer program product
US11263080B2 (en) Method, apparatus and computer program product for managing cache
CN106874459A (en) Stream data storage method and device
CN106844676A (en) Date storage method and device
EP3944556A1 (en) Block data access method and apparatus, and block data storage method and apparatus
CN109614411B (en) Data storage method, device and storage medium
CN111858602B (en) Data reading and updating method and system of block chain
CN109542860B (en) Service data management method based on HDFS and terminal equipment
CN111858603B (en) Block chain data writing method and system
CN112486988A (en) Data processing method, device, equipment and storage medium
US11194836B2 (en) Distributed data storage
CN110941587A (en) Space vector data storage method based on additional file and coordinate system conversion system
CN114996270A (en) Method and device for inquiring paging data
CN115454781A (en) Data visualization display method and system based on enterprise architecture system
CN115203211A (en) Unique hash sequence number generation method and system
CN109213760A (en) The storage of high load business and search method of non-relation data storage
US7949632B2 (en) Database-rearranging program, database-rearranging method, and database-rearranging apparatus
CN111506628B (en) Data processing method and device
CN108984615B (en) Data query method and system and storage medium
CN116010677B (en) Spatial index method and device and electronic equipment thereof

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

Effective date of registration: 20231026

Granted publication date: 20230421

PP01 Preservation of patent right
PD01 Discharge of preservation of patent

Date of cancellation: 20240307

Granted publication date: 20230421

PD01 Discharge of preservation of patent