CN102402486B - Method and device for reading data - Google Patents

Method and device for reading data Download PDF

Info

Publication number
CN102402486B
CN102402486B CN201010287000.6A CN201010287000A CN102402486B CN 102402486 B CN102402486 B CN 102402486B CN 201010287000 A CN201010287000 A CN 201010287000A CN 102402486 B CN102402486 B CN 102402486B
Authority
CN
China
Prior art keywords
pointer position
head pointer
head
tail
data packet
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
CN201010287000.6A
Other languages
Chinese (zh)
Other versions
CN102402486A (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

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 out data and device
Technical field
The present invention relates to field of computer technology, particularly a kind of method of reading out data and device.
Background technology
Increasing along with quantity of information, the storage of data and read technological means conventional while becoming process information.Each data cell in the channel (passage) of storage data can be fixed length, in order to save space, can also be elongated, and the length of each data cell is different.
No matter the data cell in channel is fixed length or elongated, and prior art, when reading out data, is all read a packet by the head pointer position in channel, solve again raw data packets, and revise head pointer, read the packet of a data cell at every turn, and process; When data volume is very large, need to ceaselessly scan the head pointer position in channel, until head pointer position and tail pointer position equate.
In realizing process of the present invention, inventor finds that prior art at least exists following shortcoming:
Prior art, when reading out data, once only reads a packet, and often reads a packet all by the head pointer position of revising in passage, causes the efficiency of reading out data not high; In addition, when the speed of read data packet is less than the speed that produces packet, the packet in channel can get more and more, and causes the most at last data from overflow in channel.
Summary of the invention
In order to reduce the number of times of reading out data, thereby improve the efficiency of reading out data, and reduce the probability of data from overflow in passage, the embodiment of the present invention provides a kind of method and device of reading out data.Described technical scheme is as follows:
On the one hand, provide a kind of method of reading out data, described method comprises:
Determine head pointer position and the tail pointer position of passage;
The height of more described head pointer position and described tail pointer position;
When comparing described head pointer position higher than described tail pointer position, from described head pointer position, start read data packet, until passage afterbody changes head pointer position, head pointer position from changing starts read data packet, until tail pointer position;
When comparing described head pointer position lower than described tail pointer position, from described head pointer position, start read data packet, until tail pointer position.
On the other hand, provide a kind of device of reading out data, described device comprises:
Determination module, for determining head pointer position and the tail pointer position of passage;
Comparison module, for the height of the definite head pointer position of more described determination module and described tail pointer position;
Read module, for when described comparison module compares described head pointer position higher than described tail pointer position, from described head pointer position, start read data packet, until passage afterbody, change head pointer position, head pointer position from changing starts read data packet, until tail pointer position;
Described read module, also when comparing described head pointer position lower than described tail pointer position at described comparison module, starts read data packet from described head pointer position, until tail pointer position.
The beneficial effect of the technical scheme that the embodiment of the present invention provides is:
By continuous read data packet, thereby can reduce the number of times of reading out data; In addition, the number of times minimizing due to reading out data, can improve the efficiency of reading out data, and then reduces the probability of data from overflow in passage.
Accompanying drawing explanation
In order to be illustrated more clearly in the technical scheme in the embodiment of the present invention, below the accompanying drawing of required use during embodiment is described is briefly described, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skills, do not paying under the prerequisite of creative work, can also obtain according to these accompanying drawings other accompanying drawing.
Fig. 1 is the method flow diagram of the reading out data that provides of the embodiment of the present invention one;
Fig. 2 is the method flow diagram of the reading out data that provides of the embodiment of the present invention two;
Fig. 3 is the channel architecture schematic diagram that the embodiment of the present invention two provides;
Fig. 4 is the another kind of channel architecture schematic diagram that the embodiment of the present invention two provides;
Fig. 5 is the apparatus structure schematic diagram of the reading out data that provides of the embodiment of the present invention three.
Embodiment
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail.
Embodiment mono-
Referring to Fig. 1, the present embodiment provides a kind of method of reading out data, and the method flow process is specific as follows:
101: head pointer position and the tail pointer position of determining 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:
When comparing head pointer position higher than tail pointer position, pointer position starts read data packet from the head, until passage afterbody.
Further, pointer position starts read data packet from the head, until after passage afterbody, also comprise:
Change head pointer position, the head pointer position from changing starts read data packet, until tail pointer position.
Alternatively, according to the continuous read data packet of comparative result, specifically comprise:
When comparing head pointer position lower than tail pointer position, pointer position starts read data packet from the head, until tail pointer position.
The method that the present embodiment provides, by continuous read data packet, thereby can reduce the number of times of reading out data; In addition, the number of times minimizing due to reading out data, can improve the efficiency of reading out data, and then reduces the probability of data from overflow in passage.
Embodiment bis-
The present embodiment provides a kind of method of reading out data, and the method, by the mode of continuous reading out data, reduces the number of times of reading out data, particularly for deal with data speed packet, is less than in the situation that produces packet speed, reduces the probability of data from overflow in passage.Referring to Fig. 2, the method flow that the present embodiment provides is specific as follows:
201: head pointer position and the tail pointer position of determining passage;
For this step, passage has a head pointer and tail pointer, packet of every increase in passage, a set form STX (0x02)+channel supplementary+raw data packets+ETX (0x03) is made a call to each packet in capital, and after the packet of increase is stored in channel, change tail pointer position simultaneously, make it point to up-to-date Data Position.Each packet is geographically continuous, the head pointer position of passage and tail pointer position can be determined when increasing packet, and definite position is head pointer and the address of tail pointer in passage, address in passage is by low address to high address, and the present embodiment does not limit the particular location of definite head pointer and tail pointer.
202: relatively head pointer position, whether higher than tail pointer position, if so, performs step 203, otherwise, execution step 204;
Particularly, description in above-mentioned steps 201 is known, head pointer position and tail pointer position need to be according to packet the determining positions in passage, due in read data packet, also may in passage, increase packet, therefore, head pointer position and tail pointer position can change in real time.Head pointer position is likely higher than tail pointer position, also likely lower than tail pointer position.Given this, the present embodiment, after definite head pointer position and tail pointer position, by relatively, can draw the height of head pointer position and tail pointer position, thereby take different data reading manners according to different situations.Fig. 3 be head pointer position higher than the situation of tail pointer position, and Fig. 4 be head pointer position lower than the situation of tail pointer position, the data reading manner of different situations refers to subsequent step.
203: pointer position starts read data packet from the head, until passage afterbody, flow process finishes;
Wherein, head pointer position higher than the access diagram of tail pointer position as shown in Figure 3, in this kind of situation, data are at the head of passage and afterbody each some, if reading total data can read in two steps, first from the head pointer position starts read data packet, until passage afterbody, pointer position all reads out to all packets between the high address of passage afterbody from the head.Next change head pointer position to high address place, then the head pointer position from changing starts read data packet, until tail pointer position.
204: pointer position starts read data packet from the head, until pointer tail position, flow process finishes.
For this step, because head pointer position is lower than tail pointer position, data are between head pointer position and tail pointer position, access diagram as shown in Figure 4, in this kind of situation, can disposable all data in passage be read out, pointer position starts read data packet from the head, until pointer tail position.
In addition, no matter whether head pointer position is higher than tail pointer position, the method that the present embodiment provides is except can disposable continuous read data packet, in order to realize read data packet one by one, the method that the present embodiment provides also supports to set in advance zone bit, indicates the number of read data packet by the zone bit arranging, for example, zone bit is 1, and pointer position starts from the head, only reads a packet at every turn; Again for example, zone bit is 2, and pointer position starts from the head, reads two packets at every turn.Zone bit is except can indicating the number of read data packet, till can also clearly indicating and read which data cell by this zone bit, for example, when current head pointer position is positioned at the 6th data cell of passage, if zone bit is set to 8, mean since the 6th data cell read data packet, until the 8th data cell.The present embodiment does not limit the set-up mode of zone bit, the content of its indication is not limited equally.
The method that the present embodiment provides, by continuous read data packet, thereby can reduce the number of times of reading out data; In addition, the number of times minimizing due to reading out data, can improve the efficiency of reading out data, and then reduces the probability of data from overflow in passage.
Embodiment tri-
Referring to Fig. 5, the present embodiment provides a kind of device of reading out data, and this device comprises:
Determination module 501, for determining head pointer position and the tail pointer position of passage;
Comparison module 502, for comparing the definite head pointer position of determination module 501 and the height of tail pointer position;
Read module 503, for according to the continuous read data packet of the comparative result of comparison module 502.
Wherein, read module 503, when comparing head pointer position higher than tail pointer position at comparison module 502, pointer position starts read data packet from the head, until passage afterbody.
Further, read module 503, also starts read data packet for pointer position from the head, until after passage afterbody, change head pointer position, the head pointer position from changing starts read data packet, until tail pointer position.
Alternatively, read module 503, when comparing head pointer position lower than tail pointer position at comparison module 502, pointer position starts read data packet from the head, until tail pointer position.
In sum, the device that the present embodiment provides, by continuous read data packet, thereby can reduce the number of times of reading out data; In addition, the number of times minimizing due to reading out data, can improve the efficiency of reading out data, and then reduces the probability of data from overflow in passage.
It should be noted that: the device of the reading out data that above-described embodiment provides is when reading out data, only the division with above-mentioned each functional module is illustrated, in practical application, can above-mentioned functions be distributed and by different functional modules, completed as required, the inner structure that is about to device is divided into different functional modules, to complete all or part of function described above.In addition, the device of the reading out data that above-described embodiment provides and the embodiment of the method for reading out data belong to same design, and its specific implementation process refers to embodiment of the method, repeats no more here.
The invention described above embodiment sequence number, just to describing, does not represent the quality of embodiment.
All or part of step in the embodiment of the present invention, can utilize software to realize, and corresponding software program can be stored in the storage medium can read, as CD or hard disk etc.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.

Claims (2)

1. a method for reading out data, is characterized in that, described method comprises:
Determine head pointer position and the tail pointer position of passage;
The height of more described head pointer position and described tail pointer position;
When comparing described head pointer position higher than described tail pointer position, from described head pointer position, start read data packet, until passage afterbody changes head pointer position, head pointer position from changing starts read data packet, until tail pointer position;
When comparing described head pointer position lower than described tail pointer position, from described head pointer position, start read data packet, until tail pointer position.
2. a device for reading out data, is characterized in that, described device comprises:
Determination module, for determining head pointer position and the tail pointer position of passage;
Comparison module, for the height of the definite head pointer position of more described determination module and described tail pointer position;
Read module, for when described comparison module compares described head pointer position higher than described tail pointer position, from described head pointer position, start read data packet, until passage afterbody, change head pointer position, head pointer position from changing starts read data packet, until tail pointer position;
Described read module, also when comparing described head pointer position lower than described tail pointer position at described comparison module, starts read data packet from described head pointer position, until 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 CN102402486A (en) 2012-04-04
CN102402486B true 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 (7)

* 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
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

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6381659B2 (en) * 1999-01-19 2002-04-30 Maxtor Corporation 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

Patent Citations (7)

* 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
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
CN102402486A (en) 2012-04-04

Similar Documents

Publication Publication Date Title
US8195845B2 (en) Memory system having high data transfer efficiency and host controller
US9063637B2 (en) Altering a view of a document on a display of a computing device
US11734113B2 (en) Solid state disk access method and apparatus, device, and medium
CN103077183A (en) Data importing method and system for distributed sequence list
RU2617388C2 (en) Method, terminal and electronic device for e-book document processing
CN103279309B (en) Based on DDR control device and the method for FPGA
CN105095287A (en) LSM (Log Structured Merge) data compact method and device
US10754770B2 (en) Work stealing of partially-marked objects
CN109240607B (en) File reading method and device
CN101571850A (en) Display packing and device of text document in support of page turn function
CN103679022A (en) Method and device for virus scanning
CN102968281A (en) Data migration method and device
CN103559146A (en) Method for increasing reading and writing speeds of NAND flash controller
US20150130761A1 (en) Method and apparatus for allocating computing resources in touch-based mobile device
CN103488502A (en) Method and device for loading data
CN103176952A (en) Document display method and document display device
CN103488504A (en) Method and device for loading data
CN102419734A (en) Method and device for storing data
CN106155572B (en) Data storage device and data access method
CN102402486B (en) Method and device for reading data
CN103399662A (en) Method, system and mobile terminal for reporting coordinate incident of touch screen
CN103176753B (en) Storing device and data managing method thereof
CN102479074B (en) A kind of method, device and application system of following the tracks of GUI list refreshing content
CN103389893A (en) Read-write method and device for configuration register
CN106469174B (en) Method for reading 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
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