CN102831196A - Rapid load record data query method and application - Google Patents

Rapid load record data query method and application Download PDF

Info

Publication number
CN102831196A
CN102831196A CN2012102765329A CN201210276532A CN102831196A CN 102831196 A CN102831196 A CN 102831196A CN 2012102765329 A CN2012102765329 A CN 2012102765329A CN 201210276532 A CN201210276532 A CN 201210276532A CN 102831196 A CN102831196 A CN 102831196A
Authority
CN
China
Prior art keywords
record
constantly
search
moment
end points
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.)
Pending
Application number
CN2012102765329A
Other languages
Chinese (zh)
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.)
ZHANGZHOU CANNET ELECTRICAL APPLIANCE CO Ltd
Original Assignee
ZHANGZHOU CANNET ELECTRICAL APPLIANCE 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 ZHANGZHOU CANNET ELECTRICAL APPLIANCE CO Ltd filed Critical ZHANGZHOU CANNET ELECTRICAL APPLIANCE CO Ltd
Priority to CN2012102765329A priority Critical patent/CN102831196A/en
Publication of CN102831196A publication Critical patent/CN102831196A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Recording Measured Values (AREA)

Abstract

The invention relates to a rapid load record data query method. The method comprises the following steps: 1) reading the record at the endpoint moment and comparing with the record to be searched; 2) ending searching if the record at the endpoint moment is the record to be searched, otherwise, reading the record at the other endpoint moment, and comparing with the record to be searched; 3) ending searching if the record at the other endpoint moment is the record to be searched, otherwise, reading the record at the middle moment of the total data record, and comparing with the record to be searched; and 4) circulating a middle comparing method until the record is researched. The method has the beneficial effect that the middle comparing method is used, the record is read by reducing the range gradually, and the data can be searched after at most (log2N)+2 times. By using the method, the time for searching the load record at the given start moment is greatly shortened, and the restriction of the maximum response time of 500 milliseconds of the frame can be met completely.

Description

A kind of quick load record data querying method and application
Technical field
The present invention relates to a kind of data enquire method, more particularly, relate to a kind of quick load record data querying method and application.
Background technology
A kind of method of very big shortening inquiry load record data time; According to " multifunctional electric energy meter communication protocol DL/T645-2007 " requirement; Have 6 type load records, be divided into and copy the earliest record block, copy given initial moment record block and copy 3 kinds of copy reading modes of a nearest record block.
When the electric energy meter load record when filling up whole storage space, and the record that meets specified criteria is when being in the bottom of storer, searching this type load required time of record will be very long.The hypothetical record number is 30,000, reads the time data of 8 bytes and judges whether that the eligible required time is approximately 200 microseconds with the I2C bus, has surpassed 6 seconds time when reading the last item data, even find qualified record also to have little time response.Because electric energy meter possibly take place repeatedly to have a power failure and modification time repeatedly at run duration, cause the load record data be late between linear the growth, therefore can not calculate the position that qualified load record is stored with the moment of specified criteria and the moment the earliest.
As: Chinese invention patent application 201110164891.0 discloses a kind of FLASH date storage method that is used for intelligent electric energy meter, may further comprise the steps:
1), calculate ammeter record or the required storage space N*m of load curve to be stored, m is the minimum memory unit;
2), be ammeter record or load curve distribute data space (N+1) * m to be stored;
3), the principle with first in first out writes data in proper order:
(3.1), storage pointed current memory cell, under original state, first storage unit is a current memory cell;
(3.2), the next storage unit of storage pointed, this next one storage unit becomes current memory cell; Data in the deletion current memory cell write data to be stored current memory cell, use up up to the space of current memory cell;
(3.3), judge whether last storage unit of current memory cell, if this will store first storage unit of pointed, and delete the data of this first storage unit, with first storage unit as buffer unit; If not, repeated execution of steps (3.2) then;
4), during reading of data, through the reading pointer reverse find with reading of data:
(4.1), with N+1 storage unit as current reading unit;
(4.2), reading pointer points to current reading unit;
(4.3), judge the unit whether current reading unit needs reading of data to exist: if then obtain the data of current reading unit; If not, then with previous storage unit as current reading unit, repeated execution of steps (4.2), step (4.3).
The technical scheme of foregoing invention patented claim writes data in proper order with the principle of first in first out, and the principle reading of data with order adopts this technical scheme, and when the bigger database of data volume was searched, the time that needs was longer.If than higher field, then this technical scheme can't reach requirement at response time requirement.
Summary of the invention
The objective of the invention is to overcome the deficiency of prior art, the quick load record data querying method that a kind of required time of load record of searching the given initial moment shortens greatly is provided, and described method is used to the field of copy reading electric energy meter.
Technical scheme of the present invention is following:
A kind of quick load record data querying method, step is following:
1) reads end points record constantly, and desire to search record and compare;
2) if this end points being recorded as constantly desires to search record, then finish to search, otherwise read another end points record constantly, and desire to search record and compare;
3) if another end points being recorded as constantly desires to search record, then finish to search, otherwise read the total data record in the middle of constantly record, and desire to search record and compare;
4) if being recorded as of the middle moment desires to search record; Then finish to search; Otherwise judge desire to search between record and two end points recording areas in the middle of the size of record in the moment; If desire to search record less than the centre record in the moment, the moment and interval constantly the earliest middle record constantly in the middle of then reading; If if desire to search record greater than the centre record in the moment, the moment and interval constantly the latest middle record constantly in the middle of then reading;
5) if middle constantly with interval constantly the earliest in the middle of constantly record, or in the middle of constantly with interval constantly the latest in the middle of being recorded as and desiring to search record constantly; Then finish to search; Otherwise method according to step 4); Remaining moment interval is judged and search, desired to search record, finish to search until finding.
As preferably, described the earliest constantly to being recorded as and increasing progressively constantly the latest.
As preferably, the end points of step 1) inquiry is moment the earliest constantly.
As preferably, if total data is recorded as odd number, then between described two the end points recording areas of step 4) in the middle of constantly in the middle of getting behind total data record+1 constantly, or between two end points recording areas in the middle of constantly in the middle of getting behind the total data record-1 constantly.
As preferably, adopt the communication interface reading and recording.
Above-mentioned each described quick load record data querying method application on the copy reading electric energy meter.
Beneficial effect of the present invention is following:
Of the present invention search that principle adopts be in the middle of the comparison method, progressively half reduces the scope and reads, and looks for (log at most 2N)+2 time, must find and want the data of searching.The required time of load record of adopting method of the present invention to search the given initial moment shortens greatly, can satisfy the restriction of 500 milliseconds of frame maximum response time fully.
Description of drawings
Fig. 1 is the schematic flow sheet of method of the present invention.
Embodiment
Below in conjunction with accompanying drawing and embodiment the present invention is further specified.
A kind of quick load record data querying method, step is following:
1) reads end points record constantly, and desire to search record and compare;
2) if this end points being recorded as constantly desires to search record, then finish to search, otherwise read another end points record constantly, and desire to search record and compare;
3) if another end points being recorded as constantly desires to search record, then finish to search, otherwise read the total data record in the middle of constantly record, and desire to search record and compare;
4) if being recorded as of the middle moment desires to search record; Then finish to search; Otherwise judge desire to search between record and two end points recording areas in the middle of the size of record in the moment; If desire to search record less than the centre record in the moment, the moment and interval constantly the earliest middle record constantly in the middle of then reading; If if desire to search record greater than the centre record in the moment, the moment and interval constantly the latest middle record constantly in the middle of then reading;
5) if middle constantly with interval constantly the earliest in the middle of constantly record, or in the middle of constantly with interval constantly the latest in the middle of being recorded as and desiring to search record constantly; Then finish to search; Otherwise method according to step 4); Remaining moment interval is judged and search, desired to search record, finish to search until finding.
Described the earliest constantly to being recorded as and increasing progressively constantly the latest.In the load record data of electric energy meter, therefore a back record can adopt method of the present invention to solve the long problem of the time of searching that the sequential search principle is brought constantly constantly greater than last record always.
The end points of step 1) inquiry is constantly for constantly the earliest.
If total data is recorded as odd number, then between described two the end points recording areas of step 4) in the middle of constantly in the middle of getting behind total data record+1 constantly, or between two end points recording areas in the middle of constantly in the middle of getting behind the total data record-1 constantly.
Method of the present invention adopts the communication interface reading and recording, in the present embodiment, adopts I 2C bus reading and recording.The described time data that is recorded as 8 bytes.
As shown in Figure 1, establishing the total number of records is N, compares article one record earlier, if not then compare N bar record, if not then compare the N/2 bar.
If not then divide two kinds of situation:
(1) < the N/>2 bar is then compared N/4 bar record constantly the given initial moment;
(2) the given initial moment>N/2 bar record then compares N3/4 bar record constantly;
If also do not find, then continue to look for down, promptly by same method
(1.1) < the N/>4 bar is then compared N/8 bar record constantly the given initial moment;
(1.2) the given initial moment>the N/4 bar then compares N3/8 bar record constantly;
(2.1) < the N3/>4 bar is then compared N5/8 bar record constantly the given initial moment;
(2.2) the given initial moment>the N3/4 bar then compares N7/8 bar record constantly.
Circulate with this, search, look for (log at most according to above-mentioned method 2N)+2 time must find.For example 30,000 records are looked at most and will be found for 17 times.
Method of the present invention is specially adapted to the copy reading electric energy meter, and the present invention provides simultaneously a kind of quick load record data querying method of the present invention is applied in the application on the copy reading electric energy meter.
The foregoing description only is to be used for explaining the present invention, and is not with the qualification of the present invention of opposing.So long as according to technical spirit of the present invention, to the foregoing description change, modification etc. all will drop in the scope of claim of the present invention.

Claims (6)

1. quick load record data querying method is characterized in that step is following:
1) reads end points record constantly, and desire to search record and compare;
2) if this end points being recorded as constantly desires to search record, then finish to search, otherwise read another end points record constantly, and desire to search record and compare;
3) if another end points being recorded as constantly desires to search record, then finish to search, otherwise read the total data record in the middle of constantly record, and desire to search record and compare;
4) if being recorded as of the middle moment desires to search record; Then finish to search; Otherwise judge desire to search between record and two end points recording areas in the middle of the size of record in the moment; If desire to search record less than the centre record in the moment, the moment and interval constantly the earliest middle record constantly in the middle of then reading; If if desire to search record greater than the centre record in the moment, the moment and interval constantly the latest middle record constantly in the middle of then reading;
5) if middle constantly with interval constantly the earliest in the middle of constantly record, or in the middle of constantly with interval constantly the latest in the middle of being recorded as and desiring to search record constantly; Then finish to search; Otherwise method according to step 4); Remaining moment interval is judged and search, desired to search record, finish to search until finding.
2. quick load record data querying method according to claim 1 is characterized in that, and is described the earliest constantly to being recorded as and increasing progressively constantly the latest.
3. quick load record data querying method according to claim 1 is characterized in that, the end points of step 1) inquiry is constantly for constantly the earliest.
4. quick load record data querying method according to claim 1; It is characterized in that; If total data is recorded as odd number; Then between described two the end points recording areas of step 4) in the middle of constantly in the middle of getting behind total data record+1 constantly, or between two end points recording areas in the middle of constantly in the middle of getting behind the total data record-1 constantly.
5. quick load record data querying method according to claim 1 is characterized in that, adopts the communication interface reading and recording.
6. the application of the described quick load record data of each in the claim 1 to 5 querying method on the copy reading electric energy meter.
CN2012102765329A 2012-08-03 2012-08-03 Rapid load record data query method and application Pending CN102831196A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2012102765329A CN102831196A (en) 2012-08-03 2012-08-03 Rapid load record data query method and application

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2012102765329A CN102831196A (en) 2012-08-03 2012-08-03 Rapid load record data query method and application

Publications (1)

Publication Number Publication Date
CN102831196A true CN102831196A (en) 2012-12-19

Family

ID=47334333

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2012102765329A Pending CN102831196A (en) 2012-08-03 2012-08-03 Rapid load record data query method and application

Country Status (1)

Country Link
CN (1) CN102831196A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103412889A (en) * 2013-07-19 2013-11-27 深圳市金正方科技股份有限公司 Data storage and query method of intelligent electric meter and system thereof
CN105319527A (en) * 2015-11-23 2016-02-10 中国电力科学研究院 An electric energy meter load record test method
CN113220668A (en) * 2021-06-01 2021-08-06 烟台东方威思顿电气有限公司 Load curve data access method based on grouping

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1556483A (en) * 2003-12-31 2004-12-22 ����ͨѶ�ɷ����޹�˾ Method of quickly locating record in data gage in data base
CN101290621A (en) * 2007-04-17 2008-10-22 上海申瑞电力科技股份有限公司 Safe digital card memory search method
CN102520242A (en) * 2011-12-12 2012-06-27 宁夏隆基宁光仪表有限公司 Recording method of load curves of electric energy meter

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1556483A (en) * 2003-12-31 2004-12-22 ����ͨѶ�ɷ����޹�˾ Method of quickly locating record in data gage in data base
CN101290621A (en) * 2007-04-17 2008-10-22 上海申瑞电力科技股份有限公司 Safe digital card memory search method
CN102520242A (en) * 2011-12-12 2012-06-27 宁夏隆基宁光仪表有限公司 Recording method of load curves of electric energy meter

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103412889A (en) * 2013-07-19 2013-11-27 深圳市金正方科技股份有限公司 Data storage and query method of intelligent electric meter and system thereof
CN103412889B (en) * 2013-07-19 2017-10-03 深圳市金正方科技股份有限公司 The data storage and query method and its system of intelligent electric meter
CN105319527A (en) * 2015-11-23 2016-02-10 中国电力科学研究院 An electric energy meter load record test method
CN105319527B (en) * 2015-11-23 2019-03-22 中国电力科学研究院 A kind of electric energy meter load record test method
CN113220668A (en) * 2021-06-01 2021-08-06 烟台东方威思顿电气有限公司 Load curve data access method based on grouping
CN113220668B (en) * 2021-06-01 2022-05-27 烟台东方威思顿电气有限公司 Load curve data access method based on grouping

Similar Documents

Publication Publication Date Title
US9449005B2 (en) Metadata storage system and management method for cluster file system
CN104899297B (en) Create the method with the hybrid index of storage perception
CN105677742B (en) A kind of method and device of storage file
CN101582076A (en) Data de-duplication method based on data base
CN103915110A (en) Refresh method for volatile memory and related volatile memory controller
CN102117248A (en) Caching system and method for caching data in caching system
CN103336849A (en) Method and device for increasing retrieval speed in database retrieval system
CN104301360A (en) Method, log server and system for recording log data
CN101576890B (en) Novel method and system for sorting fragment
CN102890722A (en) Indexing method applied to time sequence historical database
CN103605615A (en) Block-level-data-based directional allocation method for hierarchical storage
CN111367469B (en) Method and system for migrating layered storage data
CN105378716B (en) A kind of conversion method and device of data memory format
CN104317739A (en) Hybrid memory paging method and device
US8856442B2 (en) Method for volume management
CN104769520A (en) System and method for dynamic memory power management
CN102521260B (en) Data preheating method and device
CN107817945A (en) A kind of method for reading data and system for mixing internal storage structure
CN105551522A (en) Management method and management apparatus of flash memory storage device
CN113821171A (en) Key value storage method based on hash table and LSM tree
CN202472635U (en) Flash memory wear leveling device
CN104050057B (en) Historical sensed data duplicate removal fragment eliminating method and system
CN109388341A (en) A kind of system storage optimization method based on Device Mapper
CN103778120A (en) Global file identification generation method, generation device and corresponding distributed file system
CN102831196A (en) Rapid load record data query method and application

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20121219