CN105700828B - A kind of write-in of data, read method and device - Google Patents

A kind of write-in of data, read method and device Download PDF

Info

Publication number
CN105700828B
CN105700828B CN201610028102.3A CN201610028102A CN105700828B CN 105700828 B CN105700828 B CN 105700828B CN 201610028102 A CN201610028102 A CN 201610028102A CN 105700828 B CN105700828 B CN 105700828B
Authority
CN
China
Prior art keywords
time
flow data
region
write
default storage
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
CN201610028102.3A
Other languages
Chinese (zh)
Other versions
CN105700828A (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.)
Bo Hui Science And Technology Co Ltd Of Beijing
Original Assignee
Bo Hui Science And Technology Co Ltd Of Beijing
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 Bo Hui Science And Technology Co Ltd Of Beijing filed Critical Bo Hui Science And Technology Co Ltd Of Beijing
Priority to CN201610028102.3A priority Critical patent/CN105700828B/en
Publication of CN105700828A publication Critical patent/CN105700828A/en
Application granted granted Critical
Publication of CN105700828B publication Critical patent/CN105700828B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • G06F3/0631Configuration or reconfiguration of storage systems by allocating resources to storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0674Disk device
    • G06F3/0676Magnetic disk device

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Signal Processing For Digital Recording And Reproducing (AREA)

Abstract

The invention discloses a kind of write-in of data, read method and device, which may include: to obtain new TS flow data;Select next default storage region of previous writing area as current writing region from the identical default storage region of multiple memory spaces according to sequence;TS flow data is written to current writing region, is originally written into the time as current writing region at the time of write-in will be started;It is full to judge whether current writing region is write by TS flow data;When current writing region writes full by TS flow data, using end write time at the time of writing full as current writing region, and using next default storage region of the sequence after current writing region as target writing area, and subsequent TS flow data is written in target writing area, the time is originally written into as target writing area at the time of write-in will be started.Technical solution of the present invention will not generate disk fragments, and avoiding disk access becomes slowly even to collapse.

Description

A kind of write-in of data, read method and device
Technical field
The present invention relates to technical field of data processing, in particular to a kind of data write-in, read method and device.
Background technique
It, can be with when due to using transport stream (Transport Stream, hereinafter referred to as TS stream) transmission audio, video data Realize and played in transmission, and have no effect on the broadcasting of subsequent audio-video in the case where intermediate packet loss, thus TS flow gradually at The major way that audio-video is transmitted for media such as TV, networks.For this purpose, the recording technology of TS stream also becomes more to weigh It wants.
Currently, TS stream method for recording in the related technology freely deposits corresponding video file when recording TS flow data It is placed on disk.As disk uses the passage of time, due to recording the needs or other reasons in space, user can constantly be carried out The operations such as newly-increased file, deletion file, simultaneously because the size of each video file is different, so will cause many disks Fragment, eventually leading to disk access becomes extremely slowly even to collapse.
Summary of the invention
A kind of method for writing data, read method and device are provided in the embodiment of the present invention, to avoid disk fragments Occur, prevents disk access from becoming slowly even to collapse.
In order to solve the above-mentioned technical problem, the embodiment of the invention discloses following technical solutions:
A kind of method for writing data, which comprises
Obtain new TS flow data;
Select from multiple default storage regions next default storage region of previous writing area as working as according to sequence The memory space of preceding writing area, the multiple default storage region is all the same;
The TS flow data is written to the current writing region, as described presently written at the time of starting to be written Region is originally written into the time;
It is full to judge whether the current writing region is write by the TS flow data;
When the current writing region writes full by the TS flow data, using at the time of writing full as the presently written area The end write time in domain, and next default storage region of the sequence after the current writing region is write as target Enter region, and subsequent TS flow data is written in the target writing area, will start to write at the time of write-in as the target Enter region is originally written into the time.
Preferably, the method also includes:
For any writing area of the TS flow data, any writing area is written since the TS flow data Start time carries out timing;
Every prefixed time interval, record ends total write-in duration of any writing area described in current time, total write-in The data volume being written in data volume, current preset time interval.
Preferably, the method also includes:
When the target writing area does not write full by the TS flow data, judge whether the TS flow data breaks Stream;
When the TS flow data stops, by next default storage of the sequence after the target writing area Region is as fresh target writing area;
Judge whether the TS flow data restores;
When the TS flow data restores, the TS flow data after recovery is written to the fresh target writing area.
Preferably, the method also includes:
Judge the current writing region whether be in multiple default storage regions sort end default storage region;
It, will be multiple when the current writing region is the default storage region at sequence end in multiple default storage regions The default storage region of sequence first is as target writing area in default storage region.
A kind of method for reading data, which comprises
Obtain the corresponding temporal information of TS flow data to be visited;Wherein, all TS flow datas are stored in multiple storages In the identical default storage region in space, the temporal information includes starting read access time and end read access time;
Obtain the TS flow data in each default storage region is originally written into time and end write time;
It is originally written into time and end write time according to the TS flow data in each default storage region, is obtained containing It states and starts read access time and the default storage region of the one or more for terminating the TS flow data between read access time.
Preferably, the method also includes:
Obtain the write-in duration of each default storage region in one or more of default storage regions, data block offset, Corresponding relationship between writing data blocks size;
It is originally written into time and end write time according to the corresponding relationship and each default storage region are corresponding, Obtain the corresponding data block offset of the beginning read access time and the corresponding data block offset of the end read access time;
It reads the corresponding data block of the beginning read access time and deviates data block processed corresponding with the end read access time TS flow data between offset.
A kind of data transfer apparatus, described device include:
TS flow data acquiring unit, for obtaining new TS flow data;
Current writing region determination unit, for selecting previous writing area from multiple default storage regions according to sequence Next default storage region as current writing region, the memory space of the multiple default storage region is all the same;
First TS flow data writing unit will start for the TS flow data to be written to the current writing region The time is originally written into as the current writing region at the time of write-in;
Full judging unit is write, is expired for judging whether the current writing region is write by the TS flow data;
First object writing area determination unit, for when the current writing region writes full by the TS flow data, Using end write time at the time of writing full as the current writing region, and will sequence be located at the current writing region it Next default storage region afterwards is written in the target writing area as target writing area, and by subsequent TS flow data, The time is originally written into as the target writing area at the time of starting write-in.
Preferably, described device further include:
Timing starts unit, for any writing area for the TS flow data, writes since the TS flow data Enter any writing area start time progress timing;
Recording unit, for every prefixed time interval, record to end always writing for any writing area described in current time Enter duration, the interior data volume being written of data volume, current preset time interval is always written.
Preferably, described device further include:
Stop judging unit, for judging the TS when the target writing area does not write full by the TS flow data Whether flow data stops;
Fresh target writing area determination unit, for when the TS flow data stops, sequence to be located at the mesh Next default storage region after mark writing area is as fresh target writing area;
Restore judging unit, for judging whether the TS flow data restores;
2nd TS flow data writing unit, for when the TS flow data restores, the TS flow data after recovery to be written To the fresh target writing area.
Preferably, described device further include:
Region decision unit, for judging whether the current writing region is end of sorting in multiple default storage regions Default storage region;
Second target writing area determination unit, for being to be arranged in multiple default storage regions when the current writing region When the default storage region at sequence end, be written the default storage region of sequence first in multiple default storage regions as target Region.
A kind of reading data device, described device include:
Temporal information acquiring unit, for obtaining the corresponding temporal information of TS flow data to be visited;Wherein, all TS Flow data is stored in the identical default storage region of multiple memory spaces, and the temporal information includes starting read access time and knot Beam read access time;
Write time acquiring unit is originally written into time and knot for obtain the TS flow data in each default storage region The beam write time;
Storage region acquiring unit, for being originally written into time and knot according to the TS flow data in each default storage region The beam write time obtains containing the beginning read access time and one or more for terminating the TS flow data between read access time A default storage region.
Preferably, described device further include:
Corresponding relationship acquiring unit, for obtaining each default storage region in one or more of default storage regions Duration is written, data block deviates, the corresponding relationship between writing data blocks size;
Deviate acquiring unit, for according to the corresponding relationship and each default storage region is corresponding be originally written into when Between and terminate the write time, obtain the corresponding data block of the beginnings read access time and deviate and the end read access time pair The data block offset answered;
Reading unit, for reading the corresponding data block offset of the beginning read access time and the end read access time pair The TS flow data between data block processed offset answered.
The technical scheme provided by this disclosed embodiment can include the following benefits:
A kind of method for writing data and device that the embodiment of the present disclosure provides default are deposited to multiple memory spaces are identical When storing up space write-in TS flow data;It is selected under previous writing area from multiple default storage regions first, in accordance with sequence One default storage region is as current writing region;And the TS flow data is written to the current writing region, it will start The time is originally written into as the current writing region at the time of write-in.Further, when the current writing region is by institute When stating TS flow data and writing full, using end write time at the time of writing full as the current writing region, and sequence is located at Next default storage region after the current writing region, will be described in the write-in of subsequent TS flow data as target writing area In target writing area, the time is originally written into as the target writing area at the time of write-in will be started.
When application the embodiment of the present invention scheme when, when TS flow data be written, only when write expire a default memory space When, just kept away to next default memory space write-in TS flow data so technical solution of the present invention will not generate disk fragments Having exempted from disk access becomes slowly even to collapse.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, for those of ordinary skill in the art Speech, without any creative labor, is also possible to obtain other drawings based on these drawings.
Fig. 1 is a kind of flow chart of method for writing data provided in an embodiment of the present invention;
Fig. 2 is the flow chart of another method for writing data provided in an embodiment of the present invention;
The flow chart of Fig. 3 another method for writing data provided in an embodiment of the present invention;
The flow chart of Fig. 4 another method for writing data provided in an embodiment of the present invention;
A kind of Fig. 5 flow chart of method for reading data provided in an embodiment of the present invention;
The flow chart of Fig. 6 another method for reading data provided in an embodiment of the present invention;
Fig. 7 is a kind of structural schematic diagram of data transfer apparatus provided in an embodiment of the present invention;
Fig. 8 is the structural schematic diagram of another data transfer apparatus provided in an embodiment of the present invention;
The structural schematic diagram of Fig. 9 another data transfer apparatus provided in an embodiment of the present invention;
The structural schematic diagram of Figure 10 another data transfer apparatus provided in an embodiment of the present invention;
A kind of Figure 11 structural schematic diagram of reading data device provided in an embodiment of the present invention;
The structural schematic diagram of Figure 12 another reading data device provided in an embodiment of the present invention.
Specific embodiment
A kind of method for writing data, read method and device are provided in the embodiment of the present invention, to avoid disk fragments Occur, prevents disk access from becoming slowly even to collapse.
Technical solution in embodiment in order to enable those skilled in the art to better understand the present invention, and make of the invention real The above objects, features, and advantages for applying example can be more obvious and easy to understand, with reference to the accompanying drawing to technical side in the embodiment of the present invention Case is described in further detail.
As shown in Figure 1, being a kind of flow chart of method for writing data provided in an embodiment of the present invention, this method may include Following steps:
In step s101, new TS flow data is obtained;
Specifically, in this step, the new TS flow data of acquisition refers to the TS flow data for newly starting to record, for example, newly Start some radio station recorded or the TS flow data of some program.
In step s 102, next preset of previous writing area is selected to deposit from multiple default storage regions according to sequence As current writing region, the memory space of the multiple default storage region is all the same in storage area domain;
Specifically, in this step, according to the write sequence of pre-set multiple default storage regions, by write sequence Sequence be located at previous writing area next default storage region be determined as current writing region.Wherein, it is currently write in determination When entering region, the history write-in record that can be flowed according to TS searches previous writing area from multiple default storage regions, then presses Next default storage region of previous writing area is determined as current writing region by the sequence according to write sequence, can also be from multiple The default storage region that TS stream is not written is searched in default storage region, TS stream then will not be written according to the sequence of write sequence Default storage region in first default storage region be determined as current writing region etc..In addition, write sequence is adjacent The memory space of default storage region can be adjacent, can also be non-conterminous.For example, one share 5 memory spaces be ordered as A, B, the default storage region of C, D, E, pre-set write sequence is followed successively by A, B, C, D, E, and finds previous writing area To preset storage region B, then using default storage region C as current writing region.For another example, one 4 memory space sequences are shared For the default storage region of A ', B ', C ', D ', pre-set write sequence is A ', D ', B ', C ', and finds previous write-in Region is default storage region D ', then regard default storage region B ' as current writing region.Wherein, A, B, C, D, E, A ', B ', C ', D ' are the title of each default storage region, it is to be understood that aforementioned names are only schematical, and each preset is deposited The title in storage area domain, which can according to need, to be configured.
In addition, it should be noted that, the memory space of multiple default storage regions is all the same, each default storage region The size of memory space can be configured according to factors such as video recording duration, video recording size, disk sizes, for example, each preset is deposited The size of the memory space in storage area domain can be 64MB, 128MB, 256MB, 512MB, 600MB etc..Wherein, each preset is deposited Storage area domain can be sky, can also be deactivated in advance data and take.
In step s 103, the TS flow data is written to the current writing region, work at the time of write-in will be started The time is originally written into for the current writing region;
Specifically, in this step, TS flow data acquired in step s101 is written to working as of selecting in step S102 In preceding writing area, and by TS flow data start be written current writing region at the time of be recorded as current writing region initially write The angle of incidence.Wherein, when each default storage region is empty, TS flow data is gradually written in current writing region;When each When default storage region is deactivated data and takes, the invalid data in current writing region is gradually covered with TS flow data.
In addition, can set the recording state of current writing region to during current writing region write-in TS stream Just in recording state, correspondingly, stop recording TS flow data (for example, cutout, TS stream occurs in TS flow data in current writing region Data have write full current writing region or TS stream and have completed the situations such as recording in current writing region) when, it can be by presently written area The recording state in domain is set as stopping recording state.In specific setting up procedure, presently written area is marked using specific identifier The write state in domain, such as stop recording state using 0 label of number just in recording state using 1 label of number.It is understood that , during other default storage regions are written in TS data, or storage region is preset at other and stops recording TS When flow data, the recording state of corresponding default storage region also can be set, hereafter this is repeated no more.
In step S104, it is full to judge whether the current writing region is write by the TS flow data;
Specifically, in this step, the size of the statistics available TS flow data currently obtained, when the TS flow data currently obtained Size when being equal to the memory space of default storage region, it is full to determine that current writing region is write by TS flow data.When each default When storage region is empty, whether the remaining space that can detect current writing region is zero, is detecting current writing region When remaining space is zero, it is full to determine that current writing region is write by TS flow data.It is accounted for when each default storage region is deactivated data Man Shi, whether detectable current writing region has invalid data, and when detecting that there is invalid data in current writing region, determination is worked as Write by TS flow data full in preceding writing area.
When the current writing region writes full by the TS flow data, in step s105, using at the time of writing full as The end write time of the current writing region, and next default storage by sequence after the current writing region Region is written in the target writing area as target writing area, and by subsequent TS flow data, at the time of starting write-in The time is originally written into as the target writing area.
Specifically, in this step, when judging that current writing region writes full by TS flow data in step S104, by TS Flow data is recorded as the end write time of current writing region at the time of writing full current writing region, further, according to pre- The write sequence for the multiple default storage regions being first arranged, the sequence of write sequence is next after current writing region Storage region is preset as target writing area, and target writing area is written into subsequent TS flow data, TS flow data is started Target writing area is recorded as at the time of target writing area is written is originally written into the time.Wherein, when each default memory block When domain is empty, TS flow data is gradually written in target writing area;When each default storage region, which is deactivated data, to be taken, With the invalid data in TS flow data gradually coverage goal writing area.
Further, it is to be appreciated that TS flow data can be write and meet the eye on every side mark when target writing area writes full by TS flow data It is recorded as the end write time of target writing area at the time of writing area, and is located at after target writing area to sequence TS flow data is written in next default storage region.It is understood that TS flow data is when being written any default storage region Writing mode be all identical, and the beginning write time of default storage region can be all recorded at the time of corresponding and end is write The angle of incidence hereafter repeats no more this.
TS fluxion is being written to the identical default memory space of multiple memory spaces in this method provided in an embodiment of the present invention According to when;Next default storage region of previous writing area is selected to make from multiple default storage regions first, in accordance with sequence For current writing region;And the TS flow data is written to the current writing region, as institute at the time of starting to be written That states current writing region is originally written into the time.Further, when the current writing region writes full by the TS flow data, Using end write time at the time of writing full as the current writing region, and will sequence be located at the current writing region it Subsequent TS flow data is written in the target writing area as target writing area for next default storage region afterwards, will The time is originally written into as the target writing area at the time of starting write-in.
When application the embodiment of the present invention scheme when, when TS flow data be written, only when write expire a default memory space When, just kept away to next default memory space write-in TS flow data so technical solution of the present invention will not generate disk fragments Having exempted from disk access becomes slowly even to collapse.
As shown in Fig. 2, in a kind of specific embodiment of the invention, the method for writing data can also include:
In step s 201, for any writing area of the TS flow data, institute is written since the TS flow data State any writing area start time progress timing;
In step S202, every prefixed time interval, record ends always writing for any writing area described in current time Enter duration, the interior data volume being written of data volume, current preset time interval is always written.
Wherein, in specific implementation process of the present invention, the prefixed time interval is configured according to specific needs, example It such as can be 0.5s, 1s, 2s.
Specifically, in this specific embodiment, it for any writing area of TS flow data, is write since TS flow data Start timing at the beginning of entering corresponding writing area, every prefixed time interval, record cut-off current time is write accordingly Enter total write-in duration in region, the interior data volume being written of data volume, current preset time interval is always written, in corresponding write area When stopping is recorded in domain, the write-in duration of corresponding writing area can be obtained, data block deviates, between writing data blocks size Corresponding relationship.For example, prefixed time interval is 1s, a length of 100s in the recording of corresponding writing area, then in corresponding relationship Having recorded 0s, 1s, 2s, 3s ..., 100s corresponds to the data block offset and the writing data blocks size of corresponding every 1s at moment.Before The corresponding relationship stated is that the accurate access of TS flow data provides convenience.
As shown in figure 3, in a kind of specific embodiment of the invention, the method for writing data can also include:
When the target writing area does not write full by the TS flow data, in step S301, the TS fluxion is judged According to whether stopping;
When the TS flow data stops, in step s 302, sequence is located at after the target writing area Next default storage region as fresh target writing area;
In step S303, judge whether the TS flow data restores;
When the TS flow data restores, in step s 304, the TS flow data after recovery is written to the fresh target Writing area.
Specifically, in this specific embodiment, first determine whether the target writing area in step S105 is flowed by TS Data are write completely, when judging that target writing area does not write full by TS flow data, further, judge whether TS flow data occurs Cutout, and when TS flow data stops, next preset of the sequence of write sequence after target writing area is deposited Storage area domain is as fresh target writing area.Then judge whether TS flow data restores, and the TS flow data after recovery is written newly Target writing area.In the embodiment, the TS flow data after recovery is written to fresh target writing area, is write using target The beginning write time of the end write time and fresh target writing area that enter region truly record the cutout time, this is solved In the prior art due to being directly stored together the TS flow data of cutout front and back, asking for cutout time cannot be truly recorded Topic.
As shown in figure 4, in a kind of specific embodiment of the invention, the method for writing data can also include:
In step S401, judge whether the current writing region is the pre- of end of sorting in multiple default storage regions If storage region;
When the current writing region is the default storage region at sequence end in multiple default storage regions, in step In S402, using the default storage region of sequence first in multiple default storage regions as target writing area.
Specifically, in this specific embodiment, judge that current writing region is write by TS flow data in step S104 Man Shi further judges whether current writing region is to sort in multiple default storage regions according to the sequence of write sequence The default storage region at end, and determining that current writing region is the default storage at multiple default storage regions sequence ends When region, using the default storage region of write sequence sequence first in multiple default storage regions as target writing area, When TS flow data is written, TS data are gradually covered into original TS flow data in the default storage region.It is understood that It is aforementioned sequence first default storage region be fully written after, then can according to the sequence of write sequence by subsequent TS flow data to write The default storage region of sequence second is written in the identical mode of default storage region for entering aforementioned sequence first, and so on.It is logical The embodiment is crossed, the recycling of multiple default storage regions is realized.
After TS flow data is written by above method embodiment, the embodiment of the present invention also provides a kind of TS for reading write-in The method of flow data.As shown in figure 5, being a kind of flow chart of method for reading data provided in an embodiment of the present invention, this method can With the following steps are included:
In step S501, the corresponding temporal information of TS flow data to be visited is obtained;
Wherein, all TS flow datas are stored in the identical default storage region of multiple memory spaces, the time letter Breath includes starting read access time and end read access time;
Specifically, in this step, the corresponding temporal information of TS flow data to be visited is obtained, wherein the temporal information It can be obtained in such a way that user inputs, it is real that the storing process about TS flow data can refer to Fig. 1-either method shown in fig. 5 Apply example.
In step S502, when being originally written into the time and terminating write-in of the TS flow data in each default storage region is obtained Between;
Specifically, in this step, obtain the TS flow data in each default storage region is originally written into time and end Write time.
In step S503, according to the TS flow data in each default storage region when being originally written into the time and terminating to be written Between, it obtains and presets and deposit containing the beginning read access time and the one or more for terminating the TS flow data between read access time Storage area domain.
Specifically, in this step, being originally written into for TS flow data in each default storage region is obtained in step S502 After time and end write time, for the TS flow data in any default storage region, when it is originally written into time and end When thering is at least one to be located at beginning read access time and terminate between read access time in the write time, or when it is originally written into the time With start read access time it is identical when, or when its terminate the write time with terminate read access time it is identical when, determine it is corresponding preset Contain the TS flow data started between read access time and end read access time in storage region.Wherein, containing beginning read access time The number of the default storage region of TS flow data between end read access time is one or more.
For example, the beginning read access time of TS flow data to be visited is 10:30:00, end read access time is 12:30:00, One shares 5 default storage regions, wherein the time that is originally written into of first default storage region is 09:00:00, terminates to write The angle of incidence is 09:59:59;The time that is originally written into of second default storage region is 10:00:00, and terminating the write time is 10: 59:59;The time that is originally written into of the default storage region of third is 11:00:00, and the end write time is 11:59:59;4th The time that is originally written into of a default storage region is 12:00:00, and the end write time is 12:59:59;5th default storage The time that is originally written into region is 13:00:00, and the end write time is 13:59:59;Then containing beginning read access time and end The default storage region of TS flow data between read access time be second default storage region, third default storage region and 4th default storage region.
This method provided in an embodiment of the present invention includes starting read access time it is corresponding to obtain TS flow data to be visited After the temporal information of end read access time, the time is originally written into according to the TS flow data in each default storage region of acquisition With the end write time, obtain containing the beginning read access time and one for terminating the TS flow data between read access time Or multiple default storage regions.Program file phase corresponding with needing manually to search TS flow data to be visited in the related technology Than realizing the quick lookup to the corresponding default storage region of TS flow data to be visited.
As shown in fig. 6, in a kind of specific embodiment of the invention, the method for reading data can also include:
In step s 601, when obtaining the write-in of each default storage region in one or more of default storage regions Corresponding relationship between long, data block offset, writing data blocks size;
Specifically, in the step, the one or more obtained in obtaining step S503 is preset each preset in storage region and is deposited The write-in duration in storage area domain, data block offset, the corresponding relationship between writing data blocks size.Wherein, each default storage region Write-in duration, data block offset, corresponding relationship between writing data blocks size storing process can be found in reality shown in Fig. 2 Example is applied, which is not described herein again.
In step S602, according to the corresponding relationship and each default storage region it is corresponding be originally written into the time and Terminate the write time, obtains the corresponding data block offset of the beginning read access time and the end read access time is corresponding Data block offset;
Specifically, according to the corresponding relationship obtained in step S601 and each default storage region is corresponding is originally written into Time and end write time obtain and start the corresponding data block offset of read access time, and terminate the corresponding number of read access time It is deviated according to block.For example, starting read access time is 10:30:00, end read access time is 12:30:00, contains beginning read access time The number of the default storage region of TS flow data between end read access time is three, is originally written into the time and end is write The angle of incidence is respectively (10:00:00,10:59:59), (11:00:00,11:59:59), (12:00:00,12:59:59), is corresponded to The data block offset and write-in data volume that every 1s is had recorded in relationship, then it can be seen that, it is inclined to start the corresponding data block of read access time It moves are as follows: be originally written into the time and terminate the 1500s's for the default storage region that the write time is (10:00:00,10:59:59) Data block offset;Terminate read access time corresponding data block offset are as follows: be originally written into the time and terminate the write time be (12:00: 00,12:59:59) data block of the 1500s of default storage region deviates.
In step S603, the corresponding data block offset of the beginning read access time and the end read access time pair are read The TS flow data between data block processed offset answered.
Specifically, in this step, it reads and starts the corresponding data block offset of read access time and terminate read access time to correspond to Data block offset between TS flow data, i.e., read since starting corresponding data block offset place of read access time corresponding pre- It is continuous to read to terminating read access time pair then according to the recording time sequence of TS flow data if the TS flow data of storage region At the data block offset answered.The embodiment realizes the accurate access to TS flow data to be visited automatically, improves user Experience.
In preceding method embodiment, identical step can be used for reference mutually, and different steps can be freely combined, and not The scheme formed after same step combination, also belongs to the protection scope of the disclosure.
Relative to above method embodiment, the embodiment of the invention also provides a kind of data transfer apparatus.Reference Fig. 7, For a kind of structural schematic diagram of data transfer apparatus provided in an embodiment of the present invention, the apparatus may include: TS flow data obtains Unit 701, the first TS flow data writing unit 703, writes full judging unit 704 and first at current writing region determination unit 702 Target writing area determination unit 705.
TS flow data acquiring unit 701 is for obtaining new TS flow data;
Current writing region determination unit 702 is used to select previous write area from multiple default storage regions according to sequence For next default storage region in domain as current writing region, the memory space of the multiple default storage region is all the same;
First TS flow data writing unit 703 is used to the TS flow data being written to the current writing region, will open The time is originally written into as the current writing region at the time of beginning to be written;
It writes full judging unit 704 and is used to judge whether the current writing region to be write completely by the TS flow data;
First object writing area determination unit 705 is used to be write when the current writing region by the TS flow data full When, it is located at the presently written area using end write time at the time of writing full as the current writing region, and by sequence The target writing area is written as target writing area, and by subsequent TS flow data in next default storage region after domain It is interior, the time is originally written into as the target writing area at the time of write-in will be started.
TS fluxion is being written to the identical default memory space of multiple memory spaces in the device provided in an embodiment of the present invention According to when;Next default storage region of previous writing area is selected to make from multiple default storage regions first, in accordance with sequence For current writing region;And the TS flow data is written to the current writing region, as institute at the time of starting to be written That states current writing region is originally written into the time.Further, when the current writing region writes full by the TS flow data, Using end write time at the time of writing full as the current writing region, and will sequence be located at the current writing region it Subsequent TS flow data is written in the target writing area as target writing area for next default storage region afterwards, will The time is originally written into as the target writing area at the time of starting write-in.
When application the embodiment of the present invention scheme when, when TS flow data be written, only when write expire a default memory space When, just kept away to next default memory space write-in TS flow data so technical solution of the present invention will not generate disk fragments Having exempted from disk access becomes slowly even to collapse.
As shown in figure 8, the data transfer apparatus can also include: meter in a kind of specific embodiment of the invention When start unit 801 and recording unit 802.
Timing starts unit 801 for any writing area for the TS flow data, since the TS flow data Any writing area start time progress timing is written;
Recording unit 802 is used for every prefixed time interval, and record ends the total of any writing area described in current time Duration is written, the interior data volume being written of data volume, current preset time interval is always written.
As shown in figure 9, the data transfer apparatus can also include: disconnected in a kind of specific embodiment of the invention It flows judging unit 901, fresh target writing area determination unit 902, restore judging unit 903 and the 2nd TS flow data writing unit 904。
The judging unit 901 that stops is used for when the target writing area does not write full by the TS flow data, described in judgement Whether TS flow data stops;
Fresh target writing area determination unit 902 is used for when the TS flow data stops, and sequence is located at described Next default storage region after target writing area is as fresh target writing area;
Restore judging unit 903 for judging whether the TS flow data restores;
2nd TS flow data writing unit 904 is used to write the TS flow data after recovery when the TS flow data restores Enter to the fresh target writing area.
As shown in Figure 10, in a kind of specific embodiment of the invention, the data transfer apparatus can also include: area Domain judging unit 1001 and the second target writing area determination unit 1002.
Region decision unit 1001 is for judging whether the current writing region is to sort in multiple default storage regions The default storage region at end;
Second target writing area determination unit 1002 is used to when the current writing region be multiple default storage regions When the default storage region at middle sequence end, using the default storage region of sequence first in multiple default storage regions as target Writing area.
The embodiment of the invention also provides a kind of reading data devices.It as shown in figure 11, is provided in an embodiment of the present invention A kind of structural schematic diagram of reading data device, the apparatus may include: temporal information acquiring unit 1101, write time obtain Unit 1102 and storage region acquiring unit 1103.
Temporal information acquiring unit 1101 is for obtaining the corresponding temporal information of TS flow data to be visited;Wherein, own TS flow data be stored in the identical default storage region of multiple memory spaces, the temporal information include start read access time With end read access time;
What write time acquiring unit 1102 was used to obtain TS flow data in each default storage region is originally written into the time With the end write time;
Storage region acquiring unit 1103 is used to be originally written into the time according to the TS flow data in each default storage region With the end write time, obtain containing the beginning read access time and one for terminating the TS flow data between read access time Or multiple default storage regions.
The device provided in an embodiment of the present invention includes starting read access time it is corresponding to obtain TS flow data to be visited After the temporal information of end read access time, the time is originally written into according to the TS flow data in each default storage region of acquisition With the end write time, obtain containing the beginning read access time and one for terminating the TS flow data between read access time Or multiple default storage regions.Program file phase corresponding with needing manually to search TS flow data to be visited in the related technology Than realizing the quick lookup to the corresponding default storage region of TS flow data to be visited.
As shown in figure 12, in a kind of specific embodiment of the invention, the reading data device can also include: pair Answer Relation acquisition unit 1201, offset acquiring unit 1202 and reading unit 1203.
Corresponding relationship acquiring unit 1201 is for obtaining each default memory block in one or more of default storage regions The write-in duration in domain, data block offset, the corresponding relationship between writing data blocks size;
Offset acquiring unit 1202 is used for according to the corresponding relationship and each default storage region is corresponding is originally written into Time and end write time obtain the corresponding data block offset of the beginning read access time and the end read access time Corresponding data block offset;
When reading unit 1203 is for reading the corresponding data block offset of the beginning read access time and end reading Between TS flow data between corresponding data block processed offset.
About the device in above-described embodiment, wherein modules execute the concrete mode of operation in related this method Embodiment in be described in detail, no detailed explanation will be given here.And it is understood that in above-described embodiment It can be freely combined between each module of device, by the scheme after different block combiners, also belong to the protection scope of the disclosure.
It should be noted that, in this document, the relational terms of such as " first " and " second " or the like are used merely to one A entity or operation with another entity or operate distinguish, without necessarily requiring or implying these entities or operation it Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant are intended to Cover non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes those Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or setting Standby intrinsic element.
It is required that those skilled in the art can be understood that the technology in the embodiment of the present invention can add by software The mode of general hardware platform realize.Based on this understanding, the technical solution in the embodiment of the present invention substantially or Say that the part that contributes to existing technology can be embodied in the form of software products, which can deposit Storage is in storage medium, such as ROM/RAM, magnetic disk, CD, including some instructions are used so that computer equipment (can be with It is personal computer, server or the network equipment etc.) execute certain part institutes of each embodiment of the present invention or embodiment The method stated.
The embodiments of the present invention described above are not intended to limit the scope of the present invention.It is any in the present invention Spirit and principle within made modifications, equivalent substitutions and improvements etc., should all be included in the protection scope of the present invention.

Claims (8)

1. a kind of method for writing data, which is characterized in that the described method includes:
Obtain new TS flow data;
Select from multiple default storage regions next default storage region of previous writing area as currently writing according to sequence Enter region, the memory space of the multiple default storage region is all the same;
The TS flow data is written to the current writing region, as the current writing region at the time of starting to be written Be originally written into the time;
It is full to judge whether the current writing region is write by the TS flow data;
When the current writing region writes full by the TS flow data, using at the time of writing full as the current writing region Terminate the write time, and using next default storage region of the sequence after the current writing region as target write area Domain, and subsequent TS flow data is written in the target writing area, as the target write area at the time of starting to be written Domain is originally written into the time;
For any writing area of the TS flow data, any writing area is written since the TS flow data Moment carries out timing;
Every prefixed time interval, record ends total write-in duration of any writing area described in current time, data is always written The data volume being written in amount, current preset time interval.
2. the method according to claim 1, wherein the method also includes:
When the target writing area does not write full by the TS flow data, judge whether the TS flow data stops;
When the TS flow data stops, by next default storage region of the sequence after the target writing area As fresh target writing area;
Judge whether the TS flow data restores;
When the TS flow data restores, the TS flow data after recovery is written to the fresh target writing area.
3. the method according to claim 1, wherein the method also includes:
Judge the current writing region whether be in multiple default storage regions sort end default storage region;
It, will be multiple default when the current writing region is the default storage region at sequence end in multiple default storage regions The default storage region of sequence first is as target writing area in storage region.
4. a kind of method for reading data, the data -3 any the method write-in according to claim 1, which is characterized in that institute The method of stating includes:
Obtain the corresponding temporal information of TS flow data to be visited;Wherein, all TS flow datas are stored in multiple memory spaces In identical default storage region, the temporal information includes starting read access time and end read access time;
Obtain the TS flow data in each default storage region is originally written into time and end write time;
It is originally written into time and end write time according to the TS flow data in each default storage region, obtains and is opened containing described Beginning read access time and the one or more for terminating the TS flow data between read access time preset storage region;
Obtain the write-in duration of each default storage region in one or more of default storage regions, data block offset, write-in Corresponding relationship between data block size;
It is originally written into time and end write time according to the corresponding relationship and each default storage region are corresponding, is obtained The corresponding data block offset of beginning read access time and the corresponding data block offset of the end read access time;
It reads the corresponding data block offset of beginning read access time data block corresponding with the end read access time and deviates it Between TS flow data.
5. a kind of data transfer apparatus, which is characterized in that described device includes:
TS flow data acquiring unit, for obtaining new TS flow data;
Current writing region determination unit, for being selected under previous writing area from multiple default storage regions according to sequence For one default storage region as current writing region, the memory space of the multiple default storage region is all the same;
First TS flow data writing unit will start to be written for the TS flow data to be written to the current writing region At the time of as the current writing region be originally written into the time;
Full judging unit is write, is expired for judging whether the current writing region is write by the TS flow data;
First object writing area determination unit, for will write when the current writing region writes full by the TS flow data End write time at the time of full as the current writing region, and sequence is located at after the current writing region Next default storage region is written in the target writing area as target writing area, and by subsequent TS flow data, will open The time is originally written into as the target writing area at the time of beginning to be written;
Timing starts unit, and for any writing area for the TS flow data, institute is written since the TS flow data State any writing area start time progress timing;
Recording unit is used for every prefixed time interval, when record ends total write-in of any writing area described in current time Data volume long, that the interior write-in of data volume, current preset time interval is always written.
6. device according to claim 5, which is characterized in that described device further include:
Stop judging unit, for judging the TS fluxion when the target writing area does not write full by the TS flow data According to whether stopping;
Fresh target writing area determination unit, for sequence being located at the target and is write when the TS flow data stopping Enter next default storage region after region as fresh target writing area;
Restore judging unit, for judging whether the TS flow data restores;
2nd TS flow data writing unit, for when the TS flow data restores, the TS flow data after recovery to be written to institute State fresh target writing area.
7. device according to claim 5, which is characterized in that described device further include:
Region decision unit, for judging whether the current writing region is the pre- of end of sorting in multiple default storage regions If storage region;
Second target writing area determination unit, for being end of sorting in multiple default storage regions when the current writing region When the default storage region of tail, using the default storage region of sequence first in multiple default storage regions as target write area Domain.
8. a kind of reading data device, the data are written according to any device of claim 5-7, which is characterized in that Described device includes:
Temporal information acquiring unit, for obtaining the corresponding temporal information of TS flow data to be visited;Wherein, all TS fluxions According to being stored in the identical default storage region of multiple memory spaces, the temporal information includes starting read access time and terminating to read Take the time;
Write time acquiring unit, for obtain the TS flow data in each default storage region be originally written into the time and end is write The angle of incidence;
Storage region acquiring unit, for according to the TS flow data in each default storage region be originally written into the time and end is write The angle of incidence obtains pre- containing the beginning read access time and the one or more for terminating the TS flow data between read access time If storage region;
Corresponding relationship acquiring unit, for obtaining the write-in of each default storage region in one or more of default storage regions Duration, data block offset, the corresponding relationship between writing data blocks size;
Deviate acquiring unit, for according to the corresponding relationship and each default storage region it is corresponding be originally written into the time and Terminate the write time, obtains the corresponding data block offset of the beginning read access time and the end read access time is corresponding Data block offset;
Reading unit, it is corresponding with the end read access time for reading the corresponding data block offset of the beginning read access time TS flow data between data block offset.
CN201610028102.3A 2016-01-15 2016-01-15 A kind of write-in of data, read method and device Active CN105700828B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610028102.3A CN105700828B (en) 2016-01-15 2016-01-15 A kind of write-in of data, read method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610028102.3A CN105700828B (en) 2016-01-15 2016-01-15 A kind of write-in of data, read method and device

Publications (2)

Publication Number Publication Date
CN105700828A CN105700828A (en) 2016-06-22
CN105700828B true CN105700828B (en) 2019-02-01

Family

ID=56227356

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610028102.3A Active CN105700828B (en) 2016-01-15 2016-01-15 A kind of write-in of data, read method and device

Country Status (1)

Country Link
CN (1) CN105700828B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107155081A (en) * 2017-05-15 2017-09-12 青岛海信电器股份有限公司 Method of program recording and device
CN111176571A (en) * 2019-12-27 2020-05-19 浪潮电子信息产业股份有限公司 Method, device, equipment and medium for managing local object
CN111857581A (en) * 2020-07-06 2020-10-30 浙江鸿泉电子科技有限公司 Data storage processing method and system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1567476A (en) * 2003-06-24 2005-01-19 群联电子股份有限公司 High speed big block data writing method for flash memory
CN1750164A (en) * 2005-07-20 2006-03-22 杭州海康威视数字技术有限公司 Digital hard disc recorder file managing method for preventing file fragment production

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1567476A (en) * 2003-06-24 2005-01-19 群联电子股份有限公司 High speed big block data writing method for flash memory
CN1750164A (en) * 2005-07-20 2006-03-22 杭州海康威视数字技术有限公司 Digital hard disc recorder file managing method for preventing file fragment production

Also Published As

Publication number Publication date
CN105700828A (en) 2016-06-22

Similar Documents

Publication Publication Date Title
CN105700828B (en) A kind of write-in of data, read method and device
US8499091B2 (en) Method and an apparatus for data recording and streaming
CN100541634C (en) Transcriber and method
CN102905188B (en) A kind of video code flow changing method and device
US8704931B2 (en) Apparatus and method of photographing moving image
US7697816B2 (en) Circulating memory apparatus and image storage distribution system
US8326113B2 (en) Recording apparatus and recording method, program, and recording system
CN104065906B (en) Video recording method and device of digital video recording equipment
CN102004760A (en) Multimedia file storing and applying method, related device and system
CN108089814A (en) A kind of date storage method and device
CN109240607B (en) File reading method and device
MXPA05006246A (en) Information storage medium having multi-angle data structure and apparatus therefor.
CN111182087B (en) Flow playback method based on single network card binding multiple IPs
CN104702874B (en) A kind of file memory method of facing video monitoring
CN107635109A (en) One kind video recording player method and device
GB2397404A (en) Automatic selection of encoding parameters for the transmission of media objects
CN106027930B (en) Recording apparatus and control method of recording apparatus
CN105530534A (en) Video clipping method and apparatus
EP1798878B1 (en) Method and mobile communication terminal for storing broadcasting program
CN106570068A (en) Information recommendation method and device
CN106055532A (en) Processing method and device for data replication
CN103338413B (en) Local time shifting method and apparatus
CN113282475B (en) Method and device for evaluating interactive performance of interactive system
CN100559487C (en) The method and system of the recording capacity of management accounts equipment
US8037508B2 (en) Video server and file management method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant