CN109388629B - Group regulation method, device, terminal and readable medium - Google Patents

Group regulation method, device, terminal and readable medium Download PDF

Info

Publication number
CN109388629B
CN109388629B CN201811152707.9A CN201811152707A CN109388629B CN 109388629 B CN109388629 B CN 109388629B CN 201811152707 A CN201811152707 A CN 201811152707A CN 109388629 B CN109388629 B CN 109388629B
Authority
CN
China
Prior art keywords
array
data information
migration
linked list
memory
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
CN201811152707.9A
Other languages
Chinese (zh)
Other versions
CN109388629A (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.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201811152707.9A priority Critical patent/CN109388629B/en
Publication of CN109388629A publication Critical patent/CN109388629A/en
Application granted granted Critical
Publication of CN109388629B publication Critical patent/CN109388629B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a method, a device, a terminal and a readable medium for array regulation, wherein the method comprises the following steps: determining array lengths of a migration array and a backup array according to the received residual memory when the command is normalized, and defining the migration array and the backup array; polling a scanning target array, and storing non-empty data information obtained by scanning into a migration array; migrating the data information in the migration array to a linked list object and backing up the data information in the backup array so as to improve disaster tolerance; when the scanning is finished, storing the acquired data information in the linked list object into a temporary array; and when all the data information in the linked list object is stored in the temporary array, returning the data information of the temporary array to the target array. The array arrangement method, the device, the terminal and the readable medium provided by the embodiment of the invention realize array arrangement, and improve array arrangement efficiency and disaster tolerance in an arrangement process.

Description

Group regulation method, device, terminal and readable medium
Technical Field
The present invention relates to computer technologies, and in particular, to a method and an apparatus for array adjustment, a terminal, and a readable medium.
Background
When data in an array in an Android terminal is ordered data, the array is required to be regularly processed so as to be convenient for reading the ordered data and the like. The regularization processing can be understood as processing operation that ordered data are sequentially stored into an array according to the sequence of the index sequence numbers of the array being 0, 1 and 2. At present, a common array arrangement method is to migrate data in an array one by one. The operation of transferring large amount of data one by one is long in time consumption and slow in speed, so that the array arrangement efficiency is low.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, a terminal and a readable medium for array arrangement, which implement array arrangement, and improve array arrangement efficiency and disaster tolerance in an arrangement process.
In a first aspect, an embodiment of the present invention provides a method for group normalization, including:
receiving a normalization instruction, determining a residual memory according to the normalization instruction, determining the array length of a migration array and the array length of a backup array according to the residual memory and the array length of a target array, defining the migration array according to the array length of the migration array, and defining the backup array according to the array length of the backup array;
scanning the starting position to the ending position of the target array in sequence to obtain data information of the scanning position, and storing the data information into the migration array when the data information is judged not to be empty;
reading data information in the migration array according to the scanning progress of the target array and the storage state of the migration array, sequentially replacing pre-filling data information in the linked list object with the data information in the migration array, and storing the pre-filling data information in the migration array into the backup array, wherein when the writing abnormality occurs in the process of replacing the pre-filling data information in the linked list object, abnormal restoration is performed according to the data stored in the backup array;
when the data information in the migration array is completely read, clearing the data information in the migration array, and clearing the data information of the scanning position in the target array, which is scanned;
when the scanning of the target array is finished, sequentially acquiring data information in the linked list object, and storing the acquired data information in the linked list object into a temporary array, wherein the array length of the temporary array is the same as the array length of the target array;
when all the data information in the linked list object is stored in the temporary array, the data information of the temporary array is transmitted back to the target array, and the data information of the temporary array is emptied when the data information transmission is finished.
Optionally, the determining the remaining memory according to the regular instruction includes:
acquiring an ActivityManager object according to the regular instruction, and calling a memory information object acquisition method of the ActivityManager object to acquire the memory information object;
and calling the available memory obtaining method of the memory information object to obtain the available memory, calling the total memory obtaining method of the memory information object to obtain the total memory, and determining the residual memory according to the available memory and the total memory.
Optionally, the determining the array length of the migration array and the array length of the backup array according to the array lengths of the remaining memory and the target array includes:
when the residual memory is larger than or equal to the memory threshold value, taking the array length of the target array as the array length of the migration array and the array length of the backup array;
and when the residual memory is smaller than the memory threshold, taking the memory space of the residual memory with the first preset proportion as the array length of the migration array, and taking the memory space of the residual memory with the second preset proportion as the array length of the backup array.
Optionally, the reading, according to the scanning progress of the target array and the storage state of the migration array, data information in the migration array, sequentially replacing pre-filling data information in the linked list object with the data information in the migration array, and storing the pre-filling data information in the linked list object into the backup array includes:
when the migration array is fully stored, reading data information in the migration array, calling a chain table object replacement method to sequentially replace the pre-filling data information in the chain table object with the data information in the migration array, and storing the data information in the migration array replacing the pre-filling data information in the chain table object into a backup array;
and when the migration array is not fully stored and the target array is scanned, reading the data information in the migration array, calling a chain table object replacement method to sequentially replace the pre-filling data information in the chain table object with the data information in the migration array, and storing the data information in the migration array replacing the pre-filling data information in the chain table object into the backup array.
Optionally, when write-in abnormality occurs in the process of replacing the pre-filled data information in the linked list object, performing exception repair according to the data stored in the backup array, including:
and when the data information write-in error occurs in the process of replacing the pre-filling data information in the linked list object, acquiring the data information which is stored in the backup array and corresponds to the data information with the write-in error, and covering the acquired corresponding data information with the write-in error in the linked list object.
Optionally, the sequentially obtaining the data information in the linked list object and storing the obtained data information in the linked list object in the temporary array includes:
calling a linked list object acquisition method to sequentially acquire data information in the linked list object;
and calling an array storage method to store the acquired data information in the linked list object into a temporary array.
Optionally, after the receiving the warping instruction, the method includes:
calling a linked list definition method to define linked list objects, and filling data information in the defined linked list objects;
judging whether the residual memory meets the requirement of defining a temporary array, and calling an array definition method to define the temporary array when the residual memory meets the requirement of defining the temporary array;
correspondingly, when the scanning of the target array is finished, if the temporary array is defined, sequentially acquiring data information in the linked list object, and storing the acquired data information in the linked list object into the temporary array;
when the scanning of the target array is finished, if the temporary array is undefined, when the temporary array is successfully defined, the data information in the linked list object is sequentially acquired, and the acquired data information in the linked list object is stored in the temporary array.
In a second aspect, an embodiment of the present invention provides a group organizing device, including:
the array definition module is used for receiving a normalization instruction, determining a residual memory according to the normalization instruction, determining the array length of a migration array and the array length of a backup array according to the residual memory and the array length of a target array, defining the migration array according to the array length of the migration array, and defining the backup array according to the array length of the backup array;
the data storage to migration array module is used for scanning the starting position to the ending position of the target array in sequence to obtain data information of the scanning position, and storing the data information to the migration array when the data information is judged not to be empty;
the data migration to linked list object module is used for reading data information in the migration array according to the scanning progress of the target array and the storage state of the migration array, sequentially replacing the pre-filling data information in the linked list object with the data information in the migration array and storing the pre-filling data information in the migration array into the backup array, wherein when the writing-in abnormality occurs in the process of replacing the pre-filling data information in the linked list object, the abnormality is repaired according to the data stored in the backup array;
the data information clearing module is used for clearing the data information in the migration array when the data information in the migration array is completely read, and clearing the data information of the scanning position in the target array, which is scanned;
the data storage to temporary array module is used for sequentially acquiring data information in the linked list object when the scanning of the target array is finished, and storing the acquired data information in the linked list object into a temporary array, wherein the array length of the temporary array is the same as the array length of the target array;
the data returning module is used for returning the data information of the temporary array to the target array when all the data information in the linked list object is stored in the temporary array; the data information clearing module is further used for clearing the data information of the temporary array when the data information is returned to the end.
In a third aspect, an embodiment of the present invention provides a terminal, including:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement an array arrangement method as in any embodiment of the invention.
In a fourth aspect, an embodiment of the present invention provides a readable medium, on which a computer program is stored, where the computer program, when executed by a processor, implements an array arrangement method according to any embodiment of the present invention.
According to the array regulating method, the device, the terminal and the readable medium provided by the embodiment of the invention, the array lengths of the migration array and the backup array are determined according to the residual memory when the regulating instruction is received, and the migration array and the backup array are defined; polling a scanning target array, and storing non-empty data information obtained by scanning into a migration array; migrating the data information in the migration array to a linked list object and backing up the data information in the backup array so as to improve disaster tolerance; when the scanning is finished, storing the acquired data information in the linked list object into a temporary array; and when all the data information in the linked list object is stored in the temporary array, returning the data information of the temporary array to the target array. The array arrangement method, the device, the terminal and the readable medium provided by the embodiment of the invention realize array arrangement, and improve array arrangement efficiency and disaster tolerance in an arrangement process.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description will be given below of the drawings required for the embodiments or the technical solutions in the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flowchart of a method for organizing groups according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of a number-group arranging device according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a terminal according to a third embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described through embodiments with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
Fig. 1 is a flowchart of a method for organizing arrays according to an embodiment of the present invention, where the embodiment is applicable to the case of organizing arrays, and the method may be implemented by a terminal, and may be implemented by software and/or hardware in the terminal. Referring to fig. 1, the array arrangement method includes the following steps:
s110, receiving a normalization instruction, determining a residual memory according to the normalization instruction, determining the array length of a migration array and the array length of a backup array according to the residual memory and the array length of a target array, defining the migration array according to the array length of the migration array, and defining the backup array according to the array length of the backup array.
The method comprises the steps of obtaining the residual memory of the system according to the regular instruction, and determining the array lengths of the migration array and the backup array according to the size of the residual memory and the array length of the target array, so that the array lengths of the migration array and the backup array can be determined according to the actual residual memory condition when the regular instruction is received. When the residual memory is large, the array length defining the migration array and the backup array can be defined to be large so as to reduce the times of migrating the data information to the linked list object; when the remaining memory is small, the array length defining the migration array and the backup array can be defined to be smaller, so that the data information can be completely migrated under the condition that the remaining memory is tense.
Optionally, determining the remaining memory according to the normalization instruction includes:
acquiring an ActivityManager object according to the regular instruction, and calling a memory information object acquisition method of the ActivityManager object to acquire the memory information object; and calling the available memory obtaining method of the memory information object to obtain the available memory, calling the total memory obtaining method of the memory information object to obtain the total memory, and determining the residual memory according to the available memory and the total memory.
Wherein, the Android system can be used for getSystemservice (ACTIVICE) in the Android system; the method may obtain an ActivityManager object of ActivityManager type, which may be labeled mActitymanager, for example. The memory information object obtaining method of the ActivityManager object can be mActivitiymanager. The MemoryInfo is the memory information object of the system. The available memory obtaining method may be meminfo. The total memory obtaining method may be meminfo. Wherein, the available memory is subtracted from the total memory to determine the remaining memory.
Optionally, determining the array length of the migration array and the array length of the backup array according to the remaining memory and the array length of the target array includes:
when the residual memory is larger than or equal to the memory threshold value, taking the array length of the target array as the array length of the migration array and the array length of the backup array; and when the residual memory is smaller than the memory threshold, taking the memory space of the residual memory with the first preset proportion as the array length of the migration array, and taking the memory space of the residual memory with the second preset proportion as the array length of the backup array.
The memory threshold may be a fixed value set by a developer according to an actual requirement, for example, may be 10M, 12M, or 34M, and the memory threshold value is not specifically limited herein; the memory threshold may also be a value that varies according to different array lengths of the target array, and specifically, the memory threshold may be positively correlated with the array length of the target array, for example, the memory threshold may be the array length of the target array, or may be 2 times the array length of the target array, where the positive correlation coefficient is not specifically limited.
When the remaining memory is greater than or equal to the memory threshold, the remaining memory can be considered to be larger, the array length of the target array is directly used as the array length of the migration array and the backup array, the migration array can finish storing the non-empty data information of all the target arrays at one time, therefore, the non-empty data information in the target array can replace the pre-filled data in the linked list object at one time, and the data information is stored in the backup array at the same time.
When the remaining memory is smaller than the memory threshold, the remaining memory can be considered to be smaller, the first preset proportion of the remaining memory is used as the array length of the migration array, and the second preset proportion of the remaining memory is used as the array length of the backup array. If the array length of the migration array is smaller than the array length of the target array, the migration array cannot store the non-empty data information of all the target arrays at one time, and the data information needs to be replaced by the pre-filling data information in the linked list object when the storage is full, so that the migration array needs to perform at least two migration operations to complete the migration of all the data information to the linked list object.
The backup array is used for improving disaster tolerance in the normalization process, and a smaller memory space can be set for storing the latest data information in the process of migrating the migration array to the linked list object, so that the second preset proportion can be smaller than or equal to the first preset proportion. In addition, in order to ensure that the data in the migration array can be completely migrated to the linked list object, the prefilled data information size of the linked list object needs to be greater than or equal to the memory size of the migration array, and therefore the proportion of the linked list object that needs to occupy the remaining memory is greater than or equal to the first preset proportion. If the first preset proportion R1 and the second preset proportion R2 are set and the occupation proportion of the linked list objects is R3, the inequality R3, R1, R2 and R3, R2 and R1 are equal to or less than 1 are required to be satisfied. For example, R3 of 0.4, R1 of 0.3, R2 of 0.2; or R3 is 0.4, R1 is 0.4, R2 is 0.2; it is also possible that R3 is 0.4, R1 is 0.3, and R2 is 0.3, and the first predetermined ratio and the second predetermined ratio are not particularly limited.
The method has the advantages that the array length of the migration array and the backup array is determined according to the size of the residual memory and the array length of the target array, and the non-empty data information in the target array can be migrated to the linked list object once or for multiple times, so that the problem that the non-empty data information of the target array cannot be added to the linked list object due to the fact that the system memory is too small in the array arrangement process is solved, the time consumption problem of data migration one by one is solved, the data reading and writing efficiency in the arrangement process is improved, the array arrangement efficiency is improved, meanwhile, the backup data can be provided when the arrangement is abnormal by defining the backup array, and the disaster tolerance in the arrangement process is improved.
And S120, scanning the starting position to the ending position of the target array in sequence, acquiring data information of the scanning position, and storing the data information into the migration array when the data information is judged not to be empty.
The scanning is performed sequentially from the start position to the end position of the target array, which may be understood as performing polling scanning on the target array. In the polling loop structure, data information of one scanning position can be acquired every time the loop structure is cycled. When the data information is judged not to be empty, the data information can be used as effective data information and stored in the migration array. When the polling scanning of the target array is finished, all valid data in the target array can be stored in the migration array, so that the clearing of the space data of the valid data information in the target array is realized, and the primary clearing work of the space data in the regular array is finished.
The scanning is sequentially performed from the starting position to the ending position of the target array, which may specifically be:
and scanning the position with the index sequence number of 0 of the target array to the position with the index sequence number of minus 1 of the length of the target array in sequence.
The index sequence numbers of the 1 st position, the 2 nd position and the 3. n position of the target array are respectively 0, 1 st position and 2. n-1 st position, so that the index sequence numbers from the starting position to the ending position of the target array are 0, 1 st position and 2. byte1.length () -1 st; the byte1 is the name of the target array, and can represent the target array, and the name of the target array is not limited to byte 1; wherein, the length of the target array can be determined by the byte1.length method.
During scanning from the position with the index sequence number of 0, index1, to the position with the index sequence number of 1, byte1, left () -1, of the target array, the data information of the position corresponding to the index sequence number, that is, the data information of the scanning position, can be obtained by calling the method of byte1[ index1], where index1 can represent the index sequence number of the target array. After the data information is acquired, whether the data information is empty or not may be determined by calling a method of "byte 1[ index1] = ═ null | | byte1[ index1] =", and a return value is true when the data information is empty and false when the data information is not empty. And when the data is judged not to be empty, the data information can be stored in the migration array.
And S130, reading data information in the migration array according to the scanning progress of the target array and the storage state of the migration array, sequentially replacing the pre-filling data information in the linked list object with the data information in the migration array, and storing the pre-filling data information in the migration array into the backup array, wherein when the writing-in abnormality occurs in the process of replacing the pre-filling data information in the linked list object, abnormal recovery is performed according to the data stored in the backup array.
Among them, the scanning progress of the target array and the storage state of the migrated array may have three situations: firstly, the data information in the migration array is fully stored, but the scanning of the target array is not finished; secondly, when the data information in the migration array is just fully stored, the target array just finishes scanning; third, the target array scan ends, but the migration array is not yet full. When the migration array is not fully stored and the target array is not scanned, continuing to scan the target array, and storing the non-empty data information obtained by scanning into the migration array until the three conditions occur.
Optionally, reading data information in the migration array according to the scanning progress of the target array and the storage state of the migration array, sequentially replacing the pre-filling data information in the linked list object with the data information in the migration array, and storing the pre-filling data information in the linked list object into the backup array, where the method includes:
when the migration array is fully stored, reading data information in the migration array, calling a chain table object replacement method to sequentially replace the pre-filling data information in the chain table object with the data information in the migration array, and storing the data information in the migration array replacing the pre-filling data information in the chain table object into a backup array;
and when the migration array is not fully stored and the target array is scanned, reading the data information in the migration array, calling a chain table object replacement method to sequentially replace the pre-filling data information in the chain table object with the data information in the migration array, and storing the data information in the migration array replacing the pre-filling data information in the chain table object into the backup array.
When the migration array is fully stored, whether the target array is scanned completely or not is judged, the data information in the migration array needs to be replaced by the pre-filling data information in the linked list object; when the migration array is not fully stored but the target array is scanned completely, all non-empty data information in the target array is already stored in the migration array, and at this time, the migration array cannot reach the fully stored state, and the data information in the migration array which is not fully stored needs to be migrated to the linked list object.
The data information of the position corresponding to the index sequence number in the migration array can be read by calling a method of byte2[ index2], wherein byte2 is the name of the migration array and can represent the migration array, and the name of the migration array is not limited to byte 2; where index2 may represent the index sequence number of the migration array.
The method for replacing the linked list object may specifically be:
linkList.set(index,byte2[index2]);
the linkList is the name of the linked list object and can represent the linked list object, and the name of the linked list object is not limited to the linkList; the index may represent an index number of the linked list object, and the byte2[ index2] may be set to a position of the index number index in the linkList by calling a set method. The data pre-filled in the linked list object can be any data such as filling data 0, 1, 2 and the like, so that enough memory space can be allocated to the linked list object after the linked list object is defined, and the data information in the migration array can be successfully migrated into the linked list object by replacing the pre-filled data information in the linked list object.
The method for replacing the pre-filling data information in the linked list object comprises the steps of calling a byte3[ index3] ═ byte2[ index2], storing the data information in a migration array replacing the pre-filling data information in the linked list object into a backup array, wherein byte3 is the name of the backup array and can represent the backup array, and the name of the migration array is not limited to byte 3; where index3 may represent the index sequence number of the backup array. It should be noted that after the data information in the migration array is read, the data information is written into the linked list object and the backup array, which can be understood that the last bit of data information of the replaced data of the linked list object is equal to the last bit of data information stored in the backup array under normal conditions. Therefore, the backup array can complete the work of the latest data information in the process of migrating the backup migration array to the linked list object, and is used for repairing when abnormality occurs in the process of migrating the migration array to the linked list object, so that the disaster tolerance of the normalization process is improved.
The method includes the steps that when the remaining memory is small, the size of a backup array can be set to be smaller than the size of a migration array, the condition that data information of the migration array is not completely migrated but the backup array is fully stored exists in the process of migrating the backup array and the migration array to data information in a linked list object, and at the moment, if the linked list object does not send writing abnormity, the migration array can be emptied to continue data information backup work.
Optionally, when a write exception occurs in the process of replacing the pre-filled data information in the linked list object, performing exception repair according to the data stored in the backup array, where the repair includes:
and when the data information write-in error occurs in the process of replacing the pre-filling data information in the linked list object, acquiring the data information which is stored in the backup array and corresponds to the data information with the write-in error, and covering the acquired corresponding data information with the write-in error in the linked list object.
Because the last bit of data information of the replaced data of the linked list object is equal to the last bit of data information stored in the backup array under normal conditions, when data information writing errors occur in the process of replacing the pre-filling data information in the linked list object, the last bit of data information stored in the backup array can be acquired, and the information is set to the data information with writing errors in the linked list object. The problem of inconsistent data information reading and writing speeds caused by re-reading the data information from the migration array is avoided, and the disaster tolerance capability in the data normalization process is improved. In addition, when the writing abnormality occurs in the process of storing the data information by the backup array, the backup array can be directly emptied so as to continue the data information backup work.
And S140, when the data information in the migration array is completely read, clearing the data information in the migration array, and clearing the data information of the scanning position in the target array, which is scanned.
After the data information in the migration array is read, it can be understood that all the data information in the migration array has been migrated to the linked list object and stored in the backup array. When the migration array needs to be migrated for multiple times, the data information in the migration array needs to be emptied when the data information in the migration array is read out completely each time, so that the operation of storing the non-empty data information in the target array by the migration array in the next round is performed. The data information of the scanning position which is scanned in the target array is cleared, and the scanning and clearing of the target array are realized, so that the memory resource of the system is saved, and the waste of the memory resource is avoided.
S150, when the scanning of the target array is finished, sequentially acquiring data information in the linked list object, and storing the acquired data information in the linked list object into a temporary array, wherein the array length of the temporary array is the same as the array length of the target array.
When the scanning of the target array is finished, it can be understood that all the non-empty data information of the target array is migrated to the linked list object through the migration array. When the system memory is not sufficient, the temporary array may be defined after the target array is completely cleared, and the length of the temporary array is defined to be equal to the length of the target array, so as to return data information from the temporary array to the target array.
Optionally, the obtaining the data information in the linked list object in sequence, and storing the obtained data information in the linked list object into a temporary array includes:
calling a linked list object acquisition method to sequentially acquire data information in the linked list object; and calling an array storage method to store the acquired data information in the linked list object into a temporary array.
The data information in the linked list object can be obtained by calling a linkedlist.get (index) method; the index may represent an index sequence number of the linked list object, and the data information at a position corresponding to the index sequence number may be obtained by calling the get method. After the data information at the position corresponding to the index sequence number of the linked list object is obtained, the data information can be assigned to a numerical variable, and the numerical variable is assigned to the temporary array, so that the data information in the linked list object can be stored in the temporary array. Get (index) may be assigned to the variable item, and the value variable is stored to the position of the temporary array byte4 where the index sequence number is index4 by calling the method of byte4[ index4] ═ item, so as to store the data information in the linked list object into the temporary array.
The acquired data information in the linked list object is assigned to the variable, and the value of the variable is added to the position in the corresponding index serial number of the temporary array, so that the data reading and adding operation is completed through one polling, and the data processing efficiency is improved.
And S160, when all the data information in the linked list object is stored in the temporary array, returning the data information of the temporary array to the target array, and emptying the data information of the temporary array when the data information is returned.
When all data in the linked list object are stored to the temporary array, the data information of the temporary array can be returned to the target array by calling a byte 1-byte 4 method, the temporary array can be understood as being completely copied to the target array, and therefore returning of the data information among the data is completed. And emptying the temporary array after the data information of the target array is completely returned, so that the effective use of system memory resources can be realized.
Optionally, after receiving the warping instruction, the method includes:
calling a linked list definition method to define linked list objects, and filling data information in the defined linked list objects;
judging whether the residual memory meets the requirement of defining a temporary array, and calling an array definition method to define the temporary array when the residual memory meets the requirement of defining the temporary array;
correspondingly, when the scanning of the target array is finished, if the temporary array is defined, sequentially acquiring data information in the linked list object, and storing the acquired data information in the linked list object into the temporary array;
when the scanning of the target array is finished, if the temporary array is undefined, when the temporary array is successfully defined, the data information in the linked list object is sequentially acquired, and the acquired data information in the linked list object is stored in the temporary array.
Specifically, a link list () method may be called to define a link list object; the linkList is the name of the linked list object and can represent the linked list object, and the name of the linked list object is not limited to the linkList; wherein, a linked list object of LinkedList type can be newly created by a new method. The defined linked list object is filled with data information, the data information with the size of the target array can be filled when the residual memory is large, and the data information with the size of the third preset proportion of the residual memory can be filled when the residual memory is small. The third preset proportion may be set to be greater than or equal to the first preset proportion mentioned in the embodiments of the present invention.
The data pre-filled in the linked list object can be any data such as filling data 0, 1, 2 and the like, so that enough memory space can be distributed to the linked list object after the linked list object is defined, the data information in the migration array can be successfully migrated into the linked list object by replacing the pre-filled data information in the linked list object, and the condition that the data information cannot be migrated to the linked list object due to insufficient memory in the data migration process is avoided.
The remaining memory satisfies the requirement of defining the temporary array, and it can be understood that a continuous memory space with an array length greater than or equal to that of the temporary array exists in the remaining memory. When opening up the array memory space, the continuous storage unit with the array length of the defined array needs to be searched in the residual memory space, and the opening up of the array memory space can be carried out only when the continuous memory space with the array length being more than or equal to the array length exists in the residual memory, so that the definition of the array is realized.
Wherein a temporary array may be defined by calling private byte3[1024 × 5] { } method; 1024 × 5 indicates that the size of the temporary array byte3 is 5M, the length of the temporary array is equal to the length of the target array, and the temporary array can be changed according to the length of the target array, and is not limited to 5M.
The temporary array may be defined after the scanning of the target array is finished, the temporary array may be defined after the normalization instruction is received, and when a continuous memory space with an array length greater than or equal to that of the temporary array exists in the remaining memory, the array definition method is called to define the temporary array. When the scanning of the target array is finished, namely all non-empty data information of the target array is completely migrated to the linked list object through the migration array, if the temporary array is defined, the opening up of the memory space is finished, the step of storing the data information in the linked list to the temporary array can be directly carried out, so that the time for defining the temporary array is saved, and the array arrangement efficiency is further improved; if the definition of the temporary array is not finished, namely the opening of the memory space is not finished, the array definition method is called to define the temporary array only when the remaining memory meets the requirement of defining the temporary array.
In the array normalization method provided by this embodiment, the array lengths of the migration array and the backup array are determined according to the remaining memory when the normalization instruction is received, and the migration array and the backup array are defined; polling a scanning target array, and storing non-empty data information obtained by scanning into a migration array; migrating the data information in the migration array to a linked list object and backing up the data information in the backup array so as to improve disaster tolerance; when the scanning is finished, storing the acquired data information in the linked list object into a temporary array; and when all the data information in the linked list object is stored in the temporary array, returning the data information of the temporary array to the target array. The array arrangement method, the device, the terminal and the readable medium provided by the embodiment of the invention realize array arrangement, and improve array arrangement efficiency and disaster tolerance in an arrangement process.
Example two
Fig. 2 is a schematic structural diagram of a array organizing device according to a second embodiment of the present invention, which is applicable to the array organizing situation.
Referring to fig. 2, the number group regulating device in the present embodiment includes:
an array definition module 210, configured to receive a normalization instruction, determine a remaining memory according to the normalization instruction, determine an array length of a migration array and an array length of a backup array according to the remaining memory and the array length of a target array, define the migration array according to the array length of the migration array, and define the backup array according to the array length of the backup array;
the data storage to migration array module 220 is configured to scan the starting position to the ending position of the target array in sequence, acquire data information of the scanned position, and store the data information into the migration array when it is determined that the data information is not empty;
the data migration to linked list object module 230 is configured to read data information in the migration array according to the scanning progress of the target array and the storage state of the migration array, sequentially replace pre-filling data information in the linked list object with the data information in the migration array, and store the pre-filling data information in the migration array into the backup array, where when a write-in abnormality occurs in the process of replacing the pre-filling data information in the linked list object, performing an abnormality repair according to data stored in the backup array;
the data information clearing module 240 is configured to clear the data information in the migration array when the data information in the migration array is completely read, and clear the data information of the scanned position in the target array;
the data storage to temporary array module 250 is configured to, when the scanning of the target array is finished, sequentially acquire data information in the linked list object, and store the acquired data information in the linked list object in a temporary array, where the array length of the temporary array is the same as the array length of the target array;
the data returning module 260 is configured to return the data information of the temporary array to the target array when all the data information in the linked list object is stored in the temporary array; the data information clearing module 240 is further configured to clear the data information of the temporary array when the data information return is finished.
Optionally, the array definition module 210 further includes:
the residual memory determining submodule is used for acquiring an ActivityManager object according to the rule instruction and calling a memory information object acquiring method of the ActivityManager object to acquire a memory information object; and calling the available memory obtaining method of the memory information object to obtain the available memory, calling the total memory obtaining method of the memory information object to obtain the total memory, and determining the residual memory according to the available memory and the total memory.
Optionally, the array definition module 210 further includes:
the array length determining submodule is used for taking the array length of the target array as the array length of the migration array and the array length of the backup array when the residual memory is larger than or equal to the memory threshold; and when the residual memory is smaller than the memory threshold, taking the memory space of the residual memory with the first preset proportion as the array length of the migration array, and taking the memory space of the residual memory with the second preset proportion as the array length of the backup array.
Optionally, the data is migrated to the linked list object module 230, which is specifically configured to:
when the migration array is fully stored, reading data information in the migration array, calling a chain table object replacement method to sequentially replace the pre-filling data information in the chain table object with the data information in the migration array, and storing the data information in the migration array replacing the pre-filling data information in the chain table object into a backup array;
and when the migration array is not fully stored and the target array is scanned, reading the data information in the migration array, calling a chain table object replacement method to sequentially replace the pre-filling data information in the chain table object with the data information in the migration array, and storing the data information in the migration array replacing the pre-filling data information in the chain table object into the backup array.
Optionally, the data is migrated to the linked list object module 230, which is further specifically configured to:
and when the data information write-in error occurs in the process of replacing the pre-filling data information in the linked list object, acquiring the data information which is stored in the backup array and corresponds to the data information with the write-in error, and covering the acquired corresponding data information with the write-in error in the linked list object.
Optionally, the data storage to temporary array module 250 includes:
the data information acquisition submodule is used for calling an acquisition method of the linked list object to sequentially acquire the data information in the linked list object;
and the data storage to temporary array submodule is used for calling an array storage method to store the acquired data information in the linked list object to a temporary array.
Optionally, the array arrangement device further includes:
the linked list definition module is used for calling a linked list definition method to define linked list objects after receiving the order and filling data information in the defined linked list objects;
the temporary array definition module is used for judging whether the residual memory meets the requirement of defining a temporary array after receiving the regular instruction, and calling an array definition method to define the temporary array when the residual memory meets the requirement of defining the temporary array;
accordingly, the data is stored to the temporary array module 250, which is specifically configured to:
when the scanning of the target array is finished, if the temporary array is defined, sequentially acquiring data information in the linked list object, and storing the acquired data information in the linked list object into the temporary array;
when the scanning of the target array is finished, if the temporary array is undefined, when the temporary array is successfully defined, the data information in the linked list object is sequentially acquired, and the acquired data information in the linked list object is stored in the temporary array.
The array organizing device provided in this embodiment is the same as the array organizing method provided in the first embodiment, and the technical details that are not described in detail in this embodiment can be referred to in the first embodiment.
EXAMPLE III
The embodiment provides a terminal which can be used for the case of array normalization. Fig. 3 is a schematic structural diagram of a terminal according to a third embodiment of the present invention. Referring to fig. 3, the terminal includes:
one or more processors 310;
a memory 320 for storing one or more programs;
when the one or more programs are executed by the one or more processors 310, the one or more processors 310 are enabled to implement the array normalization method as set forth in the first embodiment.
In FIG. 3, a processor 310 is illustrated as an example; the processor 310 and the memory 320 may be connected by a bus or other means, such as the bus connection shown in FIG. 3.
The memory 320 is a computer-readable storage medium for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the array arrangement method in the embodiment of the present invention. The processor 310 executes various functional applications and data processing of the terminal by executing software programs, instructions and modules stored in the memory 320, that is, the above array arrangement method is implemented.
The memory 320 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 320 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 examples, the memory 320 may further include memory located remotely from the processor 310, which may be connected to the terminal over 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 terminal proposed in this embodiment and the array organizing method proposed in the first embodiment belong to the same inventive concept, and the technical details that are not described in detail in this embodiment can be referred to in the first embodiment, and this embodiment and the first embodiment have the same beneficial effects.
Example four
The present embodiment provides a readable medium, on which a computer program is stored, which when executed by a processor implements the array warping method as set forth in an embodiment.
The readable medium proposed by the embodiment and the array organizing method proposed by the first embodiment belong to the same inventive concept, and technical details that are not described in detail in the embodiment can be referred to in the first embodiment, and the first embodiment have the same beneficial effects.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention 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 invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (9)

1. A method of array normalization, comprising:
receiving a normalization instruction, determining a residual memory according to the normalization instruction, determining the array length of a migration array and the array length of a backup array according to the residual memory and the array length of a target array, defining the migration array according to the array length of the migration array, and defining the backup array according to the array length of the backup array;
scanning the starting position to the ending position of the target array in sequence to obtain data information of the scanning position, and storing the data information into the migration array when the data information is judged not to be empty;
reading data information in the migration array according to the scanning progress of the target array and the storage state of the migration array, sequentially replacing pre-filling data information in the linked list object with the data information in the migration array, and storing the pre-filling data information in the migration array into the backup array, wherein when the writing abnormality occurs in the process of replacing the pre-filling data information in the linked list object, abnormal restoration is performed according to the data stored in the backup array;
when the data information in the migration array is completely read, clearing the data information in the migration array, and clearing the data information of the scanning position in the target array, which is scanned;
when the scanning of the target array is finished, sequentially acquiring data information in the linked list object, and storing the acquired data information in the linked list object into a temporary array, wherein the array length of the temporary array is the same as the array length of the target array;
when all data information in the linked list object is stored in the temporary array, returning the data information of the temporary array to the target array, and emptying the data information of the temporary array when the data information returning is finished;
determining the array length of the migration array and the array length of the backup array according to the array lengths of the residual memory and the target array, wherein the determining comprises the following steps:
when the residual memory is larger than or equal to the memory threshold value, taking the array length of the target array as the array length of the migration array and the array length of the backup array;
and when the residual memory is smaller than the memory threshold, taking the memory space of the residual memory with the first preset proportion as the array length of the migration array, and taking the memory space of the residual memory with the second preset proportion as the array length of the backup array.
2. The method of claim 1, wherein determining remaining memory according to the warping instruction comprises:
acquiring an ActivityManager object according to the regular instruction, and calling a memory information object acquisition method of the ActivityManager object to acquire the memory information object;
and calling the available memory obtaining method of the memory information object to obtain the available memory, calling the total memory obtaining method of the memory information object to obtain the total memory, and determining the residual memory according to the available memory and the total memory.
3. The method as claimed in claim 1, wherein the reading the data information in the migration array according to the scanning progress of the target array and the storage status of the migration array, and sequentially replacing the pre-populated data information in the linked list object with the data information in the migration array and storing the data information in the migration array into the backup array comprises:
when the migration array is fully stored, reading data information in the migration array, calling a chain table object replacement method to sequentially replace the pre-filling data information in the chain table object with the data information in the migration array, and storing the data information in the migration array replacing the pre-filling data information in the chain table object into a backup array;
and when the migration array is not fully stored and the target array is scanned, reading the data information in the migration array, calling a chain table object replacement method to sequentially replace the pre-filling data information in the chain table object with the data information in the migration array, and storing the data information in the migration array replacing the pre-filling data information in the chain table object into the backup array.
4. The method of claim 1, wherein performing exception repair based on data stored in the backup array when a write exception occurs during replacement of prepopulated data information in the linked list object comprises:
and when the data information write-in error occurs in the process of replacing the pre-filling data information in the linked list object, acquiring the data information which is stored in the backup array and corresponds to the data information with the write-in error, and covering the acquired corresponding data information with the write-in error in the linked list object.
5. The method according to claim 1, wherein the sequentially obtaining the data information in the linked list object and storing the obtained data information in the linked list object in a temporary array comprises:
calling a linked list object acquisition method to sequentially acquire data information in the linked list object;
and calling an array storage method to store the acquired data information in the linked list object into a temporary array.
6. The method of claim 1, after said receiving a warping instruction, comprising:
calling a linked list definition method to define linked list objects, and filling data information in the defined linked list objects;
judging whether the residual memory meets the requirement of defining a temporary array, and calling an array definition method to define the temporary array when the residual memory meets the requirement of defining the temporary array;
correspondingly, when the scanning of the target array is finished, if the temporary array is defined, sequentially acquiring data information in the linked list object, and storing the acquired data information in the linked list object into the temporary array;
when the scanning of the target array is finished, if the temporary array is undefined, when the temporary array is successfully defined, the data information in the linked list object is sequentially acquired, and the acquired data information in the linked list object is stored in the temporary array.
7. A group organizer, comprising:
the array definition module is used for receiving a normalization instruction, determining a residual memory according to the normalization instruction, determining the array length of a migration array and the array length of a backup array according to the residual memory and the array length of a target array, defining the migration array according to the array length of the migration array, and defining the backup array according to the array length of the backup array;
the data storage to migration array module is used for scanning the starting position to the ending position of the target array in sequence to obtain data information of the scanning position, and storing the data information to the migration array when the data information is judged not to be empty;
the data migration to linked list object module is used for reading data information in the migration array according to the scanning progress of the target array and the storage state of the migration array, sequentially replacing the pre-filling data information in the linked list object with the data information in the migration array and storing the pre-filling data information in the migration array into the backup array, wherein when the writing-in abnormality occurs in the process of replacing the pre-filling data information in the linked list object, the abnormality is repaired according to the data stored in the backup array;
the data information clearing module is used for clearing the data information in the migration array when the data information in the migration array is completely read, and clearing the data information of the scanning position in the target array, which is scanned;
the data storage to temporary array module is used for sequentially acquiring data information in the linked list object when the scanning of the target array is finished, and storing the acquired data information in the linked list object into a temporary array, wherein the array length of the temporary array is the same as the array length of the target array;
the data returning module is used for returning the data information of the temporary array to the target array when all the data information in the linked list object is stored in the temporary array; the data information clearing module is also used for clearing the data information of the temporary array when the data information is returned;
wherein, the array definition module further comprises:
the array length determining submodule is used for taking the array length of the target array as the array length of the migration array and the array length of the backup array when the residual memory is larger than or equal to the memory threshold; and when the residual memory is smaller than the memory threshold, taking the memory space of the residual memory with the first preset proportion as the array length of the migration array, and taking the memory space of the residual memory with the second preset proportion as the array length of the backup array.
8. A terminal, characterized in that the terminal comprises:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the array warping method as recited in any one of claims 1-6.
9. A readable medium, on which a computer program is stored which, when being executed by a processor, carries out the array warping method as claimed in any one of claims 1-6.
CN201811152707.9A 2018-09-29 2018-09-29 Group regulation method, device, terminal and readable medium Active CN109388629B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811152707.9A CN109388629B (en) 2018-09-29 2018-09-29 Group regulation method, device, terminal and readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811152707.9A CN109388629B (en) 2018-09-29 2018-09-29 Group regulation method, device, terminal and readable medium

Publications (2)

Publication Number Publication Date
CN109388629A CN109388629A (en) 2019-02-26
CN109388629B true CN109388629B (en) 2021-04-27

Family

ID=65418976

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811152707.9A Active CN109388629B (en) 2018-09-29 2018-09-29 Group regulation method, device, terminal and readable medium

Country Status (1)

Country Link
CN (1) CN109388629B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7013373B2 (en) * 2003-07-07 2006-03-14 Hitachi, Ltd. Data backup method and system
CN101251848A (en) * 2008-04-14 2008-08-27 中山大学 Rapid word inquiring system of electronic dictionary
CN101895836A (en) * 2010-07-08 2010-11-24 中兴通讯股份有限公司 Message transmitting method and system and multimedia messaging service center
CN102326149A (en) * 2011-07-28 2012-01-18 华为技术有限公司 Realization method and apparatus for internal memory migration
CN103198028A (en) * 2013-03-18 2013-07-10 华为技术有限公司 Method, device and system for migrating stored data
CN106484326A (en) * 2016-09-14 2017-03-08 广东欧珀移动通信有限公司 A kind of data transmission processing method and mobile terminal

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090037655A1 (en) * 2007-07-30 2009-02-05 Dell Products L.P. System and Method for Data Storage and Backup

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7013373B2 (en) * 2003-07-07 2006-03-14 Hitachi, Ltd. Data backup method and system
CN101251848A (en) * 2008-04-14 2008-08-27 中山大学 Rapid word inquiring system of electronic dictionary
CN101895836A (en) * 2010-07-08 2010-11-24 中兴通讯股份有限公司 Message transmitting method and system and multimedia messaging service center
CN102326149A (en) * 2011-07-28 2012-01-18 华为技术有限公司 Realization method and apparatus for internal memory migration
CN103198028A (en) * 2013-03-18 2013-07-10 华为技术有限公司 Method, device and system for migrating stored data
CN106484326A (en) * 2016-09-14 2017-03-08 广东欧珀移动通信有限公司 A kind of data transmission processing method and mobile terminal

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Maximum and Sorted Cache Occupation Using Array Padding;Ezequiel Herruzo 等;《2007 International Conference on Embedded Computer Systems: Architectures, Modeling and Simulation》;20070808;178-185 *
非易失性内存的磨损均衡与管理优化研究;龙林波;《中国博士学位论文全文数据库 信息科技辑》;20170315(第3期);I137-9 *

Also Published As

Publication number Publication date
CN109388629A (en) 2019-02-26

Similar Documents

Publication Publication Date Title
CN107391628B (en) Data synchronization method and device
CN107528710B (en) Method, equipment and system for switching leader nodes of raft distributed system
CN104881494A (en) Method, device and system for performing data synchronization with Redis server
CN105468718B (en) Data consistency processing method, device and system
CN111580963A (en) Load balancing method and device for storage cluster, computer equipment and storage medium
CN111666088A (en) Pod replacement method and device, electronic equipment and computer-readable storage medium
CN113282580A (en) Method, storage medium and server for executing timed task
CN110377664B (en) Data synchronization method, device, server and storage medium
CN109388629B (en) Group regulation method, device, terminal and readable medium
CN114780230A (en) Memory allocation method, memory deployment method and related device
CN111124751A (en) Data recovery method and system, data storage node and database management node
US20150347409A1 (en) Convert Command Into a BULK Load Operation
CN115562805A (en) Resource migration method and device and electronic equipment
CN109408491B (en) Group regulation method, device, terminal and readable medium
CN111625500B (en) File snapshot method and device, electronic equipment and storage medium
CN114584572B (en) Data synchronization method, device, equipment and medium in distributed object storage
CN114788294A (en) Content pushing method, device, server and storage medium
CN109344091B (en) Buffer array regulation method, device, terminal and readable medium
CN116010430B (en) Data recovery method, database system, computer device, and storage medium
CN112799711B (en) Method and device for merging container images, computer equipment and storage medium
CN112000471B (en) Memory optimization method and device
CN114546669B (en) Bucket-fragmentation-based data synchronous processing method, system and terminal
CN114115915B (en) Deployment method and device of application instance
CN113821176B (en) Data migration processing method, device and storage medium
CN115987759B (en) Data processing method, device, electronic equipment and storage medium

Legal Events

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