CN102402486A - Method and device for reading data - Google Patents

Method and device for reading data Download PDF

Info

Publication number
CN102402486A
CN102402486A CN2010102870006A CN201010287000A CN102402486A CN 102402486 A CN102402486 A CN 102402486A CN 2010102870006 A CN2010102870006 A CN 2010102870006A CN 201010287000 A CN201010287000 A CN 201010287000A CN 102402486 A CN102402486 A CN 102402486A
Authority
CN
China
Prior art keywords
pointer position
reading
head
data
head pointer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN2010102870006A
Other languages
Chinese (zh)
Other versions
CN102402486B (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.)
Tencent Technology Shenzhen Co Ltd
Tencent Cloud Computing Beijing Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201010287000.6A priority Critical patent/CN102402486B/en
Publication of CN102402486A publication Critical patent/CN102402486A/en
Application granted granted Critical
Publication of CN102402486B publication Critical patent/CN102402486B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a method and a device for reading data, which belong to the technical field of computers. The method comprises the following steps: determining a head-pointer position and a tail-pointer position of a channel; comparing the height of the head-pointer position and the height of the tail-pointer position; and sequentially reading a data packet according to a comparison result. The device comprises a determining module, a comparing module and a reading module. According to the invention, through sequentially reading the data packet, the times for reading the data can be reduced; and in addition, since the times for reading the data is reduced, the efficiency for reading the data can be improved, and thus the probability that data overflow from the channel is reduced.

Description

The method of reading of data and device
Technical field
The present invention relates to field of computer technology, particularly a kind of method of reading of data and device.
Background technology
Increasing along with quantity of information, the storage of data and read technological means commonly used when becoming process information.Each data cell among the channel (passage) of storage data can be a fixed length, in order to save the space, can also be elongated, and promptly the length of each data cell is different.
No matter the data cell among the channel is a fixed length or elongated, and prior art all will be read a packet from the head pointer position in the channel when reading of data; Solve raw data packets again; And the modification head pointer, promptly read the packet of a data unit at every turn, and handle; When data volume is very big, need ceaselessly scan the head pointer position among the channel, equate up to head pointer position and tail pointer position.
In realizing process of the present invention, the inventor finds that there is following shortcoming at least in prior art:
Prior art once only reads a packet when reading of data, and whenever reads a packet and all will revise the head pointer position in the passage, causes the efficient of reading of data not high; In addition, when the speed of read data packet when producing the speed of packet, the packet among the channel can get more and more, and causes among the channel data to be overflowed the most at last.
Summary of the invention
In order to reduce the number of times of reading of data, thereby improve the efficient of reading of data, and reduce the probability that data are overflowed in the passage, the embodiment of the invention provides a kind of method and device of reading of data.Said technical scheme is following:
On the one hand, a kind of method of reading of data is provided, said method comprises:
Confirm the head pointer position and the tail pointer position of passage;
The height of more said head pointer position and said tail pointer position;
According to the continuous read data packet of comparative result.
Wherein, said according to the continuous read data packet of comparative result, specifically comprise:
Comparing said head pointer position when being higher than said tail pointer position, begin read data packet from said head pointer position, until the passage afterbody.
Further, saidly begin read data packet, after the passage afterbody, also comprise from said head pointer position:
Change the head pointer position, the head pointer position after changing begins read data packet, until the tail pointer position.
Alternatively, said according to the continuous read data packet of comparative result, specifically comprise:
Comparing said head pointer position when being lower than said tail pointer position, begin read data packet from said head pointer position, until the tail pointer position.
On the other hand, a kind of device of reading of data is provided, said device comprises:
Determination module is used for confirming the head pointer position and the tail pointer position of passage;
Comparison module is used for the definite head pointer position of more said determination module and the height of said tail pointer position;
Read module is used for according to the continuous read data packet of the comparative result of said comparison module.
Wherein, said read module specifically is used for comparing said head pointer position when being higher than said tail pointer position at said comparison module, begins read data packet from said head pointer position, until the passage afterbody.
Further, said read module also is used for beginning read data packet from said head pointer position, after the passage afterbody, changes the head pointer position, and the head pointer position after changing begins read data packet, until the tail pointer position.
Alternatively, said read module specifically is used for comparing said head pointer position when being lower than said tail pointer position at said comparison module, begins read data packet from said head pointer position, until the tail pointer position.
The beneficial effect of the technical scheme that the embodiment of the invention provides is:
Through continuous read data packet, thereby can reduce the number of times of reading of data; In addition,, can improve the efficient of reading of data, and then reduce the probability that data are overflowed in the passage because the number of times of reading of data reduces.
Description of drawings
In order to be illustrated more clearly in the technical scheme in the embodiment of the invention; The accompanying drawing of required use is done to introduce simply in will describing embodiment below; Obviously, the accompanying drawing in describing below only is some embodiments of the present invention, for those of ordinary skills; Under the prerequisite of not paying creative work, can also obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is the method flow diagram of the reading of data that provides of the embodiment of the invention one;
Fig. 2 is the method flow diagram of the reading of data that provides of the embodiment of the invention two;
Fig. 3 is the channel architecture synoptic diagram that the embodiment of the invention two provides;
Fig. 4 is the another kind of channel architecture synoptic diagram that the embodiment of the invention two provides;
Fig. 5 is the apparatus structure synoptic diagram of the reading of data that provides of the embodiment of the invention three.
Embodiment
For making the object of the invention, technical scheme and advantage clearer, will combine accompanying drawing that embodiment of the present invention is done to describe in detail further below.
Embodiment one
Referring to Fig. 1, present embodiment provides a kind of method of reading of data, and this method flow is specific as follows:
101: head pointer position and the tail pointer position of confirming passage;
102: the height that compares head pointer position and tail pointer position;
103: according to the continuous read data packet of comparative result.
Wherein, according to the continuous read data packet of comparative result, specifically comprise:
Comparing the head pointer position when being higher than the tail pointer position, pointer position begins read data packet from the head, until the passage afterbody.
Further, pointer position begins read data packet from the head, after the passage afterbody, also comprises:
Change the head pointer position, the head pointer position after changing begins read data packet, until the tail pointer position.
Alternatively, according to the continuous read data packet of comparative result, specifically comprise:
Comparing the head pointer position when being lower than the tail pointer position, pointer position begins read data packet from the head, until the tail pointer position.
The method that present embodiment provides through continuous read data packet, thereby can reduce the number of times of reading of data; In addition,, can improve the efficient of reading of data, and then reduce the probability that data are overflowed in the passage because the number of times of reading of data reduces.
Embodiment two
Present embodiment provides a kind of method of reading of data, and this method reduces the number of times of reading of data through the mode of continuous reading of data, particularly under the situation of deal with data speed packet less than generation packet speed, reduces the probability that data are overflowed in the passage.Referring to Fig. 2, the method flow that present embodiment provides is specific as follows:
201: head pointer position and the tail pointer position of confirming passage;
To this step; Passage has a head pointer and a tail pointer; Packet of every increase in passage all can be made a call to a set form STX (0x02)+channel supplementary+raw data packets+ETX (0x03) to each packet, and after being stored in the packet that increases in the channel; Change the tail pointer position simultaneously, make it point to up-to-date Data Position.Each packet geographically is continuous; The head pointer position of passage and tail pointer position can be confirmed when increasing packet; And the position of confirming is head pointer and the address of tail pointer in passage; To high address, present embodiment does not limit the definite head pointer and the particular location of tail pointer by low address in address in the passage.
202: relatively whether the head pointer position is higher than the tail pointer position, if, execution in step 203, otherwise, execution in step 204;
Particularly; Can know by the description in the above-mentioned steps 201; Head pointer position and tail pointer position need be according to the determining positions of packet in passage, owing in read data packet, also may in passage, increase packet; Therefore, head pointer position and tail pointer position can change in real time.The head pointer position might be higher than the tail pointer position, also might be lower than the tail pointer position.Given this, present embodiment through relatively, can draw the height of head pointer position and tail pointer position, thereby take different data to read mode according to different situations after definite head pointer position and tail pointer position.Fig. 3 is higher than the situation of tail pointer position for the head pointer position, and Fig. 4 is lower than the situation of tail pointer position for the head pointer position, and the data of different situations read mode and see subsequent step for details.
203: pointer position begins read data packet from the head, and until the passage afterbody, flow process finishes;
Wherein, It is as shown in Figure 3 that the head pointer position is higher than the access diagram of tail pointer position, and under this kind situation, data are at the head of passage and afterbody each some; Can read in two steps if will read total data; Pointer position begins read data packet at first from the head, and until the passage afterbody, promptly pointer position all reads out to all packets between the high address of passage afterbody from the head.Next change the head pointer position to the high address place, the head pointer position after change begins read data packet again, until the tail pointer position.
204: pointer position begins read data packet from the head, and until the pointer tail position, flow process finishes.
To this step; Because the head pointer position is lower than the tail pointer position, data are between head pointer position and tail pointer position, and access diagram is as shown in Figure 4; Under this kind situation; Can disposable all data read in the passage be taken out, promptly pointer position begins read data packet from the head, until the pointer tail position.
In addition, no matter whether the head pointer position is higher than the tail pointer position, and the method that present embodiment provides is except can disposable continuous read data packet; In order to realize read data packet one by one, the method that present embodiment provides also supports to be provided with in advance zone bit, indicates the number of read data packet through the zone bit that is provided with; For example; Zone bit is 1, and then pointer position begins from the head, only reads a packet at every turn; Again for example, zone bit is 2, and then pointer position begins from the head, reads two packets at every turn.Zone bit is except the number that can indicate read data packet; Can also through this zone bit clearly indicate read which data cell till; For example, when current head pointer position is positioned at the 6th data unit of passage, if zone bit is set to 8; Then mean since the 6th data unit read data packet, till the 8th data unit.Present embodiment does not limit the set-up mode of zone bit, the content of its indication is not limited equally.
The method that present embodiment provides through continuous read data packet, thereby can reduce the number of times of reading of data; In addition,, can improve the efficient of reading of data, and then reduce the probability that data are overflowed in the passage because the number of times of reading of data reduces.
Embodiment three
Referring to Fig. 5, present embodiment provides a kind of device of reading of data, and this device comprises:
Determination module 501 is used for confirming the head pointer position and the tail pointer position of passage;
Comparison module 502 is used for the head pointer position that comparison determination module 501 confirms and the height of tail pointer position;
Read module 503 is used for according to the continuous read data packet of the comparative result of comparison module 502.
Wherein, read module 503 specifically is used for comparing the head pointer position when being higher than the tail pointer position at comparison module 502, and pointer position begins read data packet from the head, until the passage afterbody.
Further, read module 503 is used for also from the head that pointer position begins read data packet, after the passage afterbody, changes the head pointer position, and the head pointer position after changing begins read data packet, until the tail pointer position.
Alternatively, read module 503 specifically is used for comparing the head pointer position when being lower than the tail pointer position at comparison module 502, and pointer position begins read data packet from the head, until the tail pointer position.
In sum, the device that present embodiment provides through continuous read data packet, thereby can reduce the number of times of reading of data; In addition,, can improve the efficient of reading of data, and then reduce the probability that data are overflowed in the passage because the number of times of reading of data reduces.
Need to prove: the device of the reading of data that the foregoing description provides is when reading of data; Only the division with above-mentioned each functional module is illustrated; In the practical application; Can as required above-mentioned functions be distributed by the different functional completion, the inner structure that is about to device is divided into different functional, to accomplish all or part of function of above description.In addition, the device of the reading of data that the foregoing description provides and the method embodiment of reading of data belong to same design, and its concrete implementation procedure sees method embodiment for details, repeats no more here.
The invention described above embodiment sequence number is not represented the quality of embodiment just to description.
All or part of step in the embodiment of the invention can utilize software to realize that corresponding software programs can be stored in the storage medium that can read, like CD or hard disk etc.
The above is merely preferred embodiment of the present invention, and is in order to restriction the present invention, not all within spirit of the present invention and principle, any modification of being done, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (8)

1. the method for a reading of data is characterized in that, said method comprises:
Confirm the head pointer position and the tail pointer position of passage;
The height of more said head pointer position and said tail pointer position;
According to the continuous read data packet of comparative result.
2. method according to claim 1 is characterized in that, and is said according to the continuous reading of data of comparative result, specifically comprises:
Comparing said head pointer position when being higher than said tail pointer position, begin read data packet from said head pointer position, until the passage afterbody.
3. method according to claim 2 is characterized in that, saidly begins reading of data from said head pointer position, after the passage afterbody, also comprises:
Change the head pointer position, the head pointer position after changing begins read data packet, until the tail pointer position.
4. method according to claim 1 is characterized in that, and is said according to the continuous reading of data of comparative result, specifically comprises:
Comparing said head pointer position when being lower than said tail pointer position, begin read data packet from said head pointer position, until the tail pointer position.
5. the device of a reading of data is characterized in that, said device comprises:
Determination module is used for confirming the head pointer position and the tail pointer position of passage;
Comparison module is used for the definite head pointer position of more said determination module and the height of said tail pointer position;
Read module is used for according to the continuous read data packet of the comparative result of said comparison module.
6. device according to claim 5; It is characterized in that said read module specifically is used for comparing said head pointer position when being higher than said tail pointer position at said comparison module; Begin read data packet from said head pointer position, until the passage afterbody.
7. device according to claim 6 is characterized in that, said read module; Also be used for beginning reading of data, after the passage afterbody, change the head pointer position from said head pointer position; Head pointer position after changing begins read data packet, until the tail pointer position.
8. device according to claim 5; It is characterized in that said read module specifically is used for comparing said head pointer position when being lower than said tail pointer position at said comparison module; Begin read data packet from said head pointer position, until the tail pointer position.
CN201010287000.6A 2010-09-17 2010-09-17 Method and device for reading data Active CN102402486B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201010287000.6A CN102402486B (en) 2010-09-17 2010-09-17 Method and device for reading data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201010287000.6A CN102402486B (en) 2010-09-17 2010-09-17 Method and device for reading data

Publications (2)

Publication Number Publication Date
CN102402486A true CN102402486A (en) 2012-04-04
CN102402486B CN102402486B (en) 2014-07-23

Family

ID=45884710

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201010287000.6A Active CN102402486B (en) 2010-09-17 2010-09-17 Method and device for reading data

Country Status (1)

Country Link
CN (1) CN102402486B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5873089A (en) * 1995-09-04 1999-02-16 Hewlett-Packard Company Data handling system with circular queue formed in paged memory
US5911152A (en) * 1995-09-05 1999-06-08 Compaq Computer Corporation Computer system and method for storing data in a buffer which crosses page boundaries utilizing beginning and ending buffer pointers
US5978898A (en) * 1998-10-30 1999-11-02 Intel Corporation Allocating registers in a superscalar machine
US20010054121A1 (en) * 1999-01-19 2001-12-20 Timothy Proch Method and circuit for controlling a first-in-first-out (fifo) buffer using a bank of fifo address registers capturing and saving beginning and ending write-pointer addresses
CN1632764A (en) * 2004-12-31 2005-06-29 北京中星微电子有限公司 A linear file accessing method
US7035988B1 (en) * 2003-03-17 2006-04-25 Network Equipment Technologies, Inc. Hardware implementation of an N-way dynamic linked list
CN101266573A (en) * 2008-04-29 2008-09-17 中国船舶重工集团公司第七〇九研究所 Covering allowable flash memory even wearing circulating queue technology
CN101286136A (en) * 2008-04-24 2008-10-15 北京中星微电子有限公司 Method and device storing data in electrically erasable programmable read only memory

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5873089A (en) * 1995-09-04 1999-02-16 Hewlett-Packard Company Data handling system with circular queue formed in paged memory
US5911152A (en) * 1995-09-05 1999-06-08 Compaq Computer Corporation Computer system and method for storing data in a buffer which crosses page boundaries utilizing beginning and ending buffer pointers
US5978898A (en) * 1998-10-30 1999-11-02 Intel Corporation Allocating registers in a superscalar machine
US20010054121A1 (en) * 1999-01-19 2001-12-20 Timothy Proch Method and circuit for controlling a first-in-first-out (fifo) buffer using a bank of fifo address registers capturing and saving beginning and ending write-pointer addresses
US7035988B1 (en) * 2003-03-17 2006-04-25 Network Equipment Technologies, Inc. Hardware implementation of an N-way dynamic linked list
CN1632764A (en) * 2004-12-31 2005-06-29 北京中星微电子有限公司 A linear file accessing method
CN101286136A (en) * 2008-04-24 2008-10-15 北京中星微电子有限公司 Method and device storing data in electrically erasable programmable read only memory
CN101266573A (en) * 2008-04-29 2008-09-17 中国船舶重工集团公司第七〇九研究所 Covering allowable flash memory even wearing circulating queue technology

Also Published As

Publication number Publication date
CN102402486B (en) 2014-07-23

Similar Documents

Publication Publication Date Title
CN103077183A (en) Data importing method and system for distributed sequence list
CN105320490A (en) Method and apparatus for asynchronous FIFO circuit
CN105677742A (en) Method and apparatus for storing files
CN103019949A (en) Allocation method and device of write combine attribute memory space
US20080120456A1 (en) Method for flash memory data management
CN109240607B (en) File reading method and device
CN101382948A (en) File memory method, apparatus and system
US11210228B2 (en) Method, device and computer program product for cache management
CN102662713A (en) Method, device and terminal for increasing running speed of application programs
CN101571850A (en) Display packing and device of text document in support of page turn function
CN103023755A (en) Method and electronic device for data transmission
CN102324246A (en) Indexed register access for memory device
CN104092670A (en) Method for utilizing network cache server to process files and device for processing cache files
CN103425435A (en) Disk storage method and disk storage system
CN110543435B (en) Mixed mapping operation method, device and equipment of storage unit and storage medium
CN1813303A (en) Storage device for storing different data formats
CN103399662A (en) Method, system and mobile terminal for reporting coordinate incident of touch screen
CN102402486B (en) Method and device for reading data
CN102981721A (en) Method and device and mobile terminal for deleting application program
US20210349817A1 (en) Method for releasing memory
CN113778455B (en) Code conversion method and device, electronic equipment and storage medium
US20100023708A1 (en) Variable-length code (vlc) bitstream parsing in a multi-core processor with buffer overlap regions
CN102609240B (en) The method of processor circuit and reading data
CN112596949B (en) High-efficiency SSD (solid State disk) deleted data recovery method and system
US11055217B2 (en) Using additional intermediate buffer queues to identify interleaved media data to be read together

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20190731

Address after: 518000 Guangdong city of Shenzhen province Futian District SEG Science Park 2 East Room 403

Co-patentee after: Tencent cloud computing (Beijing) limited liability company

Patentee after: Tencent Technology (Shenzhen) Co., Ltd.

Address before: 518000 Guangdong city of Shenzhen province Futian District SEG Science Park 2 East Room 403

Patentee before: Tencent Technology (Shenzhen) Co., Ltd.

TR01 Transfer of patent right