CN113157703B - Data query method and device, electronic equipment and storage medium - Google Patents

Data query method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113157703B
CN113157703B CN202110473531.2A CN202110473531A CN113157703B CN 113157703 B CN113157703 B CN 113157703B CN 202110473531 A CN202110473531 A CN 202110473531A CN 113157703 B CN113157703 B CN 113157703B
Authority
CN
China
Prior art keywords
data
index
preset
target
offset value
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
CN202110473531.2A
Other languages
Chinese (zh)
Other versions
CN113157703A (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.)
Beijing Xiaomi Mobile Software Co Ltd
Beijing Xiaomi Pinecone Electronic Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software Co Ltd
Beijing Xiaomi Pinecone Electronic 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 Beijing Xiaomi Mobile Software Co Ltd, Beijing Xiaomi Pinecone Electronic Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN202110473531.2A priority Critical patent/CN113157703B/en
Publication of CN113157703A publication Critical patent/CN113157703A/en
Application granted granted Critical
Publication of CN113157703B publication Critical patent/CN113157703B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • G06F16/24554Unary operations; Data partitioning operations
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure relates to a data query method, a device, an electronic device and a storage medium, and relates to the technical field of data processing, wherein the method comprises the following steps: acquiring a data sequence number of data to be queried in a preset data set, determining a first target offset value through a first index table according to the data sequence number, wherein each first index in the first index table corresponds to each pre-divided data interval in the preset data set one by one, the first index corresponds to the first offset value, the first offset value is an offset of a storage address of the data interval corresponding to the first index relative to a starting storage address of the preset data set, the first target offset value is a first offset value corresponding to the target data interval where the data to be queried is located, determining a second target offset value through a second index table according to the data sequence number, and querying the data to be queried from the preset data set according to the first target offset value and the second target offset value.

Description

Data query method and device, electronic equipment and storage medium
Technical Field
The disclosure relates to the technical field of data processing, and in particular relates to a data query method, a data query device, electronic equipment and a storage medium.
Background
With the continuous development of internet technology and computer technology, the requirement on data query speed is also increasing. In order to increase the data query speed, an index set for a data set in which data to be queried is located is established, and data query is performed through the index set. However, when the data set in which the data to be queried is located includes a large amount of data, a corresponding index needs to be established for each data in the data set, and a storage space required for each index is large, which causes the whole index set to occupy a large storage space.
Disclosure of Invention
In order to overcome the problems in the related art, the present disclosure provides a data query method, apparatus, electronic device, and storage medium.
According to a first aspect of embodiments of the present disclosure, there is provided a data query method, the method including:
acquiring a data sequence number of data to be queried in a preset data set, wherein the preset data set comprises a plurality of data which are sequentially arranged;
determining a first target offset value through a first index table according to the data sequence number; each first index in the first index table corresponds to each pre-divided data interval in the preset data set one by one, the first index corresponds to a first offset value, the first offset value is an offset of a storage address of the data interval corresponding to the first index relative to a starting storage address of the preset data set, and the first target offset value is a first offset value corresponding to a target data interval where the data to be queried is located;
Determining a second target offset value through a second index table according to the data sequence number; the second index table comprises the data size of each datum in the preset data set, and the second target offset value is the sum of the data sizes of the data before the data to be queried in the target data interval;
and inquiring the data to be inquired from the preset data set according to the first target offset value and the second target offset value.
Optionally, the first index table is obtained by:
segmenting a first number of preset indexes in a preset index set according to the number of preset segments to obtain a second number of index segments; each data corresponds to one preset index, the preset index corresponds to a preset offset value, and the preset offset value is the offset of a storage address of the data corresponding to the preset index relative to the initial storage address; each index segment comprises a preset number of preset indexes of the preset segments and corresponds to one data interval;
and taking a first preset index in each index segment as the first index to obtain the first index table.
Optionally, the determining, according to the data sequence number, the first target offset value through a first index table includes:
calculating the ratio of the data sequence number to the preset segmentation number;
determining the target data interval from a plurality of data intervals according to the ratio;
and determining a target index corresponding to the target data interval from a plurality of first indexes through the first index table, and taking a first offset value corresponding to the target index as the first target offset value.
Optionally, the determining the target data interval from a plurality of data intervals according to the ratio includes:
if the ratio is an integer, taking the ratio as a target sequence, and selecting a data interval with the sequence of the target sequence from a plurality of data intervals as the target data interval;
if the ratio is not an integer, the ratio is rounded up and then used as the target sequence, and a data interval with the sequence of the target sequence is selected from a plurality of data intervals to be used as the target data interval.
Optionally, the determining, according to the data sequence number, a second target offset value through a second index table includes:
Calculating the remainder of the data sequence number divided by the preset segmentation number;
determining a target position of the data to be queried in the target data interval according to the remainder;
and acquiring a sum value of data sizes of data positioned in front of the target position in the target data interval, and taking the sum value as the second target offset value.
Optionally, the first index table is obtained by:
segmenting a first number of preset indexes in a preset index set according to a plurality of preset segmentation numbers which are sequentially arranged to obtain a third number of index segments; each data corresponds to one preset index, the preset index corresponds to a preset offset value, each index section corresponds to one preset segmentation number and corresponds to one data interval, and each index section comprises the preset indexes of the preset segmentation number corresponding to the index section;
and taking a first preset index in each index segment as the first index to obtain the first index table.
Optionally, the determining, according to the data sequence number, the first target offset value through a first index table includes:
Determining the target data interval according to the data sequence number and the data quantity included in each data interval;
and determining a target index corresponding to the target data interval from a plurality of first indexes through the first index table, and taking a first offset value corresponding to the target index as the first target offset value.
Optionally, the determining, according to the data sequence number, a second target offset value through a second index table includes:
determining a target position of the data to be queried in the target data interval according to the data sequence number and the data quantity included in each data interval;
and acquiring a sum value of data sizes of data positioned in front of the target position in the target data interval, and taking the sum value as the second target offset value.
Optionally, the second index table is obtained by:
and for each data, taking the data size of the data as a second index corresponding to the data, and replacing a preset index corresponding to the data in the preset index set by using the second index corresponding to the data to obtain the second index table.
Optionally, the querying the data to be queried from the preset data set according to the first target offset value and the second target offset value includes:
Taking the sum of the first target offset value and the second target offset value as the position offset value of the data to be queried;
and inquiring the data to be inquired from the preset data set according to the position offset value.
According to a second aspect of embodiments of the present disclosure, there is provided a data querying device, the device including:
the acquisition module is configured to acquire a data sequence number of data to be queried in a preset data set, wherein the preset data set comprises a plurality of data which are sequentially arranged;
a first determining module configured to determine a first target offset value according to the data sequence number through a first index table; each first index in the first index table corresponds to each pre-divided data interval in the preset data set one by one, the first index corresponds to a first offset value, the first offset value is an offset of a storage address of the data interval corresponding to the first index relative to a starting storage address of the preset data set, and the first target offset value is a first offset value corresponding to a target data interval where the data to be queried is located;
a second determining module configured to determine a second target offset value according to the data sequence number through a second index table; the second index table comprises the data size of each datum in the preset data set, and the second target offset value is the sum of the data sizes of the data before the data to be queried in the target data interval;
And the query module is configured to query the data to be queried from the preset data set according to the first target offset value and the second target offset value.
Optionally, the first determining module is configured to obtain the first index table by:
segmenting a first number of preset indexes in a preset index set according to the number of preset segments to obtain a second number of index segments; each data corresponds to one preset index, the preset index corresponds to a preset offset value, and the preset offset value is the offset of a storage address of the data corresponding to the preset index relative to the initial storage address; each index segment comprises a preset number of preset indexes of the preset segments and corresponds to one data interval;
and taking a first preset index in each index segment as the first index to obtain the first index table.
Optionally, the first determining module includes:
a first calculation sub-module configured to calculate a ratio of the data sequence number to the preset number of segments;
a first determination submodule configured to determine the target data interval from a plurality of the data intervals according to the ratio;
The first determining submodule is further configured to determine a target index corresponding to the target data interval from a plurality of first indexes through the first index table, and take a first offset value corresponding to the target index as the first target offset value.
Optionally, the first determination submodule is configured to:
if the ratio is an integer, taking the ratio as a target sequence, and selecting a data interval with the sequence of the target sequence from a plurality of data intervals as the target data interval;
if the ratio is not an integer, the ratio is rounded up and then used as the target sequence, and a data interval with the sequence of the target sequence is selected from a plurality of data intervals to be used as the target data interval.
Optionally, the second determining module includes:
a second calculation sub-module configured to calculate a remainder of the data sequence number divided by the preset number of segments;
a second determining submodule configured to determine a target position of the data to be queried in the target data interval according to the remainder;
the second determining submodule is further configured to acquire a sum value of data sizes of data located before the target position in the target data section, and take the sum value as the second target offset value.
Optionally, the first determining module is configured to obtain the first index table by:
segmenting a first number of preset indexes in a preset index set according to a plurality of preset segmentation numbers which are sequentially arranged to obtain a third number of index segments; each data corresponds to one preset index, the preset index corresponds to a preset offset value, each index section corresponds to one preset segmentation number and corresponds to one data interval, and each index section comprises the preset indexes of the preset segmentation number corresponding to the index section;
and taking a first preset index in each index segment as the first index to obtain the first index table.
Optionally, the first determining module includes:
a third calculation sub-module configured to determine the target data interval according to the data sequence number and the data quantity included in each data interval;
and the third determining submodule is configured to determine a target index corresponding to the target data interval from a plurality of first indexes through the first index table, and takes a first offset value corresponding to the target index as the first target offset value.
Optionally, the second determining module includes:
a fourth calculation sub-module configured to determine a target position of the data to be queried in the target data interval according to the data sequence number and the data quantity included in each data interval;
and a fourth determining submodule configured to acquire a sum value of data sizes of data located before the target position in the target data section, and take the sum value as the second target offset value.
Optionally, the second determining module is configured to obtain the second index table by:
and for each data, taking the data size of the data as a second index corresponding to the data, and replacing a preset index corresponding to the data in the preset index set by using the second index corresponding to the data to obtain the second index table.
Optionally, the query module includes:
a third determining submodule configured to take a sum of the first target offset value and the second target offset value as a position offset value of the data to be queried;
and the inquiring sub-module is configured to inquire the data to be inquired from the preset data set according to the position offset value.
According to a third aspect of embodiments of the present disclosure, there is provided an electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the steps of the method of querying data provided by the first aspect of the present disclosure.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the steps of the method of querying data provided by the first aspect of the present disclosure.
The technical scheme provided by the embodiment of the disclosure can comprise the following beneficial effects: the method comprises the steps of firstly obtaining a data sequence number of data to be queried in a preset data set, determining a first target offset value through a first index table according to the data sequence number, wherein each first index in the first index table corresponds to each data interval in the preset data set one by one, the first index corresponds to the first offset value, then determining a second target offset value through a second index table comprising the data size of each data in the preset data set according to the data sequence number, and finally querying the data to be queried from the preset data set according to the first target offset value and the second target offset value. The first index table in the disclosure includes a first index corresponding to a data interval, the second index table includes a data size of each data, the storage space occupied by the first index table and the second index table is smaller, and the data to be queried is queried through the first index table and the second index table, so that the storage space required for storing the indexes can be saved while the data query speed is ensured.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
FIG. 1 is a flow chart illustrating a method of querying data according to an exemplary embodiment.
Fig. 2 is a flow chart illustrating a method of retrieving a first index table according to an exemplary embodiment.
FIG. 3 is a diagram illustrating a default index set and a default data set according to an exemplary embodiment.
Fig. 4 is a flow chart illustrating one step 102 according to the embodiment shown in fig. 1.
Fig. 5 is a flow chart illustrating one step 103 according to the embodiment shown in fig. 1.
Fig. 6 is a flowchart illustrating another method of retrieving a first index table according to an exemplary embodiment.
Fig. 7 is a flow chart illustrating another step 102 according to the embodiment shown in fig. 1.
Fig. 8 is a flow chart illustrating another step 103 according to the embodiment shown in fig. 1.
Fig. 9 is a block diagram of a data querying device, according to an example embodiment.
Fig. 10 is a block diagram of a first determination module shown in accordance with the embodiment of fig. 9.
Fig. 11 is a block diagram of a second determination module shown in accordance with the embodiment of fig. 9.
Fig. 12 is a block diagram of another first determination module shown in accordance with the embodiment of fig. 9.
Fig. 13 is a block diagram of another second determination module shown in accordance with the embodiment of fig. 9.
FIG. 14 is a block diagram of a query module shown in accordance with the embodiment of FIG. 9.
Fig. 15 is a block diagram of an electronic device, according to an example embodiment.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
Before introducing the data query method, device, electronic equipment and storage medium provided by the disclosure, application scenarios related to various embodiments of the disclosure are first described. The application scene can be any scene requiring data query by using index, for example, the application scene can be a scene of intelligent search, query of characters in a word stock and the like. In addition, the execution subject of the data query method provided in the present disclosure may be a terminal device (i.e., the process of data query is performed on the terminal device) or a server (i.e., the process of data query is performed on the server). The terminal device may be a mobile terminal such as a smart phone, a tablet computer, a smart watch, a smart bracelet, a PDA (english: personal Digital Assistant, chinese: personal digital assistant), or a fixed terminal such as a desktop computer. The server may include, but is not limited to: entity servers, server clusters, cloud servers, and the like.
FIG. 1 is a flow chart illustrating a method of querying data according to an exemplary embodiment. As shown in fig. 1, the method may include the steps of:
in step 101, a data sequence number of data to be queried in a preset data set is obtained, where the preset data set includes a plurality of data sequentially arranged.
For example, when querying the data to be queried, the data sequence number of the data to be queried in the preset data set may be obtained first. The data sequence number is used for indicating the sequence of the data to be queried in a plurality of sequentially arranged data included in a preset data set. For example, if the preset data set is a Chinese character library, if the designated Chinese characters in the Chinese character library are queried (i.e. the data to be queried is the designated Chinese characters), the data sequence number of the designated Chinese characters in the Chinese character library can be determined according to the corresponding GB2312 codes of the designated Chinese characters.
In step 102, a first target offset value is determined from the data sequence number via a first index table.
Each first index in the first index table corresponds to each pre-divided data interval in the preset data set one by one, the first index corresponds to a first offset value, the first offset value is an offset of a storage address of the data interval corresponding to the first index relative to a starting storage address of the preset data set, and the first target offset value is a first offset value corresponding to a target data interval where data to be queried is located.
In step 103, a second target offset value is determined from the data sequence number by means of a second index table.
The second index table comprises a preset data size of each data in the data set, and the second target offset value is a sum value of data sizes of data before the data to be queried in the target data interval.
For example, in order to increase the data query speed, a preset index set corresponding to the preset data set may be established according to the data in the preset data set, and the data to be queried may be queried through the preset index set. Wherein an offset (i.e., an offset relative to a starting memory address) of each data in the preset data set relative to a memory address of a first data in the preset data set can be determined by the preset index set. If the preset data set contains a larger amount of data, the preset index set occupies a larger storage space. In order to reduce the storage space occupied by the index set, a mode of compressing the index set can be adopted to reduce the storage space occupied by the index set. Specifically, the preset data set may be first divided into a plurality of data intervals according to the preset index set (the number of data included in each data interval may be the same or different). Then, for each data interval, a first offset value corresponding to the data interval is determined according to the offset of the storage address of the data interval relative to the initial storage address, and a first index corresponding to the data interval is generated (the first index is used for storing the corresponding first offset value). And then constructing a first index table according to the first index corresponding to each data interval. While constructing the first index table, a second index table can be constructed according to the data size of each data in the preset data set.
After the first index table and the second index table are built, a target data interval where the data to be queried is located can be determined according to the data sequence number and the data quantity included in each data area, and a first offset value corresponding to the target data area is used as a first target offset value through the first index table. Meanwhile, according to the data sequence number and the data quantity included in each data area, the data before the data to be queried in the target data interval can be determined, and the sum of the data sizes of the data before the data to be queried in the target data interval is used as a second target offset value through a second index table. For example, when the data sequence number is 35, if the number of data in each data area is 32, it may be determined that the data to be queried should be in a second data area in the preset data set, and the data preceding the data to be queried (i.e. the data sequence number is 35) in the second data area is the data of the data sequence numbers 33 and 34, then the second data area may be taken as a target data interval, and the first offset value corresponding to the second data area may be taken as a first target offset value according to the first index table, and meanwhile, the sum of the data sizes of the data sequence numbers 33 and 34 may be taken as a second target offset value according to the second index table.
In step 104, the data to be queried is queried from the preset data set according to the first target offset value and the second target offset value.
Further, the first target offset value actually reflects the offset of the target data interval in which the data to be queried is located from the initial storage address, and the second target offset value actually reflects the offset of the data to be queried from the storage address of the target data interval. That is, the sum of the first target offset value and the second target offset value is the offset of the data to be queried relative to the initial storage address. Therefore, the sum of the first target offset value and the second target offset value can be used as the position offset value of the data to be queried, and the data to be queried can be queried from the preset data set according to the position offset value.
It should be noted that, the larger the data amount of the preset index set is relative to the offset of the initial storage address, the larger the value of the offset to be stored by the data in the back of the preset data set is, which causes the preset index set to occupy a larger storage space. The first index table in the present disclosure only needs to store the first index corresponding to each data interval, but does not need to store the index corresponding to each data, and the second index table stores the data size of each data in the preset data set in fact, and the data size of the data is greatly reduced relative to the value of the offset. Therefore, the first index table and the second index table occupy less storage space than the preset index set.
In summary, the disclosure first obtains a data sequence number of data to be queried in a preset data set, determines a first target offset value according to the data sequence number through a first index table, wherein each first index in the first index table corresponds to each data interval in the preset data set one by one, the first index corresponds to the first offset value, then determines a second target offset value according to the data sequence number through a second index table including a data size of each data in the preset data set, and finally queries the data to be queried from the preset data set according to the first target offset value and the second target offset value. The first index table in the disclosure includes a first index corresponding to a data interval, the second index table includes a data size of each data, the storage space occupied by the first index table and the second index table is smaller, and the data to be queried is queried through the first index table and the second index table, so that the storage space required for storing the indexes can be saved while the data query speed is ensured.
Fig. 2 is a flow chart illustrating a method of retrieving a first index table according to an exemplary embodiment. As shown in fig. 2, the first index table is obtained by:
In step 201, a first number of preset indexes in a preset index set is segmented according to the number of preset segments, so as to obtain a second number of index segments.
Each data corresponds to a preset index, the preset index corresponds to a preset offset value, the preset offset value is an offset of a storage address of the data corresponding to the preset index relative to a starting storage address, and each index segment comprises a preset number of preset indexes corresponding to a data interval.
In step 202, a first preset index in each index segment is used as a first index to obtain a first index table.
In one scenario, as shown in fig. 3, the preset data set may include a plurality of data (i.e., 1-X shown in fig. 3) arranged in sequence, the preset Index set may include a plurality of preset indexes (i.e., index1-N shown in fig. 3), each of the data may be of different lengths, and each of the preset indexes may be of equal lengths, i.e., the storage space occupied by each of the preset indexes is the same. Each data in the preset data set corresponds to a preset index, and the numerical value stored in each preset index is a preset offset value, wherein the preset offset value is used for indicating the offset of the corresponding data of the preset index relative to the initial storage address. In fig. 3, "0" in the preset index set indicates that the preset index has no corresponding data in the preset data set, that is, the number of preset indexes included in the preset index set is greater than or equal to the number of data included in the preset data set.
When the first index table is constructed, a preset segmentation number can be preset, and according to the preset segmentation number, a first number of preset indexes in a preset index set are segmented into a second number of index segments. Each index segment comprises a preset number of preset indexes of preset segments and corresponds to one data interval. In addition, the second number is equal to an integer of 'N/L', N is the first number, L is the preset segmentation number, and if 'N/L' is not an integer, the 'N/L' is rounded up and then is used as the second number. Then, a first preset index in each index segment may be used as a first index to construct a first index table. For example, when N is 1000 and the number of preset segments is 32, the second number may be determined to be 32, and then 1000 preset indexes in the preset index set may be segmented into 32 index segments according to the sequence, that is, the 1 st to 32 th preset indexes, the 33 rd to 64 th preset indexes, the 65 th to 96 th preset indexes, … …, the 993 th to 1000 th preset indexes are respectively used as one index segment, and the 1 st, 33, 65, … …, 993 th preset indexes are used as the first indexes, so as to obtain the first index table.
It should be noted that, if the preset index of the first preset index in a certain index segment is 0 in the preset index set, the second preset index of the index segment is taken as the first index.
Fig. 4 is a flow chart illustrating one step 102 according to the embodiment shown in fig. 1. As shown in fig. 4, step 102 may include the steps of:
in step 1021, the ratio of the data sequence number to the number of preset segments is calculated.
In step 1022, a target data interval is determined from the plurality of data intervals based on the ratio.
In step 1023, a target index corresponding to the target data interval is determined from the plurality of first indexes through the first index table, and the first offset value corresponding to the target index is used as the first target offset value.
For example, when the preset index set is segmented by a preset number of segments, the ratio of the data sequence number to the preset number of segments may be calculated first. If the ratio is an integer, the ratio is used as a target sequence, and a data interval with the sequence being the target sequence is selected from a plurality of data intervals to be used as a target data interval. If the ratio is not an integer, the ratio is rounded up and then used as a target sequence, and a data interval with the sequence being the target sequence is selected from a plurality of data intervals to be used as a target data interval. And then taking the first offset value corresponding to the target data area as a first target offset value through the first index table. For example, when the data sequence number is 35 and the preset number of segments is 32, the ratio of the data sequence number to the preset number of segments is 1.09375 (not an integer), 1.09375 is rounded up to 2, and 2 is taken as the target sequence, then the data section with the sequence of 2 in the multiple data sections may be taken as the target data section, that is, the data to be queried should be located in the second data area in the multiple data sections, and then the first offset value corresponding to the second data area may be taken as the first target offset value according to the first index table.
Fig. 5 is a flow chart illustrating one step 103 according to the embodiment shown in fig. 1. As shown in fig. 5, step 103 may include the steps of:
in step 1031, a remainder of the data sequence number divided by the preset number of segments is calculated.
In step 1032, a target location of the data to be queried in the target data interval is determined from the remainder.
In step 1033, a sum of data sizes of data located before the target position in the target data section is obtained, and the sum is taken as the second target offset value.
For example, in the case of segmenting the preset index set by one preset segmentation number, a remainder of the data sequence number divided by the preset segmentation number may be calculated first, and the remainder may be taken as a position order. Then, the position of the data (i.e. the data to be queried) in the target data interval in the order of the position order is taken as the target position, and the sum of the data sizes of the data in the target data interval before the target position is taken as the second target offset value through the second index table. For example, when the data sequence number is 35 and the preset segment number is 32, the remainder of dividing the data sequence number by the preset segment number is 3, it may be determined that the data to be queried should be the 3 rd data in the target data interval, and then the sum of the data sizes of the first two data in the target data interval may be used as the second target offset value according to the second index table. It should be noted that, if the second target offset value is 0, it is indicated that the data to be queried has no data in the preset data set.
Fig. 6 is a flowchart illustrating another method of retrieving a first index table according to an exemplary embodiment. As shown in fig. 6, the first index table is obtained by:
in step 203, according to the number of the preset segments arranged in sequence, the first number of preset indexes in the preset index set are segmented to obtain a third number of index segments.
Each data corresponds to a preset index, each preset index corresponds to a preset offset value, each index segment corresponds to a preset segmentation number, and corresponds to a data interval, and each index segment comprises a preset segmentation number corresponding to the index segment.
In step 204, a first preset index in each index segment is used as a first index to obtain a first index table.
In another scenario, a plurality of preset segments may be preset, and according to an arrangement sequence of the preset segments, a first number of preset indexes in the preset index set may be segmented in sequence to obtain a third number of index segments. Each index segment corresponds to a preset segment number, and each index segment comprises a preset index corresponding to the preset segment number of the index segment. For example, when N is 1002 and the number of the plurality of preset segments is 100, 200, 300, 400, 500, … …, 100N (N is a positive integer greater than 1), the 1 st to 100 th preset indexes, the 101 st to 300 th preset indexes, the 301 st to 600 th preset indexes, the 601 st to 1000 th preset indexes, and the 1001 st and 1002 th preset indexes in the preset index set may be respectively used as one index segment, and the 1 st, 101, 301, 601, 1001 st preset indexes may be used as the first indexes to obtain the first index table.
Fig. 7 is a flow chart illustrating another step 102 according to the embodiment shown in fig. 1. As shown in fig. 7, step 102 may include the steps of:
in step 1024, a target data interval is determined based on the data sequence number and the amount of data included in each data interval.
In step 1025, a target index corresponding to the target data interval is determined from the plurality of first indexes through the first index table, and the first offset value corresponding to the target index is used as the first target offset value.
For example, in the case of segmenting the preset index set by a plurality of preset segmentation numbers, a sequence number range corresponding to each data area may be determined according to the number of data included in each data area, then a target data area may be determined from a plurality of data areas according to the data sequence number and the sequence number range corresponding to each data area, and a first offset value corresponding to the target data area may be used as the first target offset value through the first index table. For example, when the number of data included in the preset index set is 1500 and the number of segments included in the preset index set is 100, 200, 300, 400, and 500, respectively, the number of data included in the data intervals in the preset index set is 100, 200, 300, 400, and 500 in sequence, then the sequence number ranges corresponding to the data intervals are 1-100, 101-300, 301-600, 601-1000, 1001-1500 in sequence, if the data sequence number is 1002, it may be determined that the data to be queried should be in a fifth data area in the preset data set, and the first offset value corresponding to the fifth data area is used as the first target offset value according to the first index table.
Fig. 8 is a flow chart illustrating another step 103 according to the embodiment shown in fig. 1. As shown in fig. 8, step 103 may include the steps of:
in step 1034, a target position of the data to be queried in the target data interval is determined according to the data sequence number and the data quantity included in each data interval.
In step 1035, a sum of data sizes of data located before the target position in the target data section is acquired, and the sum is taken as a second target offset value.
For example, in the case of segmenting the preset index set by a plurality of preset segmentation numbers, a sequence number range corresponding to each data area may be determined according to the number of data included in each data area, then a target position of the data to be queried in the target data interval may be determined according to the data sequence number and the sequence number range corresponding to each data area, and a sum value of data sizes of data before the data to be queried in the target data interval may be used as the second target offset value through the second index table. For example, when the sequence number ranges corresponding to the plurality of data intervals are sequentially 1-100, 101-300, 301-600, 601-1000, 1001-1500, if the sequence number of the data is 1004, it may be determined that the data to be queried should be the 4 th data in the target data interval (the data interval with the sequence number range of 1001-1500), and then the sum of the data sizes of the first three data in the target data interval may be used as the second target offset value according to the second index table.
Optionally, the second index table is obtained by:
and for each data, taking the data size of the data as a second index corresponding to the data, and replacing a preset index corresponding to the data in a preset index set by using the second index corresponding to the data to obtain a second index table.
For example, the data size of each data in the preset data set may be used as the second index corresponding to the data, and the second index corresponding to the data in the preset index set may be replaced by the second index corresponding to each data, so as to construct the second index table. For example, when the preset data set includes 10 data, and the data sizes of the 10 data are sequentially 100, 150, 200, 300, 200, 240, 400, 350, 180, 450, the second index table may be expressed as {100, 150, 200, 300, 200, 240, 400, 350, 180, 450}.
In summary, the disclosure first obtains a data sequence number of data to be queried in a preset data set, determines a first target offset value according to the data sequence number through a first index table, wherein each first index in the first index table corresponds to each data interval in the preset data set one by one, the first index corresponds to the first offset value, then determines a second target offset value according to the data sequence number through a second index table including a data size of each data in the preset data set, and finally queries the data to be queried from the preset data set according to the first target offset value and the second target offset value. The first index table in the disclosure includes a first index corresponding to a data interval, the second index table includes a data size of each data, the storage space occupied by the first index table and the second index table is smaller, and the data to be queried is queried through the first index table and the second index table, so that the storage space required for storing the indexes can be saved while the data query speed is ensured.
Fig. 9 is a block diagram of a data querying device, according to an example embodiment. As shown in fig. 9, the apparatus 300 includes:
the acquiring module 301 is configured to acquire a data sequence number of data to be queried in a preset data set, where the preset data set includes a plurality of data sequentially arranged.
The first determining module 302 is configured to determine the first target offset value according to the data sequence number through the first index table.
Each first index in the first index table corresponds to each pre-divided data interval in the preset data set one by one, the first index corresponds to a first offset value, the first offset value is an offset of a storage address of the data interval corresponding to the first index relative to a starting storage address of the preset data set, and the first target offset value is a first offset value corresponding to a target data interval where data to be queried is located.
The second determining module 303 is configured to determine a second target offset value according to the data sequence number through a second index table, where the second index table includes a data size of each data in the preset data set, and the second target offset value is a sum of data sizes of data preceding the data to be queried in the target data interval.
The query module 304 is configured to query the data to be queried from the preset data set according to the first target offset value and the second target offset value.
Optionally, the first determining module 302 is configured to obtain the first index table by:
segmenting a first number of preset indexes in a preset index set according to the number of preset segments to obtain a second number of index segments.
Each data corresponds to a preset index, the preset index corresponds to a preset offset value, the preset offset value is an offset of a storage address of the data corresponding to the preset index relative to a starting storage address, and each index segment comprises a preset number of preset indexes corresponding to a data interval.
And taking a first preset index in each index section as a first index to obtain a first index table.
Fig. 10 is a block diagram of a first determination module shown in accordance with the embodiment of fig. 9. As shown in fig. 10, the first determining module 302 includes:
a first calculation sub-module 3021 configured to calculate a ratio of the data sequence number and the preset number of segments.
A first determination submodule 3022 configured to determine a target data interval from the plurality of data intervals according to the ratio.
The first determining submodule 3022 is further configured to determine a target index corresponding to the target data interval from the plurality of first indexes through the first index table, and take a first offset value corresponding to the target index as the first target offset value.
Optionally, the first determining submodule 3022 is configured to:
if the ratio is an integer, the ratio is used as a target sequence, and a data interval with the sequence being the target sequence is selected from a plurality of data intervals to be used as a target data interval.
If the ratio is not an integer, taking the ratio as a target sequence after being rounded upwards, and selecting a data interval with the sequence of the target sequence from a plurality of data intervals as a target data interval.
Fig. 11 is a block diagram of a second determination module shown in accordance with the embodiment of fig. 9. As shown in fig. 11, the second determining module 303 includes:
the second calculation sub-module 3031 is configured to calculate a remainder of the data sequence number divided by the preset number of segments.
The second determining submodule 3032 is configured to determine a target position of the data to be queried in the target data interval according to the remainder.
The second determining submodule 3032 is further configured to obtain a sum value of data sizes of data located before the target position in the target data interval, and take the sum value as a second target offset value.
Optionally, the first determining module 302 is configured to obtain the first index table by:
segmenting a first number of preset indexes in a preset index set according to a plurality of preset segmentation numbers which are sequentially arranged, and obtaining a third number of index segments.
Each data corresponds to a preset index, each preset index corresponds to a preset offset value, each index segment corresponds to a preset segmentation number, and corresponds to a data interval, and each index segment comprises a preset segmentation number corresponding to the index segment.
And taking a first preset index in each index section as a first index to obtain a first index table.
Fig. 12 is a block diagram of another first determination module shown in accordance with the embodiment of fig. 9. As shown in fig. 12, the first determining module 302 includes:
the third calculation sub-module 3023 is configured to determine the target data interval according to the data sequence number and the data amount included in each data interval.
The first determining submodule 3024 is configured to determine a target index corresponding to the target data interval from the plurality of first indexes through the first index table, and take a first offset value corresponding to the target index as a first target offset value.
Fig. 13 is a block diagram of another second determination module shown in accordance with the embodiment of fig. 9. As shown in fig. 13, the second determining module 303 includes:
the fourth calculation submodule 3033 is configured to determine a target position of the data to be queried in the target data interval according to the data sequence number and the data quantity included in each data interval.
The fourth determining submodule 3034 is configured to acquire a sum value of data sizes of data located before the target position in the target data interval, and takes the sum value as a second target offset value.
Optionally, the second determining module 303 is configured to obtain the second index table by:
and for each data, taking the data size of the data as a second index corresponding to the data, and replacing a preset index corresponding to the data in a preset index set by using the second index corresponding to the data to obtain a second index table.
FIG. 14 is a block diagram of a query module shown in accordance with the embodiment of FIG. 9. As shown in fig. 14, the query module 304 includes:
the fifth determining submodule 3041 is configured to take the sum value of the first target offset value and the second target offset value as the position offset value of the data to be queried.
The query sub-module 3042 is configured to query the data to be queried from the preset data set according to the position offset value.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
In summary, the disclosure first obtains a data sequence number of data to be queried in a preset data set, determines a first target offset value according to the data sequence number through a first index table, wherein each first index in the first index table corresponds to each data interval in the preset data set one by one, the first index corresponds to the first offset value, then determines a second target offset value according to the data sequence number through a second index table including a data size of each data in the preset data set, and finally queries the data to be queried from the preset data set according to the first target offset value and the second target offset value. The first index table in the disclosure includes a first index corresponding to a data interval, the second index table includes a data size of each data, the storage space occupied by the first index table and the second index table is smaller, and the data to be queried is queried through the first index table and the second index table, so that the storage space required for storing the indexes can be saved while the data query speed is ensured.
The present disclosure also provides a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the steps of the data querying method provided by the present disclosure.
Fig. 15 is a block diagram of an electronic device, according to an example embodiment. For example, apparatus 800 may be a mobile phone, computer, digital broadcast terminal, messaging device, game console, tablet device, medical device, exercise device, personal digital assistant, or the like.
Referring to fig. 15, apparatus 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls overall operation of the apparatus 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to perform all or part of the steps of the data querying method described above. Further, the processing component 802 can include one or more modules that facilitate interactions between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the apparatus 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phonebook data, messages, pictures, videos, and the like. The memory 804 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power component 806 provides power to the various components of the device 800. The power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the device 800.
The multimedia component 808 includes a screen between the device 800 and the user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and/or a rear camera. The front camera and/or the rear camera may receive external multimedia data when the apparatus 800 is in an operational mode, such as a photographing mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 further includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be a keyboard, click wheel, buttons, etc. These buttons may include, but are not limited to: homepage button, volume button, start button, and lock button.
The sensor assembly 814 includes one or more sensors for providing status assessment of various aspects of the apparatus 800. For example, the sensor assembly 814 may detect an on/off state of the device 800, a relative positioning of the components, such as a display and keypad of the device 800, the sensor assembly 814 may also detect a change in position of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, an orientation or acceleration/deceleration of the device 800, and a change in temperature of the device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communication between the apparatus 800 and other devices, either in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as WiFi,2G or 3G, or a combination thereof. In one exemplary embodiment, the communication component 816 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements for performing the above-described data querying method.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided, such as memory 804 including instructions executable by processor 820 of apparatus 800 to perform the data querying method described above. For example, the non-transitory computer readable storage medium may be ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
In another exemplary embodiment, a computer program product is also provided, comprising a computer program executable by a programmable apparatus, the computer program having code portions for performing the above-described data querying method when executed by the programmable apparatus.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure. This application is intended to cover any adaptations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It is to be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (22)

1. A method for querying data, the method comprising:
Acquiring a data sequence number of data to be queried in a preset data set, wherein the preset data set comprises a plurality of data which are sequentially arranged;
determining a first target offset value through a first index table according to the data sequence number; each first index in the first index table corresponds to each pre-divided data interval in the preset data set one by one, the first index corresponds to a first offset value, the first offset value is an offset of a storage address of the data interval corresponding to the first index relative to a starting storage address of the preset data set, and the first target offset value is a first offset value corresponding to a target data interval where the data to be queried is located;
determining a second target offset value through a second index table according to the data sequence number; the second index table comprises the data size of each datum in the preset data set, and the second target offset value is the sum of the data sizes of the data before the data to be queried in the target data interval;
and inquiring the data to be inquired from the preset data set according to the first target offset value and the second target offset value.
2. The method of claim 1, wherein the first index table is obtained by:
Segmenting a first number of preset indexes in a preset index set according to the number of preset segments to obtain a second number of index segments; each data corresponds to one preset index, the preset index corresponds to a preset offset value, and the preset offset value is the offset of a storage address of the data corresponding to the preset index relative to the initial storage address; each index segment comprises a preset number of preset indexes of the preset segments and corresponds to one data interval;
and taking a first preset index in each index segment as the first index to obtain the first index table.
3. The method of claim 2, wherein determining the first target offset value from the data sequence number via a first index table comprises:
calculating the ratio of the data sequence number to the preset segmentation number;
determining the target data interval from a plurality of data intervals according to the ratio;
and determining a target index corresponding to the target data interval from a plurality of first indexes through the first index table, and taking a first offset value corresponding to the target index as the first target offset value.
4. A method according to claim 3, wherein said determining said target data interval from a plurality of said data intervals according to said ratio comprises:
if the ratio is an integer, taking the ratio as a target sequence, and selecting a data interval with the sequence of the target sequence from a plurality of data intervals as the target data interval;
if the ratio is not an integer, the ratio is rounded up and then used as the target sequence, and a data interval with the sequence of the target sequence is selected from a plurality of data intervals to be used as the target data interval.
5. The method of claim 2, wherein determining a second target offset value from the data sequence number via a second index table comprises:
calculating the remainder of the data sequence number divided by the preset segmentation number;
determining a target position of the data to be queried in the target data interval according to the remainder;
and acquiring a sum value of data sizes of data positioned in front of the target position in the target data interval, and taking the sum value as the second target offset value.
6. The method of claim 1, wherein the first index table is obtained by:
Segmenting a first number of preset indexes in a preset index set according to a plurality of preset segmentation numbers which are sequentially arranged to obtain a third number of index segments; each data corresponds to one preset index, the preset index corresponds to a preset offset value, each index section corresponds to one preset segmentation number and corresponds to one data interval, and each index section comprises the preset indexes of the preset segmentation number corresponding to the index section;
and taking a first preset index in each index segment as the first index to obtain the first index table.
7. The method of claim 6, wherein determining a first target offset value from the data sequence number via a first index table comprises:
determining the target data interval according to the data sequence number and the data quantity included in each data interval;
and determining a target index corresponding to the target data interval from a plurality of first indexes through the first index table, and taking a first offset value corresponding to the target index as the first target offset value.
8. The method of claim 6, wherein determining a second target offset value from the data sequence number via a second index table comprises:
Determining a target position of the data to be queried in the target data interval according to the data sequence number and the data quantity included in each data interval;
and acquiring a sum value of data sizes of data positioned in front of the target position in the target data interval, and taking the sum value as the second target offset value.
9. The method of claim 2, wherein the second index table is obtained by:
and for each data, taking the data size of the data as a second index corresponding to the data, and replacing a preset index corresponding to the data in the preset index set by using the second index corresponding to the data to obtain the second index table.
10. The method of claim 1, wherein querying the data to be queried from the preset dataset according to the first target offset value and the second target offset value comprises:
taking the sum of the first target offset value and the second target offset value as the position offset value of the data to be queried;
and inquiring the data to be inquired from the preset data set according to the position offset value.
11. A data querying device, the device comprising:
the acquisition module is configured to acquire a data sequence number of data to be queried in a preset data set, wherein the preset data set comprises a plurality of data which are sequentially arranged;
a first determining module configured to determine a first target offset value according to the data sequence number through a first index table; each first index in the first index table corresponds to each pre-divided data interval in the preset data set one by one, the first index corresponds to a first offset value, the first offset value is an offset of a storage address of the data interval corresponding to the first index relative to a starting storage address of the preset data set, and the first target offset value is a first offset value corresponding to a target data interval where the data to be queried is located;
a second determining module configured to determine a second target offset value according to the data sequence number through a second index table; the second index table comprises the data size of each datum in the preset data set, and the second target offset value is the sum of the data sizes of the data before the data to be queried in the target data interval;
And the query module is configured to query the data to be queried from the preset data set according to the first target offset value and the second target offset value.
12. The apparatus of claim 11, wherein the first determination module is configured to obtain the first index table by:
segmenting a first number of preset indexes in a preset index set according to the number of preset segments to obtain a second number of index segments; each data corresponds to one preset index, the preset index corresponds to a preset offset value, and the preset offset value is the offset of a storage address of the data corresponding to the preset index relative to the initial storage address; each index segment comprises a preset number of preset indexes of the preset segments and corresponds to one data interval;
and taking a first preset index in each index segment as the first index to obtain the first index table.
13. The apparatus of claim 12, wherein the first determining module comprises:
a first calculation sub-module configured to calculate a ratio of the data sequence number to the preset number of segments;
A first determination submodule configured to determine the target data interval from a plurality of the data intervals according to the ratio;
the first determining submodule is further configured to determine a target index corresponding to the target data interval from a plurality of first indexes through the first index table, and take a first offset value corresponding to the target index as the first target offset value.
14. The apparatus of claim 13, wherein the first determination submodule is configured to:
if the ratio is an integer, taking the ratio as a target sequence, and selecting a data interval with the sequence of the target sequence from a plurality of data intervals as the target data interval;
if the ratio is not an integer, the ratio is rounded up and then used as the target sequence, and a data interval with the sequence of the target sequence is selected from a plurality of data intervals to be used as the target data interval.
15. The apparatus of claim 12, wherein the second determining module comprises:
a second calculation sub-module configured to calculate a remainder of the data sequence number divided by the preset number of segments;
A second determining submodule configured to determine a target position of the data to be queried in the target data interval according to the remainder;
the second determining submodule is further configured to acquire a sum value of data sizes of data located before the target position in the target data section, and take the sum value as the second target offset value.
16. The apparatus of claim 11, wherein the first determination module is configured to obtain the first index table by:
segmenting a first number of preset indexes in a preset index set according to a plurality of preset segmentation numbers which are sequentially arranged to obtain a third number of index segments; each data corresponds to one preset index, the preset index corresponds to a preset offset value, each index section corresponds to one preset segmentation number and corresponds to one data interval, and each index section comprises the preset indexes of the preset segmentation number corresponding to the index section;
and taking a first preset index in each index segment as the first index to obtain the first index table.
17. The apparatus of claim 16, wherein the first determining module comprises:
A third calculation sub-module configured to determine the target data interval according to the data sequence number and the data quantity included in each data interval;
and the third determining submodule is configured to determine a target index corresponding to the target data interval from a plurality of first indexes through the first index table, and takes a first offset value corresponding to the target index as the first target offset value.
18. The apparatus of claim 16, wherein the second determining module comprises:
a fourth calculation sub-module configured to determine a target position of the data to be queried in the target data interval according to the data sequence number and the data quantity included in each data interval;
and a fourth determining submodule configured to acquire a sum value of data sizes of data located before the target position in the target data section, and take the sum value as the second target offset value.
19. The apparatus of claim 12, wherein the second determination module is configured to obtain the second index table by:
and for each data, taking the data size of the data as a second index corresponding to the data, and replacing a preset index corresponding to the data in the preset index set by using the second index corresponding to the data to obtain the second index table.
20. The apparatus of claim 11, wherein the query module comprises:
a fifth determining submodule configured to take a sum of the first target offset value and the second target offset value as a position offset value of the data to be queried;
and the inquiring sub-module is configured to inquire the data to be inquired from the preset data set according to the position offset value.
21. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the steps of the method of any of claims 1-10.
22. A computer readable storage medium having stored thereon computer program instructions, which when executed by a processor, implement the steps of the method of any of claims 1-10.
CN202110473531.2A 2021-04-29 2021-04-29 Data query method and device, electronic equipment and storage medium Active CN113157703B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110473531.2A CN113157703B (en) 2021-04-29 2021-04-29 Data query method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110473531.2A CN113157703B (en) 2021-04-29 2021-04-29 Data query method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113157703A CN113157703A (en) 2021-07-23
CN113157703B true CN113157703B (en) 2023-11-21

Family

ID=76872284

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110473531.2A Active CN113157703B (en) 2021-04-29 2021-04-29 Data query method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113157703B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6865577B1 (en) * 2000-11-06 2005-03-08 At&T Corp. Method and system for efficiently retrieving information from a database
WO2015007187A1 (en) * 2013-07-18 2015-01-22 Tencent Technology (Shenzhen) Company Limited Method, device and storage medium for providing data statistics
CN108255958A (en) * 2017-12-21 2018-07-06 百度在线网络技术(北京)有限公司 Data query method, apparatus and storage medium
CN112364014A (en) * 2020-10-26 2021-02-12 北京达佳互联信息技术有限公司 Data query method, device, server and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6865577B1 (en) * 2000-11-06 2005-03-08 At&T Corp. Method and system for efficiently retrieving information from a database
WO2015007187A1 (en) * 2013-07-18 2015-01-22 Tencent Technology (Shenzhen) Company Limited Method, device and storage medium for providing data statistics
CN108255958A (en) * 2017-12-21 2018-07-06 百度在线网络技术(北京)有限公司 Data query method, apparatus and storage medium
CN112364014A (en) * 2020-10-26 2021-02-12 北京达佳互联信息技术有限公司 Data query method, device, server and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
云数据的划分存储和查询研究;邵秀丽;耿梅洁;孟凤娇;王志刚;;南开大学学报(自然科学版)(03);全文 *
基于实时数据和历史查询分布的时空索引新方法;孟学潮;叶少珍;;计算机应用(03);全文 *

Also Published As

Publication number Publication date
CN113157703A (en) 2021-07-23

Similar Documents

Publication Publication Date Title
CN105653276A (en) Method and apparatus for language setting
CN106919629B (en) Method and device for realizing information screening in group chat
US11388652B2 (en) Method and apparatus for indicating position of cell-defining synchronization signal block and searching for the same, and base station
CN105376412A (en) Information processing method and device
CN107943317B (en) Input method and device
CN107402767B (en) Method and device for displaying push message
CN107608714B (en) Byte alignment method, device and computer readable storage medium
CN104951522B (en) Method and device for searching
CN113920293A (en) Information identification method and device, electronic equipment and storage medium
CN108241438B (en) Input method, input device and input device
CN106447747B (en) Image processing method and device
CN115512116B (en) Image segmentation model optimization method and device, electronic equipment and readable storage medium
CN110147426B (en) Method for determining classification label of query text and related device
CN113157703B (en) Data query method and device, electronic equipment and storage medium
CN112988822B (en) Data query method, device, equipment, readable storage medium and product
CN106851418B (en) Video recommendation method and device
CN104317480B (en) Character keys display methods, device and terminal
CN111241097B (en) Method for processing object, device for processing object and storage medium
CN113761275A (en) Video preview moving picture generation method, device and equipment and readable storage medium
CN110019657B (en) Processing method, apparatus and machine-readable medium
CN109710146B (en) Document display method and device
CN113191792B (en) Task processing method, device, electronic equipment, storage medium and program product
CN112182027B (en) Information query method, device, electronic equipment and storage medium
CN111949139B (en) Input method and device
CN111752397B (en) Candidate word determining method and device

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