CN108197157B - Method, apparatus and computer-readable storage medium for managing data to be stored - Google Patents
Method, apparatus and computer-readable storage medium for managing data to be stored Download PDFInfo
- Publication number
- CN108197157B CN108197157B CN201711310277.4A CN201711310277A CN108197157B CN 108197157 B CN108197157 B CN 108197157B CN 201711310277 A CN201711310277 A CN 201711310277A CN 108197157 B CN108197157 B CN 108197157B
- Authority
- CN
- China
- Prior art keywords
- stored
- data
- index value
- storage file
- file
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/172—Caching, prefetching or hoarding of files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/13—File access structures, e.g. distributed indices
Abstract
The invention introduces a method, a device and a computer readable storage medium for managing data to be stored, wherein the method comprises the following steps: acquiring data to be stored, and calculating an index value of the data to be stored; setting the name of the storage file and/or a superior subdirectory of the storage file according to the index value; and storing the data to be stored into a set storage file. In the invention, a developer only needs to specify the key words of the data to be stored, and does not need to specify the file name and the upper subdirectory of the storage file. The invention can reduce the development and use cost of storing and reading data and improve the efficiency of storing and reading operation.
Description
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method and an apparatus for managing data to be stored, and a computer-readable storage medium.
Background
The mobile terminal caches the data by storing the data locally. The storage mode in the prior art is divided into two types, namely SharedPreferences storage and file storage through a lightweight data storage class. When using SharedPreferences storage, a developer needs to specify a Key value of data to be stored and a file name of an XML (Extensible Markup Language) file for storing the data to be stored. When using file storage, a developer needs to specify a Key value of data to be stored and a subdirectory of a file for storing the data to be stored. Therefore, when storing data once, a developer is required to specify two values, and when reading the cached data, it is also required to perform a read operation using the two values. According to the storage and reading mode in the prior art, not only is the development and use cost increased, but also the operation is very inconvenient and the efficiency is low.
Disclosure of Invention
The invention mainly aims to provide a method, equipment and a computer readable storage medium for managing data to be stored, which can reduce development and use cost of storing and reading data and improve efficiency of storing and reading operation.
To achieve the above object, the present invention provides a method for managing data to be stored, the method comprising:
acquiring data to be stored, and calculating an index value of the data to be stored;
setting the name of the storage file and/or a superior subdirectory of the storage file according to the index value;
and storing the data to be stored into a set storage file.
Optionally, the calculating an index value of the data to be stored includes:
determining keywords of the data to be stored;
calculating the hash value of the keyword by using a hash algorithm;
and carrying out bit operation on the hash value to obtain an index value of the data to be stored.
Optionally, the setting, according to the index value, the name of the storage file and/or the upper subdirectory of the storage file includes:
adding the index value to the name of the storage file and/or adding the index value to an upper subdirectory of the storage file.
Optionally, after the data to be stored is stored in the set storage file, the method further includes:
searching the storage file with the name containing the index value, and acquiring the data to be stored from the searched storage file.
Optionally, after the data to be stored is stored in the set storage file, the method further includes:
and searching the subdirectory containing the index value, and acquiring the data to be stored from the storage file under the searched subdirectory.
Optionally, the adding the index value to the name of the storage file includes:
when the lightweight data storage class SharedPreferences is used for storing the data to be stored, the storage file is an extensible markup language (XML) file;
and adding the index value into the name of the XML file.
Optionally, the adding the index value to the upper subdirectory of the storage file includes:
when a Read Only Memory (ROM) file is used for storing the data to be stored, the storage file is positioned in the ROM file;
and setting the index value as an upper subdirectory of the storage file.
In addition, to achieve the above object, the present invention also provides an apparatus for managing data to be stored, the apparatus comprising: a processor, a memory, and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is used for executing the program for managing the data to be stored in the memory so as to realize the following steps:
acquiring data to be stored, and calculating an index value of the data to be stored;
setting the name of the storage file and/or a superior subdirectory of the storage file according to the index value;
and storing the data to be stored into a set storage file.
Optionally, when the processor executes the step of setting the name of the storage file and/or the upper subdirectory of the storage file according to the index value, the method includes:
adding the index value to the name of the storage file and/or adding the index value to an upper subdirectory of the storage file.
Further, to achieve the above object, the present invention also proposes a computer-readable storage medium storing a program for managing data to be stored;
when the program for managing data to be stored is executed by at least one processor, it causes the at least one processor to carry out the steps of the method for managing data to be stored as described above.
The method, the equipment and the computer readable storage medium for managing the data to be stored automatically set the name of a file and/or a superior subdirectory for storing the data to be stored according to the keyword value of the data to be stored. In the invention, a developer only needs to specify the key words of the data to be stored, and does not need to specify the file name and the upper subdirectory of the storage file. The invention can reduce the development and use cost of storing and reading data and improve the efficiency of storing and reading operation.
Drawings
FIG. 1 is a flowchart of a method of managing data to be stored according to a first embodiment of the present invention;
FIG. 2 is a flowchart of a method of managing data to be stored according to a second embodiment of the present invention;
FIG. 3 is a flowchart of a method of managing data to be stored according to a third embodiment of the present invention;
fig. 4 is a schematic diagram of the composition structure of an apparatus for managing data to be stored according to a fourth embodiment of the present invention.
Detailed Description
To further explain the technical means and effects of the present invention adopted to achieve the intended purpose, the present invention will be described in detail with reference to the accompanying drawings and preferred embodiments.
A first embodiment of the present invention provides a method for managing data to be stored, and as shown in fig. 1, the method specifically includes the following steps:
step S101: and acquiring data to be stored, and calculating an index value of the data to be stored.
Specifically, the calculating the index value of the data to be stored includes:
step A1: and determining the keywords of the data to be stored.
The keyword is generally a character string, and preferably, the character string in this embodiment is a binary string.
By establishing the corresponding relation between the data to be stored and the keywords, the data to be stored can be conveniently found through the keywords in the later period.
Step A2: and calculating the hash value of the keyword by using a hash algorithm.
Binary values of arbitrary length can be mapped to shorter binary values of fixed length by a hash algorithm.
Step A3: and carrying out bit operation on the hash value to obtain an index value of the data to be stored.
Step S102: and setting the name of the storage file and/or the superior subdirectory of the storage file according to the index value.
Specifically, the storage file is a file for storing the data to be stored.
The upper subdirectory of the storage file refers to a subdirectory containing the storage file in the storage path.
Further, step S102 includes:
adding the index value to the name of the storage file and/or adding the index value to an upper subdirectory of the storage file.
The index value may be directly used as the name of the storage file, or may be combined with other characters for identifying the data to be stored to be used as the name of the storage file.
The index value may be directly used as the upper subdirectory of the storage file, or may be combined with other characters for identifying the data to be stored to be used as the upper subdirectory of the storage file.
It should be noted that, after the index value is added to the upper subdirectory of the storage file, the index value may be added to the name of the storage file, or the name of the storage file may be set according to other characters for identifying the data to be stored.
Step S103: and storing the data to be stored into a set storage file.
Specifically, after step S103, the method further includes:
calculating an index value of the data to be stored;
searching the storage file with the name containing the index value, and acquiring the data to be stored from the searched storage file.
Further, after step S103, the method further includes:
calculating an index value of the data to be stored;
and searching the subdirectory containing the index value, and acquiring the data to be stored from the storage file under the searched subdirectory.
Compared with the prior art, the method has the advantages that the name of the storage file and the superior subdirectory of the storage file are not required to be set, the index value can be generated according to the keyword of the data to be stored, and the name of the storage file and the superior subdirectory can be automatically set according to the index value. During searching, an index value is generated according to a keyword of data to be stored, and then the name of a storage file containing the index value is searched, or a subdirectory containing the index value is searched.
A second embodiment of the present invention provides a method for managing data to be stored, which is applied to a scenario where lightweight data storage classes SharedPreferences are used to store data to be stored, as shown in fig. 2, where the method specifically includes the following steps:
step S201: and acquiring data to be stored, and calculating an index value of the data to be stored.
Specifically, the calculating the index value of the data to be stored includes:
step B1: and determining the keywords of the data to be stored.
The keyword is generally a character string, and preferably, the character string in this embodiment is a binary string.
By establishing the corresponding relation between the data to be stored and the keywords, the data to be stored can be conveniently found through the keywords in the later period.
Step B2: and calculating the hash value of the keyword by using a hash algorithm.
A binary value of arbitrary length can be mapped to a shorter binary value of fixed length by a hashing algorithm.
Step B3: and carrying out bit operation on the hash value to obtain an index value of the data to be stored.
Step S202: and setting the name of the XML file for storing the data to be stored according to the index value.
Further, step S202 includes:
and adding the index value into the name of the XML file.
Preferably, the index value may be directly used as a name of the XML file, or may be combined with other characters for identifying the data to be stored to be used as a name of the XML file.
Step S203: and storing the data to be stored into the set XML file.
For example, when storing data to be stored with a keyword "wl og _ gate", the index value of the data to be stored is calculated to be 2 by using the method of step S201, and when storing data to be stored with a keyword "wl og _ gate", the name of the XML file is automatically set to "wuba 2", so that the data to be stored with a keyword "wl og _ gate" is stored in a file of wuba2.
Specifically, after step S203, the method further includes:
when data to be stored needs to be read, calculating an index value of the data to be stored;
and searching the XML file with the name containing the index value, and acquiring the data to be stored from the searched XML file.
For example, when reading the data to be stored with the keyword "wl _ gate", the index value of the data to be stored is 2 by calculation using the method in step S201, find the XML file with the name containing the number "2", i.e. find the file with the name of wuba2.XML, and read the data to be stored with the keyword "wl _ gate" from the file with the name of wuba2. XML.
In the prior art, SharedPreferences is used for storing data to be stored, and besides a keyword needs to be set, the name of an XML file also needs to be specified. By the method of the embodiment, the name of the XML file can be automatically set according to the keywords of the data to be stored.
A third embodiment of the present invention provides a method for managing data to be stored, which is applied to a scenario in which a Read-Only Memory (ROM) file is used to store data to be stored, and as shown in fig. 3, the method specifically includes the following steps:
step S301: and acquiring data to be stored, and calculating an index value of the data to be stored.
Specifically, the calculating the index value of the data to be stored includes:
step C1: and determining the keywords of the data to be stored.
The keyword is generally a character string, and preferably, the character string in this embodiment is a binary string.
By establishing the corresponding relation between the data to be stored and the keywords, the data to be stored can be conveniently found through the keywords in the later period.
Step C2: and calculating the hash value of the keyword by using a hash algorithm.
Binary values of arbitrary length can be mapped to shorter binary values of fixed length by a hash algorithm.
Step C3: and carrying out bit operation on the hash value to obtain an index value of the data to be stored.
Step S302: and setting an upper subdirectory of a storage file in the ROM file according to the index value.
Specifically, the storage file is a file for storing the data to be stored.
The upper subdirectory of the storage file refers to a subdirectory containing the storage file in the storage path.
Further, step S302 includes:
and adding the index value into an upper subdirectory of the storage file.
The index value may be directly used as the upper subdirectory of the storage file, or may be combined with other characters for identifying the data to be stored to be used as the upper subdirectory of the storage file.
It should be noted that, after the index value is added to the upper subdirectory of the storage file, the index value may be added to the name of the storage file, or the name of the storage file may be set according to other characters for identifying the data to be stored.
Step S303: and storing the data to be stored into a set storage file.
For example: when the data to be stored with the key word "ab _ test" is stored, the index value of the data to be stored is calculated to be 67 by using the method in step S301, then when the data to be stored with the key word "ab _ test" is stored, the storage file is stored in the directory of data/data/com.
Specifically, after step S303, the method further includes:
when data to be stored needs to be read, calculating an index value of the data to be stored;
and searching the subdirectory containing the index value, and acquiring the data to be stored from the storage file under the searched subdirectory.
For example, when data to be stored with a keyword "ab _ test" is read, the index value of the data to be stored is calculated to be 67 by using the method in step S301, a subdirectory containing the number "67" is searched, that is, data/data/com.wuba/files/storage/67 is found, a file with a file name "ab _ test" is searched from the data/data/com.wuba/files/storage/67 directory, and the data to be stored with the keyword "ab _ test" is read from the file.
In the prior art, a ROM file is used for storing data to be stored, and besides setting keywords, a specific storage path needs to be specified. By the method of the embodiment, the upper-level subdirectory for storing the file of the data to be stored can be automatically set according to the keyword of the data to be stored.
A fourth embodiment of the present invention provides an apparatus for managing data to be stored, where as shown in fig. 4, the apparatus includes: a processor 401, a memory 402, and a communication bus;
the communication bus is used for realizing connection communication between the processor 401 and the memory 402;
the processor 401 is configured to execute a program stored in the memory 402 for managing data to be stored, so as to implement the following steps:
acquiring data to be stored, and calculating an index value of the data to be stored;
setting the name of the storage file and/or a superior subdirectory of the storage file according to the index value;
and storing the data to be stored into a set storage file.
Specifically, when the step of calculating the index value of the data to be stored is executed, the processor 401 includes:
determining keywords of the data to be stored;
calculating the hash value of the keyword by using a hash algorithm;
and carrying out bit operation on the hash value to obtain an index value of the data to be stored.
Further, when executing the step of setting the name of the storage file and/or the upper subdirectory of the storage file according to the index value, the processor 401 includes:
adding the index value to the name of the storage file and/or adding the index value to an upper subdirectory of the storage file.
Further, after storing the data to be stored in the set storage file, the processor 401 is further configured to execute the program for managing the data to be stored in the memory 402, so as to implement the following steps:
searching the storage file with the name containing the index value, and acquiring the data to be stored from the searched storage file.
Further, after storing the data to be stored in the set storage file, the processor 401 is further configured to execute the program for managing the data to be stored in the memory 402, so as to implement the following steps:
and searching the subdirectory containing the index value, and acquiring the data to be stored from the storage file under the searched subdirectory.
A fifth embodiment of the present invention proposes a computer-readable storage medium storing a program for managing data to be stored;
when executed by at least one processor, causes the at least one processor to perform the steps of:
acquiring data to be stored, and calculating an index value of the data to be stored;
setting the name of the storage file and/or a superior subdirectory of the storage file according to the index value;
and storing the data to be stored into a set storage file.
According to the method, the device and the computer readable storage medium for managing the data to be stored, which are introduced in the embodiment of the invention, the name of the file and/or the superior subdirectory for storing the data to be stored are/is automatically set according to the keyword value of the data to be stored. In the invention, a developer only needs to specify the key words of the data to be stored, and does not need to specify the file name and the upper subdirectory of the storage file. The invention can reduce the development and use cost of storing and reading data and improve the efficiency of storing and reading operation.
While the invention has been described in connection with specific embodiments thereof, it is to be understood that it is intended by the appended drawings and description that the invention may be embodied in other specific forms without departing from the spirit or scope of the invention.
Claims (7)
1. A method of managing data to be stored, the method comprising:
acquiring data to be stored, and calculating an index value of the data to be stored;
setting the name of the storage file and/or a superior subdirectory of the storage file according to the index value;
storing the data to be stored into a set storage file;
the calculating the index value of the data to be stored includes:
determining keywords of the data to be stored;
calculating the hash value of the keyword by using a hash algorithm;
performing bit operation on the hash value to obtain an index value of the data to be stored;
the setting of the name of the storage file and/or the superior subdirectory of the storage file according to the index value includes: and adding the index value into the name of the storage file, and adding the index value into an upper subdirectory of the storage file.
2. The method for managing data to be stored according to claim 1, wherein after storing the data to be stored in the set storage file, the method further comprises:
searching the storage file with the name containing the index value, and acquiring the data to be stored from the searched storage file.
3. The method for managing data to be stored according to claim 1, wherein after storing the data to be stored in the set storage file, the method further comprises:
and searching the subdirectory containing the index value, and acquiring the data to be stored from the storage file under the searched subdirectory.
4. The method for managing data to be stored according to claim 1, wherein the adding the index value to the name of the storage file comprises:
when the lightweight data storage class SharedPreferences is used for storing the data to be stored, the storage file is an extensible markup language (XML) file;
and adding the index value into the name of the XML file.
5. The method of claim 1, wherein the adding the index value to an upper subdirectory of the storage file comprises:
when a Read Only Memory (ROM) file is used for storing the data to be stored, the storage file is positioned in the ROM file;
and setting the index value as an upper subdirectory of the storage file.
6. An apparatus for managing data to be stored, the apparatus comprising: a processor, a memory, and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is used for executing the program for managing the data to be stored in the memory so as to realize the following steps:
acquiring data to be stored, and calculating an index value of the data to be stored;
setting the name of the storage file and/or a superior subdirectory of the storage file according to the index value;
storing the data to be stored into a set storage file;
the calculating the index value of the data to be stored comprises:
determining keywords of the data to be stored;
calculating the hash value of the keyword by using a hash algorithm;
performing bit operation on the hash value to obtain an index value of the data to be stored;
when the processor executes the step of setting the name of the storage file and/or the superior subdirectory of the storage file according to the index value, the method comprises the following steps:
and adding the index value into the name of the storage file, and adding the index value into an upper subdirectory of the storage file.
7. A computer-readable storage medium characterized in that the computer-readable storage medium stores a program that manages data to be stored;
the program for managing data to be stored, when executed by at least one processor, causes the at least one processor to perform the steps of the method for managing data to be stored of any of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711310277.4A CN108197157B (en) | 2017-12-11 | 2017-12-11 | Method, apparatus and computer-readable storage medium for managing data to be stored |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711310277.4A CN108197157B (en) | 2017-12-11 | 2017-12-11 | Method, apparatus and computer-readable storage medium for managing data to be stored |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108197157A CN108197157A (en) | 2018-06-22 |
CN108197157B true CN108197157B (en) | 2022-05-31 |
Family
ID=62574049
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711310277.4A Active CN108197157B (en) | 2017-12-11 | 2017-12-11 | Method, apparatus and computer-readable storage medium for managing data to be stored |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108197157B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110083675B (en) * | 2019-04-19 | 2021-11-30 | 宝能汽车集团有限公司 | Text processing method and device |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101398869A (en) * | 2008-10-07 | 2009-04-01 | 深圳市蓝韵实业有限公司 | Mass data storage means |
CN101582082A (en) * | 2009-06-16 | 2009-11-18 | 深圳市茁壮网络股份有限公司 | Method and device for dynamically adapting for data by Hash table |
CN101753445A (en) * | 2009-12-23 | 2010-06-23 | 重庆邮电大学 | Fast flow classification method based on keyword decomposition hash algorithm |
CN105159987A (en) * | 2015-08-31 | 2015-12-16 | 深圳市茁壮网络股份有限公司 | Data storage and query method and apparatus |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8412677B2 (en) * | 2008-11-26 | 2013-04-02 | Commvault Systems, Inc. | Systems and methods for byte-level or quasi byte-level single instancing |
-
2017
- 2017-12-11 CN CN201711310277.4A patent/CN108197157B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101398869A (en) * | 2008-10-07 | 2009-04-01 | 深圳市蓝韵实业有限公司 | Mass data storage means |
CN101582082A (en) * | 2009-06-16 | 2009-11-18 | 深圳市茁壮网络股份有限公司 | Method and device for dynamically adapting for data by Hash table |
CN101753445A (en) * | 2009-12-23 | 2010-06-23 | 重庆邮电大学 | Fast flow classification method based on keyword decomposition hash algorithm |
CN105159987A (en) * | 2015-08-31 | 2015-12-16 | 深圳市茁壮网络股份有限公司 | Data storage and query method and apparatus |
Also Published As
Publication number | Publication date |
---|---|
CN108197157A (en) | 2018-06-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110058873B (en) | Application page updating method, device, equipment and storage medium | |
CN109388766B (en) | Page loading method and device | |
US9305176B2 (en) | Database generation from a spreadsheet | |
CN105095226A (en) | Method and apparatus for loading webpage resource | |
US8352541B2 (en) | Identifying relevant data from unstructured feeds | |
US20120317363A1 (en) | Memory Caching for Browser Processes | |
US20180075003A1 (en) | Verifying content of resources in markup language documents | |
CN106708825A (en) | Data file processing method and system | |
CN104320312A (en) | Network application safety test tool and fuzz test case generation method and system | |
CN111552640A (en) | Code detection method, device, equipment and storage medium | |
MXPA04007146A (en) | Method and apparatus for late-binding/dynamic pathname resolution. | |
CN108197157B (en) | Method, apparatus and computer-readable storage medium for managing data to be stored | |
CN111107133A (en) | Generation method of difference packet, data updating method, device and storage medium | |
CN104166649A (en) | Caching method and device for search engine | |
CN111858612B (en) | Data accelerated access method and device based on graph database and storage medium | |
US20100287331A1 (en) | Electronic device and method for recording power-on time thereof | |
US11340999B2 (en) | Fast restoration method from inode based backup to path based structure | |
EP2312473A1 (en) | System, apparatus and method for processing content on a computing device | |
US8793663B2 (en) | Smart cache for a server test environment in an application development tool | |
US8214336B2 (en) | Preservation of digital content | |
CN113448869B (en) | Method and device for generating test case, electronic equipment and computer readable medium | |
CN104598554A (en) | Webpage page loading method and device | |
CN109635175B (en) | Page data splicing method and device, readable storage medium and electronic equipment | |
CN109558375B (en) | Optimized file storage method, storage medium, equipment and system | |
US9606783B2 (en) | Dynamic code selection based on data policies |
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 | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20230930 Address after: Room 210-03, 2nd floor, block C, office building, Nangang Industrial Zone, Tianjin Binhai New Area Economic and Technological Development Zone, 300450 Patentee after: 58Tongcheng Information Technology Co.,Ltd. Address before: Room 210-03, 2nd floor, block C, office building, Nangang Industrial Zone, Tianjin Binhai New Area Economic and Technological Development Zone, 300450 Patentee before: 58 Co.,Ltd. |