CN117632953B - Data cycle storage method, device, server and storage medium - Google Patents

Data cycle storage method, device, server and storage medium Download PDF

Info

Publication number
CN117632953B
CN117632953B CN202311552730.8A CN202311552730A CN117632953B CN 117632953 B CN117632953 B CN 117632953B CN 202311552730 A CN202311552730 A CN 202311552730A CN 117632953 B CN117632953 B CN 117632953B
Authority
CN
China
Prior art keywords
index
target
state
data
storage space
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
CN202311552730.8A
Other languages
Chinese (zh)
Other versions
CN117632953A (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.)
Guangzhou Zhiyuan Electronics Co Ltd
Original Assignee
Guangzhou Zhiyuan Electronics Co Ltd
Filing date
Publication date
Application filed by Guangzhou Zhiyuan Electronics Co Ltd filed Critical Guangzhou Zhiyuan Electronics Co Ltd
Priority to CN202311552730.8A priority Critical patent/CN117632953B/en
Publication of CN117632953A publication Critical patent/CN117632953A/en
Application granted granted Critical
Publication of CN117632953B publication Critical patent/CN117632953B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The embodiment of the application provides a data circulation storage method, a device, a server and a storage medium, which relate to the technical field of the Internet of things.

Description

Data cycle storage method, device, server and storage medium
Technical Field
The present application relates to the field of internet of things, and in particular, to a data cycle storage method, device, server and storage medium.
Background
In the internet of things system, the equipment end collects data based on various sensors and reports the data to the cloud end (namely the server end) through a network by taking the data as equipment data, and the cloud end cleans the equipment data which are reported by the equipment and are encrypted by an encryption protocol and stores the equipment data in a database corresponding to the server. The user can carry out analysis, statistics and other processing on the equipment data through a data analysis engine provided by the cloud to obtain an analysis result.
Generally, considering the cost of storage space, after analysis is completed, the user chooses to delete the old data to free up storage space to store new device data, thereby achieving cost savings.
The related art generally adopts an elastic search engine to manage, analyze and the like on data, and the elastic search engine is a distributed, high-expansion and high-real-time search and data analysis engine, which provides two deletion modes of a deletion mode based on query and a deletion mode based on index.
And the related art generally stores the same type of device data into the same index to reduce the number of indexes, the index-based deletion method is to delete the entire index to delete the data stored in the index, but this method easily causes device data of other users to be deleted erroneously in case of multiple users. The query-based deletion method consumes a large amount of memory resources and CPU (Central Processing Unit ) resources during running, and has resource limitation in the ES engine, so that the deletion speed of the method is very slow. Therefore, in the case where the storage space provided to the user is limited, it is difficult to realize recycling of the storage space.
Disclosure of Invention
The application provides a data circulation storage method, a device, a server and a storage medium.
In a first aspect, the present application provides a data cycle storage method, applied to a server, where the server is equipped with an ES engine, and the ES engine is configured to store device data by indexing, the method includes:
determining a configurable index and index information in the user storage space based on the capacity of the configured user storage space, wherein the index information comprises the number of the configurable indexes in the user storage space and the storage capacity corresponding to each index;
determining an index array corresponding to each user storage space according to the indexes and the index quantity to generate an index list for maintaining index states corresponding to all indexes in each user storage space;
According to the user identification obtained by analyzing the received equipment data, selecting a first target index from the index list so as to store the equipment data into the first target index;
Updating the index state of the first target index based on the storage capacity corresponding to the first target index in the index information;
Under the condition that the index state corresponding to the first target index is a full state, selecting a second target index from the index list as an index of the storage device data, wherein the second target index is the next index which is continuous with the first target index in the cyclic selection sequence in the index list, and the cyclic selection sequence is a sequence which circulates according to the sequence of all indexes in the index array;
And determining whether to perform index deletion operation based on the index state of the second target index so as to recycle the user storage space after performing the index deletion operation.
In a second aspect, the present application also provides a data cycle storage apparatus applied to a server, the server being equipped with an ES engine for storing device data by indexing, the apparatus comprising:
An index configuration module configured to determine, based on a capacity of the configured user storage space, an index configurable in the user storage space and index information including a number of indexes configurable in the user storage space and a storage capacity corresponding to each index;
The list generation module is configured to determine an index array corresponding to each user storage space according to the indexes and the index quantity so as to generate an index list for maintaining index states corresponding to all indexes in each user storage space;
The first data storage module is configured to select a first target index from the index list according to the user identification obtained by analyzing the received equipment data so as to store the equipment data into the first target index;
The state updating module is configured to update the index state of the first target index based on the storage capacity corresponding to the first target index in the index information;
the index selection module is configured to select a second target index from the index list as an index of the storage device data when an index state corresponding to the first target index is a full state, wherein the second target index is a next index which is continuous with the first target index in a cyclic selection sequence in the index list, and the cyclic selection sequence is a sequence of circulating in order of all indexes in the index array;
And the second data storage module is configured to determine whether to perform index deletion operation based on the index state of the second target index so as to circularly use the user storage space after performing the index deletion operation.
In a third aspect, the present application also provides a server, comprising:
One or more processors;
And a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the data cycle storage method as described above.
In a fourth aspect, the present application also provides a storage medium storing computer executable instructions which, when executed by a processor, are adapted to carry out a data loop storage method as described above.
In the scheme of the application, the server pre-configures corresponding indexes according to the user storage space corresponding to the user, and maintains the index state of the indexes by utilizing the index list, so that the equipment data corresponding to the same user are sequentially stored into the corresponding indexes according to the set sequence, after all the indexes are full, the indexes are continuously deleted, the index array is maintained, the indexes after the data are cleared are reused, and the cyclic storage and utilization of the indexes are realized, so that the input of new equipment data is always kept.
Drawings
FIG. 1 is a schematic diagram illustrating steps of a data cycle storage method according to an embodiment of the present application;
FIG. 2 is a schematic diagram illustrating steps for determining configurable indexes and index information according to an embodiment of the present application;
FIG. 3 is a schematic diagram illustrating steps for updating an index state according to an embodiment of the present application;
FIG. 4 is a schematic diagram illustrating steps for performing an index deletion operation according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a data cycle memory device according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a server according to an embodiment of the present application.
Detailed Description
Embodiments of the present application will be described in further detail below with reference to the drawings and examples. It should be understood that the particular embodiments described herein are illustrative only and are not limiting of embodiments of the application. It should be further noted that, for convenience of description, only some, but not all structures related to the embodiments of the present application are shown in the drawings, and those skilled in the art will appreciate that any combination of technical features may constitute alternative embodiments as long as the technical features are not contradictory to each other after reading the present specification.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged, as appropriate, such that embodiments of the present application may be implemented in sequences other than those illustrated or described herein, and that the objects identified by "first," "second," etc. are generally of a type, and are not limited to the number of objects, such as the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship. In the description of the present application, "a plurality" means two or more, and "a number" means one or more.
The storage of data in an ES engine, which is inseparable from the index, in an ES engine, the data is stored in documents and the documents are stored in the index, i.e. the index in an ES engine is a data structure containing the documents, which allows searching and analysis of the documents. In data storage, the ES engine adds data in the form of documents to the corresponding index.
The server based on the ES engine needs to delete the old data stored in the storage space corresponding to the user continuously, so that enough storage space is available for storing when the user uploads new device data through the device side. The two ways provided in the related art are slower to delete data due to occupation of resources or easy to delete data by mistake, so that the server based on the ES engine is difficult to meet the requirement of an application scene with a large amount of equipment data uploading.
In this regard, the present application provides a data circulation storage method, which is of course applied to a server equipped with an ES engine, to store data uploaded by a user through a device end and to recycle a storage space allocated to the user. Fig. 1 is a schematic diagram of steps of a data cycle storage method according to an embodiment of the present application, which includes the following specific steps:
Step S110, based on the capacity of the configured user storage space, determining the index and index information which are configurable in the user storage space, wherein the index information comprises the number of the indexes which are configurable in the user storage space and the storage capacity corresponding to each index.
It will be appreciated that the server needs to configure the index and index information that can be configured in the storage space of each user according to the capacity configured for the storage space of the user corresponding to each user, for example, determining the index ID, the number of indexes, the storage capacity corresponding to each index, and so on, so as to store new device data. It is to be understood that the capacity of the user storage space corresponding to each user is different, and the index allocated to each user storage space may be different in number and capacity.
Accordingly, the server configures a number of indexes to the user storage space according to the corresponding configuration policy. Fig. 2 is a schematic diagram of steps for determining configurable indexes and index information provided in an embodiment of the present application, where a server allocates corresponding user storage space according to a set calculation mode, so as to determine a corresponding number of indexes and storage capacity of each index, and the specific steps are as follows:
step S210, based on the capacity of the user storage space, determining the estimated number of corresponding indexes in the user storage space.
Step S220, selecting the maximum value of the estimated quantity and the preset quantity as the index quantity.
Step S230, combining the capacity of the storage space of the user and the number of indexes to determine the storage capacity corresponding to each index.
It can be understood that the estimated number calculated by the server is calculated based on a corresponding calculation formula, and is a sum of a plurality of values, such as a sum of a first quotient value, a second quotient value and a preset compensation value, where the first quotient value is a value obtained by dividing a capacity value of the user storage space by a first preset divisor, the second quotient value is a value obtained by dividing a remainder value by a second preset divisor, and the remainder value is a value obtained by dividing a capacity value of the user storage space by a first preset divisor. It is conceivable that the above values are rounded up when the server performs the calculation.
The server is further provided with a preset number, and the estimated number is compared with the preset number, so that a maximum value is selected as the index number. Therefore, when the capacity of the user storage space and the number of indexes are determined, the storage capacity corresponding to each index can be determined.
For example, the first preset divisor is 100, the second preset divisor is 10, the preset compensation value is 4, and the number of indexes and the storage capacity corresponding to the indexes are calculated as follows:
INum=max{(SG/100)+[(SG%100)/10)]+4,50)}
ISize=SG/INum
Wherein, I Num is the number of indexes, I Size is the storage capacity corresponding to each index, SG is the capacity of the storage space of the user, and max { a, b } is a function of selecting the maximum value from a and b.
It should be noted that, in some embodiments, the server may also configure a fixed number and index of fixed storage capacity corresponding to the allocated user storage space. And after allocating corresponding indexes to the user storage space, the server can set corresponding index IDs (identities) in turn according to the storage fragments corresponding to the indexes so as to distinguish and search the configured indexes.
Therefore, the scheme can effectively avoid the situation that the equipment data of different users are mixed under the condition of multiple users according to the user storage space corresponding to each user, and a plurality of indexes and the storage capacity corresponding to the indexes are preconfigured for each user storage space so as to be convenient for circularly utilizing the plurality of indexes to store the equipment data.
Step S120, according to the indexes and the index number, determining an index array corresponding to each user storage space to generate an index list for maintaining index states corresponding to all indexes in each user storage space.
It is conceivable that the number of indexes corresponds to the size of the index array, i.e. represents the number of data stored by the index array. Each index array corresponds to the index configured in each user storage space, the configured index is recorded in the index array, and each index is sequentially recorded in the index array according to the corresponding sequence.
In addition, the server may generate an index list based on the index array, where each index and an index state corresponding to the index are recorded, and it is conceivable that indexes configured in a plurality of user storage spaces and index states corresponding to the indexes are recorded in the index list, so as to facilitate maintenance of index states corresponding to all indexes.
The index state is used for indicating whether the index is available and whether the storage capacity corresponding to the index is occupied. It is conceivable that the server may detect whether each index is available through an API interface provided by the ES engine to acquire the index state; and for whether the storage capacity is full, the server may invoke an API interface provided by the ES engine to obtain the size of the index to query the size of the corresponding index and compare with the storage capacity of the index (e.g., I Size described above) to determine whether the storage capacity corresponding to the index is full.
Step S130, selecting a first target index from the index list according to the user identification obtained by analyzing the received device data, so as to store the device data into the first target index.
It will be appreciated that when a user uploads device data to a server via a device, the device data typically carries a corresponding user identifier to determine the source of the device data. In a scenario of multi-user uploading, a server needs to analyze equipment data to determine a user identifier carried by the equipment data, so as to determine a user storage space for storing the equipment data, and further select a first target index from an index list to store the equipment data to the first target index. It is contemplated that the first target index is an index configured within a determined user storage space for storing the device data, and that the storage segment corresponding to the first target index is not full of data in order to continue storing the device data.
Step S140, updating the index state of the first target index based on the storage capacity corresponding to the first target index in the index information.
It may be appreciated that the server may detect the storage partition corresponding to the first target index to determine the current data amount stored, and further compare the current data amount stored with the storage capacity corresponding to the first target index, determine whether the storage partition corresponding to the first target index is already full, so as to update the index state of the first target index, for example, update the index state corresponding to the first target index to a full state if the storage partition corresponding to the first target index is already full.
Step S150, selecting a second target index from the index list as an index of the storage device data when the index state corresponding to the first target index is a full state.
The server is provided with a corresponding cyclic selection sequence corresponding to the indexes in the same user storage space in the index list, the cyclic selection sequence is associated with an index array, and is a sequence for circulating the indexes in the index array, and an index array comprises an index I, an index II and an index III, and the cyclic selection sequence is sequentially the index I, the index II, the index III, the index I and the index II … …, namely, the cyclic selection sequence is continuously circulated according to the sequence of the indexes in the index array.
In the cyclic selection order, the second target index is the next index in the index list that is consecutive to the first target index in the cyclic selection order, and both are consecutive in the cyclic selection order. Therefore, when the index state corresponding to the first target index is the full state, the server selects the index next to the second target index for storing the device data.
Step S160, based on the index state of the second target index, determining whether to perform index deletion operation or not so as to circularly use the user storage space after performing the index deletion operation.
The server detects the index state of the second target index to determine whether to perform index deletion operation, that is, determine whether the storage segment corresponding to the second target index is already full, so as to perform index deletion operation on the second target index when the storage segment is full. It can be understood that the server adopts a circulation selection sequence for the indexes configured in the user storage space to circularly utilize each index to store the device data, so that after all indexes are full of the device data, the server needs to empty the device data currently stored in the index for storing the device data before entering the next circulation, so as to be convenient for re-storing the data, thereby realizing the circular use of the user storage space.
For example, a user storage space is configured with index I, index II, and index III, and the corresponding cyclic selection order is index I, index II, index III, index I, and index II … … in sequence. If the current first target index is the index I, after the index I is full of the device data, the server selects the index II to store the device data. After the indexes I, II and III are all full, namely, for the case that the current first target index is the index III and the second target index is the index I, the server performs index deletion operation on the index I to delete the device data stored in the storage segment corresponding to the index I, so that new device data is stored again.
According to the scheme, the server pre-configures the corresponding indexes according to the user storage space corresponding to the user, and maintains the index states of the indexes by utilizing the index list, so that the equipment data corresponding to the same user are sequentially stored into the corresponding indexes according to the set sequence, after all the indexes are full, the indexes are continuously deleted, the index array is maintained, the indexes after the data are cleared are reused, and the cyclic storage and the utilization of the indexes are realized, so that the input of new equipment data is always kept.
In some embodiments, the server is further piggybacked with a Redis service, through which the index list generated by the server may be managed, i.e., the server may cache the index list. The server may update the index list according to the index status of each index to maintain the index list. It is contemplated that the server may query through the index list cached in the Redis service when querying the index state of each index. The server provides the same data cycle storage scheme for different equipment ends, for example, the function is realized through corresponding service, and further, for a plurality of equipment, the server is provided with the same number of service copies so as to finish the storage of equipment data.
Therefore, the server provides unified management on the index list by using the Redis service, so that when other service copies need to inquire the index state, the index state can be learned through the index list provided by the Redis service, and the index state of the target index is updated by using an update request initiated by the Redis service to each service copy.
In one embodiment, in the case of selecting an index and storing device data into a storage partition corresponding to the index, the server needs to detect the index to determine an index state of the index. Fig. 3 is a schematic diagram of steps for updating an index state according to an embodiment of the present application, which includes the following steps:
Step S310, based on a preset detection duration interval, detecting the data amount stored in the first target index at regular time to determine whether the stored data amount exceeds the storage capacity corresponding to the first target index.
Step S320, according to the comparison result of the stored data volume and the storage capacity, determining the index state of the first target index, and updating the index state of the first target index in the index list.
It can be understood that when the server allocates the corresponding user storage space to each user, a corresponding redundant storage space is configured for each user storage space to store the data uploaded after the overflow capacity. Therefore, the server detects the data amount of the stored data in the currently stored index at fixed time, namely, detects the current first target index at fixed time according to a preset detection duration interval so as to determine whether the stored data amount exceeds the storage capacity corresponding to the first target index. It should be noted that the set detection duration interval may be set according to actual application requirements.
After the stored data volume is detected, the stored data volume is compared with the storage capacity of the first target index, and the server determines the index state of the first target index according to the comparison result and updates the index state in the index list.
For example, at the time of detection of the timing, if it is detected that the stored data amount is greater than or equal to the storage capacity of the first target index, correspondingly, the server may determine that the index state of the first target index is a full state, and the server may further update the index state of the first target index in the index list. It is conceivable that if the stored data amount reaches the storage capacity corresponding to the first target index before the detection time, the excess portion is stored in the redundant storage space, and of course, when the stored data amount is calculated, statistics needs to be performed on the storage fragments corresponding to the first target index and the storage fragments corresponding to the redundant storage space.
Therefore, the server detects the index state of the index at fixed time, thereby realizing the detection of the data storage condition in the storage fragments corresponding to the index, and updating the index list so as to conveniently call the next index to store the data and keep the input of new equipment data.
In an embodiment, the server needs to combine the index states of the second target index for performing the index deletion operation, and fig. 4 is a schematic diagram of steps for performing the index deletion operation according to an embodiment of the present application, which specifically includes the following steps:
In step S410, if the index state of the second target index is the full state, the second target index is deleted, and the index ID and the index state of the second target index are reserved in the index list.
Step S420, based on the user storage space after the data is cleared, regenerating a third target index which is the same as the index ID of the second target index, and associating the index ID corresponding to the second target index with the third target index in the index list so as to record the index state of the third target index.
Step S430, updating the index list to update the index state of the third target index to the non-stored state, and storing the device data to the third target index until the index state of the third target index is the full state.
It can be understood that after the server detects that the index state of the second target index is the full state, the server deletes the second target index, but the server does not delete the record related to the second target index in the index list synchronously, that is, the server still maintains the index ID and the index state of the second target index in the index list.
After deleting the data of the storage fragments corresponding to the second target index, the server regenerates a third target index, wherein the index ID of the third target index is the same as that of the second target index, and the storage fragments originally corresponding to the second target index are associated with the third target index, namely the server reconfigures the corresponding indexes corresponding to the storage fragments after data removal, and still keeps the same index ID. It is contemplated that in the round robin selection order, the third target index replaces the position of the second target index in the round robin selection order because the index ID of the second target index is the same as the index ID of the third target index.
Further, in the index list, an index ID corresponding to the second target index is associated with the third target index, and the index state of the third target index is recorded by the index list. It is conceivable that the storage fragment corresponding to the third target index does not store data, and correspondingly, the index list is updated to update the index state of the third target index to the non-stored state. And storing the newly received device data into the third target index until the index state of the third target index is a full state.
Therefore, the server continuously deletes and reconfigures the index, so that the resource occupation of the server is reduced, the data deleting efficiency is effectively improved, the cyclic storage utilization of the storage fragments corresponding to the index is realized, and the entry of new equipment data is kept all the time.
If the index state of the second target index is not the full state, the device data is stored in the second target index until the index state of the second target index is the full state.
In some embodiments, the server, upon detecting the index state of the second target index, determines that the index state of the second target index is a full state and that there is an empty index with an index state that is not a full state, and the server reorders the indices in the round robin selection order.
For example, when a user expands the user storage space in the server, the server may configure the user storage space with a new index, i.e., a null index. Therefore, the server sets the order of all the empty indexes to be higher than the order of the second target index, and replaces the second target index with the empty index with the highest order for data storage.
For example, the current user storage space is configured with an index I, an index II, and an index III, the corresponding cycle selection order is sequentially the index I, the index II, the index III, the index I, and the index II … …, and the newly added index IV is used as the empty index. If the first target index is index II and the second target index is index III, and both index II and index III are in full state, the updated cycle selection order is index I, index II, index IV, index III, index I, index II … …, i.e. the empty index is used as the index of the next stored data. It is conceivable that if there are a plurality of empty indexes, a plurality of empty indexes are inserted between the first target index and the second target index in the cyclic selection sequence, wherein a next index located after the first target index in the plurality of empty indexes is an empty index with a highest order in the plurality of empty indexes.
Therefore, in the case that the empty index exists, the server preferentially utilizes the empty index, which is helpful to improve the data storage efficiency, so as to store the device data into the user storage space.
Fig. 5 is a schematic structural diagram of a data cycle storage device according to an embodiment of the present application, where the device is applied to a server, and the server is equipped with an ES engine, and the ES engine is configured to store device data by indexing. The device is used for executing the data cycle storage method provided by the embodiment, and has the function modules and the beneficial effects corresponding to the execution method. As shown, the apparatus includes an index configuration module 501, a list generation module 502, a first data storage module 503, a status update module 504, an index selection module 505, and a second data storage module 506.
Wherein, the index configuration module 501 is configured to determine, based on the capacity of the configured user storage space, an index configurable in the user storage space and index information, where the index information includes the number of indexes configurable in the user storage space and a storage capacity corresponding to each index;
The list generation module 502 is configured to determine an index array corresponding to each user storage space according to the indexes and the index number, so as to generate an index list for maintaining index states corresponding to all indexes in each user storage space;
The first data storage module 503 is configured to select a first target index from the index list according to the user identifier obtained by parsing the received device data, so as to store the device data to the first target index;
The state updating module 504 is configured to update an index state of a first target index based on a storage capacity corresponding to the first target index in the index information;
The index selection module 505 is configured to select a second target index in the index list as an index of the storage device data when an index state corresponding to the first target index is a full state, where the second target index is a next index in the index list that is continuous with the first target index in a cyclic selection order, and the cyclic selection order is an order in which the indexes in the index array are ordered to be circulated;
the second data storage module 506 is configured to determine whether to perform an index deletion operation based on an index state of the second target index to recycle the user storage space after performing the index deletion operation.
Based on the above embodiment, the index configuration module 501 is further configured to:
Determining an estimated number of corresponding indexes in the user storage space based on the capacity of the user storage space, wherein the estimated number is the sum of a first quotient value, a second quotient value and a preset compensation value, the first quotient value is the value obtained by dividing the capacity value of the user storage space by a first preset divisor, the second quotient value is the value obtained by dividing the residual value by a second preset divisor, and the residual value is the value obtained by dividing the capacity value of the user storage space by the first preset divisor;
Selecting the maximum value of the estimated quantity and the preset quantity as the index quantity;
And determining the storage capacity corresponding to each index by combining the capacity of the storage space of the user and the number of the indexes.
On the basis of the above embodiment, the server is further equipped with a Redis service, where the Redis service is used to cache the index list, and update the index list according to the index states of the indexes, so as to maintain the index list.
Based on the above embodiments, the status update module 504 is further configured to:
based on a preset detection duration interval, detecting the data amount stored in the first target index at fixed time to determine whether the stored data amount exceeds the storage capacity corresponding to the first target index;
And determining the index state of the first target index according to the comparison result of the stored data quantity and the storage capacity, and updating the index state of the first target index in the index list.
Based on the above embodiments, the second data storage module 506 is further configured to:
if the index state of the second target index is the full state, deleting the second target index, and reserving the index ID and the index state of the second target index in an index list;
Regenerating a third target index which is the same as the index ID of the second target index based on the user storage space after data removal, and associating the index ID corresponding to the second target index in the index list with the third target index so as to record the index state of the third target index;
And updating the index list to update the index state of the third target index to an unstored state, and storing the device data to the third target index until the index state of the third target index is a full state.
Based on the above embodiments, the second data storage module 506 is further configured to:
and if the index state of the second target index is not the full state, storing the equipment data to the second target index until the index state of the second target index is the full state.
On the basis of the above embodiment, the apparatus further includes an index ordering module configured to:
And if the index state of the second target index is the full state and the index state is the empty index which is not the full state, reordering the indexes in the cyclic selection sequence to set the sequence of all the empty indexes to be higher than the sequence of the second target index, and replacing the second target index with the empty index with the highest sequence for data storage.
It should be noted that, in the embodiment of the data cycle storage device, each module is only divided according to the functional logic, but not limited to the above division, so long as the corresponding function can be implemented; in addition, the specific names of the modules are only for distinguishing from each other, and are not used to limit the protection scope of the present application.
Fig. 6 is a schematic structural diagram of a server according to an embodiment of the present application, where the device is configured to execute the data cycle storage method according to the foregoing embodiment, and has functional modules and beneficial effects corresponding to the execution method. As shown, the server includes a processor 601, a memory 602, an input device 603, and an output device 604. The number of processors 601 may be one or more, one processor 601 being illustrated in the figure; the processor 601, memory 602, input device 603 and output device 604 may be connected by a bus or other means, the connection being illustrated by a bus. The memory 602 is a computer readable storage medium, and may be used to store a software program, a computer executable program, and modules, such as program instructions/modules corresponding to the data loop storage method in the embodiment of the present application. The processor 601 executes corresponding various functional applications and data processing by running software programs, instructions and modules stored in the memory 602, i.e., implements the data loop storage method described above.
The memory 602 may include primarily a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application program required for functionality; the storage data area may store data or the like recorded or created according to the use process. In addition, the memory 602 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 602 may further comprise remotely located memory relative to the processor 601, which may be connected to the terminal device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input means 603 may be used to input corresponding numeric or character information to the processor 601 and to generate key signal inputs related to user settings and function control of the device; the output means 604 may be used to send or display key signal outputs related to user settings and function control of the device.
Embodiments of the present application also provide a storage medium storing computer-executable instructions that, when executed by a processor, are configured to perform related operations in a data loop storage method provided by any of the embodiments of the present application.
Computer-readable storage media, including both permanent and non-permanent, removable and non-removable media, may be implemented in any method or technology for storage of information. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
Note that the above is only a preferred embodiment of the present application and the technical principle applied. It will be understood by those skilled in the art that the present application is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the application. Therefore, while the application has been described in connection with the above embodiments, the application is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the application, which is set forth in the following claims.

Claims (10)

1. A data cycle storage method, applied to a server, the server being equipped with an ES engine for storing device data by indexing, the method comprising:
Determining a configurable index and index information in a user storage space based on the capacity of the configured user storage space, wherein the index information comprises the number of the configurable indexes in the user storage space and the storage capacity corresponding to each index;
Determining an index array corresponding to each user storage space according to the indexes and the index quantity to generate an index list for maintaining index states corresponding to all indexes in each user storage space;
according to a user identification obtained by analyzing the received equipment data, selecting a first target index from the index list so as to store the equipment data into the first target index;
updating the index state of the first target index based on the storage capacity corresponding to the first target index in the index information;
Selecting a second target index from the index list as an index for storing the device data when the index state corresponding to the first target index is a full state, wherein the second target index is the next index which is continuous with the first target index in a cyclic selection sequence in the index list, and the cyclic selection sequence is a sequence for circulating in the sequence of the indexes in the index array;
And determining whether to perform index deletion operation based on the index state of the second target index so as to recycle the user storage space after performing the index deletion operation.
2. The data cycle storage method according to claim 1, wherein the determining, based on the capacity of the configured user storage space, the index and index information configurable in the user storage space, the index information including the number of indexes configurable in the user storage space and the storage capacity corresponding to each index, includes:
determining an estimated number of indexes corresponding to the user storage space based on the capacity of the user storage space, wherein the estimated number is the sum of a first quotient value, a second quotient value and a preset compensation value, the first quotient value is the value obtained by dividing the capacity value of the user storage space by a first preset divisor, the second quotient value is the value obtained by dividing a remainder value by a second preset divisor, and the remainder value is the value obtained by dividing the capacity value of the user storage space by the first preset divisor;
selecting the maximum value of the estimated quantity and the preset quantity as the index quantity;
And combining the capacity of the user storage space and the index number to determine the storage capacity corresponding to each index.
3. The data cycle storage method according to claim 1, wherein the server is further equipped with a Redis service, the Redis service is configured to cache the index list, and update the index list according to an index state of each index, so as to maintain the index list.
4. The method according to claim 1, wherein updating the index state of the first target index based on the storage capacity corresponding to the first target index in the index information includes:
Based on a preset detection duration interval, detecting the data amount stored in the first target index at regular time to determine whether the stored data amount exceeds the storage capacity corresponding to the first target index;
And determining the index state of the first target index according to the comparison result of the stored data quantity and the storage capacity, and updating the index state of the first target index in the index list.
5. The data cycle storage method of claim 1, wherein determining whether to perform an index deletion operation based on an index state of the second target index to cycle the user storage space after performing the index deletion operation comprises:
If the index state of the second target index is a full state, deleting the second target index, and reserving an index ID and an index state of the second target index in the index list;
Regenerating a third target index which is the same as the index ID of the second target index based on the user storage space after data removal, and associating the index ID corresponding to the second target index in the index list with the third target index so as to record the index state of the third target index;
Updating the index list to update the index state of the third target index to an unstored state, and storing the device data to the third target index until the index state of the third target index is a full state.
6. The data circulation storage method according to claim 1 or 5, wherein the determining whether to perform an index deletion operation to circulate the user storage space after performing the index deletion operation based on the index state of the second target index includes:
And if the index state of the second target index is not the full state, storing the equipment data to the second target index until the index state of the second target index is the full state.
7. The data cycle storage method of claim 1, wherein the method further comprises:
And if the index state of the second target index is a full state and the index state is an empty index which is not the full state, reordering all indexes in the cyclic selection sequence to set the sequence of all the empty indexes to be higher than the sequence of the second target index, and replacing the second target index with the empty index with the highest sequence for data storage.
8. A data cycle storage apparatus applied to a server on which an ES engine for storing device data by indexing is mounted, the apparatus comprising:
An index configuration module configured to determine, based on a capacity of a configured user storage space, an index configurable in the user storage space and index information including a number of indexes configurable in the user storage space and a storage capacity corresponding to each index;
the list generation module is configured to determine an index array corresponding to each user storage space according to the indexes and the index quantity so as to generate an index list for maintaining index states corresponding to all indexes in each user storage space;
the first data storage module is configured to select a first target index from the index list according to a user identifier obtained by analyzing the received equipment data so as to store the equipment data into the first target index;
A state updating module configured to update an index state of the first target index based on a storage capacity corresponding to the first target index in the index information;
The index selection module is configured to select a second target index from the index list as an index for storing the device data when an index state corresponding to the first target index is a full state, wherein the second target index is a next index which is continuous with the first target index in a cyclic selection sequence in the index list, and the cyclic selection sequence is a sequence of circulating in the sequence of each index in the index array;
and the second data storage module is configured to determine whether to perform index deletion operation based on the index state of the second target index so as to recycle the user storage space after performing the index deletion operation.
9. A server, comprising:
One or more processors;
storage means for storing one or more programs which when executed by one or more of the processors cause the one or more processors to implement a data cycle storage method as claimed in any one of claims 1 to 7.
10. A storage medium storing computer executable instructions which, when executed by a processor, are adapted to perform the data loop storage method of any one of claims 1 to 7.
CN202311552730.8A 2023-11-20 Data cycle storage method, device, server and storage medium Active CN117632953B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311552730.8A CN117632953B (en) 2023-11-20 Data cycle storage method, device, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311552730.8A CN117632953B (en) 2023-11-20 Data cycle storage method, device, server and storage medium

Publications (2)

Publication Number Publication Date
CN117632953A CN117632953A (en) 2024-03-01
CN117632953B true CN117632953B (en) 2024-07-16

Family

ID=

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111797096A (en) * 2020-06-29 2020-10-20 中国平安财产保险股份有限公司 Data indexing method and device based on ElasticSearch, computer equipment and storage medium
CN114205641A (en) * 2021-11-30 2022-03-18 杭州华橙软件技术有限公司 Video data processing method and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111797096A (en) * 2020-06-29 2020-10-20 中国平安财产保险股份有限公司 Data indexing method and device based on ElasticSearch, computer equipment and storage medium
CN114205641A (en) * 2021-11-30 2022-03-18 杭州华橙软件技术有限公司 Video data processing method and device

Similar Documents

Publication Publication Date Title
US11474972B2 (en) Metadata query method and apparatus
CN107622091B (en) Database query method and device
CN102932415B (en) Method and device for storing mirror image document
CN106294190B (en) Storage space management method and device
CN110858162B (en) Memory management method and device and server
CN109240607B (en) File reading method and device
CN110945486B (en) Storage fragment management method and terminal
CN106503008B (en) File storage method and device and file query method and device
CN109766318B (en) File reading method and device
CN113568582B (en) Data management method, device and storage equipment
CN114253908A (en) Data management method and device of key value storage system
WO2022083287A1 (en) Storage space management method and apparatus, device, and storage medium
WO2024041376A1 (en) Distributed graph data processing system, method, apparatus and device, and storage medium
CN106294189B (en) Memory defragmentation method and device
CN112711564B (en) Merging processing method and related equipment
CN106354793B (en) Method and device for monitoring hot spot object
KR102354343B1 (en) Spatial indexing method and apparatus for blockchain-based geospatial data
CN117632953B (en) Data cycle storage method, device, server and storage medium
CN111752941B (en) Data storage and access method and device, server and storage medium
CN112527479A (en) Task execution method and device, computer equipment and storage medium
CN108804571B (en) Data storage method, device and equipment
CN107111549B (en) File system management method and device
CN117632953A (en) Data cycle storage method, device, server and storage medium
CN111857556A (en) Method, apparatus and computer program product for managing metadata of storage objects
CN115145954A (en) Data query method, data storage method and device

Legal Events

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