WO2020177379A1 - 分级存储方法、装置、电子设备及计算机可读存储介质 - Google Patents

分级存储方法、装置、电子设备及计算机可读存储介质 Download PDF

Info

Publication number
WO2020177379A1
WO2020177379A1 PCT/CN2019/117558 CN2019117558W WO2020177379A1 WO 2020177379 A1 WO2020177379 A1 WO 2020177379A1 CN 2019117558 W CN2019117558 W CN 2019117558W WO 2020177379 A1 WO2020177379 A1 WO 2020177379A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
stored
data stream
memory
stream
Prior art date
Application number
PCT/CN2019/117558
Other languages
English (en)
French (fr)
Inventor
丁磊
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020177379A1 publication Critical patent/WO2020177379A1/zh

Links

Images

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/0604Improving or facilitating administration, e.g. storage management
    • 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/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]

Definitions

  • This application relates to the field of computer technology, and in particular to a hierarchical storage method, device, electronic equipment, and computer-readable storage medium.
  • the storage space of the memory is limited. If all data is stored in a memory, the storage space of the memory will be quickly exhausted, resulting in the failure of subsequent data to be successfully stored in the memory, making the storage performance of the electronic device relatively low. low. Therefore, how to improve the storage performance of electronic devices has become an urgent problem to be solved.
  • the embodiment of the application discloses a hierarchical storage method, device, electronic device, and computer-readable storage medium, which can avoid storing all the data to be stored in the data stream to be stored in the default memory of the electronic device, which is beneficial to improve the overall electronic device Storage performance.
  • an embodiment of the present application discloses a hierarchical storage method, which is applied to an electronic device.
  • the electronic device includes a first memory and a second memory.
  • the first memory is the default memory of the electronic device.
  • the method may include: obtaining Multiple to-be-stored data streams; detect the data volume of each to-be-stored data stream among the multiple to-be-stored data streams; among the multiple to-be-stored data streams, determine the to-be-stored data stream whose data volume is greater than the first data volume threshold as The first data stream; the number of the first data stream is obtained, and the ratio between the number of the first data stream and the number of data streams to be stored is used as the first ratio; if the first ratio is greater than the preset ratio, the number of data streams to be stored The data to be stored in the data stream are all stored in the second memory.
  • an embodiment of the present application discloses a hierarchical storage device, the hierarchical storage device includes a first memory and a second memory, the first memory is the default memory of the hierarchical storage device; the hierarchical storage device includes:
  • the obtaining unit is used to obtain multiple data streams to be stored
  • a processing unit for detecting the data volume of each of the multiple data streams to be stored
  • the processing unit is further configured to determine, among the multiple data streams to be stored, the data stream to be stored whose data volume is greater than the first data volume threshold as the first data stream;
  • the acquiring unit is further configured to acquire the number of the first data stream
  • the processing unit is further configured to use the ratio between the number of the first data stream and the number of the aforementioned data streams to be stored as the first ratio
  • the storage unit is configured to store all the data to be stored in the data stream to be stored in the second memory if the first ratio is greater than the preset ratio.
  • an embodiment of the present application discloses an electronic device, the electronic device includes a first memory, a second memory, and a processor.
  • the first memory is the default memory of the electronic device; the first memory or the second memory
  • the computer program includes program instructions, and the processor is configured to call the program instructions to perform the following steps:
  • embodiments of the present application provide a computer-readable storage medium that stores a computer program, and the computer program includes program instructions that when executed by a processor cause the processor to execute the first The method described in one aspect.
  • FIG. 1 is a schematic flowchart of a hierarchical storage method provided by an embodiment of the present application
  • FIG. 1a is a schematic diagram of the storage location of each data included in a continuous data stream provided in an embodiment of the present application in an electronic device;
  • FIG. 2 is a schematic flowchart of another tiered storage method provided by an embodiment of the present application.
  • 2a is a schematic diagram of a scenario where an electronic device stores 4 data streams to be stored according to an embodiment of the present application
  • FIG. 3 is a schematic structural diagram of a hierarchical storage device provided by an embodiment of the present application.
  • Fig. 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • FIG. 1 is a schematic flowchart of a hierarchical storage method provided by an embodiment of the present application. The method is applied to an electronic device.
  • the electronic device may include a first memory and a second memory.
  • the first memory is the default memory of the electronic device.
  • the hierarchical storage method of the embodiment of the present application may include but is not limited to the following steps:
  • the electronic device obtains multiple data streams to be stored.
  • each data stream to be stored is composed of multiple data to be stored, and the data to be stored may be input/output (Input/Output, IO) data.
  • IO input/output
  • the mobile phone can receive the multiple sub-files that are divided into , In order to compose a complete movie file.
  • each sub-file received by the mobile phone can be used as a data to be stored (ie IO data), and multiple sub-files received by the mobile phone can be used as a data stream to be stored (ie IO stream).
  • the electronic device can obtain the data stream to be stored from its own cache queue, or the electronic device can receive the data stream to be stored through the transceiver, which is not limited in this embodiment of the application.
  • the electronic device allocates a cache queue for each data stream to be stored.
  • the data stream to be stored buffered in the cache queue is stored in the memory of the electronic device ,
  • the buffer queue can be used to buffer other data streams to be stored.
  • the first memory when the first memory is the default memory of the electronic device, when the electronic device receives any data to be stored, it will store the data to be stored in the default memory (ie, the first memory) by default.
  • the default memory may be set by the electronic device by default, or may be determined by the electronic device according to a user operation, which is not limited in the embodiment of the present application.
  • the first memory and the second memory in the electronic device may be different types of memory.
  • the first memory may be a solid state disk (Solid State Disk, SSD), and the second memory may be a hard disk drive ( Hard Disk Drive, HDD) or serial hard disk (Serial Advanced Technology Attachment hard disk, SATA).
  • the first memory and the second memory may be memories with different storage performance.
  • the random read and write performance of the first memory (such as SSD) is higher than that of the second memory (such as HDD)
  • the second memory such as HDD
  • the sequential read and write performance (such as HDD) is higher than that of the first storage (such as SSD).
  • the electronic device includes two memories (that is, the first memory and the second memory) are only used for illustration, in other feasible implementation manners, the electronic device may also include 3, 6, or other numbers
  • the type of the memory wherein the type of each memory may be different, or the type of part of the memory may be the same, and the type of another part of the memory may be different, which is not limited in the embodiment of the present application.
  • the electronic device may be a terminal device or a server.
  • the terminal device can be a smart phone, a tablet computer, a personal computer (PC), a smart TV, a smart watch, a vehicle-mounted device, a wearable device, the 5th Generation (5G) network of the future mobile communication technology
  • the embodiment of the present application does not limit the terminal equipment in the device.
  • each data stream to be stored obtained by the electronic device may be a continuous data stream.
  • the continuous data stream means that when the electronic device stores the data included in the continuous data stream, it needs to follow the sequence of the data in the continuous data stream. Storage, and the storage address of the data in the continuous data stream must be continuous, that is, the end address of the previous data in the continuous data stream is continuous with the start address of the next data. Take the schematic diagram of the storage location of each data included in a continuous data stream shown in Figure 1a as an example. If the continuous data stream includes 3 data (such as Data1, Data2, and Data3), Data1, Data2, and Data3 are in the cache The sequence in the queue is shown in Figure 1a, and Data1, Data2, and Data3 all occupy 4 storage units in the memory.
  • the electronic device After the electronic device stores Data1 in the memory, it can use the next address d2 of the end address d1 of Data1 as The starting address of Data2, in the same way, after the electronic device stores Data2 in the memory, the next address d4 of the end address d3 of Data2 can be used as the starting address of Data3.
  • the electronic device may receive data to be stored belonging to other data streams to be stored in the process of receiving data stream 1 to be stored (ie continuous data stream 1). At this time, the data stream to be stored 1 is disrupted by data to be stored belonging to other data streams to be stored.
  • the electronic device needs to accurately identify the data stream to be stored to which each data to be stored belongs, and then classify each data to be stored into multiple data streams to be stored, and then make statistics The data volume of each data stream to be stored.
  • the specific implementation manner for the electronic device to obtain multiple data streams to be stored may be: the electronic device obtains multiple data to be stored and attribute information of each data to be stored.
  • the attribute information may include but is not limited to the initial One or more of the address, termination address, data length, and data stream identifier; and according to the attribute information of each data to be stored in the multiple data to be stored, the data stream to which the data to be stored belongs is determined, and the data stream will be determined.
  • the data stream serves as the data stream to be stored. In this way, it is possible to accurately identify the data stream to be stored to which each data to be stored received by the electronic device belongs, which is beneficial to improve the accuracy of the statistics of the data volume of each data stream to be stored.
  • the electronic device when the electronic device receives the data to be stored, it may simultaneously receive the attribute information of the data to be stored.
  • it can parse the data to be stored to obtain the attribute information of the data to be stored. For example, the electronic device can extract the data to be stored from preset fields Output data length or data stream identifier.
  • the electronic device when the electronic device receives the data to be stored, it can set attribute information for the data to be stored. For example, when the electronic device receives the data to be stored, it can set the data to be stored in the default memory in advance. Start address and end address in.
  • the data length can be used to characterize the data size of the data to be stored, the data length can be recorded in the first preset field of the data to be stored, or the data length can also be obtained by the electronic device detecting the data to be stored
  • the data stream identifier can be recorded in the second preset field of the data to be stored, and the data stream to which the data to be stored belongs can be determined through the data stream identifier.
  • the data stream indicated by the data stream identifier is the data stream to which the data to be stored belongs.
  • all 10 data streams to be stored include at least one data to be stored, and each of the 10 data streams to be stored includes the data to be stored in order Arrangement
  • the electronic device can obtain the initial address set for the new data to be stored Data, and obtain each of the 10 data streams to be stored
  • the end address of the last data to be stored is calculated, and then the next storage address of the end address of the 10 last data to be stored is calculated, and it is judged whether the initial address of the new data to be stored is aligned with the 10
  • the target storage address in the next storage address of the end address of the last data to be stored is the same.
  • the data stream to be stored to which the data to be stored corresponding to the target storage address belongs is determined as the data to which the new data to be stored Data belongs. Stream; if they are not the same, it indicates that the data stream to which the new data to be stored belongs is a new data stream.
  • the attribute information of the data to be stored may only include the start address and data length of the data to be stored.
  • the electronic device can be based on the start address and data length of the data to be stored.
  • the data length is used to obtain the end address of the data to be stored, and then the data stream to which the data to be stored belongs is determined according to the start address and the end address of the data to be stored.
  • the attribute information may include a data stream identifier; the specific implementation manner for the electronic device to determine the data stream corresponding to the data to be stored according to the attribute information of each data to be stored in the plurality of data to be stored may be:
  • the electronic device uses the data stream indicated by the data stream identifier of each data to be stored in the plurality of data to be stored as the data stream corresponding to the data to be stored.
  • part of the data to be stored received by the electronic device may be sent by the resource server, and the part of the data to be stored in the resource server can be used to form a complete resource (such as a movie or a song).
  • the resource is reorganized and output in the device.
  • the resource server can send the data stream identifier to which each data to be stored included in the data stream to be stored belongs to the electronic device, so that the electronic device can according to each data stream to be stored
  • the data stream identifier of the data determines the data stream corresponding to the data to be stored.
  • the resource server when the resource server sends multiple to-be-stored data included in a certain resource to the electronic device, in order to prevent network reasons, the sequence of each to-be-stored data that composes the resource is transmitted to the electronic device
  • the sending sequence of the resource server is inconsistent, and the electronic device may make an error when outputting the resource.
  • the picture is not continuous when playing a movie, which affects the viewing experience.
  • the resource server when the resource server sends the data stream to be stored, in addition to the data stream identifier to which each data stream to be stored belongs to be sent to the electronic device, it can also include the data stream to be stored.
  • the serial number of each data to be stored is sent to the electronic device together.
  • the sequence number of the data to be stored is used to indicate the arrangement position of the data to be stored in the to-be-stored data stream (ie resource) to which it belongs. For example, if the resource server sequentially sends 3 data to be stored (such as Data1, Data2, and Data3) to the electronic device, these 3 data to be stored form a data stream to be stored, and the serial numbers of Data1, Data2, and Data3 are 1, 2, and respectively. 3.
  • the electronic device receives the three data to be stored in the receiving order: Data2, Data1, Data3, the electronic device can reorder the three received data to be stored according to the sequence numbers of the three data to be stored.
  • the sequence of the data to be stored in the restored data stream to be stored is: Data1, Data2, Data3.
  • errors can be avoided when the resources corresponding to the data stream to be stored are output in the electronic device, which is beneficial to improve user experience.
  • the electronic device detects the data volume of each of the multiple data streams to be stored.
  • the data volume of each data stream to be stored is the sum of the data volume of each data to be stored included in the data stream to be stored.
  • the electronic device can detect the data volume of each data to be stored included in each data stream to be stored. , To obtain the data volume of the data stream to be stored, where the data volume of the data to be stored can be used to characterize the data size of the data to be stored.
  • the data volume of each data to be stored can be directly recorded in the third preset field of the data to be stored.
  • the data volume of the data to be stored can be directly recorded in the internet protocol of the data to be stored.
  • IP Internet Protocol Address
  • the data volume of the data to be stored can be obtained by obtaining the packet length in the packet length field in the header of the IP packet of the data to be stored, and The obtained packet length is obtained by subtracting the header length of the IP packet and the header length of the transport layer protocol (such as TCP, UDP) data packet.
  • IP Internet Protocol Address
  • the electronic device when the electronic device receives the data to be stored, it can detect the data length of the data to be stored to obtain the data amount of the data to be stored.
  • the data to be stored included in the data stream to be stored is transmitted to the electronic device at different times.
  • the electronic device may continue to receive The to-be-stored data of the to-be-stored data stream. Therefore, when the electronic device does not completely receive all the to-be-stored data included in the to-be-stored data stream, the detected data volume of the to-be-stored data stream is not the actual amount of the to-be-stored data stream. The amount of data.
  • the electronic device needs to re-check the data volume of the to-be-stored data stream every time it receives a piece of to-be-stored data belonging to the to-be-stored data stream. Specifically, the electronic device can detect the newly received data to be stored. Store the data volume of the data, and then add the detected data volume to the data volume of the to-be-stored data stream obtained before receiving the new to-be-stored data to obtain the data volume of the current to-be-stored data stream.
  • the electronic device determines, among the multiple data streams to be stored, the data stream to be stored whose data volume is greater than the first data volume threshold as the first data stream.
  • the electronic device may determine the data stream to be stored whose data volume is greater than the first data volume threshold among the multiple data streams to be stored as the first data stream.
  • the data volume to be stored with the data volume greater than the first data volume threshold is relatively large and needs to occupy a larger storage space in the memory, while the data volume to be stored with the data volume less than or equal to the first data volume threshold is small. Occupies less storage space.
  • the electronic device may further obtain the ratio between the number of the first data stream and the number of data streams to be stored, and determine how to store the data to be stored according to the ratio flow.
  • the electronic device when storing the data stream to be stored whose data volume is less than or equal to the first data volume threshold, more storage units need to be occupied.
  • the electronic device when storing the data stream to be stored whose data volume is greater than the first data volume threshold, more storage units need to be occupied.
  • the electronic device stores the data to be stored in the storage unit, it first needs to obtain the address of the storage unit, and then can store the data to be stored in the storage unit according to the address. Therefore, when the amount of stored data is greater than the first data amount threshold
  • streaming the total length of time to obtain the address of the storage unit becomes one of the main factors limiting storage efficiency.
  • the data to be stored when the second memory stores the data to be stored, the data to be stored is stored in a storage unit with consecutive storage addresses, so that the second memory only needs to obtain the address of the first storage unit that stores the data to be stored.
  • the data to be stored can be stored sequentially without re-acquiring the address of the storage unit. Therefore, when the second memory stores the data stream to be stored with more storage units occupied, the cost of storing each data to be stored is The average duration is shorter.
  • the first memory when the first memory stores the data to be stored, it stores the data to be stored in a random storage unit.
  • the second memory stores a data to be stored and needs to obtain the address of the storage unit multiple times, for example, a data to be stored Need to occupy 4 storage units
  • the first memory needs to obtain the addresses of the 4 storage units respectively to successfully store the data to be stored, and the addresses of the 4 storage units may not be continuous. Therefore, the first memory is
  • the average time it takes to store each data to be stored is longer. Since the sequential read and write performance of the second memory is higher than that of the first memory, compared to storing the data stream to be stored with the data amount greater than the first data amount threshold in the first memory, the data amount is greater than the first data amount threshold.
  • the total time taken to obtain the address of the storage unit is shorter, which can improve storage efficiency and overall storage performance of the electronic device.
  • the first data amount threshold may be set by the electronic device by default, or may be determined by the electronic device according to an empirical value input by the user, which is not limited in the embodiment of the present application.
  • the electronic device obtains the number of first data streams, and uses a ratio between the number of first data streams and the number of data streams to be stored as the first ratio.
  • the electronic device determines the first data stream, it can count the number of the first data stream, then calculate the ratio between the number of the first data stream and the number of data streams to be stored, and use the calculated ratio as the first Ratio, the first ratio can be used to characterize the proportion of the first data stream among all the data streams to be stored currently received by the electronic device, or the first ratio can be used to characterize all the data streams to be stored currently received by the electronic device In the data stream, the proportion of large IO streams.
  • the first ratio is greater than the preset ratio, it indicates that among all data streams to be stored currently received by the electronic device, large IO streams account for a relatively high proportion. Compared with storing the large IO stream in the first memory and storing the large IO stream in the second memory, the total time taken to obtain the address of the storage unit is shorter. Therefore, when the first ratio is greater than the preset ratio, the corresponding Compared with storing all the data to be stored in the data stream to be stored in the first memory, the electronic device stores all the data to be stored in the data stream to be stored in the second memory, which can reduce the total time for obtaining the address of the storage unit, which is beneficial to Improve the storage efficiency and overall storage performance of electronic devices.
  • the preset ratio is greater than 0 and less than 1.
  • the preset ratio may be set by the electronic device by default, or may be determined by the electronic device according to an empirical value input by the user, which is not limited in the embodiment of the present application.
  • the specific implementation manner in which the electronic device stores all the data to be stored in the data stream to be stored in the second memory may be: the electronic device stores all the data to be stored in the second memory through the second type of storage path. Memory. Wherein, when the second storage is an HDD, the storage path of the second type may be a storage path prefixed with "/HDD".
  • the electronic device may also detect whether the hierarchical cache function is enabled, if it is enabled, execute step S102, and if it is not enabled, directly store the acquired multiple data streams to be stored in the default memory ,
  • the default memory can be any memory in the electronic device (such as the first memory or the second memory).
  • the electronic device may not need to enable the hierarchical cache function, so that when multiple data streams to be stored are received, the multiple data streams to be stored can be directly used.
  • the stored data stream is stored in the first memory without detecting the data volume of each data to be stored, and the first data stream is determined according to the data volume of each data to be stored, and according to the number of first data streams and the number of data streams to be stored
  • the ratio between determines whether to store the acquired data to be stored in the first memory or the second memory.
  • the electronic device may enable the hierarchical cache function only when the remaining storage space of the first memory is relatively limited, so as to prevent the storage space of the first memory from being exhausted. In this way, the storage resources of each memory in the electronic device can be better utilized, and the overall storage performance of the electronic device can be improved.
  • FIG. 2 is a schematic flowchart of another hierarchical storage method provided by an embodiment of the present application.
  • the method is applied to an electronic device.
  • the electronic device may include a first memory and a second memory.
  • the first memory is the default memory of the electronic device.
  • the hierarchical storage method of the embodiment of the present application may include but is not limited to the following steps:
  • the electronic device obtains multiple data streams to be stored.
  • the electronic device detects the data volume of each of the multiple data streams to be stored.
  • the electronic device determines, among the multiple data streams to be stored, the data stream to be stored whose data volume is greater than the first data volume threshold as the first data stream.
  • the electronic device obtains the number of first data streams, and uses a ratio between the number of first data streams and the number of data streams to be stored as the first ratio.
  • step S201 to step S205 please refer to the specific description of step S101 to step 105 in FIG. 1 respectively, which will not be repeated here.
  • the first storage when obtaining the storage address of a single storage unit, the first storage is faster than the second storage. However, since the first storage uses random storage and the second storage uses sequential storage, When storing continuous large IO streams, the storage efficiency of the second memory is higher than that of the first memory, but when storing small IO streams, the storage efficiency of the first memory is higher than that of the second memory. In an implementation manner, if the first ratio is less than or equal to the preset ratio, it indicates that among all the data streams to be stored currently received by the electronic device, the small IO stream accounts for a relatively high proportion. When storing small IO streams, the storage efficiency of the first memory is higher than that of the second memory.
  • the cost of acquiring storage is The total duration of the unit address is shorter. Therefore, when the first ratio is less than or equal to the preset ratio, compared to storing all the data to be stored in the data stream to be stored in the second memory, the electronic device stores the data stream to be stored Part of the data to be stored is stored in the first memory, which can reduce the total time for obtaining the address of the storage unit, which is beneficial to improve the storage efficiency and overall storage performance of the electronic device. It should be noted that, in one implementation, the storage space of the first memory is smaller than the storage space of the second memory.
  • the currently acquired multiple data streams to be stored still include A large IO stream (that is, the first data stream), if the data volume of the large IO stream is extremely large, and the electronic device also stores all the data to be stored included in the large IO stream in the first memory, it will result in the failure of the first memory. The space is quickly exhausted. Therefore, the electronic device can store part of the data to be stored in the data stream to be stored in the first memory, and then further judge whether to store all the data to be stored in the large IO stream based on the data volume of the large IO stream All are stored in the first memory.
  • the electronic device may determine the data stream to be stored whose data volume is less than or equal to the first data volume threshold as the second data stream, because the data volume of the second data stream is very small. Therefore, all data to be stored included in the second data stream can be directly stored in the first memory.
  • the first data to be stored can be extracted from the first data stream according to the order in which the data to be stored in the first data stream is arranged in the data queue, and the first data to be stored can be stored in the first memory, Among them, the data volume of the first data to be stored is equal to the first data volume threshold.
  • the data queue can refer to the buffer queue for buffering the data stream to be stored, or can refer to the receiving queue for receiving the data stream to be stored.
  • the data to be stored The data to be stored included in the stream are arranged in ascending sequence number. For other data to be stored in the first data stream except the first data to be stored, it is necessary to further determine whether it should be stored in the first memory or the second memory.
  • the electronic device determines, among all the first data streams, the first data stream whose data volume is greater than the second data volume threshold as the third data stream, and the second data volume threshold Greater than the first data amount threshold.
  • the electronic device may determine, among all the first data streams, the first data stream whose data amount is greater than the second data amount threshold as the third data stream.
  • the second data volume threshold may be an integer multiple of the first data volume threshold. For example, when the first data volume threshold is 128KB, the second data volume threshold may be 256KB.
  • the second data amount threshold may be set by the electronic device by default, or may be determined by the electronic device according to an empirical value input by the user, which is not limited in the embodiment of the present application.
  • the electronic device obtains the number of third data streams, and uses a ratio between the number of third data streams and the number of first data streams as the second ratio.
  • the electronic device can determine how to store the data to be stored in the first data stream other than the first data to be stored according to the second ratio. In one implementation, if the second ratio is greater than the preset ratio, the electronic device can store all the data to be stored in the first data stream except the first data to be stored in the second memory; if the second ratio is less than Or equal to the preset ratio, the electronic device can store all other data to be stored in the first data stream except the first data to be stored in the first memory.
  • the electronic device extracts the first data to be stored from the first data stream according to the order in which the data to be stored in the first data stream is arranged in the data queue, and transfers the first data to be stored Store to the first memory, and store the to-be-stored data in the second data stream to the first memory.
  • the electronic device can trigger the execution of extracting the first data to be stored from the first data stream according to the sequence of the data to be stored in the first data stream in the data queue, and then A step of storing data to be stored in the first memory, and storing the data to be stored in the second data stream in the first memory.
  • the electronic device may first extract the first data to be stored from the first data stream, store the first data to be stored in the first memory, and store the data to be stored in the second data stream in the The first memory is then executed to store all other data to be stored in the first data stream except the first data to be stored in the second memory.
  • the electronic device may simultaneously extract the first data to be stored from the first data stream, store the first data to be stored in the first memory, and store the data to be stored in the second data stream in the first memory, and store All data to be stored in the first data stream except the first data to be stored are stored in the second memory.
  • the electronic device stores all other data to be stored in the first data stream except the first data to be stored in the second memory.
  • the electronic device may store all other data to be stored in the first data stream except the first data to be stored in the second memory.
  • the electronic device stores part of the data to be stored in the first data stream (that is, the first data to be stored) in the first memory, and stores the first data stream
  • the remaining data to be stored (that is, other data to be stored except the first data to be stored) is stored in the second memory, which can avoid storing all the data to be stored in the same memory, which is beneficial to simultaneously play the first memory and
  • the storage performance of the second memory is beneficial to improve the overall storage performance of the electronic device.
  • the data volumes of the 4 data streams to be stored a, data stream b to be stored, data stream c to be stored and data stream d to be stored are 384KB, 288KB, 224KB, and 96KB respectively.
  • the first data stream threshold is 128KB
  • the second data stream The flow threshold is 256KB, and the preset ratio is 1/2, it can be obtained that the first ratio is 3/4 and the second ratio is 2/3.
  • the data stream c to be stored is the first data stream
  • the data stream d to be stored is the second data stream
  • the data stream a to be stored and the data stream b to be stored are the third data stream. Therefore, the electronic device can store the data to be stored in the second data stream and the first data to be stored in the first data stream (that is, the data to be stored shown in the shaded part in the figure) into the first memory, and store the first All data to be stored except the first data to be stored in the data stream are stored in the second memory.
  • the electronic device may also format the first storage (and the second storage) into a file system with a preset format, so as to facilitate searching or managing data in the first storage (and the second storage). For example, after the first storage is formatted as a file system, the user can easily search for data, copy data, delete data, or migrate data in the first storage. In this way, the electronic device can better manage the first storage.
  • the storage space of the memory further improves the storage performance of the first memory.
  • the file system is the method and data structure used by the operating system to specify the files on the storage device (such as the first storage and/or the second storage) or partition.
  • the file system organizes the space of the file storage device And distribution, a system responsible for file storage and protection and retrieval of stored files.
  • the preset format may be the fourth-generation extended file system (EXT4) format, or other file system formats supported by the Linux operating system.
  • the preset format may be NTFS (New Technology File System) format, or file allocation table (File Allocation Table, FAT) format.
  • the electronic device may set a timer for the data to be stored for counting the stored duration of the data to be stored.
  • the electronic device can also count the total number of times the data to be stored is called during the storage period, and further, use the ratio between the total number of times the data to be stored is called during the storage period and the stored duration of the data to be stored as the The frequency of stored data being recalled during storage.
  • the electronic device can obtain the weight of the data volume and the weight of the call frequency, and then according to the weight of the data volume and the weight of the call frequency, the data volume of each data stored in the first memory and each data are called during storage Perform weighted summation of the frequency of each data to obtain the storage value of each data, and migrate the data with the smallest storage value to the second storage device, that is, delete the data with the smallest storage value in the first storage and store the data with the smallest storage value To the second storage. In this way, it can be avoided that the remaining storage space of the first memory is too small, and the subsequent received data to be stored cannot be stored, which is beneficial to improving the storage performance of the electronic device.
  • the electronic device migrates the data with the smallest storage value in each data to the second storage device, if it detects that the remaining storage space of the first storage is still less than the second storage space threshold, the electronic device also needs to The data stored in the first storage is deleted in an increasing order of storage value until the remaining storage space of the first storage is greater than or equal to the second storage space threshold.
  • FIG. 3 is a schematic structural diagram of a hierarchical storage device according to an embodiment of the present application.
  • the hierarchical storage device includes a first memory and a second memory.
  • the first memory is the default memory of the hierarchical storage device.
  • the hierarchical storage device 30 may include:
  • the obtaining unit 301 is configured to obtain multiple data streams to be stored
  • the processing unit 302 is configured to detect the data volume of each of the multiple data streams to be stored
  • the processing unit 302 is further configured to determine, among the multiple data streams to be stored, the data stream to be stored whose data volume is greater than the first data volume threshold as the first data stream;
  • the acquiring unit 301 is further configured to acquire the number of first data streams, and the processing unit 302 is further configured to use the ratio between the number of first data streams and the number of data streams to be stored as the first ratio;
  • the storage unit 303 is configured to store all the data to be stored in the data stream to be stored in the second memory if the first ratio is greater than the preset ratio.
  • the storage unit 303 is further configured to extract from the first data stream according to the order in which the data to be stored in the first data stream is arranged in the data queue if the first ratio is less than or equal to the preset ratio First data to be stored, storing the first data to be stored in the first memory, and storing the data to be stored in the second data stream in the first memory; wherein the data amount of the first data to be stored is equal to the first data amount Threshold, the second data stream is a data stream to be stored whose data volume is less than or equal to the first data volume threshold among the multiple data streams to be stored.
  • the processing unit 302 is further configured to, if the first ratio is less than or equal to the preset ratio, among all the first data streams, determine the first data stream whose data volume is greater than the second data volume threshold as For the third data stream, the second data volume threshold is greater than the first data volume threshold; the acquiring unit 301 is further configured to acquire the number of the third data stream, and the processing unit 302 is further configured to compare the number of the third data stream with the first data stream.
  • the storage unit 303 is also used for triggering execution according to the arrangement order of the data to be stored in the first data stream in the data queue if the second ratio is greater than the preset ratio.
  • the acquiring unit 301 when used to acquire multiple data streams to be stored, it can be specifically used to acquire multiple data to be stored and attribute information of each data to be stored.
  • the attribute information includes a starting address and an ending address.
  • the data to be stored may include the second data to be stored and the third data to be stored, and the attribute information may include the start address and the end address;
  • the attribute information of the stored data determines the data stream corresponding to the data to be stored, it can be specifically used to: if the start address of the second data to be stored is continuous with the end address of the third data to be stored, determine the second to be stored The data and the third data to be stored belong to the same data stream.
  • the data to be stored may include the second data to be stored and the third data to be stored, and the attribute information may include the start address and the data length;
  • the attribute information of the stored data determines the data stream corresponding to the data to be stored, it can be specifically used to: obtain the end of the corresponding data to be stored according to the start address and data length of each data to be stored in the multiple data to be stored Address; if the start address of the second data to be stored is continuous with the end address of the third data to be stored, it is determined that the second data to be stored and the third data to be stored belong to the same data stream.
  • the attribute information may include a data stream identifier; the obtaining unit 301 is configured to determine the data stream corresponding to the data to be stored according to the attribute information of each data to be stored in the plurality of data to be stored. Used for: taking the data stream indicated by the data stream identifier of each data to be stored in the plurality of data to be stored as the data stream to which the corresponding data to be stored belongs.
  • FIG. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
  • the electronic device 40 may include a first memory 401, a second memory 402, a processor 403, and a network interface 404.
  • the first memory 401, the second memory 402, the processor 403, and the network interface 404 are connected by one or more communication buses.
  • the network interface 404 is controlled by the processor 403 for sending and receiving messages.
  • the first memory 401 (and the second memory 402) may include a read-only memory and a random access memory, and provide instructions and data to the processor 403.
  • a part of the first memory 401 (and the second memory 402) may also include a non-volatile random access memory.
  • the processor 403 may be a central processing unit (CPU), and the processor 403 may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (ASICs). ), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor.
  • the processor 403 may also be any conventional processor. among them:
  • the first memory 401 (or the second memory 402) is used to store program instructions.
  • the processor 403 is configured to call program instructions stored in the first memory 401 (or the second memory 402) to execute the following steps:
  • a data stream to be stored with a data volume greater than a first data volume threshold is determined as the first data stream
  • the processor 403 may also perform the following steps: if the first ratio is less than or equal to the preset ratio, according to the arrangement order of the data to be stored in the first data stream in the data queue, from the first data stream Extract the first to-be-stored data, store the first to-be-stored data in the first memory 401, and store the to-be-stored data in the second data stream in the first memory 401; wherein the data amount of the first to-be-stored data is equal
  • the first data volume threshold and the second data stream are the data streams to be stored whose data volume is less than or equal to the first data volume threshold among the multiple data streams to be stored.
  • the processor 403 may further perform the following steps: if the first ratio is less than or equal to the preset ratio, among all the first data streams, the first data stream whose data volume is greater than the second data volume threshold Determined as the third data stream, the second data volume threshold is greater than the first data volume threshold; the number of third data streams is obtained, and the ratio between the number of third data streams and the number of first data streams is used as the second ratio If the second ratio is greater than the preset ratio, the execution is triggered to extract the first data to be stored from the first data stream according to the sequence of the data to be stored in the first data stream in the data queue, and the first to be stored The step of storing data in the first memory 401, and storing the data to be stored in the second data stream in the first memory 401; storing all the data to be stored in the first data stream except the first data to be stored in the first memory 401 Two storage 402.
  • the processor 403 executes acquiring multiple data streams to be stored, the following steps may be specifically performed: acquiring multiple data to be stored and attribute information of each data to be stored, the attribute information including the start address and the end One or more of the address, data length and data stream identifier; and according to the attribute information of each data to be stored in the multiple data to be stored, the data stream to which the data to be stored belongs is determined, and the determined data stream is taken as Data stream to be stored.
  • the data to be stored may include the second data to be stored and the third data to be stored, and the attribute information may include the start address and the end address;
  • the attribute information of the data determines the data stream corresponding to the data to be stored, the following steps can be specifically performed: if the start address of the second data to be stored is continuous with the end address of the third data to be stored, then the second to be stored is determined.
  • the data and the third data to be stored belong to the same data stream.
  • the data to be stored may include the second data to be stored and the third data to be stored, and the attribute information may include the start address and the data length; the processor 403 is executed according to each of the plurality of data to be stored.
  • the attribute information of the stored data determines the data stream corresponding to the data to be stored, the following steps can be specifically performed: According to the start address and data length of each data to be stored in the multiple data to be stored, the corresponding data to be stored is obtained End address; if the start address of the second data to be stored is continuous with the end address of the third data to be stored, it is determined that the second data to be stored and the third data to be stored belong to the same data stream.
  • the attribute information may include a data stream identifier; when the processor 403 determines the data stream corresponding to the data to be stored according to the attribute information of each data to be stored in the plurality of data to be stored, it can specifically execute The following steps: take the data stream indicated by the data stream identifier of each data to be stored in the plurality of data to be stored as the data stream to which the corresponding data to be stored belongs.
  • the embodiment of the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program.
  • the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the instructions shown in Figure 1- Figure 2. Steps performed in the method embodiment.

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)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

一种分级存储方法、装置、电子设备(40)及计算机可读存储介质,该方法可以应用于存储技术领域,该方法可以应用于包括第一存储器(401)和第二存储器(402)的电子设备(40),该第一存储器(401)为电子设备(40)的默认存储器。该方法包括:电子设备(40)获取多个待存储数据流(S101);电子设备(40)检测多个待存储数据流中每个待存储数据流的数据量(S102);电子设备(40)在多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流(S103);电子设备(40)获取第一数据流的数量,并将第一数据流的数量与待存储数据流的数量之间的比值作为第一比值(S104);若第一比值大于预设比值,则电子设备(40)将待存储数据流中的待存储数据均存储至第二存储器(402)(S105)。通过上述方法,有利于提高电子设备(40)整体的存储性能。

Description

分级存储方法、装置、电子设备及计算机可读存储介质
本申请要求于2019年3月1日提交中国专利局、申请号为2019101561881、申请名称为“分级存储方法、装置、电子设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,尤其涉及一种分级存储方法、装置、电子设备及计算机可读存储介质。
背景技术
随着网络技术的不断进步,网络中数据量呈爆发式的增长趋势,这一现象对数据存储提出了新的挑战。电子设备在存储数据时,是将数据存储至电子设备中的存储器。
然而,存储器的存储空间是有限的,若将所有数据均存储至一个存储器,将导致该存储器的存储空间很快被耗尽,导致后续数据无法成功存储至该存储器,使得电子设备的存储性能较低。因此,如何提高电子设备的存储性能成为一个亟待解决的问题。
发明内容
本申请实施例公开了一种分级存储方法、装置、电子设备及计算机可读存储介质,可以避免将待存储数据流中的待存储数据均存储至电子设备的默认存储器,有利于提高电子设备整体的存储性能。
第一方面,本申请实施例公开了一种分级存储方法,该方法应用于电子设备,电子设备包括第一存储器和第二存储器,第一存储器为电子设备的默认存储器,该方法可以包括:获取多个待存储数据流;检测多个待存储数据流中每个待存储数据流的数据量;在多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流;获取第一数据流的数量,并将第一数据流的数量与待存储数据流的数量之间的比值作为第一比值;若第一比值大于预设比值,则将待存储数据流中的待存储数据均存储至第二存储器。
第二方面,本申请实施例公开了一种分级存储装置,该分级存储装置包括第一存储器和第二存储器,该第一存储器为该分级存储装置的默认存储器;该分级存储装置包括:
获取单元,用于获取多个待存储数据流;
处理单元,用于检测多个待存储数据流中每个待存储数据流的数据量;
处理单元,还用于在多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流;
获取单元,还用于获取该第一数据流的数量,该处理单元还用于将该第一数据流的数量与前述待存储数据流的数量之间的比值作为第一比值;
存储单元,用于若第一比值大于预设比值,则将该待存储数据流中的待存储数据均存储至第二存储器。
第三方面,本申请实施例公开了一种电子设备,该电子设备包括第一存储器、第二存储器和处理器,该第一存储器为电子设备的默认存储器;该第一存储器或该第二存储器用 于存储计算机程序,计算机程序包括程序指令,该处理器被配置用于调用该程序指令,执行以下步骤:
获取多个待存储数据流;检测多个待存储数据流中每个待存储数据流的数据量;在多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流;获取第一数据流的数量,并将第一数据流的数量与待存储数据流的数量之间的比值作为第一比值;若第一比值大于预设比值,则将待存储数据流中的待存储数据均存储至第二存储器。
第四方面,本申请实施例提供了一种计算机可读存储介质,该计算机可读存储介质存储有计算机程序,计算机程序包括程序指令,该程序指令当被处理器执行时使该处理器执行第一方面所述的方法。
通过实施本申请实施例,可以避免将获取的待存储数据流中的待存储数据均存储至默认存储器,有利于提高电子设备整体的存储性能。
附图说明
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图进行说明。
图1是本申请实施例提供的一种分级存储方法的流程示意图;
图1a是本申请实施例提供的一种连续数据流包括的各个数据在电子设备中的存储位置示意图;
图2是本申请实施例提供的另一种分级存储方法的流程示意图;
图2a是本申请实施例提供的一种电子设备存储4个待存储数据流的场景示意图;
图3是本申请实施例提供的一种分级存储装置的结构示意图;
图4是本申请实施例提供的一种电子设备的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。
请参阅图1,图1是本申请实施例提供的一种分级存储方法的流程示意图。该方法应用于电子设备,该电子设备可以包括第一存储器和第二存储器,第一存储器为电子设备的默认存储器。具体的,如图1所示,本申请实施例的分级存储方法可以包括但不限于如下步骤:
S101、电子设备获取多个待存储数据流。
其中,每个待存储数据流是由多个待存储数据组成的,待存储数据可以是输入/输出(Input/Output,IO)数据。例如,用户通过手机在网上下载电影时,当电影文件的数据量较大时,该电影文件可以被切分成多个子文件在网络中传输,此时,手机可以通过接收被切分成的多个子文件,以便组成完整的电影文件。其中,手机接收到的每个子文件可以作为一个待存储数据(即IO数据),手机接收到的多个子文件可以作为一个待存储数据流(即IO流)。
在一种实现方式中,电子设备可以从自身的缓存队列中获取待存储数据流,或者,电子设备可以通过收发器接收待存储数据流,本申请实施例对此不作限定。当电子设备从自 身的缓存队列中获取待存储数据流时,电子设备为每一个待存储数据流分配有一个缓存队列,当缓存队列中缓存的待存储数据流被存储至电子设备的存储器中后,该缓存队列可以用于缓存其他的待存储数据流。
在本申请实施例中,当第一存储器为电子设备的默认存储器时,电子设备在接收到任何待存储数据时,均会默认将该待存储数据存储至默认存储器(即第一存储器)中。在一种实现方式中,默认存储器可以是电子设备默认设置的,也可以是电子设备根据用户操作确定的,本申请实施例对此不作限定。
在一种实现方式中,电子设备中的第一存储器和第二存储器可以是不同类型的存储器,例如,第一存储器可以为固态硬盘(Solid State Disk,SSD),第二存储器可以为硬盘驱动器(Hard Disk Drive,HDD)或者串口硬盘(Serial Advanced Technology Attachment hard disk,SATA)。在一种实现方式中,第一存储器和第二存储器可以是存储性能不同的存储器,例如,第一存储器(如SSD)的随机读写性能高于第二存储器(如HDD),而第二存储器(如HDD)的顺序读写性能高于第一存储器(如SSD)。
需要说明的是,电子设备中包括2个存储器(即第一存储器和第二存储器)仅用于举例说明,在其他可行的实现方式中,电子设备还可以包括3个、6个或者其他数量的存储器,其中,各个存储器的类型均可以不同,或者,部分存储器的类型可以相同,另一部分存储器的类型可以不同,本申请实施例对此不作限定。
在本申请实施例中,电子设备可以是终端设备,也可以是服务器。其中,该终端设备可以是智能手机、平板电脑、个人计算机(Personal Computer,PC)、智能电视、智能手表、车载设备、可穿戴设备、未来第五代移动通信技术(the 5th Generation,5G)网络中的终端设备等,本申请实施例对此不作限定。
在一种实现方式中,电子设备获取的各个待存储数据流可以是连续数据流,连续数据流是指电子设备在存储连续数据流包括的数据时,需要按照连续数据流中数据的排列顺序进行存储,且连续数据流中的数据的存储地址需连续,也就是说,连续数据流中的前一个数据的终止地址与后一个数据的起始地址连续。以图1a所示的一种连续数据流包括的各个数据在电子设备中的存储位置示意图为例,若连续数据流包括3个数据(如Data1、Data2和Data3),Data1、Data2和Data3在缓存队列中的排列顺序如图1a所示,且Data1、Data2和Data3在存储器中均占据4个存储单元,则电子设备在存储器中存储Data1之后,可以将Data1的终止地址d1的下一个地址d2作为Data2的起始地址,同理,电子设备在存储器中存储Data2之后,可以将Data2的终止地址d3的下一个地址d4作为Data3的起始地址。
在一种实现方式中,电子设备在接收待存储数据流1(即连续数据流1)的过程中,可能会接收到属于其他待存储数据流的待存储数据,此时,该待存储数据流1被属于其他待存储数据流的待存储数据所打乱。为了能够准确检测出连续的待存储数据流1的数据量,电子设备需要准确识别出各个待存储数据所属的待存储数据流,进而将各个待存储数据分类为多个待存储数据流,进而统计各个待存储数据流的数据量。
在一种实现方式中,电子设备获取多个待存储数据流的具体实施方式可以为:电子设备获取多个待存储数据以及每个待存储数据的属性信息,属性信息可以包括但不限于起始地址、终止地址、数据长度和数据流标识中的一个或多个;并根据多个待存储数据中每个 待存储数据的属性信息,确定出对应待存储数据所属的数据流,将确定出的数据流作为待存储数据流。通过这种方式,可以准确识别出电子设备接收到的各个待存储数据所属的待存储数据流,有利于提高统计的各个待存储数据流的数据量的准确度。
在一种实现方式中,电子设备在接收到待存储数据时,可以同时接收到该待存储数据的属性信息。在一种实现方式中,电子设备在接收到待存储数据时,可以解析该待存储数据,以得到该待存储数据的属性信息,例如,电子设备可以从该待存储数据的预设字段中提取出数据长度或数据流标识。在一种实现方式中,电子设备在接收到待存储数据时,可以为该待存储数据设置属性信息,例如,电子设备在接收到待存储数据时,可以预先为该待存储数据设置在默认存储器中的起始地址和终止地址。
其中,数据长度可以用于表征该待存储数据的数据大小,数据长度可以记录于该待存储数据的第一预设字段中,或者,数据长度也可以是电子设备对该待存储数据进行检测得到的;数据流标识可以记录于该待存储数据的第二预设字段中,通过数据流标识可以确定待存储数据所属的数据流。例如,数据流标识指示的数据流即为待存储数据所属的数据流。
在一种实现方式中,待存储数据可以包括第二待存储数据和第三待存储数据,属性信息可以包括起始地址和终止地址;电子设备根据多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流的具体实施方式可以为:若第二待存储数据的起始地址与第三待存储数据的终止地址连续,则电子设备确定第二待存储数据和第三待存储数据属于同一个数据流。例如,若电子设备中存在10个待存储数据流,10个待存储数据流均至少包括一个待存储数据,且10个待存储数据流中的每个待存储数据流包括的待存储数据按序排列,当电子设备接收到一个新的待存储数据Data时,电子设备可以获取为该新的待存储数据Data设置的初始地址,并获取10个待存储数据流中的每个待存储数据流中排在最后的待存储数据的终止地址,然后分别计算得到10个排在最后的待存储数据的终止地址的下一个存储地址,并判断新的待存储数据Data的初始地址是否与10个排在最后的待存储数据的终止地址的下一个存储地址中的目标存储地址相同,若相同,则将目标存储地址对应的待存储数据所属的待存储数据流确定为新的待存储数据Data所属的数据流;若不相同,则表明该新的待存储数据Data所属的数据流为一个新的数据流。
在一种实现方式中,待存储数据可以包括第二待存储数据和第三待存储数据,属性信息可以包括起始地址和数据长度;电子设备根据多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流的具体实施方式可以为:电子设备根据多个待存储数据中每个待存储数据的起始地址和数据长度,得到对应待存储数据的终止地址;若第二待存储数据的起始地址与第三待存储数据的终止地址连续,则电子设备确定第二待存储数据和第三待存储数据属于同一个数据流。在一种实现方式中,待存储数据的属性信息可能只包括待存储数据的起始地址和数据长度,为了确定该待存储数据所属的数据流,电子设备可以根据待存储数据的起始地址和数据长度,得到该待存储数据的终止地址,进而根据该待存储数据的起始地址和终止地址,确定该待存储数据所属的数据流。
在一种实现方式中,属性信息可以包括数据流标识;电子设备根据多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流的具体实施方式可以为:电子设备将多个待存储数据中每个待存储数据的数据流标识指示的数据流作为对应待存储 数据所属的数据流。具体的,电子设备接收到的部分待存储数据可以是由资源服务器发送的,该部分待存储数据在资源服务器中可以用于组成一个完整的资源(如一部电影或一首歌曲),为了在电子设备中重组并输出该资源,资源服务器在发送待存储数据流时,可以将待存储数据流包括的各个待存储数据所属的数据流标识一并发送给电子设备,以便电子设备可以根据各个待存储数据的数据流标识,确定对应待存储数据所属的数据流。
在一种实现方式中,在资源服务器将某个资源包括的多个待存储数据发送给电子设备时,为了防止因网络原因,导致组成该资源的各个待存储数据在传输至电子设备时的顺序与资源服务器的发送顺序不一致,而使得电子设备在输出该资源时,发生错误,例如,播放电影时,画面不连续,影响观看体验。为了避免上述问题,资源服务器在发送待存储数据流时,除了可以将待存储数据流包括的各个待存储数据所属的数据流标识一并发送给电子设备以外,还可以将待存储数据流包括的各个待存储数据的序号一并发送给电子设备。其中,待存储数据的序号用于指示该待存储数据在所属的待存储数据流(即资源)中的排列位置。例如,若资源服务器向电子设备依次发送3个待存储数据(如Data1、Data2和Data3),这3个待存储数据组成一个待存储数据流,Data1、Data2和Data3的序号分别为1、2和3,且电子设备接收这3个待存储数据的接收顺序为:Data2、Data1、Data3时,电子设备可以根据这3个待存储数据的序号,将接收到的3个待存储数据进行重新排序,以恢复待存储数据流,恢复得到的待存储数据流中的待存储数据的排列顺序为:Data1、Data2、Data3。通过这种方式,可以避免待存储数据流对应的资源在电子设备中输出时,发生错误,有利于提高用户体验。
S102、电子设备检测多个待存储数据流中每个待存储数据流的数据量。
具体的,每个待存储数据流的数据量为该待存储数据流包括的各个待存储数据的数据量的总和,电子设备可以通过检测每个待存储数据流包括的各个待存储数据的数据量,以得到该待存储数据流的数据量,其中,待存储数据的数据量可以用于表征该待存储数据的数据大小。
在一种实现方式中,每个待存储数据的数据量可以直接记录于该待存储数据的第三预设字段中,例如,待存储数据的数据量可以直接记录于该待存储数据的网际协议地址(Internet Protocol Address,IP)包的包头中的某一个字段中,或者,待存储数据的数据量可以通过获取该待存储数据的IP包的包头中的包长字段中的包长,并将获取的包长减去IP包的包头长度以及运输层协议(如TCP、UDP)数据包的包头长度得到。在一种实现方式中,电子设备在接收到待存储数据时,可以检测该待存储数据的数据长度,得到该待存储数据的数据量。
需要说明的是,待存储数据流包括的待存储数据在传输至电子设备的时间是不同的,电子设备在接收到待存储数据流包括的部分待存储数据时,后续可能还会不断接收到属于该待存储数据流的待存储数据,因此,电子设备在未完全接收到待存储数据流包括的所有待存储数据时,检测到的该待存储数据流的数据量不是该待存储数据流实际的数据量。在本申请实施例中,电子设备每接收到一个属于该待存储数据流的待存储数据就需要重新检测一次该待存储数据流的数据量,具体的,电子设备可以通过检测新接收到的待存储数据的数据量,然后将检测到的数据量与接收新待存储数据之前得到的该待存储数据流的数据 量相加,即可得到当前待存储数据流的数据量。
S103、电子设备在多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流。
具体的,电子设备在检测到各个待存储数据流的当前数据量之后,可以在多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流。数据量大于第一数据量阈值的待存储数据流的数据量较大,需要占据存储器较大的存储空间,而数据量小于或等于第一数据量阈值的待存储数据流的数据量较小,占据的存储空间较小。电子设备在确定出数据量大于第一数据量阈值的第一数据流之后,可以进一步获取第一数据流的数量与待存储数据流的数量之间的比值,并根据比值确定如何存储待存储数据流。
在一种实现方式中,相较于数据量小于或等于第一数据量阈值的待存储数据流,在存储数据量大于第一数据量阈值的待存储数据流时,需要占据更多的存储单元,电子设备在将待存储数据存储至存储单元时,首先需要获取存储单元的地址,然后才能按照地址将待存储数据存储至存储单元,因此在存储数据量大于第一数据量阈值的待存储数据流时,获取存储单元的地址的总时长成为限制存储效率的主要因素之一。
在一种实现方式中,第二存储器在存储待存储数据时,将待存储数据存储至存储地址连续的存储单元中,这样第二存储器只要获取到存储待存储数据的首个存储单元的地址,即可顺序存储待存储数据,而不需再重新获取存储单元的地址,因此,第二存储器在存储占据的存储单元越多的待存储数据流时,对于存储每个待存储数据的所花费的平均时长更短。然而,第一存储器在存储待存储数据时,将待存储数据存储至随机的存储单元中,这样第二存储器在存储一个待存储数据,需要多次获取存储单元的地址,例如,一个待存储数据需要占据4个存储单元,则第一存储器需要分别获取4个存储单元的地址,才能成功存储该待存储数据,且4个存储单元的地址可能不是连续的,因此,第一存储器在存储占据的存储单元越多的待存储数据流时,对于存储每个待存储数据的所花费的平均时长更长。由于第二存储器的顺序读写性能高于第一存储器,因此,相较于将数据量大于第一数据量阈值的待存储数据流存储至第一存储器,将数据量大于第一数据量阈值的待存储数据流存储至第二存储器,所花费的获取存储单元地址的总时长更短,能提高存储效率以及电子设备整体的存储性能。
在一种实现方式中,第一数据量阈值可以是电子设备默认设置的,也可以是电子设备根据用户输入的经验值确定的,本申请实施例对此不作限定。
S104、电子设备获取第一数据流的数量,并将第一数据流的数量与待存储数据流的数量之间的比值作为第一比值。
具体的,电子设备确定第一数据流之后,可以统计第一数据流的数量,然后计算第一数据流的数量与待存储数据流的数量之间的比值,并将计算得到的比值作为第一比值,该第一比值可以用于表征电子设备当前接收到的所有待存储数据流中,第一数据流的占比,或者,该第一比值可以用于表征电子设备当前接收到的所有待存储数据流中,大IO流的占比。
S105、若第一比值大于预设比值,则电子设备将待存储数据流中的待存储数据均存储至第二存储器。
具体的,若第一比值大于预设比值,则表明电子设备当前接收到的所有待存储数据流中,大IO流的占比较高。由于相较于将大IO流存储至第一存储器,将大IO流存储至第二存储器,所花费的获取存储单元地址的总时长更短,因此,在第一比值大于预设比值时,相较于将待存储数据流中的待存储数据均存储至第一存储器,电子设备将待存储数据流中的待存储数据均存储至第二存储器,可以降低获取存储单元地址的总时长,有利于提高电子设备的存储效率以及整体的存储性能。其中,预设比值大于0且小于1。在一种实现方式中,预设比值可以是电子设备默认设置的,也可以是电子设备根据用户输入的经验值确定的,本申请实施例对此不作限定。
在一种实现方式中,电子设备将待存储数据流中的待存储数据均存储至第二存储器的具体实施方式可以为:电子设备通过第二类型的存储路径将待存储数据存储均至第二存储器。其中,当第二存储器为HDD时,第二类型的存储路径可以为前缀为“/HDD”的存储路径。
在一种实现方式中,在步骤S102之前,电子设备还可以检测是否开启分级缓存功能,若开启,则执行步骤S102,若未开启,则将获取的多个待存储数据流直接存储至默认存储器,其中,默认存储器可以是电子设备中的任意一个存储器(如第一存储器或者第二存储器)。例如,当默认存储器为第一存储器,且第一存储器的剩余存储空间非常大时,电子设备可以不用开启分级缓存功能,这样在接收到多个待存储数据流时,可以直接将该多个待存储数据流存储至第一存储器,而无需检测各个待存储数据的数据量,并根据各个待存储数据的数据量确定第一数据流,并根据第一数据流的数量与待存储数据流的数量之间的比值判断将获取的待存储数据存储至第一存储器还是第二存储器,通过这种方式,可以降低电子设备的功耗。也就是说,电子设备可以在第一存储器的剩余存储空间较有限时,才开启分级缓存功能,以防止第一存储器的存储空间被耗尽。通过这种方式,可以更好地利用电子设备中的各个存储器的存储资源,提高电子设备整体的存储性能。
通过实施本申请实施例,可以避免将获取的待存储数据流中的待存储数据均存储至默认存储器,有利于提高电子设备整体的存储性能。
请参阅图2,图2是本申请实施例提供的另一种分级存储方法的流程示意图。该方法应用于电子设备,该电子设备可以包括第一存储器和第二存储器,第一存储器为电子设备的默认存储器。具体的,如图2所示,本申请实施例的分级存储方法可以包括但不限于如下步骤:
S201、电子设备获取多个待存储数据流。
S202、电子设备检测多个待存储数据流中每个待存储数据流的数据量。
S203、电子设备在多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流。
S204、电子设备获取第一数据流的数量,并将第一数据流的数量与待存储数据流的数量之间的比值作为第一比值。
S205、若第一比值大于预设比值,则电子设备将待存储数据流中的待存储数据均存储至第二存储器。
需要说明的是,步骤S201~步骤S205的执行过程可以分别参见图1中步骤S101~步骤105中的具体描述,在此不赘述。
在一种实现方式中,在获取单个存储单元的存储地址时,第一存储器的获取速度快于第二存储器,但是由于第一存储器采用随机存储的方式,第二存储器采用顺序存储的方式,因此,在存储连续的大IO流时,第二存储器的存储效率高于第一存储器,但是在存储小IO流时,第一存储器的存储效率高于第二存储器。在一种实现方式中,若第一比值小于或等于预设比值,则表明电子设备当前接收到的所有待存储数据流中,小IO流的占比较高。由于在存储小IO流时,第一存储器的存储效率高于第二存储器,因此,相较于将小IO流存储至第二存储器,将小IO流存储至第一存储器,所花费的获取存储单元地址的总时长更短,因此,在第一比值小于或等于预设比值时,相较于将待存储数据流中的待存储数据均存储至第二存储器,电子设备将待存储数据流中的部分待存储数据均存储至第一存储器,可以降低获取存储单元地址的总时长,有利于提高电子设备的存储效率以及整体的存储性能。需要说明的是,在一种实现方式中,第一存储器的存储空间小于第二存储器的存储空间,虽然第一比值小于或等于预设比值,但是当前获取的多个待存储数据流中仍然包括大IO流(即第一数据流),若该大IO流的数据量极大,而电子设备将该大IO流包括的所有待存储数据也全部存储至第一存储器,将导致第一存储器的空间很快被耗尽,因此,电子设备可以将待存储数据流中的部分待存储数据均存储至第一存储器,然后再进一步根据大IO流的数据量判断是否将大IO的所有待存储数据均存储至第一存储器。
具体的,电子设备在获取的多个待存储数据流中,可以将数据量小于或等于第一数据量阈值的待存储数据流确定为第二数据流,由于第二数据流的数据量很小,因此可以直接将第二数据流包括的所有待存储数据均存储至第一存储器。对于第一数据流,可以按照第一数据流中待存储数据在数据队列中的排列顺序,从第一数据流中提取第一待存储数据,并将第一待存储数据存储至第一存储器,其中,第一待存储数据的数据量等于第一数据量阈值,数据队列可以指缓存待存储数据流的缓存队列,也可以指接收待存储数据流的接收队列,在数据队列中,待存储数据流包括的待存储数据按照序号从小到大的顺序排列。对于第一数据流中除了第一待存储数据以外的其他待存储数据,需要进一步判断应该存储至第一存储器还是第二存储器。
S206、若第一比值小于或等于预设比值,则电子设备在所有第一数据流中,将数据量大于第二数据量阈值的第一数据流确定为第三数据流,第二数据量阈值大于第一数据量阈值。
具体的,若第一比值小于或等于预设比值,则电子设备可以在所有第一数据流中,将数据量大于第二数据量阈值的第一数据流确定为第三数据流。第二数据量阈值可以是第一数据量阈值的整数倍,例如,第一数据量阈值为128KB时,第二数据量阈值可以为256KB。在一种实现方式中,第二数据量阈值可以是电子设备默认设置的,也可以是电子设备根据用户输入的经验值确定的,本申请实施例对此不作限定。
S207、电子设备获取第三数据流的数量,并将第三数据流的数量与第一数据流的数量之间的比值作为第二比值。
具体的,电子设备获取第二比值之后,可以根据第二比值,确定如何存储第一数据流 中除了第一待存储数据以外的其他待存储数据。在一种实现方式中,若第二比值大于预设比值,则电子设备可以将第一数据流中除第一待存储数据以外的其他待存储数据均存储至第二存储器;若第二比值小于或等于预设比值,则电子设备可以将第一数据流中除第一待存储数据以外的其他待存储数据均存储至第一存储器。
S208、若第二比值大于预设比值,则电子设备按照第一数据流中待存储数据在数据队列中的排列顺序,从第一数据流中提取第一待存储数据,将第一待存储数据存储至第一存储器,并将第二数据流中的待存储数据存储至第一存储器。
具体的,若第二比值大于预设比值,则电子设备可以触发执行按照第一数据流中待存储数据在数据队列中的排列顺序,从第一数据流中提取第一待存储数据,将第一待存储数据存储至第一存储器,并将第二数据流中的待存储数据存储至第一存储器的步骤。在一种实现方式中,电子设备可以先执行从第一数据流中提取第一待存储数据,将第一待存储数据存储至第一存储器,并将第二数据流中的待存储数据存储至第一存储器,然后再执行将第一数据流中除第一待存储数据以外的其他待存储数据均存储至第二存储器。或者,电子设备可以同时执行从第一数据流中提取第一待存储数据,将第一待存储数据存储至第一存储器,并将第二数据流中的待存储数据存储至第一存储器,将第一数据流中除第一待存储数据以外的其他待存储数据均存储至第二存储器。
S209、电子设备将第一数据流中除第一待存储数据以外的其他待存储数据均存储至第二存储器。
具体的,若第二比值大于预设比值,则电子设备可以将第一数据流中除第一待存储数据以外的其他待存储数据均存储至第二存储器。通过这种方式,在第一比值小于或等于预设比值时,电子设备将第一数据流中的部分待存储数据(即第一待存储数据)存储至第一存储器,并将第一数据流中的剩余待存储数据(即除第一待存储数据以外的其他待存储数据)存储至第二存储器,可以避免将所有待存储数据均存储至同一个存储器,有利于同时发挥出第一存储器和第二存储器的存储性能,即有利于提高电子设备整体的存储性能。
以图2a所示的电子设备存储4个待存储数据流(待存储数据流a、待存储数据流b、待存储数据流c和待存储数据流d)的场景示意图为例,若电子设备获取的4个待存储数据流a、待存储数据流b、待存储数据流c和待存储数据流d的数据量分别为384KB、288KB、224KB、96KB,第一数据流阈值为128KB,第二数据流阈值为256KB,且预设比值为1/2,则可以得到,第一比值为3/4,第二比值为2/3,因此,图2a中待存储数据流a、待存储数据流b、待存储数据流c均为第一数据流,待存储数据流d为第二数据流,且待存储数据流a、待存储数据流b为第三数据流。因此,电子设备可以将第二数据流中的待存储数据以及第一数据流中的第一待存储数据(即图中阴影部分所示的待存储数据)存储至第一存储器,并将第一数据流中除第一待存储数据意外的待存储数据均存储至第二存储器。
在一种实现方式中,电子设备还可以将第一存储器(和第二存储器)格式化为预设格式的文件系统,以便于在第一存储器(和第二存储器)中查找数据或者管理数据。例如,将第一存储器格式化为文件系统之后,用户可以很方便地在第一存储器中查找数据、拷贝数据、删除数据或者迁移数据等,通过这种方式,电子设备可以更好地管理第一存储器的存储空间,进而提高第一存储器的存储性能。文件系统是操作系统用于明确存储设备(如 第一存储器和/或第二存储器)或分区上的文件的方法和数据结构,从系统角度来看,文件系统是对文件存储设备的空间进行组织和分配,负责文件存储并对存入的文件进行保护和检索的系统。在一种实现方式中,当电子设备的操作系统为Linux时,预设格式可以为第四代扩展文件系统(Fourth extended file system,EXT4)格式,或者,Linux操作系统支持的其他文件系统格式。在一种实现方式中,当电子设备的操作系统为Windows时,预设格式可以为NTFS(New Technology File System)格式,或者,文件分配表(File Allocation Table,FAT)格式。
在一种实现方式中,电子设备在将待存储数据存储中第一存储器之后,可以针对该待存储数据设置一个计时器,用于统计该待存储数据的已存储时长。另外,电子设备还可以统计该待存储数据在存储期间被调用的总次数,进而,将待存储数据在存储期间被调用的总次数与该待存储数据的已存储时长之间的比值作为该待存储数据的在存储期间被调用的频率。然后,电子设备可以获取数据量的权重、以及调用频率的权重,进而根据数据量的权重、以及调用频率的权重,对第一存储器中存储的各个数据的数据量和各个数据在存储期间被调用的频率进行加权求和,得到各个数据的存储价值,并将存储价值最小的数据迁移至第二存储设备,即在第一存储器中删除存储价值最小的数据,并将该存储价值最小的数据存储至第二存储器。通过这种方式,可以避免第一存储器的剩余存储空间过小时,无法存储后续接收到的待存储数据,有利于提高电子设备的存储性能。
在一种实现方式中,电子设备将各个数据中存储价值最小的数据迁移至第二存储设备之后,若检测到第一存储器的剩余存储空间仍然小于第二存储空间阈值,则电子设备还需要根据存储价值递增的顺序删除第一存储器中存储的数据,直至第一存储器的剩余存储空间大于或等于第二存储空间阈值。
通过实施本申请实施例,可以避免将所有待存储数据均存储至同一个存储器,有利于同时发挥出第一存储器和第二存储器的存储性能,即有利于提高电子设备整体的存储性能。
请参见图3,图3是本申请实施例提供的一种分级存储装置的结构示意图,该分级存储装置包括第一存储器和第二存储器,第一存储器为该分级存储装置的默认存储器,具体的,如图3所示,该分级存储装置30,可以包括:
获取单元301,用于获取多个待存储数据流;
处理单元302,用于检测多个待存储数据流中每个待存储数据流的数据量;
处理单元302,还用于在多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流;
获取单元301,还用于获取第一数据流的数量,处理单元302还用于将第一数据流的数量与待存储数据流的数量之间的比值作为第一比值;
存储单元303,用于若第一比值大于预设比值,则将待存储数据流中的待存储数据均存储至第二存储器。
在一种实现方式中,存储单元303,还用于若第一比值小于或等于预设比值,则按照第一数据流中待存储数据在数据队列中的排列顺序,从第一数据流中提取第一待存储数据,将第一待存储数据存储至第一存储器,并将第二数据流中的待存储数据存储至第一存储器; 其中,第一待存储数据的数据量等于第一数据量阈值,第二数据流为多个待存储数据流中数据量小于或等于第一数据量阈值的待存储数据流。
在一种实现方式中,处理单元302,还用于若第一比值小于或等于预设比值,则在所有第一数据流中,将数据量大于第二数据量阈值的第一数据流确定为第三数据流,第二数据量阈值大于第一数据量阈值;获取单元301,还用于获取第三数据流的数量,处理单元302还用于将第三数据流的数量与第一数据流的数量之间的比值作为第二比值;存储单元303,还用于若第二比值大于所述预设比值,则触发执行按照第一数据流中待存储数据在数据队列中的排列顺序,从第一数据流中提取第一待存储数据,将第一待存储数据存储至第一存储器,并将第二数据流中的待存储数据存储至第一存储器的步骤;将第一数据流中除第一待存储数据以外的其他待存储数据均存储至第二存储器。
在一种实现方式中,获取单元301用于获取多个待存储数据流时,具体可以用于:获取多个待存储数据以及每个待存储数据的属性信息,属性信息包括起始地址、终止地址、数据长度和数据流标识中的一个或多个;并根据多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流,将确定出的数据流作为待存储数据流。
在一种实现方式中,待存储数据可以包括第二待存储数据和第三待存储数据,属性信息可以包括起始地址和终止地址;获取单元301用于根据多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流时,具体可以用于:若第二待存储数据的起始地址与第三待存储数据的终止地址连续,则确定第二待存储数据和第三待存储数据属于同一个数据流。
在一种实现方式中,待存储数据可以包括第二待存储数据和第三待存储数据,属性信息可以包括起始地址和数据长度;获取单元301用于根据多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流时,具体可以用于:根据多个待存储数据中每个待存储数据的起始地址和数据长度,得到对应待存储数据的终止地址;若第二待存储数据的起始地址与第三待存储数据的终止地址连续,则确定第二待存储数据和第三待存储数据属于同一个数据流。
在一种实现方式中,属性信息可以包括数据流标识;获取单元301用于根据多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流时,具体可以用于:将多个待存储数据中每个待存储数据的数据流标识指示的数据流作为对应待存储数据所属的数据流。
本申请实施例和图1-图2所示方法实施例基于同一构思,其带来的技术效果也相同,具体原理请参照图1-图2所示实施例的描述,在此不赘述。
请参阅图4,图4是本申请实施例提供的一种电子设备的结构示意图。该电子设备40可以包括第一存储器401、第二存储器402、处理器403和网络接口404,第一存储器401、第二存储器402、处理器403和网络接口404通过一条或多条通信总线连接。其中,网络接口404受处理器403的控制用于收发消息。
第一存储器401(和第二存储器402)可以包括只读存储器和随机存取存储器,并向处理器403提供指令和数据。第一存储器401(和第二存储器402)的一部分还可以包括非 易失性随机存取存储器。
处理器403可以是中央处理单元(Central Processing Unit,CPU),该处理器403还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器,可选的,该处理器403也可以是任何常规的处理器等。其中:
第一存储器401(或第二存储器402),用于存储程序指令。
处理器403,用于调用第一存储器401(或第二存储器402)中存储的程序指令,以执行以下步骤:
获取多个待存储数据流;
检测多个待存储数据流中每个待存储数据流的数据量;
在多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流;
获取第一数据流的数量,并将第一数据流的数量与待存储数据流的数量之间的比值作为第一比值;
若第一比值大于预设比值,则将待存储数据流中的待存储数据均存储至第二存储器402。
在一种实现方式中,处理器403还可以执行以下步骤:若第一比值小于或等于预设比值,则按照第一数据流中待存储数据在数据队列中的排列顺序,从第一数据流中提取第一待存储数据,将第一待存储数据存储至第一存储器401,并将第二数据流中的待存储数据存储至第一存储器401;其中,第一待存储数据的数据量等于第一数据量阈值,第二数据流为多个待存储数据流中数据量小于或等于第一数据量阈值的待存储数据流。
在一种实现方式中,处理器403还可以执行以下步骤:若第一比值小于或等于预设比值,则在所有第一数据流中,将数据量大于第二数据量阈值的第一数据流确定为第三数据流,第二数据量阈值大于第一数据量阈值;获取第三数据流的数量,并将第三数据流的数量与第一数据流的数量之间的比值作为第二比值;若第二比值大于所述预设比值,则触发执行按照第一数据流中待存储数据在数据队列中的排列顺序,从第一数据流中提取第一待存储数据,将第一待存储数据存储至第一存储器401,并将第二数据流中的待存储数据存储至第一存储器401的步骤;将第一数据流中除第一待存储数据以外的其他待存储数据均存储至第二存储器402。
在一种实现方式中,处理器403执行获取多个待存储数据流时,具体可以执行以下步骤:获取多个待存储数据以及每个待存储数据的属性信息,属性信息包括起始地址、终止地址、数据长度和数据流标识中的一个或多个;并根据多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流,将确定出的数据流作为待存储数据流。
在一种实现方式中,待存储数据可以包括第二待存储数据和第三待存储数据,属性信息可以包括起始地址和终止地址;处理器403执行根据多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流时,具体可以执行以下步骤:若第二待 存储数据的起始地址与第三待存储数据的终止地址连续,则确定第二待存储数据和第三待存储数据属于同一个数据流。
在一种实现方式中,待存储数据可以包括第二待存储数据和第三待存储数据,属性信息可以包括起始地址和数据长度;处理器403执行于根据多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流时,具体可以执行以下步骤:根据多个待存储数据中每个待存储数据的起始地址和数据长度,得到对应待存储数据的终止地址;若第二待存储数据的起始地址与第三待存储数据的终止地址连续,则确定第二待存储数据和第三待存储数据属于同一个数据流。
在一种实现方式中,属性信息可以包括数据流标识;处理器403执行根据多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流时,具体可以执行以下步骤:将多个待存储数据中每个待存储数据的数据流标识指示的数据流作为对应待存储数据所属的数据流。
需要说明的是,图4对应的实施例中未提及的内容以及各个步骤的具体实现方式可参见图1-图2所示实施例以及前述内容,这里不再赘述。
本申请实施例还提供一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序包括程序指令,程序指令被处理器执行时,使处理器执行如图1-图2所示方法实施例中所执行的步骤。
以上所揭露的仅为本申请的部分实施例而已,当然不能以此来限定本申请之权利范围,本领域普通技术人员可以理解实现上述实施例的全部或部分流程,并依本申请权利要求所作的等同变化,仍属于发明所涵盖的范围。

Claims (20)

  1. 一种分级存储方法,应用于电子设备,其特征在于,所述电子设备包括第一存储器和第二存储器,所述第一存储器为所述电子设备的默认存储器;所述方法包括:
    获取多个待存储数据流;
    检测所述多个待存储数据流中每个待存储数据流的数据量;
    在所述多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流;
    获取所述第一数据流的数量,并将所述第一数据流的数量与所述待存储数据流的数量之间的比值作为第一比值;
    若所述第一比值大于预设比值,则将所述待存储数据流中的待存储数据均存储至所述第二存储器。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    若所述第一比值小于或等于所述预设比值,则按照所述第一数据流中待存储数据在数据队列中的排列顺序,从所述第一数据流中提取第一待存储数据,将所述第一待存储数据存储至所述第一存储器,并将第二数据流中的待存储数据存储至所述第一存储器;
    其中,所述第一待存储数据的数据量等于所述第一数据量阈值,所述第二数据流为所述多个待存储数据流中数据量小于或等于所述第一数据量阈值的待存储数据流。
  3. 根据权利要求2所述的方法,其特征在于,所述按照所述第一数据流中待存储数据在数据队列中的排列顺序,从所述第一数据流中提取第一待存储数据,将所述第一待存储数据存储至所述第一存储器,并将第二数据流中的待存储数据存储至所述第一存储器之前,所述方法还包括:
    若所述第一比值小于或等于所述预设比值,则在所有第一数据流中,将数据量大于第二数据量阈值的第一数据流确定为第三数据流,所述第二数据量阈值大于所述第一数据量阈值;
    获取所述第三数据流的数量,并将所述第三数据流的数量与所述第一数据流的数量之间的比值作为第二比值;
    若所述第二比值大于所述预设比值,则触发执行按照所述第一数据流中待存储数据在数据队列中的排列顺序,从所述第一数据流中提取第一待存储数据,将所述第一待存储数据存储至所述第一存储器,并将第二数据流中的待存储数据存储至所述第一存储器的步骤;
    将所述第一数据流中除所述第一待存储数据以外的其他待存储数据均存储至所述第二存储器。
  4. 根据权利要求1~3任一项所述的方法,其特征在于,所述获取多个待存储数据流,包括:
    获取多个待存储数据以及每个待存储数据的属性信息,所述属性信息包括起始地址、终止地址、数据长度和数据流标识中的一个或多个;
    根据所述多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流,将确定出的数据流作为待存储数据流。
  5. 根据权利要求4所述的方法,其特征在于,所述待存储数据包括第二待存储数据和第三待存储数据,所述属性信息包括起始地址和终止地址;
    所述根据所述多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流,包括:
    若所述第二待存储数据的起始地址与所述第三待存储数据的终止地址连续,则确定所述第二待存储数据和第三待存储数据属于同一个数据流。
  6. 根据权利要求4所述的方法,其特征在于,所述待存储数据包括第二待存储数据和第三待存储数据,所述属性信息包括起始地址和数据长度;
    所述根据所述多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流,包括:
    根据所述多个待存储数据中每个待存储数据的起始地址和数据长度,得到对应待存储数据的终止地址;
    若所述第二待存储数据的起始地址与所述第三待存储数据的终止地址连续,则确定所述第二待存储数据和第三待存储数据属于同一个数据流。
  7. 根据权利要求4所述的方法,其特征在于,所述属性信息包括数据流标识;
    所述根据所述多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流,包括:
    将所述多个待存储数据中每个待存储数据的数据流标识指示的数据流作为对应待存储数据所属的数据流。
  8. 一种分级存储装置,其特征在于,所述分级存储装置包括第一存储器和第二存储器,所述第一存储器为所述分级存储装置的默认存储器;所述分级存储装置包括:
    获取单元,用于获取多个待存储数据流;
    处理单元,用于检测所述多个待存储数据流中每个待存储数据流的数据量;
    所述处理单元,还用于在所述多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流;
    所述获取单元,还用于获取所述第一数据流的数量,所述处理单元还用于将所述第一数据流的数量与所述待存储数据流的数量之间的比值作为第一比值;
    存储单元,用于若所述第一比值大于预设比值,则将所述待存储数据流中的待存储数据均存储至所述第二存储器。
  9. 根据权利要求8所述的分级存储装置,其特征在于,
    所述存储单元,还用于若所述第一比值小于或等于所述预设比值,则按照所述第一数据流中待存储数据在数据队列中的排列顺序,从所述第一数据流中提取第一待存储数据,将所述第一待存储数据存储至所述第一存储器,并将第二数据流中的待存储数据存储至所述第一存储器;
    其中,所述第一待存储数据的数据量等于所述第一数据量阈值,所述第二数据流为所述多个待存储数据流中数据量小于或等于所述第一数据量阈值的待存储数据流。
  10. 根据权利要求9所述的分级存储装置,其特征在于,
    所述处理单元,还用于若所述第一比值小于或等于所述预设比值,则在所有第一数据 流中,将数据量大于第二数据量阈值的第一数据流确定为第三数据流,所述第二数据量阈值大于所述第一数据量阈值;
    所述获取单元,还用于获取所述第三数据流的数量;
    所述处理单元,还用于将所述第三数据流的数量与所述第一数据流的数量之间的比值作为第二比值;
    所述存储单元,还用于若所述第二比值大于所述预设比值,则触发执行按照所述第一数据流中待存储数据在数据队列中的排列顺序,从所述第一数据流中提取第一待存储数据,将所述第一待存储数据存储至所述第一存储器,并将第二数据流中的待存储数据存储至所述第一存储器的步骤;并将所述第一数据流中除所述第一待存储数据以外的其他待存储数据均存储至所述第二存储器。
  11. 根据权利要求8~10任一项所述的分级存储装置,其特征在于,
    所述获取单元用于获取多个待存储数据流时,具体用于:获取多个待存储数据以及每个待存储数据的属性信息,所述属性信息包括起始地址、终止地址、数据长度和数据流标识中的一个或多个;并根据所述多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流,将确定出的数据流作为待存储数据流。
  12. 根据权利要求11所述的分级存储装置,其特征在于,所述待存储数据包括第二待存储数据和第三待存储数据,所述属性信息包括起始地址和终止地址;
    所述获取单元用于根据所述多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流时,具体用于:若所述第二待存储数据的起始地址与所述第三待存储数据的终止地址连续,则确定所述第二待存储数据和第三待存储数据属于同一个数据流。
  13. 根据权利要求11所述的分级存储装置,其特征在于,所述待存储数据包括第二待存储数据和第三待存储数据,所述属性信息包括起始地址和数据长度;
    所述获取单元用于根据所述多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流时,具体用于:根据所述多个待存储数据中每个待存储数据的起始地址和数据长度,得到对应待存储数据的终止地址;若所述第二待存储数据的起始地址与所述第三待存储数据的终止地址连续,则确定所述第二待存储数据和第三待存储数据属于同一个数据流。
  14. 根据权利要求11所述的分级存储装置,其特征在于,所述属性信息包括数据流标识;
    所述获取单元用于根据所述多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流时,具体用于:将所述多个待存储数据中每个待存储数据的数据流标识指示的数据流作为对应待存储数据所属的数据流。
  15. 一种电子设备,其特征在于,所述电子设备包括第一存储器、第二存储器和处理器,所述第一存储器为所述电子设备的默认存储器;所述第一存储器或所述第二存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,执行以下步骤:
    获取多个待存储数据流;
    检测所述多个待存储数据流中每个待存储数据流的数据量;
    在所述多个待存储数据流中,将数据量大于第一数据量阈值的待存储数据流确定为第一数据流;
    获取所述第一数据流的数量,并将所述第一数据流的数量与所述待存储数据流的数量之间的比值作为第一比值;
    若所述第一比值大于预设比值,则将所述待存储数据流中的待存储数据均存储至所述第二存储器。
  16. 根据权利要求15所述的电子设备,其特征在于,所述处理器还用于调用所述程序指令执行以下步骤:
    若所述第一比值小于或等于所述预设比值,则按照所述第一数据流中待存储数据在数据队列中的排列顺序,从所述第一数据流中提取第一待存储数据,将所述第一待存储数据存储至所述第一存储器,并将第二数据流中的待存储数据存储至所述第一存储器;
    其中,所述第一待存储数据的数据量等于所述第一数据量阈值,所述第二数据流为所述多个待存储数据流中数据量小于或等于所述第一数据量阈值的待存储数据流。
  17. 根据权利要求16所述的电子设备,其特征在于,所述处理器还用于调用所述程序指令执行以下步骤:
    若所述第一比值小于或等于所述预设比值,则在所有第一数据流中,将数据量大于第二数据量阈值的第一数据流确定为第三数据流,所述第二数据量阈值大于所述第一数据量阈值;
    获取所述第三数据流的数量,并将所述第三数据流的数量与所述第一数据流的数量之间的比值作为第二比值;
    若所述第二比值大于所述预设比值,则触发执行按照所述第一数据流中待存储数据在数据队列中的排列顺序,从所述第一数据流中提取第一待存储数据,将所述第一待存储数据存储至所述第一存储器,并将第二数据流中的待存储数据存储至所述第一存储器的步骤;
    将所述第一数据流中除所述第一待存储数据以外的其他待存储数据均存储至所述第二存储器。
  18. 根据权利要求15~17任一项所述的电子设备,其特征在于,所述处理器执行所述获取多个待存储数据流时,具体执行以下步骤:
    获取多个待存储数据以及每个待存储数据的属性信息,所述属性信息包括起始地址、终止地址、数据长度和数据流标识中的一个或多个;
    根据所述多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流,将确定出的数据流作为待存储数据流。
  19. 根据权利要求18所述的电子设备,其特征在于,所述待存储数据包括第二待存储数据和第三待存储数据,所述属性信息包括起始地址和终止地址;
    所述处理器执行所述根据所述多个待存储数据中每个待存储数据的属性信息,确定出对应待存储数据所属的数据流时,具体执行以下步骤:若所述第二待存储数据的起始地址与所述第三待存储数据的终止地址连续,则确定所述第二待存储数据和第三待存储数据属于同一个数据流。
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求1~7任一项所述的方法。
PCT/CN2019/117558 2019-03-01 2019-11-12 分级存储方法、装置、电子设备及计算机可读存储介质 WO2020177379A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910156188.1 2019-03-01
CN201910156188.1A CN110045924B (zh) 2019-03-01 2019-03-01 分级存储方法、装置、电子设备及计算机可读存储介质

Publications (1)

Publication Number Publication Date
WO2020177379A1 true WO2020177379A1 (zh) 2020-09-10

Family

ID=67274428

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/117558 WO2020177379A1 (zh) 2019-03-01 2019-11-12 分级存储方法、装置、电子设备及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN110045924B (zh)
WO (1) WO2020177379A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117762327A (zh) * 2023-11-15 2024-03-26 成都睿众博芯微电子技术有限公司 数据存储方法、装置、设备以及存储介质

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110045924B (zh) * 2019-03-01 2022-02-11 平安科技(深圳)有限公司 分级存储方法、装置、电子设备及计算机可读存储介质
CN113885795B (zh) * 2021-09-23 2024-01-19 惠州Tcl移动通信有限公司 一种数据存储方法、装置、终端设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140289470A1 (en) * 2013-03-21 2014-09-25 Sharp Laboratories Of America, Inc. Computing Device Having Optimized File System and Methods for Use Therein
CN104461935A (zh) * 2014-11-27 2015-03-25 华为技术有限公司 一种进行数据存储的方法、装置及系统
CN105718530A (zh) * 2016-01-15 2016-06-29 上海磁宇信息科技有限公司 文件存储系统及其文件存储控制方法
CN108089814A (zh) * 2016-11-23 2018-05-29 中移(苏州)软件技术有限公司 一种数据存储方法及装置
CN110045924A (zh) * 2019-03-01 2019-07-23 平安科技(深圳)有限公司 分级存储方法、装置、电子设备及计算机可读存储介质

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6230247B1 (en) * 1997-10-29 2001-05-08 International Business Machines Corporation Method and apparatus for adaptive storage space allocation
US6701392B1 (en) * 2001-11-14 2004-03-02 Emc Corporation Hierarchical approach to indentifying changing device characteristics
CN106502576B (zh) * 2015-09-06 2020-06-23 中兴通讯股份有限公司 迁移策略调整方法及装置
CN107220263B (zh) * 2016-03-22 2021-09-03 阿里巴巴集团控股有限公司 数据迁移的优化方法、评估方法及处理方法及装置
CN108268207B (zh) * 2016-12-30 2021-04-02 杭州海康威视数字技术股份有限公司 一种基于云存储的元数据管理方法及装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140289470A1 (en) * 2013-03-21 2014-09-25 Sharp Laboratories Of America, Inc. Computing Device Having Optimized File System and Methods for Use Therein
CN104461935A (zh) * 2014-11-27 2015-03-25 华为技术有限公司 一种进行数据存储的方法、装置及系统
CN105718530A (zh) * 2016-01-15 2016-06-29 上海磁宇信息科技有限公司 文件存储系统及其文件存储控制方法
CN108089814A (zh) * 2016-11-23 2018-05-29 中移(苏州)软件技术有限公司 一种数据存储方法及装置
CN110045924A (zh) * 2019-03-01 2019-07-23 平安科技(深圳)有限公司 分级存储方法、装置、电子设备及计算机可读存储介质

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117762327A (zh) * 2023-11-15 2024-03-26 成都睿众博芯微电子技术有限公司 数据存储方法、装置、设备以及存储介质

Also Published As

Publication number Publication date
CN110045924B (zh) 2022-02-11
CN110045924A (zh) 2019-07-23

Similar Documents

Publication Publication Date Title
WO2020177379A1 (zh) 分级存储方法、装置、电子设备及计算机可读存储介质
US9830101B2 (en) Managing data storage in a set of storage systems using usage counters
US9021537B2 (en) Pre-buffering audio streams
US9253548B2 (en) Optimizing caches for media streaming
WO2016061898A1 (zh) 直播间的频道访问方法和系统
CN102761517B (zh) 一种高速网络的内容还原方法
US10771358B2 (en) Data acquisition device, data acquisition method and storage medium
US20120303905A1 (en) Method and apparatus for implementing cache
CN110018788A (zh) 分级存储方法、装置、电子设备及计算机可读存储介质
CN109542361A (zh) 一种分布式存储系统文件读取方法、系统及相关装置
CN110162270B (zh) 基于分布式存储系统的数据存储方法、存储节点及介质
US20160277544A1 (en) Protocol data unit interface
US11704063B2 (en) Efficient storage architecture for high speed packet capture
CN116661705B (zh) 基于kafka的数据管理方法、系统、电子设备及存储介质
CN114201421A (zh) 一种数据流处理方法、存储控制节点及可读存储介质
US9137780B1 (en) Synchronizing multicast data distribution on a computing device
BR112012030152B1 (pt) método e sistema para determinar um fator de retardo de sistema
CN109587232A (zh) 基于iOS网络的文件断点续传方法
WO2014153931A1 (zh) 文件存储方法、装置、访问客户端及元数据服务器系统
WO2020024944A1 (zh) 热点数据的识别方法、装置、设备及存储介质
CN114035750A (zh) 文件处理方法、装置、设备、介质及产品
CN112269763A (zh) 一种文件聚合方法及相关装置
CN112433848A (zh) 资源处理方法、装置、存储介质和缓存服务器
JP6378044B2 (ja) データ処理装置、データ処理方法およびプログラム
WO2023083213A1 (zh) 一种数据解码方法、装置、电子设备及可读存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19918264

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19918264

Country of ref document: EP

Kind code of ref document: A1