CN103019951B - The recording method and device of ordered data, the access method of ordered data and device - Google Patents

The recording method and device of ordered data, the access method of ordered data and device Download PDF

Info

Publication number
CN103019951B
CN103019951B CN201110280428.2A CN201110280428A CN103019951B CN 103019951 B CN103019951 B CN 103019951B CN 201110280428 A CN201110280428 A CN 201110280428A CN 103019951 B CN103019951 B CN 103019951B
Authority
CN
China
Prior art keywords
interval
access
field
record
block
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
CN201110280428.2A
Other languages
Chinese (zh)
Other versions
CN103019951A (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.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201110280428.2A priority Critical patent/CN103019951B/en
Publication of CN103019951A publication Critical patent/CN103019951A/en
Application granted granted Critical
Publication of CN103019951B publication Critical patent/CN103019951B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

This application provides the recording method and device of a kind of ordered data, the access method of a kind of ordered data and device, recording method therein specifically includes: for ordered data, set up disk file;In this disk file, described ordered data is carried out record by block mode, the quantity of described piece is two or more, described recording process includes: record field interval and the record count in this field interval of corresponding ordered data in each piece, wherein, store in order according to described field at ordered data described in data base.Block that the application only need to be covered from the record corresponding to described specific paged content and corresponding interval read data, it is possible to accomplish to avoid reading redundant data, to reduce the I/O operation of disk as far as possible.

Description

The recording method and device of ordered data, the access method of ordered data and device
Technical field
The application relates to technical field of computer data storage, particularly relates to the record of a kind of ordered data Method and apparatus, the access method of a kind of ordered data and device.
Background technology
In order to reduce network traffics, improving the access speed of the page, application on site program tends not to one Show full content in Ye, but full content is divided into multipage according to certain rule and shows, every page The record of display some.This just requires that user initiates page access to server by the way of paging Request, by server according to the page number in accessing page request, obtains the most respectively from background data base Corresponding record data also show.
To assume to have in server background data base ID be 1,2,3,4,5,6,7,8,9 ..., 100 totally 100 records exist in disk, it is assumed that the size of paging is 10, i.e. every page display 10 notes Record.If active user asks the content of page 2, then it represents that the data that user needs be ID from 11 to The record data of 20.During accessing page request under receiving above-mentioned sight, existing server is usual First whole 100 disks recorded from backstage are read to internal memory, then filter out ID from internal memory From the record data of 11 to 20.
But, except ID is from 10 record data of 11 to 20, and other 90 record data are all It is that redundancy reads;For the angle of disk, the IO that the reading of described redundancy adds disk undoubtedly is (defeated Enter output, Input Output) operation, reduce the IO performance on backstage, cause consuming too much reading Take the time, thus add the process time of accessing page request;For the angle of internal memory, due to interior The total size deposited is limited, and described redundancy reading can take substantial amounts of internal memory, when paging sum is excessive, Even there will be the situation of low memory, and low memory easily causes, and disk read failure etc. is a series of asks Topic, thus reduce the process accuracy rate of accessing page request.
In a word, the technical problem that those skilled in the art urgently solve is needed exactly: how can carry The treatment effeciency of high accessing page request and process accuracy rate.
Summary of the invention
Technical problems to be solved in this application are to provide the recording method and device of a kind of ordered data, In disk file, by block mode, ordered data can be carried out record, wherein, each piece is used for recording phase Answer interval and the record count of ordered data.
Accordingly, present invention also provides access method and the device of a kind of ordered data, only need to be from described Block that record corresponding to specific paged content is covered and corresponding interval read data, it is possible to accomplish Avoid reading redundant data, to reduce the I/O operation of disk as far as possible.
In order to solve the problems referred to above, this application discloses the recording method of a kind of ordered data, including:
For ordered data, set up disk file;
In this disk file, by block mode, described ordered data being carried out record, the quantity of described piece is two Individual or multiple, described recording process includes:
Field interval and the record count in this field interval of corresponding ordered data is recorded in each piece, Wherein, store in order according to described field at ordered data described in data base.
Preferably, for different sequence indexs, in this disk file by corresponding ordered data record extremely Different blocks, wherein, described sequence index is the sort by of described ordered data.
On the other hand, disclosed herein as well is the recording equipment of a kind of ordered data, including:
Set up module, for for ordered data, set up disk file;And
Logging modle, carries out record by described ordered data by block mode in this disk file, described piece Quantity be two or more, including:
Block record sub module, for recording field interval and this field of corresponding ordered data in each piece Record count in interval, wherein, is carried out according to described field at ordered data described in data base in order Storage.
Preferably, described logging modle, specifically for for different sequence indexs, in this disk file Middle by blocks the most different for corresponding ordered data record, wherein, described sequence index is described ordered data Sort by.
On the other hand, disclosed herein as well is the access method of a kind of ordered data, including:
Receive user's paging access request for ordered data;
According to described paging access request, calculate the access skew of respective record and access length;
Access skew according to described and access length, obtaining record corresponding to described paging access request and cover Block and corresponding field interval;Wherein, described piece is positioned in the disk file of described ordered data, In each piece, record has field interval and the record count in this field interval of corresponding ordered data;
Field according to described covering is interval, accesses the ordered data in data base.
Preferably, described according to described access skew and access length, obtain described paging access request pair The step of the interval and corresponding block of field that the record answered covers, including:
Read the block in this disk file;
If described access offsets in the field interval of certain block, then interval with this block and corresponding field First piece and the corresponding first field interval covered as the record that described paging access request is corresponding;
If the described operation result accessing skew and described access length falls in the field interval of certain block, Then using cover as the record that described paging access request is corresponding between this block with corresponding field area second Block and corresponding second field are interval;Wherein, if described ordered data is ascending order arrangement, the most described fortune Calculate result be described access skew with described access length and, if described ordered data be ascending order arrange Row, the most described operation result is the described difference accessing skew and described access length;
By the continuous blocks between described first piece, first piece and second piece and second piece composition merge block and Corresponding field is interval, the block covered as the record that described paging access request is corresponding and corresponding field Interval.
Preferably, described piece has a corresponding block number, word recorded in the order of described block number and block Sequence consensus that section is interval or contrary;
First piece and corresponding first word of the record covering that described acquisition described paging access request is corresponding The step that section is interval, including:
From the beginning of minimum block number, it is successively read the block in this disk file, and carries out corresponding first Covering judgment, described first Covering judgment process includes:
Judge whether described access skew falls in the field interval of current block, the most then with this current block With first piece covered as the record that described paging access request is corresponding between corresponding field area and corresponding The first field interval, and terminate to read;Otherwise, block number adds 1, continues to read in this disk file Block;
Second piece and corresponding second word of the record covering that described acquisition described paging access request is corresponding The step that section is interval, including:
From the beginning of minimum block number, it is successively read the block in this disk file, and carries out corresponding second Covering judgment, described second Covering judgment process includes:
Judge whether the described operation result accessing skew and described access length falls in the field of current block In interval, the most then using corresponding as described paging access request between this current block with corresponding field area Cover second piece of record and corresponding second field interval;Otherwise, block number adds 1, continues to read Block in this disk file;Wherein, if described ordered data is ascending order arrangement, the most described operation result For described access skew with described access length and, if described ordered data be ascending order arrange, then institute Stating operation result is the described difference accessing skew and described access length.
Preferably, for different sequence indexs, to there being different blocks in this disk file, wherein, Described sequence index is the sort by of described ordered data;
Described according to described access skew and access length, obtain the record that described paging access request is corresponding The block covered and the step in corresponding field interval, including:
According to described paging access request, it is thus achieved that the access sequence index of corresponding ordered data;
Obtain from this disk file and access the sequence corresponding access block of index with described;
By reading described access block, obtain block and phase that record corresponding to described paging access request covers The field answered is interval.
Preferably, the field according to described covering is interval, the step of the ordered data in access data base, Including:
Judge that the field of described covering is interval and whether described paging access request mates, the most then from number Data are recorded according to reading is corresponding with the field interval of described covering in storehouse;Otherwise, read from data base With the field of described covering interval corresponding record data to internal memory, and to the record read in internal memory Data are screened, until the selection result is mated with described paging access request.
On the other hand, disclosed herein as well is the access device of a kind of ordered data, including:
Interface module, for receiving user's paging access request for ordered data;
Computing module, for according to described paging access request, calculating the access skew of respective record and visit Ask length;
Cover acquisition module, for accessing skew according to described and access length, obtain described paging and access Block and the corresponding field of the record covering that request is corresponding are interval;Wherein, described piece be positioned at described in have ordinal number According to disk file in, in each piece, record has the field of corresponding ordered data interval and this field is interval Interior record count;And
Access modules, interval for the field according to described covering, access the ordered data in data base
Compared with prior art, the application has the advantage that
Relative to disk file in prior art using ID or ID section as database index, the application is at magnetic The index of database of record paged content in dish file, specifically, by ordered data in disk file Carrying out record by block (block) mode, wherein, each block is for recording the word of corresponding ordered data Record count in section interval and this field interval;In practice, described field interval is often ID word The interval of section, so, when user asks specific paged content, is not that similar prior art is from data base Full content corresponding between the middle reading whole district, but only from the record corresponding to described specific paged content Field interval corresponding for covered block is read data, that is, the application reading is local content, Therefore, it is possible to accomplish to avoid reading redundant data as far as possible.
For the angle of disk, what described redundancy read avoids reducing the I/O operation of disk, carries The IO performance on high backstage, reduces the reading time such that it is able to reduce the process time of paging access request.
For the angle of internal memory, what described redundancy read avoid it can be avoided that the distributing in a large number and account for of internal memory With such that it is able to avoid the situation of the low memory occurred when paging sum is excessive, and low memory The series of problems such as the disk read failure caused such that it is able to the process improving accessing page request is accurate Rate.
The block covered at the record corresponding to described specific paged content and corresponding field interval with During described paging access request coupling, the record data read can directly be shown at foreground page by the application Face, and without committed memory, now, it is possible to improve internal memory performance to greatest extent.
Accompanying drawing explanation
Fig. 1 is the flow chart of the recording method embodiment of a kind of ordered data of the application;
Fig. 2 is the storage organization schematic diagram of the application a kind of B+ tree;
Fig. 3 is the structure chart of the recording equipment embodiment of a kind of ordered data of the application;
Fig. 4 is the flow chart of the access method embodiment of a kind of ordered data of the application;
Fig. 5 is the structure chart accessing device embodiment of a kind of ordered data of the application.
Detailed description of the invention
Understandable, below in conjunction with the accompanying drawings for enabling the above-mentioned purpose of the application, feature and advantage to become apparent from With detailed description of the invention, the application is described in further detail.
For making those skilled in the art be more fully understood that the application, the most simply introduce server background number According to the storage mode of ordered data in storehouse.
To assume to have in server background data base ID be 1,2,3,4,5,6,7,8,9 ..., 100 totally 100 records, it will usually use the date that these 100 records are carried out inverted order arrangement, Jing Guopai 100 records after sequence are referred to as ordered data, and these ordered datas are stored in magnetic the most in the form of a file In dish, as the Bigtable data base of Google used SSTable file record ordered data.
At present, server background data base generally uses the B+ tree storage ordered data of 2 layers, and B+ tree has There is a following characteristic:
1, during all keywords (upper ID in example) appear at the chained list of leafy node (dense index), And the keyword in chained list is precisely ascending order arrangement;
2, can not hit at non-leaf node;
3, non-leaf node is the equal of the index (sparse index) of leafy node, and leafy node is equivalent to It it is the data Layer of storage (keyword) data.
According to the above-mentioned characteristic of B+ tree, the content of disk file record may include that single data and leaf Data, wherein, single data is for storing the maximum ID and minimum ID of each leaf node and each Leaf node deviation post in disk file.Wherein, leaf data are for storing the ID of ascending order arrangement.
Above-mentioned disk file is capable of: provides any ID and can navigate to leaf node, then will The record digital independent of leaf node, to internal memory, filters out the scheme of the record data meeting user's request. Generally, the table of every data base has multiple such disk file, reads the when of record from up-to-date every time Disk file start to read by above method, if read less than, then read time new disk file. Here, the renewal time of up-to-date and secondary new Main Basis disk file defines and weighs.When reading one section During the data of data, such as ID1 to ID3, this segment data likely falls at disk file 1, disk literary composition In part 2 and disk file 3, now, also these 3 disk file respective reading results should be done once Multichannel is returned just can obtain final reading result.
In sum, in prior art, the structure of disk file can only carry out data according to ID or ID section The inquiry in storehouse is read, and cannot carry out the inquiry reading of data base according to the page number.Because in prior art The structure of disk file can only navigate to certain ID, and cannot navigate to certain record, so existing skill First all data must all be inquired about according to ID or ID section by art and read out, then enter in internal memory Row paging.
Example in correspondence, if user asks the content of page 2, what prior art inquiry was read is interior Hold [1,100];It practice, user's record corresponding to any one paged content to be accessed is only one In the range of individual, such as the record corresponding to the content of page 2 is only in the range of [11,20].
One of core idea of the embodiment of the present application is, is not disk file record in similar prior art ID or ID section is as the index of access data base's full content, but database of record in disk file The index of paged content, specifically, is entered ordered data by block (block) mode in disk file Row record, wherein, each block is interval for the field recording corresponding ordered data and this field is interval Interior record count.In practice, described field interval is often the interval of id field, so, When user asks specific paged content, the block read in corresponding disk file can be first passed through, obtain Take block and corresponding field interval that the record corresponding to described specific paged content is covered, then Data are read from described field interval corresponding for covering block.Read accordingly, with respect to from data base Taking the prior art of full content corresponding between the whole district, the application only need to be right from described specific paged content institute The field interval corresponding for the covered block of record answered is read data, it is possible to accomplish to avoid reading as far as possible Redundant data, to reduce the I/O operation of disk.
With reference to Fig. 1, it illustrates the flow chart of the recording method embodiment of a kind of ordered data of the application, Specifically may include that
Step 101, for ordered data, set up disk file;
Step 102, in this disk file, described ordered data is carried out record by block mode, described piece Quantity be two or more, described recording process may include that
In step 121, the field interval recording corresponding ordered data in each piece and this field interval Record count, wherein, stores according to described field in order at ordered data described in data base.
As the data record stored in order according to described field in data base, in practice, described Ordered data can apply to the various programs needing to access ordered data such as application on site program.Online should Referring mainly to band network by program connect or need network to connect the program that could use, it can be that B/S is (clear Look at device/server, Browser/Server) structure, as network mailbox, web blog, network microblog, Network forum, instant messaging, e-commerce website etc. need the program that browser is supported.Below mainly with Network mailbox is as the example of application scenarios, it practice, concrete application on site program is not added with by the application To limit, other application scenarios please be cross-referenced.
With reference to table 1, it illustrates data list structure conventional in current network mailbox and recording mode.
Table 1
ID Contact person Theme Date
1 Zhang San Theme 1 2011-9-6 10:31
2 Li Si Theme 2 2011-9-5 12:30
3 Zhang San Theme 1 2011-9-5 08:30
4 King five Theme 3 2011-9-3 19:30
... ... ... ...
N Contact person N Theme N Date N
Tables of data shown in table 1 was made up of ID, contact person, theme and date, wherein, and conventional ID Field is automatic numbering, and when often adding a new record, the value of this id field can be incremented by automatically (subtracting) assignment, the date represents the final updating time of certain record, the most the more commonly used.
Normally, in order to show up front by up-to-date content, the date typically can be used described data Record proceeds to sequence arrangement, obtains ordered data.Here, the date as the sequence index of ordered data, It practice, other field such as contact person, theme all can be as the sequence index of ordered data.
Regardless of the database environment residing for ordered data, in practice, phase can be set up for it The disk file answered.Such as, under network mailbox scene, access to preferably meet the paging of user Request, can set up corresponding disk file for the ordered data of each user.It is understood that Those skilled in the art can be with the recording method of flexible Application the application, and the application can't be to disk file Corresponding ordered data scope is any limitation as.
It addition, the field interval recorded in the number of block, and each block in disk file Left and right end points, it is possible to be configured according to actual needs by those skilled in the art, the application also will not add To limit.To assume to have in the server background data base of network mailbox ID be 1,2,3,4,5,6, 7,8,9 ..., 100 totally 100 records, and use the date that these 100 records are carried out inverted order arrangement; So, those skilled in the art can be first according to paging size (namely record count of every page of display) Determining the number of block, in general, the number=100/ paging size of block, such as, in paging When size is 10, the number of block is 10, and when paging size is 20, the number of block is 5.
In a preferred embodiment of the present application, described piece has corresponding block number, described block number The order sequence consensus interval with field recorded in block or contrary.Such as, it is 10 in paging size Time, table 2 shows the recorded content example of block in a kind of disk file of the application.
Table 2
Block number Field is interval Record count
block1 [1,10] 10
block2 [11,20] 10
block3 [21,30] 10
block4 [31,40] 10
... ... ...
block10 [91,100] 10
Upper example belongs to the situation of the sequence consensus that field is interval recorded in the order of described block number and block; Certainly, described block number can reverse, and as block1 is corresponding [91,100], block2 is corresponding [81,90], Etc..
Above example determines the number of block according to paging size, and, arrange for each block Identical record count;It practice, those skilled in the art can take other strategy to determine block Number, and different record counts is set for each block, the application another kind block deposits Storage structure example is:
Block1:{ [key1, key2], 8}, block2{ [Key3, key4], 10}
The recorded content of block represents that ID is a total of 8 records, block2 between key1 to key2 Recorded content represent a total of 10 records of key3 to key4.
In whole recording process, can be for the ordered data in particular data lab environment, it is thus achieved that each Block needs field interval and the record count in this field interval of the corresponding ordered data of record.
Assume that the server background data base of network mailbox uses the B+ tree of 2 layers to store ordered data, ginseng According to Fig. 2, it illustrates the storage organization schematic diagram of the application a kind of B+ tree.The most in practice, permissible By traveling through this B+ tree, to obtain the field interval of each piece of corresponding ordered data needing record and to be somebody's turn to do Record count in field interval, owing to traversal B+ tree is the common knowledge of this area, therefore does not makees at this Repeat.
In the embodiment of the present application, it is preferred that JSON (JavaScript.Object can be used Natation) form records field interval and the record in this field interval of corresponding ordered data in block Number.JSON is the data interchange format of a kind of lightweight, is suitable for server and JavaScript's Alternately, the data form of JSON is very simple, can transmit a simple String with JSON (character string), Number (digital), Boolean (Boolean), it is also possible to transmit an array, or The Object object that person one is complicated.
Although source data is identical, but in the case of using difference sequence index, the ordered data obtained It is different.Therefore, in a preferred embodiment of the present application, can for different sequence indexs, By corresponding ordered data record to different blocks in this disk file, wherein, described sequence index is institute State the sort by of ordered data.
Such as, under network mailbox application scenarios, described sequence index can include in following index Plant or multiple: date, contact person, theme.Under other application scenarios, described sequence index is all right Being other field, concrete sequence index is not any limitation as by the application.
In a word, the application is by carrying out record by ordered data by block mode in disk file, each Block record count in the field interval recording corresponding ordered data and this field interval;Due to Described field interval is often the interval of id field, so, when user asks specific paged content, Described interrecord structure can be the most corresponding from the covered block of record corresponding to described specific paged content Field interval is read data, that is, the application can support the access of described specific paged content, and Avoid the access of full content.
Corresponding to aforementioned recording method embodiment, disclosed herein as well is the record dress of a kind of ordered data Put, exhibition Fig. 3, specifically may include that
Set up module 301, for for ordered data, set up disk file;And
Logging modle 302, carries out record, institute by described ordered data by block mode in this disk file The quantity stating block is two or more, specifically may include that
Block record sub module 321, for recording the field interval of corresponding ordered data and being somebody's turn to do in each piece Record count in field interval, wherein, is carried out according to described field at ordered data described in data base Storage in order.
In the embodiment of the present application, it is preferred that described field includes id field.
In a preferred embodiment of the present application, described piece has corresponding block number, described block number The order sequence consensus interval with field recorded in block or contrary.
In another preferred embodiment of the present application, described logging modle 302, specifically for for not Same sequence index, by corresponding ordered data record to the most different blocks, wherein, institute in this disk file State the sort by that sequence index is described ordered data.
In the embodiment of the present application, it is preferred that described sequence index can include in following index Plant or multiple: date, contact person, theme.
For recording equipment embodiment, due to itself and recording method embodiment basic simlarity, so retouching That states is fairly simple, and relevant part sees the part of embodiment of the method and illustrates.
With reference to Fig. 4, it is shown that the flow chart of the access method embodiment of a kind of ordered data of the application, tool Body may include that
Step 401, receive user for the paging access request of ordered data;
Step 402, according to described paging access request, calculate the access skew of respective record and access long Degree;
Step 403, access skew according to described and access length, obtaining described paging access request corresponding The block that covers of record and corresponding field interval;Wherein, the described piece of disk being positioned at described ordered data In file, in each piece, record has field interval and the record in this field interval of corresponding ordered data Number;
Step 404, interval according to the field of described covering, access the ordered data in data base.
The embodiment of the present application can apply to, in various online network program, be used for reducing network traffics, carry The processing speed of high score access to web page request and process accuracy rate.
In a preferred embodiment of the present application, described according to described access skew and access length, obtain Take the step of the interval and corresponding block of field that record corresponding to described paging access request covers, specifically may be used To include:
Sub-step A1, the block read in this disk file;
If described access of sub-step A2 offsets in the field interval of certain block, then with this block and phase First piece and corresponding the covered as the record that described paging access request is corresponding between the field area answered One field is interval;
If the described operation result accessing skew and described access length of sub-step A3 falls at certain block In field interval, then using between this block with corresponding field area as the record that described paging access request is corresponding Second piece and the corresponding second field interval covered;Wherein, if described ordered data is ascending order arrangement, The most described operation result be described access skew with described access length and, if described ordered data is Ascending order arranges, and the most described operation result is the described difference accessing skew and described access length;
Sub-step A4, by the continuous blocks between described first piece, first piece and second piece and second piece of group The merging block and the corresponding field that become are interval, the block covered as the record that described paging access request is corresponding Interval with corresponding field.
In the embodiment of the present application, it is preferred that described field can include id field.Assume online To have ID in the server background data base of network program be 1,2,3,4,5,6,7,8,9 ..., 100 totally 100 records exist in disk, it is assumed that the size of paging is 10 (namely every page show 10 Record), then, if now user asks the content of page 2, then it represents that the data that user needs are ID, from the record data of 11 to 20, that is, the access skew of respective record is 11-10=10, accesses A length of 20-11+1=10.
Assume that the disk file organization that described 100 records are corresponding is as follows:
Block1:{ [key1, key2], 8},
Block2{ [Key3, key4], 3},
Block3{ [Key5, key6], 4}
Block4{ [Key7, key8], 5}
So, first piece of the acquisition of sub-step A2 is block2, and second piece of the acquisition of sub-step A3 is Block4, the merging block that sub-step A4 obtains is block2, block3 and block4, so, step 404 when accessing data base, only needs record data read-out in [key3, key8].Such as, exist In SqlServer, query statement ID >=' Key3 ' And ID <=' Key8 ' can be passed through and realize above-mentioned Read.
In another preferred embodiment of the present application, described piece has corresponding block number, described piece of volume Number the order sequence consensus interval with field recorded in block or contrary;
Now, described sub-step A2 may further include:
From the beginning of minimum block number, it is successively read the block in this disk file, and carries out corresponding first Covering judgment, described first Covering judgment process includes:
Judge whether described access skew falls in the field interval of current block, the most then with this current block With first piece covered as the record that described paging access request is corresponding between corresponding field area and corresponding The first field interval, and terminate to read;Otherwise, block number adds 1, continues to read in this disk file Block;
Described sub-step A3 may further include:
From the beginning of minimum block number, it is successively read the block in this disk file, and carries out corresponding second Covering judgment, described second Covering judgment process includes:
Judge whether the described operation result accessing skew and described access length falls in the field of current block In interval, the most then using corresponding as described paging access request between this current block with corresponding field area Cover second piece of record and corresponding second field interval;Otherwise, block number adds 1, continues to read Block in this disk file;Wherein, if described ordered data is ascending order arrangement, the most described operation result For described access skew with described access length and, if described ordered data be ascending order arrange, then institute Stating operation result is the described difference accessing skew and described access length.
In another preferred embodiment of the present application, in recording process, can be for different sequences Index, to there being different blocks in this disk file, wherein, described sequence index be described in have ordinal number According to sort by;
Correspondingly, described according to described access skew and access length, obtain described paging access request pair The block of the record covering answered and the step in corresponding field interval, may further include:
Sub-step B1, according to described paging access request, it is thus achieved that the access sequence of corresponding ordered data refers to Mark;
Sub-step B2, from this disk file obtain with described access sort the corresponding access block of index;
Sub-step B3, by read described access block, obtain the record that described paging access request is corresponding The block and the corresponding field that cover are interval.
In implementing, described sequence index can include one or more in following index: the date, Contact person, theme.Assume disk file is respectively directed to date, contact person, theme three kinds sequence index Have recorded corresponding block, then, when accessing sequence index and being the date, then need to obtain from disk file Take access block corresponding with the date.
In a preferred embodiment of the present application, the field according to described covering is interval, accesses data base In the step of ordered data, specifically may include that
Judge that the field of described covering is interval and whether described paging access request mates, the most then from number Data are recorded according to reading is corresponding with the field interval of described covering in storehouse;Otherwise, read from data base With the field of described covering interval corresponding record data to internal memory, and to the record read in internal memory Data are screened, until the selection result is mated with described paging access request.
In upper example, in [key3, key8], record data are mated, the most completely with described paging access request Read and reading result is shown on foreground;And if it does not match, need first to read record number According to internal memory, then after the selection result is mated with described paging access request, the selection result is shown Front page layout.
Now, although be also required to committed memory space, but, read from data base relative to prior art Taking full content corresponding between the whole district, the application only need to be from the record institute corresponding to described specific paged content Cover in field interval corresponding to block and read data, that is, the application reading is local content, Can accomplish to avoid reading redundant data as far as possible.
For the angle of disk, what described redundancy read avoids reducing the I/O operation of disk, carries The IO performance on high backstage, reduces the reading time such that it is able to reduce the process time of paging access request; For the angle of internal memory, what described redundancy read avoid it can be avoided that the distributing in a large number and take of internal memory, It is thus possible to avoid the situation of the low memory occurred when paging sum is excessive, and low memory causes The series of problems such as disk read failure such that it is able to improve the process accuracy rate of accessing page request.
Corresponding to aforementioned access embodiment of the method, disclosed herein as well is the access dress of a kind of ordered data Put, with reference to Fig. 5, specifically may include that
Interface module 501, for receiving user's paging access request for ordered data;
Computing module 502, for according to described paging access request, calculating the access skew of respective record With access length;
Cover acquisition module 503, for accessing skew according to described and access length, obtain described paging Block and the corresponding field of the record covering that access request is corresponding are interval;Wherein, described piece be positioned at described in have In the disk file of ordinal number evidence, in each piece, record has field interval and this field of corresponding ordered data Record count in interval;And
Access modules 504, interval for the field according to described covering, accessing has ordinal number in data base According to.
In the embodiment of the present application, it is preferred that described field can include id field.
In a preferred embodiment of the present application, described covering acquisition module 503, can wrap further Include:
Reading submodule, for reading the block in this disk file;
First covers acquisition submodule, is used for when described access skew falls in the field interval of certain block, Using first piece covered as the record that described paging access request is corresponding between this block with corresponding field area And corresponding first field is interval;
Second covers acquisition submodule, at the described operation result accessing skew and described access length When falling in the field interval of certain block, using between this block and corresponding field area as described paging access request Second piece and the corresponding second field interval that corresponding record covers;Wherein, if described ordered data For ascending order arrange, the most described operation result be described access skew with described access length and, if institute Stating ordered data is ascending order arrangement, and the most described operation result is that described access offsets and described access length Difference;
Merge submodule, for by the continuous blocks and second between described first piece, first piece and second piece Merging block and the corresponding field of block composition are interval, and the record corresponding as described paging access request covers Block and corresponding field interval.
In another preferred embodiment of the present application, described piece has corresponding block number, described piece of volume Number the order sequence consensus interval with field recorded in block or contrary;
Correspondingly, described first covers acquisition submodule, may further include:
First reads unit, for, from the beginning of minimum block number, being successively read the block in this disk file;
First Covering judgment unit, for according to the current block read, carrying out corresponding first Covering judgment, Described first Covering judgment process may include that
Judge whether described access skew falls in the field interval of current block, the most then with this current block With first piece covered as the record that described paging access request is corresponding between corresponding field area and corresponding The first field interval, and terminate to read;Otherwise, block number adds 1, continues to read in this disk file Block;
Described second covers acquisition submodule, may further include:
Second reads unit, for, from the beginning of minimum block number, being successively read the block in this disk file;
Second Covering judgment unit, for according to the current block read, carrying out corresponding second Covering judgment, Described second Covering judgment process may include that
Judge whether the described operation result accessing skew and described access length falls in the field of current block In interval, the most then using corresponding as described paging access request between this current block with corresponding field area Cover second piece of record and corresponding second field interval;Otherwise, block number adds 1, continues to read Block in this disk file;Wherein, if described ordered data is ascending order arrangement, the most described operation result For described access skew with described access length and, if described ordered data be ascending order arrange, then institute Stating operation result is the described difference accessing skew and described access length.
Plant in preferred embodiment again in the application, for different sequence indexs, can be at this disk literary composition To there being different blocks in part, wherein, described sequence index is the sort by of described ordered data;
Correspondingly, described covering acquisition module 503, may further include:
Access sequence index selection submodule, for according to described paging access request, it is thus achieved that the most orderly The access sequence index of data;
Access block obtains submodule, corresponding to described access sequence index for obtaining from this disk file Access block;And
Read and obtain submodule, for by reading described access block, obtaining described paging access request pair Block and corresponding field that the record answered covers are interval.
In the embodiment of the present application, it is preferred that described sequence index can include in following index Plant or multiple: date, contact person, theme.
For accessing device embodiment, due to itself and access method embodiment basic simlarity, so retouching That states is fairly simple, and relevant part sees the part of access method embodiment and illustrates.
Each embodiment in this specification all uses the mode gone forward one by one to describe, and each embodiment stresses Be all the difference with other embodiments, between each embodiment, identical similar part sees mutually ?.
Recording method and device to a kind of ordered data provided herein above, a kind of ordered data Access method and device, be described in detail, former to the application of specific case used herein Reason and embodiment are set forth, and the explanation of above example is only intended to help to understand the side of the application Method and core concept thereof;Simultaneously for one of ordinary skill in the art, according to the thought of the application, The most all will change, in sum, this specification content is not It is interpreted as the restriction to the application.

Claims (6)

1. the access method of an ordered data, it is characterised in that including:
Receive user's paging access request for ordered data;
According to described paging access request, calculate the access skew of respective record and access length;Wherein, Described access offsets the owner record being described paging access request corresponding record relative to described ordered data Numbering skew;
Access skew according to described and access length, obtaining record corresponding to described paging access request and cover Block and corresponding field interval;Wherein, described piece is positioned in the disk file of described ordered data, In each piece, record has field interval and the record count in this field interval of corresponding ordered data, described Record count in the interval and described field interval of field is for the index of database paging content;
Field according to described covering is interval, accesses the ordered data in data base.
2. the method for claim 1, it is characterised in that described according to described access skew and Access length, obtain the interval and corresponding block of field of record covering corresponding to described paging access request Step, including:
Read the block in this disk file;
If described access offsets in the field interval of certain block, then interval with this block and corresponding field First piece and the corresponding first field interval covered as the record that described paging access request is corresponding;
If the described operation result accessing skew and described access length falls in the field interval of certain block, Then using cover as the record that described paging access request is corresponding between this block with corresponding field area second Block and corresponding second field are interval;Wherein, if described ordered data is ascending order arrangement, the most described fortune Calculate result be described access skew with described access length and, if described ordered data be backward arrange Row, the most described operation result is the described difference accessing skew and described access length;
By the continuous blocks between described first piece, first piece and second piece and second piece composition merge block and Corresponding field is interval, the block covered as the record that described paging access request is corresponding and corresponding field Interval.
3. method as claimed in claim 2, it is characterised in that described piece has corresponding block number, Sequence consensus that the order of described block number is interval with field recorded in block or contrary;
First piece and corresponding first word of the record covering that described acquisition described paging access request is corresponding The step that section is interval, including:
From the beginning of minimum block number, it is successively read the block in this disk file, and carries out corresponding first Covering judgment, described first Covering judgment process includes:
Judge whether described access skew falls in the field interval of current block, the most then with this current block With first piece covered as the record that described paging access request is corresponding between corresponding field area and corresponding The first field interval, and terminate to read;Otherwise, block number adds 1, continues to read in this disk file Block;
Second piece and corresponding second word of the record covering that described acquisition described paging access request is corresponding The step that section is interval, including:
From the beginning of minimum block number, it is successively read the block in this disk file, and carries out corresponding second Covering judgment, described second Covering judgment process includes:
Judge whether the described operation result accessing skew and described access length falls in the field of current block In interval, the most then using corresponding as described paging access request between this current block with corresponding field area Cover second piece of record and corresponding second field interval;Otherwise, block number adds 1, continues to read Block in this disk file;Wherein, if described ordered data is ascending order arrangement, the most described operation result For described access skew with described access length and, if described ordered data is for reversing, then institute Stating operation result is the described difference accessing skew and described access length.
4. the method for claim 1, it is characterised in that for different sequence indexs, To there being different blocks in this disk file, wherein, described sequence index is the sequence of described ordered data Foundation;
Described according to described access skew and access length, obtain the record that described paging access request is corresponding The block covered and the step in corresponding field interval, including:
According to described paging access request, it is thus achieved that the access sequence index of corresponding ordered data;
Obtain from this disk file and access the sequence corresponding access block of index with described;
By reading described access block, obtain block and phase that record corresponding to described paging access request covers The field answered is interval.
5. the method for claim 1, it is characterised in that the field according to described covering is interval, The step of the ordered data in access data base, including:
Judge that the field of described covering is interval and whether described paging access request mates, the most then from number Data are recorded according to reading is corresponding with the field interval of described covering in storehouse;Otherwise, read from data base With the field of described covering interval corresponding record data to internal memory, and to the record read in internal memory Data are screened, until the selection result is mated with described paging access request.
6. the access device of an ordered data, it is characterised in that including:
Interface module, for receiving user's paging access request for ordered data;
Computing module, for according to described paging access request, calculating the access skew of respective record and visit Ask length;Wherein, described access skew for described paging access request corresponding record relative to described in order The numbering skew of the owner record of data;
Cover acquisition module, for accessing skew according to described and access length, obtain described paging and access Block and the corresponding field of the record covering that request is corresponding are interval;Wherein, described piece be positioned at described in have ordinal number According to disk file in, in each piece, record has the field of corresponding ordered data interval and this field is interval Interior record count, the record count in the interval and described field interval of described field is used for database paging The index of content;And
Access modules, interval for the field according to described covering, access the ordered data in data base.
CN201110280428.2A 2011-09-20 2011-09-20 The recording method and device of ordered data, the access method of ordered data and device Active CN103019951B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201110280428.2A CN103019951B (en) 2011-09-20 2011-09-20 The recording method and device of ordered data, the access method of ordered data and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201110280428.2A CN103019951B (en) 2011-09-20 2011-09-20 The recording method and device of ordered data, the access method of ordered data and device

Publications (2)

Publication Number Publication Date
CN103019951A CN103019951A (en) 2013-04-03
CN103019951B true CN103019951B (en) 2016-12-07

Family

ID=47968576

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201110280428.2A Active CN103019951B (en) 2011-09-20 2011-09-20 The recording method and device of ordered data, the access method of ordered data and device

Country Status (1)

Country Link
CN (1) CN103019951B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105760457A (en) * 2016-02-05 2016-07-13 成都康赛信息技术有限公司 Data paging optimizing method based on MongoDB

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6009425A (en) * 1996-08-21 1999-12-28 International Business Machines Corporation System and method for performing record deletions using index scans
CN1688998A (en) * 2002-10-18 2005-10-26 国际商业机器公司 Method and system for online analytical processing (OLAP)
CN101996250A (en) * 2010-11-15 2011-03-30 中国科学院计算技术研究所 Hadoop-based mass stream data storage and query method and system
CN102012851A (en) * 2010-12-20 2011-04-13 浪潮(北京)电子信息产业有限公司 Continuous data protection method and server

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7941451B1 (en) * 2006-08-18 2011-05-10 Unisys Corporation Dynamic preconditioning of a B+ tree

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6009425A (en) * 1996-08-21 1999-12-28 International Business Machines Corporation System and method for performing record deletions using index scans
CN1688998A (en) * 2002-10-18 2005-10-26 国际商业机器公司 Method and system for online analytical processing (OLAP)
CN101996250A (en) * 2010-11-15 2011-03-30 中国科学院计算技术研究所 Hadoop-based mass stream data storage and query method and system
CN102012851A (en) * 2010-12-20 2011-04-13 浪潮(北京)电子信息产业有限公司 Continuous data protection method and server

Also Published As

Publication number Publication date
CN103019951A (en) 2013-04-03

Similar Documents

Publication Publication Date Title
US8352490B2 (en) Method and system for locating update operations in a virtual machine disk image
Rhea et al. Littletable: A time-series database and its uses
CN101916261A (en) Data partitioning method for distributed parallel database system
CN106648446A (en) Time series data storage method and apparatus, and electronic device
CN106095807B (en) A kind of distributed file system correcting and eleting codes buffer storage and its caching method
CN107766374B (en) Optimization method and system for storage and reading of massive small files
CN107807932B (en) Hierarchical data management method and system based on path enumeration
CN107818115A (en) A kind of method and device of processing data table
CN106528793A (en) Spatial-temporal fragment storage method for distributed spatial database
CN102890678A (en) Gray-code-based distributed data layout method and query method
CN103714086A (en) Method and device used for generating non-relational data base module
WO2021179488A1 (en) Monitoring data storage method and device, server and storage medium
US20110179013A1 (en) Search Log Online Analytic Processing
Nodine et al. Greed sort: Optimal deterministic sorting on parallel disks
WO2014010038A1 (en) Information processing system
US9275091B2 (en) Database management device and database management method
CN110309143A (en) Data similarity determines method, apparatus and processing equipment
EP3767486A1 (en) Multi-record index structure for key-value stores
CN107609011A (en) The maintaining method and device of a kind of data-base recording
CN106294468A (en) The method and apparatus processing business datum
CN107395694A (en) A kind of big data management system
CN114329096A (en) Method and system for processing native map database
CN107301249A (en) A kind of file access information recording method, system and distributed cluster system
CN106570029A (en) Data processing method and data processing system of distributed relation type database
CN103019951B (en) The recording method and device of ordered data, the access method of ordered data and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 1179365

Country of ref document: HK

C14 Grant of patent or utility model
GR01 Patent grant