Summary of the invention
The purpose of the application is to provide method, system, equipment and the computer-readable storage of a kind of block chain reading data
Medium, for promoting block chain entirety reading performance.
In order to solve the above technical problems, the application provides a kind of method of block chain reading data, this method comprises:
Receive data read request;
The keyword of data to be read is determined according to the data read request;
Bottom LSM storage engines are called successively to search the keyword in memory database and volatile data base corresponding
Data item;
If not finding the corresponding data item of the keyword, in each level of file system described in parallel search
The corresponding data item of keyword.
Optionally, described in each level of file system the corresponding data item of keyword described in parallel search it
Afterwards, further includes:
Judge whether to find the corresponding data item of the keyword;
If it is not, then returning to miscue information;
If so, whether the data item that judgement is found is unique;
When the data item is not unique, the minimum data item of the level is returned.
Optionally, further includes:
Receive data write request;
Call the bottom LSM storage engines that journal file is written in the corresponding data to be written of the data write request
In, and the data to be written are written in the memory database;
When the data stored in the memory database reach predetermined threshold, secondary union operation is executed, it will be described
The data persistence stored in memory database is into the file system.
Optionally, after the secondary union operation of execution, further includes:
Obtain block chain state of a process information;
When the block chain state of a process is idle, the legacy data in the journal file is recycled.
Optionally, the storage medium of the file system is solid state hard disk;
The size of SSTable file is at least one in 1mb, 2mb, 4mb in the file system.
Optionally, the corresponding data item of keyword described in parallel search in each level of file system, comprising:
By Memory Mapping File mode by the maps data items in the zero layer grade of the file system to the memory number
According in library;
The corresponding data item of the keyword is searched in the memory database.
The application also provides a kind of system of block chain reading data, which includes:
First receiving module, for receiving data read requests;
Determining module, for determining the keyword of data to be read according to the data read request;
First calling module, for calling bottom LSM storage engines successively to look into memory database and volatile data base
Look for the corresponding data item of the keyword;
Parallel search module, for when not finding the corresponding data item of the keyword, in each of file system
The corresponding data item of keyword described in parallel search in level.
Optionally, further includes:
First judgment module finds the corresponding data item of the keyword for judging whether;
First return module, for returning to miscue information when not finding the corresponding data item of the keyword;
Second judgment module, for judging the number found when finding the corresponding data item of the keyword
It is whether unique according to item;
Second return module, for returning to the minimum data item of the level when the data item is not unique.
The application also provides a kind of block chain reading data equipment, which includes:
Memory, for storing computer program;
Processor realizes the side of the block chain reading data as described in any of the above-described when for executing the computer program
The step of method.
The application also provides a kind of computer readable storage medium, and calculating is stored on the computer readable storage medium
Machine program, realizing the method for block chain reading data as described in any of the above-described when the computer program is executed by processor
Step.
The method of block chain reading data provided herein, comprising: receive data read request;It is asked according to reading data
Seek the keyword for determining data to be read;Bottom LSM storage engines are called successively to look into memory database and volatile data base
Look for the corresponding data item of keyword;If not finding the corresponding data item of the keyword, in each level of file system
The corresponding data item of middle parallel search keyword.
Technical solution provided herein, by not finding keyword pair in memory database and volatile data base
When the data item answered, the corresponding data item of parallel search keyword in each level of file system, to reduce the reading of block chain
The time overhead of operation, and the use of block chain is supplied in the form of plug-in unit, it greatly reduces and is led since LSM level is excessive
The slow problem of the read-write of cause, makes LSM reading performance have the promotion of highly significant.The application additionally provides a kind of block chain number simultaneously
According to the system, equipment and computer readable storage medium of reading, there is above-mentioned beneficial effect, details are not described herein.
Specific embodiment
The core of the application is to provide method, system, equipment and the computer-readable storage of a kind of block chain reading data
Medium, for promoting block chain entirety reading performance.
To keep the purposes, technical schemes and advantages of the embodiment of the present application clearer, below in conjunction with the embodiment of the present application
In attached drawing, the technical scheme in the embodiment of the application is clearly and completely described, it is clear that described embodiment is
Some embodiments of the present application, instead of all the embodiments.Based on the embodiment in the application, those of ordinary skill in the art
Every other embodiment obtained without making creative work, shall fall in the protection scope of this application.
Referring to FIG. 1, Fig. 1 is a kind of flow chart of the method for block chain reading data provided by the embodiment of the present application.
It specifically comprises the following steps:
S101: data read request is received;
Block chain stores data by LSM Tree structure, and LSM Tree is a kind of data knot based on the hard disk
Structure can reduce hard disk tracking expense, and can provide the high speed to file in longer time compared with B+tree significantly
It is inserted into (deletion).However LSM-tree is in some cases, especially when inquiry needs quick response, performance is bad.Usually
LSM-tree is suitable for indexing the insertion application system more more frequent than retrieving.
When the size of data stored in memory database reaches preset predetermined threshold, LSM storage engines can execute secondary
Union operation (Minor Compaction) is wanted, by the data persistence in memory database into file system, please refers to figure
2, Fig. 2 execute the schematic diagram of secondary union operation for LSM storage engines, as shown in Fig. 2, secondary union operation be choose one or
The data stored in multiple small, adjacent dump SSTable files and 0 or multiple memory databases are merged into one bigger
SSTable file, Minor Compaction's the result is that less and bigger SSTable file;
When there are following three kinds of situations, secondary union operation operation can be triggered:
1) when 0 layer of number of files is more than the scheduled upper limit;
2) when the maximum capacity limitation that the file total size of a certain layer has been more than this layer;
3) when some file is invalid read number it is excessive;
Referring to FIG. 3, Fig. 3 is the schematic diagram that LSM storage engines execute main union operation, as shown in figure 3, main merge
Operating (Major Compaction) is by the SSTable file of multiple low-levels and the SSTable for being merged into a high-level
File, under normal circumstances, the main union operation time can be persistently long, and whole process can consume a large amount of system resources, to upper
Layer service has bigger influence, and after data volume increases, level level can increase therewith, and LSM is caused to read scale-up problem
It is more obvious, therefore this application provides a kind of methods of block chain reading data, for solving the above problems.
S102: the keyword of data to be read is determined according to data read request;
S103: calling bottom LSM storage engines, successively search key is corresponding in memory database and volatile data base
Data item;
Value based on the data to be read is likely to be present in memory database, volatile data base or file system, therefore
The embodiment of the present application calls bottom LSM storage engines after the keyword for determining data to be read according to data read request
The successively corresponding data item of search key in memory database and volatile data base, if finding, directly returning should
The read operation of data can be completed in data item.
S104: if not finding the corresponding data item of keyword, parallel search is closed in each level of file system
The corresponding data item of key word.
Optionally, the parallel search keyword corresponding data item mentioned herein in each level of file system,
It is specifically as follows:
By Memory Mapping File mode by the maps data items in the zero layer grade of file system into memory database;
The corresponding data item of search key in memory database;
Since 0 layer of level is special one layer, SSTable file executes Minor Compaction by memtable
Operation directly obtains, thus the key in 0 layer of level be it is unordered, a LSM read operation may be read in level 0
Take multiple files, all SSTable files read in 0 layer of level that we can be serial under extreme scenes, in level 0
Read operation can also execute concurrent read operation.But the SSTable file storage in level 0 is smaller, therefore the application
Embodiment takes the file in 0 layer of level to promote reading performance by the mode that mmap mode maps to memory;
It optionally, can be in each level in file system after the corresponding data item of parallel search keyword
Execute following steps:
Judge whether to find the corresponding data item of keyword;
If it is not, then returning to miscue information;
If so, whether the data item that judgement is found is unique;
When data item is not unique, the minimum data item of level is returned.
Optionally, when data item is unique, the data item is directly returned;
The purpose mentioned herein that the minimum data item of level is returned when data item is not unique is, file system middle layer
The lower data of grade are newer, therefore return to the minimum data item of level;
Preferably, due to when some file is invalid read number it is excessive when can trigger LSM Major Compaction operation,
And concurrently read characteristic undoubtedly and can amplify that file is invalid reads bring and influence, therefore the embodiment of the present application can also concurrently read scheme
The middle condition by the Major Compaction that file is invalid reads triggering LSM removes, and reads number to avoid file is invalid and excessively leads
Problem is lost in performance caused by the Major Compaction operation of cause;
Preferably, since solid state hard disk has random write performance advantage, the block chain node benefit of solid state hard disk is used
It more can increase the reading performance of LSM with this programme;On this basis, the SSTable file size that block chain LSM can also be stored
It is adjusted by 64kb to 1mb, 2mb or 4mb, so that SSTable file is more suitable for solid state hard disk storage medium;
It, completely can be with since solid state hard disk storage medium common on current market can support the literacy of 100,000 iops
Meet the concurrently reading characteristic based on level level, therefore technical solution provided herein enable to solid state hard disk with
Machine-readable performance is played, and will need originally to read N layers of time, is uniformly optimized for reading 1 layer of time, since solid state hard disk possesses
Higher iops ability, and due to the lesser reason of block chain reading db data volume per second, so that LSM concurrently reads scheme in block
It can be put to good use well in chain project;
Based on the above-mentioned technical proposal, the method for a kind of block chain reading data provided herein, by memory number
When according to the corresponding data item of keyword is not found in library and volatile data base, the parallel search in each level of file system
The corresponding data item of keyword to reduce the time overhead of block chain read operation, and is supplied to block chain in the form of plug-in unit and makes
With, greatly reduce due to LSM level it is excessive caused by read and write slow problem, so that LSM reading performance is had highly significant
It is promoted.
It on the basis of the above embodiments, can also include step as shown in Figure 4 when receiving data writing commands
Suddenly, it is illustrated below with reference to Fig. 4.
Referring to FIG. 4, Fig. 4 is the process of the method for the storage of another kind block chain data provided by the embodiment of the present application
Figure.
Itself specifically includes the following steps:
S401: data write request is received;
S402: calling bottom LSM storage engines to write data into the corresponding data write-in journal file to be written of request,
And it is written into data write-in memory database;
S403: when the data stored in memory database reach predetermined threshold, secondary union operation is executed, by memory
The data persistence stored in database is into file system.
Secondary union operation mentioned herein is the Minor Compaction being mentioned above;
Optionally, after executing secondary union operation, following steps can also be performed:
Obtain block chain state of a process information;
When block chain state of a process is idle, the legacy data in journal file is recycled.
Legacy data of the embodiment of the present application when block chain process is idle in recycling journal file, to ensure storage overhead not
Can infinitely it be amplified.
Referring to FIG. 5, Fig. 5 is a kind of structure chart of the system of block chain reading data provided by the embodiment of the present application.
The system may include:
First receiving module 100, for receiving data read requests;
Determining module 200, for determining the keyword of data to be read according to data read request;
First calling module 300, for calling bottom LSM storage engines successively in memory database and volatile data base
The corresponding data item of search key;
Parallel search module 400, for when not finding the corresponding data item of keyword, in each layer of file system
The corresponding data item of parallel search keyword in grade.
Referring to FIG. 6, Fig. 6 is the structure of the system of another kind block chain reading data provided by the embodiment of the present application
Figure.
The system can also include:
First judgment module finds the corresponding data item of keyword for judging whether;
First return module, for returning to miscue information when not finding the corresponding data item of keyword;
Second judgment module, for whether judging the data item found when finding the corresponding data item of keyword
Uniquely;
Second return module, for when data item is not unique, returning to the minimum data item of level.
The system can also include:
Second receiving module, for receiving data write request;
Second calling module is write for calling bottom LSM storage engines to write data into the corresponding data to be written of request
Enter in journal file, and is written into data write-in memory database;
Execution module, for executing secondary union operation when the data stored in memory database reach predetermined threshold,
With by the data persistence stored in memory database into file system.
The system can also include:
Module is obtained, for obtaining block chain state of a process information;
Recycling module, for recycling the legacy data in journal file when block chain state of a process is idle.
Optionally, the storage medium of this document system can be solid state hard disk;
The size of SSTable file can be at least one in 1mb, 2mb, 4mb in this document system.
The parallel search module 400 may include:
Mapping submodule, for by Memory Mapping File mode by the maps data items in the zero layer grade of file system extremely
In memory database;
Submodule is searched, for the corresponding data item of search key in memory database.
Each component part in system above can be applied in embodiment below:
First receiving module receives data read request;Determining module determines data to be read according to data read request
Keyword;It is crucial that first calling module calls bottom LSM storage engines successively to search in memory database and volatile data base
The corresponding data item of word;When not finding the corresponding data item of keyword, each layer of the parallel search module in file system
The corresponding data item of parallel search keyword in grade.
First judgment module judges whether to find the corresponding data item of keyword;When not finding the corresponding number of keyword
When according to item, the first return module returns to miscue information;When finding the corresponding data item of keyword, the second judgment module
Judge whether the data item found is unique;When data item is not unique, the second return module returns to the minimum data item of level.
Second receiving module receives data write request;Second calling module calls bottom LSM storage engines to write data
Enter to request in corresponding data write-in journal file to be written, and is written into data write-in memory database;When memory number
When reaching predetermined threshold according to the data stored in library, execution module executes secondary union operation, will store in memory database
Data persistence into file system;It obtains module and obtains block chain state of a process information;When block chain state of a process
Legacy data when being idle, in recycling module recycling journal file.
Referring to FIG. 7, Fig. 7 is a kind of structure chart of block chain reading data equipment provided by the embodiment of the present application.
The block chain reading data equipment 700 can generate bigger difference because configuration or performance are different, may include
One or more processors (central processing units, CPU) 722 are (for example, one or more are handled
Device) and memory 732, one or more storage application programs 742 or data 744 storage medium 730 (such as one or
More than one mass memory unit).Wherein, memory 732 and storage medium 730 can be of short duration storage or persistent storage.It deposits
Storage may include one or more modules (diagram does not mark) in the program of storage medium 730, and each module may include
To the series of instructions operation in device.Further, central processing unit 722 can be set to communicate with storage medium 730,
The series of instructions operation in storage medium 730 is executed in block chain reading data equipment 700.
Block chain reading data equipment 700 can also include one or more power supplys 727, one or more have
Line or radio network interface 750, one or more input/output interfaces 758, and/or, one or more operation systems
System 741, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM etc..
Step in the method for block chain reading data described in above-mentioned Fig. 1 to Fig. 4 is by block chain reading data equipment
It is realized based on the structure shown in Fig. 7.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description,
The specific work process of device and module, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In several embodiments provided herein, it should be understood that disclosed device, device and method, it can be with
It realizes by another way.For example, the apparatus embodiments described above are merely exemplary, for example, the division of module,
Only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple module or components can be with
In conjunction with or be desirably integrated into another system, or some features can be ignored or not executed.Another point, it is shown or discussed
Mutual coupling, direct-coupling or communication connection can be through some interfaces, the INDIRECT COUPLING of device or module or
Communication connection can be electrical property, mechanical or other forms.
Module may or may not be physically separated as illustrated by the separation member, show as module
Component may or may not be physical module, it can and it is in one place, or may be distributed over multiple networks
In module.Some or all of the modules therein can be selected to achieve the purpose of the solution of this embodiment according to the actual needs.
It, can also be in addition, can integrate in a processing module in each functional module in each embodiment of the application
It is that modules physically exist alone, can also be integrated in two or more modules in a module.Above-mentioned integrated mould
Block both can take the form of hardware realization, can also be realized in the form of software function module.
If integrated module is realized and when sold or used as an independent product in the form of software function module, can
To be stored in a computer readable storage medium.Based on this understanding, the technical solution of the application substantially or
Say that all or part of the part that contributes to existing technology or the technical solution can embody in the form of software products
Out, which is stored in a storage medium, including some instructions are used so that a computer equipment
The whole of (can be personal computer, funcall device or the network equipment etc.) execution each embodiment method of the application
Or part steps.And storage medium above-mentioned include: USB flash disk, mobile hard disk, read-only memory (Read-Only Memory,
ROM), random access memory (Random Access Memory, RAM), magnetic or disk etc. are various can store program
The medium of code.
It to a kind of method of block chain reading data provided herein, system, equipment and computer-readable deposits above
Storage media is described in detail.Specific examples are used herein to illustrate the principle and implementation manner of the present application,
The description of the example is only used to help understand the method for the present application and its core ideas.It should be pointed out that for this technology
For the those of ordinary skill in field, under the premise of not departing from the application principle, several improvement can also be carried out to the application
And modification, these improvement and modification are also fallen into the protection scope of the claim of this application.
It should also be noted that, in the present specification, relational terms such as first and second and the like be used merely to by
One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation
Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning
Covering non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes that
A little elements, but also including other elements that are not explicitly listed, or further include for this process, method, article or
The intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arranged
Except there is also other identical elements in the process, method, article or equipment for including element.