The content of the invention
It is a primary object of the present invention to provide a kind of method for reading data and device, read with solving data in the prior art
The problem of taking efficiency low.
To achieve these goals, a kind of one side according to embodiments of the present invention, there is provided method for reading data.
Included according to the method for reading data of the present invention:Segmentation mark is added to the original input stream received;Read institute
Original input stream is stated, and multiple data slices are obtained according to original input stream described in the segmentation mark cutting in reading process
Section, and addition end of identification to the multiple data slot in the first data slot, first data slot be positioned at
The data slot of the original input stream end;According to priority position of the multiple data slot in the original input stream
Sequentially, the multiple data slot is stored successively to data buffer zone;And read data from the data buffer zone.
Further, multiple data are obtained according to original input stream described in the segmentation mark cutting in reading process
Fragment includes:A segmentation mark is often read, it is once described initial from cutting from the location of described segmentation mark
Inlet flow, obtain the multiple data slot.
Further, included from the data buffer zone read data packet:Travel through the data buffer zone;Judge whether to read
To the end of identification;In the case where judging to read the end of identification, terminate to travel through the data buffer zone;And
In the case where judging not read the end of identification, continue to travel through the data buffer zone.
Further, the priority sequence of positions according to the multiple data slot in the original input stream, is deposited successively
Storing up the multiple data slot to data buffer zone includes:The first data slot group is stored to the data buffer zone, wherein, institute
Stating the first data slot group includes at least one data slot in the multiple data slot;And in the data buffer zone
In first data slot be read after, storage the second data slot group to the data buffer zone, wherein, described second
Data slot group include the multiple data slot at least one data slot, and the second place be located at first position it
Afterwards, the first position is position of the first data slot group in the original input stream, and the second place is institute
State position of the data slot in the second data slot group in the original input stream.
Further, before segmentation mark to the original input stream received is added, the method for reading data also wraps
Include:Receive and instruction is set;And set instruction that the segmentation mark is set according to described.
To achieve these goals, a kind of another aspect according to embodiments of the present invention, there is provided digital independent device.
Included according to the digital independent device of the present invention:Adding device, it is initial to what is received for adding segmentation mark
Inlet flow;Processing unit, for reading the original input stream, and according to described in the segmentation mark cutting in reading process
Original input stream, obtain the first data slice in multiple data slots, and addition end of identification to the multiple data slot
Section, first data slot are the data slot positioned at the original input stream end;Memory cell, for according to described more
Priority sequence of positions of the individual data slot in the original input stream, stores the multiple data slot to data buffering successively
Area;And reading unit, for reading data from the data buffer zone.
Further, the processing unit includes:Cutting module, for often reading a segmentation mark, from institute
The location of segmentation mark place cutting once original input stream is stated, obtains the multiple data slot.
Further, the reading unit includes:Spider module, for traveling through the data buffer zone;Judge module, use
In judging whether to read the end of identification, wherein, in the case where judging to read the end of identification, the traversal
Module terminates to travel through the data buffer zone, in the case where judging not read the end of identification, the spider module
Continue to travel through the data buffer zone.
Further, the memory cell includes:First memory module, for storing the first data slot group to the number
According to buffering area, wherein, the first data slot group includes at least one data slot in the multiple data slot;And
Second memory module, after being read for first data slot in the data buffer zone, store the second data slice
Data buffer zone described in Duan Zuzhi, wherein, the second data slot group includes at least one in the multiple data slot
Data slot, and the second place is located at after first position, and the first position is the first data slot group described
Position in original input stream, the second place are the data slot in the second data slot group in the initial input
Position in stream.
Further, the digital independent device also includes:Receiving unit, for adding cutting mark in the adding device
Know to before the original input stream received, receive and instruction is set;And setting unit, for setting instruction to set according to described
The segmentation mark.
According to embodiments of the present invention, using addition segmentation mark to the original input stream received;Read described initial defeated
Become a mandarin, and multiple data slots, Yi Jitian are obtained according to original input stream described in the segmentation mark cutting in reading process
Add the first data slot in end of identification to the multiple data slot, first data slot is positioned at described initial defeated
Become a mandarin the data slot of end;According to priority sequence of positions of the multiple data slot in the original input stream, successively
The multiple data slot is stored to data buffer zone;And read data from the data buffer zone.By to initial input
Stream carries out cutting, and adds end of identification to the data slot for being located at original input stream end, then deposits multiple data slots
Store up in data buffer zone, realize and inlet flow is encapsulated in walker, in data read process is carried out from data buffer zone,
The data slot segmented is directly read, until end of identification is read, it is determined that follow-up data no longer be present, whole reading process
Follow-up data need not be judged whether always, whether terminates to read, and simplify data reading step, solve prior art
The problem of middle data reading performance using redundancy is low, and then improve data reading speed and the effect of reading efficiency.
Embodiment
It should be noted that in the case where not conflicting, the feature in embodiment and embodiment in the application can phase
Mutually combination.Describe the present invention in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
In order that those skilled in the art more fully understand the present invention program, below in conjunction with the embodiment of the present invention
Accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is only
The embodiment of a part of the invention, rather than whole embodiments.Based on the embodiment in the present invention, ordinary skill people
The every other embodiment that member is obtained under the premise of creative work is not made, it should all belong to the model that the present invention protects
Enclose.
It should be noted that term " first " in description and claims of this specification and above-mentioned accompanying drawing, "
Two " etc. be for distinguishing similar object, without for describing specific order or precedence.It should be appreciated that so use
Data can exchange in the appropriate case, so as to embodiments of the invention described herein.In addition, term " comprising " and " tool
Have " and their any deformation, it is intended that cover it is non-exclusive include, for example, containing series of steps or unit
Process, method, system, product or equipment are not necessarily limited to those steps clearly listed or unit, but may include without clear
It is listing to Chu or for the intrinsic other steps of these processes, method, product or equipment or unit.
It is as follows to the explanation of technical terms involved by the embodiment of the present invention:
Java:It is a kind of object oriented program language that can write cross-platform software, is by Sun
Java applet design language and Java platform that Microsystems companies release May nineteen ninety-five (i.e. JavaEE, JavaME,
JavaSE general name).
Inlet flow:The object that a byte sequence can be read is referred to as an inlet flow.
Walker:A kind of also referred to as iterator, there is provided each member in one container (container) object of way access
Element, and it is not required to expose the interior details of the object.
Object:The anything studied, the aircraft etc. from simplest integer to complexity can regard object as, it
Specific things can not only be represented, moreover it is possible to represent abstract rule, plan or event.
Class:The abstract of object with identical characteristic (data element) and behavior (function) is exactly class.Therefore, object is taken out
As if class, the materialization of class is exactly object, it may also be said to, the example of class is object, and class is actually a kind of data type.
The embodiments of the invention provide a kind of method for reading data, the digital independent provided below the embodiment of the present invention
Method does specific introduction.
Fig. 1 is the flow chart of method for reading data according to embodiments of the present invention.As shown in figure 1, the method for reading data
Comprise the following steps S102 to step S108:
Step S102, addition segmentation mark to the original input stream received, wherein, segmentation mark can be paddle symbol,
Space etc..
Step S104, original input stream is read, and obtained in reading process according to segmentation mark cutting original input stream
The first data slot in multiple data slots, and the addition at most individual data slot of end of identification, the first data slot is position
Data slot in original input stream end.
Step S106, according to priority sequence of positions of multiple data slots in original input stream, more numbers are stored successively
According to fragment to data buffer zone, specifically, first number can will be stored in positioned at the data slot of the forward opening position of original input stream
According to buffering area, then again by positioned at original input stream, the data slot of opening position is stored in data buffer zone rearward relatively.
Step S108, data are read from data buffer zone.
The method for reading data that the embodiment of the present invention is provided, by carrying out cutting to original input stream, and add and terminate
Then multiple data slots are stored in data buffer zone, realized by mark to the data slot for being located at original input stream end
Inlet flow is encapsulated in walker, in data read process is carried out from data buffer zone, directly reads the data segmented
Fragment, until reading end of identification, it is determined that follow-up data no longer be present, whole reading process need not judge whether to deposit always
In follow-up data, whether terminate to read, simplify data reading step, solve that data reading performance using redundancy in the prior art is low to ask
Topic, and then improve data reading speed and the effect of reading efficiency.Also, the data that the embodiment of the present invention is provided are read
Method is taken, by the way that inlet flow is encapsulated in walker, such a method for reading data based on encapsulation class, execution number can be increased
According to the readability of the code of reading, code only needs to write once, reduces during follow-up use because repeating to write
Caused by mistake, reach improve digital independent the degree of accuracy.
Fig. 2 is the flow chart of method for reading data according to the preferred embodiment of the invention.As shown in Fig. 2 the digital independent
Method comprises the following steps S201 to step S209:
Step S201, receive original input stream.
Step S202:Interpolation data segmentation mark is specifically, identical with above-mentioned steps S102 to original input stream.
Step S203:Read the original input stream after addition segmentation mark.
Step S204:During reading original input stream, judge whether to read segmentation mark, wherein, in judged result
In the case of being, step S205 is performed, in the case where judged result is no, return to step S203.
Step S205:Original input stream after cutting addition segmentation mark.
Step S206:Addition end of identification to end data fragment, end data fragment is located at the end of original input stream,
It is identical with above-mentioned first data slot.
Wherein, step S203 to step S206 is cut equivalent to above-mentioned steps S104 in reading process according to segmentation mark
Point original input stream is specially:A segmentation mark is often read, cutting is once initial defeated from the location of segmentation mark
Become a mandarin, obtain multiple data slots, in the case of not reading segmentation mark, continue initial defeated after reading addition segmentation mark
Become a mandarin, and add end of identification to the data slot for being located at original input stream end.That is, in multiple opening positions of original input stream
It with the addition of segmentation mark, in dicing process, often run into a segmentation mark, the then cutting from the location of the segmentation mark
Original input stream.
Step S207:The data slot after cutting is stored to data buffer zone, it is identical with above-mentioned steps S106, be equally by
According to priority sequence of positions of multiple data slots in original input stream, multiple data slots are stored successively to data buffer zone,
Specifically, the first data slot group can first be stored to data buffer zone, wherein, the first data slot group includes multiple data slices
At least one data slot in section, then, after the first data slot in data buffer zone is read, store the second data
Fragment group to data buffer zone, wherein, the second data slot group include multiple data slots at least one data slot, and
And the second place is located at after first position, first position is position of the first data slot group in original input stream, second
Position is position of the data slot in original input stream in the second data slot group.Once store to number in data buffer zone
It can be set according to the number of fragment according to the buffer capacity of system, if system can distribute more internal memory to data buffering
Area, then the data slot of larger data amount can be stored to data buffer zone, conversely, then data slot of the storage compared with small data quantity
To data buffer zone.Stored data slot is called in data buffer zone reads until then, can by it is to be stored extremely
The data slot of data buffer zone is temporarily stored in data working area, and data working area is the area for temporary transient data storage fragment
Domain.
Step S208, data are read from data buffer zone.
Step S209, judge whether the end of identification read.
Wherein, step S208 and step S209 specifically, can use traversal mode from number equivalent to above-mentioned steps S108
Digital independent is carried out according to buffering area, often travels through a data buffer zone, whether judgement once reads end of identification, judging
In the case of reading end of identification, terminate ergodic data buffering area, in the case where judging not read end of identification, after
Continuous ergodic data buffering area.
Preferably, before segmentation mark to the original input stream received is added, the digital independent of the embodiment of the present invention
Method also includes:Receive and instruction is set, wherein, it can be the instruction that user is issued by input equipment to set instruction, then, pressed
Segmentation mark is set according to setting to instruct, i.e. self-defined setting is carried out to segmentation mark according to the instruction of user.
By the way that according to setting instruction to set segmentation mark, different cut can be set according to the demand of different user by realizing
Minute mark is known, so that the data slot of cutting can farthest meet user's request.
It should be noted that in embodiments of the present invention, can root if user does not have self-defined setting segmentation mark
According to practical experience, the segmentation mark of acquiescence is added to original input stream.
The embodiment of the present invention additionally provides a kind of digital independent device, and the digital independent device is mainly used in performing the present invention
The method for reading data that embodiment the above is provided, the digital independent device provided below the embodiment of the present invention, which is done, to be had
Body introduction.
Fig. 3 is the schematic diagram of digital independent device according to embodiments of the present invention, as shown in figure 3, the digital independent device
Mainly include adding device 10, processing unit 20, memory cell 30 and reading unit 40, wherein:
Adding device 10 is used to add segmentation mark to the original input stream received, wherein, segmentation mark can be drawn
Row symbol, space etc..
Processing unit 20 is used to read original input stream, and according to segmentation mark cutting initial input in reading process
Stream, obtain the first data slot in multiple data slots, and the addition at most individual data slot of end of identification, the first data slice
Section is the data slot positioned at original input stream end.
Memory cell 30 is used for the priority sequence of positions according to multiple data slots in original input stream, stores successively more
Individual data slot, specifically, can be first by the data slot storage positioned at the forward opening position of original input stream to data buffer zone
In data buffer zone, then again by positioned at original input stream, the data slot of opening position is stored in data buffer zone rearward relatively.
Reading unit 40 is used to read data from data buffer zone.
The digital independent device that the embodiment of the present invention is provided, by carrying out cutting to original input stream, and add and terminate
Then multiple data slots are stored in data buffer zone, realized by mark to the data slot for being located at original input stream end
Inlet flow is encapsulated in walker, in data read process is carried out from data buffer zone, directly reads the data segmented
Fragment, until reading end of identification, it is determined that follow-up data no longer be present, whole reading process need not judge whether to deposit always
In follow-up data, whether terminate to read, simplify data reading step, solve that data reading performance using redundancy in the prior art is low to ask
Topic, and then improve data reading speed and the effect of reading efficiency.Also, the data that the embodiment of the present invention is provided are read
Method is taken, by the way that inlet flow is encapsulated in walker, such a method for reading data based on encapsulation class, execution number can be increased
According to the readability of the code of reading, code only needs to write once, reduces during follow-up use because repeating to write
Caused by mistake, reach improve digital independent the degree of accuracy.
Wherein, processing unit 20 mainly includes cutting module, and the cutting module is used to often read a segmentation mark, from
Original input stream of the location of segmentation mark place cutting, obtains multiple data slots.That is, adding device 10 is initial defeated
The multiple opening positions to become a mandarin with the addition of segmentation mark, in dicing process, often run into a segmentation mark, cutting module is cut from this
Minute mark knows original input stream of cutting at location.
Memory cell 30 mainly includes the first memory module and the second memory module, and specifically, the first memory module is used for
Store the first data slot group to data buffer zone, the second memory module and be used for the first data slot quilt in data buffer zone
After reading, the second data slot group is stored to data buffer zone, wherein, the first data slot group is included in multiple data slots
At least one data slot, the second data slot group include at least one data slot in multiple data slots, and second
Position is located at after first position, and first position is position of the first data slot group in original input stream, and the second place is
Position of the data slot in original input stream in second data slot group.Once store to data slot in data buffer zone
Number can be set according to the buffer capacity of system, can if system can distribute more internal memory to data buffer zone
To store the data slot of larger data amount to data buffer zone, conversely, then storage compared with the data slot of small data quantity to data
Buffering area.Stored data slot is called in data buffer zone reads until then, can delay to be stored to data
The data slot for rushing area is temporarily stored in data working area, and data working area is the region for temporary transient data storage fragment.
Reading unit 40 mainly includes spider module and judge module, wherein, spider module is used for ergodic data buffering area,
Judge module is used to judge whether to read end of identification, in the case where judging to read end of identification, spider module knot
Beam ergodic data buffering area, in the case where judging not read end of identification, spider module continues ergodic data buffering area.
Preferably, the digital independent device that the embodiment of the present invention is provided can also include receiving unit and setting unit,
Before adding device 10 adds segmentation mark to the original input stream received, receiving unit, which is used to receive, sets instruction, should
It can be the instruction that user is issued by input equipment to set instruction, and setting unit, which is used to instruct according to setting, sets cutting mark
Know, i.e. self-defined setting is carried out to segmentation mark according to the instruction of user.
By the way that according to setting instruction to set segmentation mark, different cut can be set according to the demand of different user by realizing
Minute mark is known, so that the data slot of cutting can farthest meet user's request.
It should be noted that for foregoing each method embodiment, in order to be briefly described, therefore it is all expressed as a series of
Combination of actions, but those skilled in the art should know, the present invention is not limited by described sequence of movement because
According to the present invention, some steps can use other orders or carry out simultaneously.Secondly, those skilled in the art should also know
Know, embodiment described in this description belongs to preferred embodiment, and involved action and module are not necessarily of the invention
It is necessary.
In the above-described embodiments, the description to each embodiment all emphasizes particularly on different fields, and does not have the portion being described in detail in some embodiment
Point, it may refer to the associated description of other embodiment.
In several embodiments provided herein, it should be understood that disclosed device, can be by another way
Realize.For example, device embodiment described above is only schematical, such as the division of the unit, it is only one kind
Division of logic function, can there is an other dividing mode when actually realizing, such as multiple units or component can combine or can
To be integrated into another system, or some features can be ignored, or not perform.Another, shown or discussed is mutual
Coupling direct-coupling or communication connection can be by some interfaces, the INDIRECT COUPLING or communication connection of device or unit,
Can be electrical or other forms.
The unit illustrated as separating component can be or may not be physically separate, show as unit
The part shown can be or may not be physical location, you can with positioned at a place, or can also be distributed to multiple
On NE.Some or all of unit therein can be selected to realize the mesh of this embodiment scheme according to the actual needs
's.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, can also
That unit is individually physically present, can also two or more units it is integrated in a unit.Above-mentioned integrated list
Member can both be realized in the form of hardware, can also be realized in the form of SFU software functional unit.
If the integrated unit is realized in the form of SFU software functional unit and is used as independent production marketing or use
When, it can be stored in a computer read/write memory medium.Based on such understanding, technical scheme is substantially
The part to be contributed in other words to prior art or all or part of the technical scheme can be in the form of software products
Embody, the computer software product is stored in a storage medium, including some instructions are causing a computer
Equipment (can be personal computer, mobile terminal, server or network equipment etc.) performs side described in each embodiment of the present invention
The all or part of step of method.And foregoing storage medium includes:USB flash disk, read-only storage (ROM, Read-Only Memory),
Random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disc or CD etc. are various to be stored
The medium of program code.
The preferred embodiments of the present invention are the foregoing is only, are not intended to limit the invention, for the skill of this area
For art personnel, the present invention can have various modifications and variations.Within the spirit and principles of the invention, that is made any repaiies
Change, equivalent substitution, improvement etc., should be included in the scope of the protection.