CN117149709A - Query method and device for image file, electronic equipment and storage medium - Google Patents

Query method and device for image file, electronic equipment and storage medium Download PDF

Info

Publication number
CN117149709A
CN117149709A CN202311412922.9A CN202311412922A CN117149709A CN 117149709 A CN117149709 A CN 117149709A CN 202311412922 A CN202311412922 A CN 202311412922A CN 117149709 A CN117149709 A CN 117149709A
Authority
CN
China
Prior art keywords
index
query
image file
identifier
target
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.)
Granted
Application number
CN202311412922.9A
Other languages
Chinese (zh)
Other versions
CN117149709B (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.)
Taiping Finance Technology Services Shanghai Co ltd
Original Assignee
Taiping Finance Technology Services Shanghai 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 Taiping Finance Technology Services Shanghai Co ltd filed Critical Taiping Finance Technology Services Shanghai Co ltd
Priority to CN202311412922.9A priority Critical patent/CN117149709B/en
Publication of CN117149709A publication Critical patent/CN117149709A/en
Application granted granted Critical
Publication of CN117149709B publication Critical patent/CN117149709B/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/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/14Details of searching files based on file metadata
    • G06F16/148File search processing
    • 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)
  • Library & Information Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a query method and device for image files, electronic equipment and a storage medium. The method comprises the following steps: acquiring a query identifier of an image file to be queried, and serializing the query identifier into a retrieval number string; searching the retrieval digit string in the pre-established index library dynamic routing information; if the search digit string falls into the index digit string range of the target index library, searching the query identifier in the target index library to obtain a target image file storage address matched with the query identifier; and acquiring a target image file matched with the target image file storage address, and taking the target image file as a feedback result of the query identifier. The technical scheme of the embodiment of the invention can greatly improve the query performance of the image system, reduce the query response time, effectively reduce the expenditure of the ES database on the query thread pool and the query queue, and ensure the high availability of the whole image system.

Description

Query method and device for image file, electronic equipment and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and apparatus for querying an image file, an electronic device, and a storage medium.
Background
With the rise of internet web2.0 websites, the non-relational database has been developed very rapidly due to its own characteristics. The generation of the non-relational database aims to solve the challenges caused by multiple data types of a large-scale data set, and particularly the difficult problem of large-data application. The data has no relation, so the expansion is very easy. Intangible space also brings about scalability at the architectural level. The Elastic Search (ES) database is used as the most popular open source non-relational database, and has the characteristics of large data volume, high performance and easy expansion.
Currently, the mainstream image system is constructed based on an ES database, and the image system is mainly used for storing image files uploaded by an external system, and feeding back corresponding image files in response to a query request of the external system. After uploading the image file to the image system, the external system can save the query identifier returned by the image system, and then can query the uploaded image file in the image system based on the query identifier.
The inventors have found that the following drawbacks exist in the prior art in the process of implementing the present invention: because only the query identifier of the image file is stored when the external system is in butt joint with the image system, the image system needs to query in all index libraries of the image system after receiving the query request containing the query identifier. The full-library query mode has low query efficiency and long response time, and can occupy a large amount of query thread pools and query queues of the ES database. Particularly, under the condition that the external system has high concurrent query requests, the query queue of the ES database may be occupied, the newly entered query request is refused, and the condition that the data is not queried occurs.
Disclosure of Invention
The embodiment of the invention provides a query method, a query device, electronic equipment and a storage medium for image files, which are used for improving the query performance of the image files and ensuring the high availability of an image system.
According to an aspect of the embodiment of the present invention, there is provided a query method for an image file, including:
acquiring a query identifier of an image file to be queried, and serializing the query identifier into a retrieval number string;
inquiring the retrieval digit string in the pre-established index library dynamic routing information;
the index library dynamic routing information stores a mapping relation between an index library and an index number string range, and the index library stores a mapping relation between an index identifier and an image file storage address;
if the search number string falls into the index number string range of the target index library, searching the query identifier in the target index library to obtain a target image file storage address matched with the query identifier;
and acquiring a target image file matched with the target image file storage address, and taking the target image file as a feedback result of the query identifier.
According to another aspect of the embodiment of the present invention, there is also provided an image file query apparatus, including:
the serialization module is used for acquiring the query identification of the image file to be queried and serializing the query identification into a retrieval digital string;
the digital string inquiry module is used for inquiring the retrieval digital string in the pre-established dynamic routing information of the index library;
the index library dynamic routing information stores a mapping relation between an index library and an index number string range, and the index library stores a mapping relation between an index identifier and an image file storage address;
the storage address acquisition module is used for searching the query identifier in the target index library to acquire a target image file storage address matched with the query identifier if the search number string falls into the index number string range of the target index library;
and the result feedback module is used for acquiring a target image file matched with the target image file storage address and taking the target image file as a feedback result of the query identifier.
According to another aspect of the embodiment of the present invention, there is also provided an electronic device including:
At least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the method for querying an image file according to any of the embodiments of the present invention.
According to another aspect of the embodiments of the present invention, there is further provided a computer readable storage medium storing computer instructions for implementing the method for querying an image file according to any of the embodiments of the present invention when executed by a processor.
According to the technical scheme, the query identification of the image file to be queried is obtained, and the query identification is serialized into the retrieval digital string; inquiring the retrieval digit string in the pre-established index library dynamic routing information; if the search number string falls into the index number string range of the target index library, searching the query identifier in the target index library to obtain a target image file storage address matched with the query identifier; the method comprises the steps of obtaining a target image file matched with the storage address of the target image file, using the target image file as a feedback result of the query identifier, and rapidly positioning an index library to which the query identifier belongs through simple data string range comparison, so that the image file matched with the query identifier can be efficiently and rapidly positioned. The technical scheme of the embodiment of the invention can greatly improve the query performance of the image system, reduce the query response time, effectively reduce the expenditure of the ES database on the query thread pool and the query queue, and ensure the high availability of the whole image system.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for querying an image file according to a first embodiment of the present invention;
FIG. 2 is a flowchart of a method for querying an image file according to a second embodiment of the present invention;
FIG. 3 is a schematic diagram of an index number string range for constructing an index library, to which the technical solution of the embodiment of the present invention is applicable;
FIG. 4 is a flowchart of a method for querying an image file according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of an image file query device according to a fourth embodiment of the present invention;
Fig. 6 is a schematic structural diagram of an electronic device for implementing a query method of an image file according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In order to facilitate understanding of the implementation of the embodiments of the present invention, the main inventive concepts of the embodiments of the present invention will be briefly described.
Firstly, the image system of each embodiment of the invention is used for storing each image file uploaded by the external system, and feeding back the stored image file matched with the query request in response to the query request of the external system. One or more users in the external system can upload the image files to be stored to the image system in advance, and the image system feeds back the file Identification (ID) matched with the image files to the external system after finishing storing the image files. The file identifier is used for uniquely identifying the image file matched with the file identifier. Correspondingly, when a user in the external system wants to inquire and acquire a stored image file A again from the image system, the file identifier corresponding to the image file A can be used as an inquiry identifier, and an inquiry request is constructed based on the inquiry identifier and sent to the image system so as to request to acquire the image file A from the image system.
Meanwhile, in order to facilitate the external system to quickly index the queried image files, one or more index libraries (generally a plurality of index libraries) are pre-established in the image system. In each index repository, a plurality of index identities (i.e., file identities previously generated for locally stored video files) are stored, along with a video file storage address that matches the index identity. Therefore, when searching for the image file based on the query identifier, the image file does not need to be really searched for in a matching way, and only the index identifier stored in each index library is needed to be searched for. The way to construct one or more index libraries may be: the upper limit value of the number of index identifications included in each index library is preset, for example, 100 or 1000, and the upper limit value of the number can be dynamically determined according to the actual software and hardware retrieval performance of the image system or the actual application scene. And each time a new image file uploaded by the external system is received, the file identification of the new image file can be used as an index identification and additionally stored in an index library. Each time the index identifier stored in one index library reaches the upper limit of the number of index identifiers stored in the index library, a new index library can be established to continue with the additional storage of the index identifiers.
However, in the searching mode in the prior art, the full-quantity searching of index identification is required to be carried out in all index libraries, and the searching efficiency is extremely low. Based on this, the inventor creatively proposes an implementation manner of establishing an index number string range for each index library, and establishes an index number string range matched with all index identifications stored in one index library based on the all index identifications. That is, all index identifiers included in one index library fall within the range of index numeric strings corresponding to the index library after the serialization process. At this time, when a query identifier needs to be searched, it can be determined which index number string range of the index library the query identifier specifically falls into first, and then the search of all index libraries is not needed, and only the index library in which the query identifier falls is searched, which can greatly improve the query performance of the image system and reduce the query response time.
Example 1
Fig. 1 is a flowchart of an image file query method according to an embodiment of the present invention, which is applicable to a case of quickly querying an image file in an image system constructed based on an ES database. The method can be performed by a query device for image files, which can be implemented in hardware and/or software, and is generally configured in an image system. As shown in fig. 1, the method includes:
S110, acquiring a query identifier of the image file to be queried, and serializing the query identifier into a retrieval number string.
As described above, the obtaining the query identifier of the image file to be queried may be: responding to an image file query request sent by an external system, and extracting a query identifier of an image file to be queried from the image file query request.
The query identifier is a file identifier automatically generated by the image system aiming at the image file to be queried when the external system uploads the image file to be queried to the image system for storage. In the image system, the file identification and the storage address of the image file to be queried are stored in a correlated mode.
Generally, the query identifier may be formed by a plurality of character combinations, and the data form of the characters may include letters, numbers and special symbols (for example, "_" or "%"), so that, to achieve the effect described in the gist of the invention, the query identifier needs to be first converted into a pure digital form to perform subsequent comparison and judgment, that is, the query identifier is serialized into a search number string.
Wherein the way in which the query identity is serialized into a search string of digits should be consistent with the way in which the range of index strings is generated for each index base. Typically, the serialization manner may be hash calculation, ASCII code calculation, calculation according to a set mapping relationship, or the like, which is not limited in this embodiment.
Further, the method of serializing the query identifier into the search string may be a method of serializing all the characters in the query identifier, or a method of serializing only the characters with the number of bits set in the query identifier (the first N bits, N >2; the odd bits or even bits, etc.), which is not limited in this embodiment.
S120, inquiring the retrieval digit string in the pre-established index library dynamic routing information.
The index library dynamic routing information stores the mapping relation between the index library and the index number string range, and the index library stores the mapping relation between the index identifier and the image file storage address.
As previously described, a plurality of index identities (i.e., file identities previously generated for locally stored video files) and video file storage addresses matching the index identities are stored in each index library. Because the file identifiers are dynamically updated along with the storage of the image file, in general, a certain character arrangement rule is presented between the sequentially generated file identifiers, for example, two adjacently generated file identifiers may be: ABC001 and ABC002. Further, there is generally a certain character difference between the file identifications stored in different index libraries, for example, each file identification stored in index library a starts with "ABCa", and each file identification stored in index library B starts with "ABCb", etc.
Further, by using character features identified by the respective indexes stored in each index base, an index numeric string range corresponding to each index base can be generated. The left value in the range of the index number string can be obtained by serializing according to the first index identification in the index library, and the right value in the index number string can be obtained by serializing according to the last index identification in the index library. And because the generation of the file identification accords with a certain character arrangement rule, the index number string ranges corresponding to each index library respectively generally have no overlapping condition or less overlapping condition.
Similarly, the index number string range may be obtained by serializing all the characters included in the index identifier, or may be obtained by serializing only the characters with a set number of bits in the index identifier, which is not limited in this embodiment.
In this embodiment, after the index number string ranges corresponding to each index library in the image system are generated, the mapping relationship between the index library and the matched index number string may be stored in the index library dynamic routing information, so as to further improve the retrieval speed of the index library.
S130, if the search number string falls into the index number string range of the target index library, searching the query identifier in the target index library to obtain a target image file storage address matched with the query identifier.
In this embodiment, by matching the index number string of the image file to be queried with the index number string range of each index library included in the index library dynamic routing information, it can be quickly determined which index library (i.e., the target index library) the index number string specifically falls within. Through the arrangement, the index library which does not need to be compared can be rapidly and accurately eliminated, and the technical effect of improving the query performance is achieved.
After the target index library is quickly positioned, the query identifier can be further searched in the target index library to obtain a target image file storage address matched with the query identifier.
Of course, because various abnormal situations occur, for example, the update speed of the index number string range of the index library is not timely, and the time interval from uploading to searching again of an image file is small, or the situation that the file identifier generates an abnormality may occur, and the situation that the index number string does not fall into the index number string range of any index library may occur, at this time, the query identifier may be searched in all index libraries, or the query identifier may be searched in one or more index libraries that are newly generated, which is used as a spam searching policy in the technical scheme of the present invention.
Of course, it can be understood that if the target image file storage addresses matched with the query identifier are not obtained by searching all the index libraries, a query failure response can be generated as a feedback result of the query identifier.
S140, acquiring a target image file matched with the target image file storage address, and taking the target image file as a feedback result of the query identifier.
In this embodiment, after the target image file storage address is found, the image file to be queried, that is, the target image file, stored in advance may be obtained from the target image file storage address. Furthermore, the target image file can be provided to an external system as a feedback result of the query identifier.
According to the technical scheme, the query identification of the image file to be queried is obtained, and the query identification is serialized into the retrieval digital string; inquiring the retrieval digit string in the pre-established index library dynamic routing information; if the search number string falls into the index number string range of the target index library, searching the query identifier in the target index library to obtain a target image file storage address matched with the query identifier; the method comprises the steps of obtaining a target image file matched with the storage address of the target image file, using the target image file as a feedback result of the query identifier, and rapidly positioning an index library to which the query identifier belongs through simple data string range comparison, so that the image file matched with the query identifier can be efficiently and rapidly positioned. The technical scheme of the embodiment of the invention can greatly improve the query performance of the image system, reduce the query response time, effectively reduce the expenditure of the ES database on the query thread pool and the query queue, and ensure the high availability of the whole image system.
On the basis of the above embodiments, the method may further include:
each time the updating condition of the dynamic routing information of the index library is met, at least one updated index library to be updated currently is obtained;
acquiring a target identification bit number matched with the at least one updated index library, and generating an index number string range corresponding to each updated index library according to the target identification bit number;
and updating the dynamic routing information of the index library according to the index number string ranges respectively corresponding to the updating index libraries.
In this alternative embodiment, it is considered that the image file is uploaded to the image system in real time for storage, and further, the index library and the index number string range of the index library need to be dynamically updated, and further, dynamic routing information of the index library needs to be dynamically updated. Accordingly, the above-described update process may be implemented whenever the update condition of the index library dynamic routing information is satisfied.
The update condition of the dynamic routing information of the index library may be preset according to the actual situation, for example, when a preset timing update time (every hour, every half day, every day, etc.) is reached, or when a set number (for example, 100 or 1000, etc.) of image files are newly stored, it is determined that the update condition of the dynamic routing information of the index library is satisfied.
The updating of the index library can be understood as an index library in which the stored file identifier is changed after the dynamic routing information of the index library is updated last time, and a newly established index library.
The target identification bit number may be preset according to a character arrangement rule of each index identification in the index library stored in the history, for example, 4 bits, 5 bits, or 6 bits, or may be set in real time according to a character arrangement rule of each index identification in the update index library newly generated at present, which is not limited in this embodiment.
In the optional implementation manner, the query performance of the image system can be further optimized and the query success rate can be improved by reasonably setting the update condition of the dynamic routing information of the index library and the target identification bit number.
Example two
Fig. 2 is a flowchart of a query method for image files according to a second embodiment of the present invention, which is optimized based on the above embodiments. In this embodiment, the updating process of the dynamic routing information of the index library is specifically refined.
Accordingly, as shown in fig. 2, the method includes:
s210, each time the updating condition of the dynamic routing information of the index library is met, at least one updated index library to be updated currently is obtained.
S220, acquiring adjacent first index libraries and second index libraries from all the updated index libraries.
In this embodiment, in view of the rule of generating the index libraries, the first index library and the second index library that are adjacent to each other may be sequentially acquired and processed after each index library is ordered according to the generation time.
In a specific example, if the updated index library sequentially generated according to the time sequence includes an index library W, an index library X, an index library Y, and an index library Z, two adjacent index libraries are respectively: index library W and index library X, index library X and index library Y, and index library Y and index library Z.
S230, acquiring a target last-bit identification identifier of the first index library and a target first-bit identification identifier of the second index library.
In this embodiment, considering that each index identifier stored in each index library conforms to a certain character distribution rule, in order to dynamically distinguish the index numeric string range between every two adjacent first index libraries and second index libraries, it is necessary to dynamically determine the character distribution difference between the index identifiers stored in the first index libraries and the second index libraries.
Correspondingly, in order to compare the character distribution differences, only the character differences between the target last identification mark of the first index library and the target first identification mark of the second index library need to be compared.
The target last identification of the first index library may be understood as the last index identification stored in the first index library, and the target first identification of the second index library may be understood as the first index identification stored in the second index library.
S240, calculating the appearance position of the first different character between the target last-bit identification mark and the target first-bit identification mark, and determining the distinguishable identification bit number according to the appearance position.
In this embodiment, in order to most efficiently distinguish the range of index number strings between different index libraries, it is only necessary to find the position where the first distinct character appears between the index identifiers of two adjacent index libraries, and perform serialization processing based on the position.
In one specific example, the target last identification of the first index library is identified as abca025—4650u and the target first identification of the second index library is identified as ABCsdfr34718. The appearance position of the first distinct character between the target last-bit identification mark and the target first-bit identification mark can be directly determined to be the fourth bit, and further, the distinguishable identification bit number corresponding to the first index library and the second index library can be determined to be 4. In other words, the first 4 bits of the index identifiers in the two index libraries are used to generate the index number string range, so that the index identifiers falling into the two index libraries can be effectively distinguished.
S250, judging whether the distinguishable identification bit numbers among all adjacent index libraries are determined: if yes, executing S260; otherwise, execution returns to S220.
S260, obtaining the maximum distinguishable identification digit as the target identification digit.
S270, respectively obtaining the current first-bit identification mark and the current last-bit identification mark in each updating index library.
The current first identification mark in each update index library is the first index mark in the update index library, and the current last identification mark in each update index library is the last index mark in the update index library.
S280, intercepting a first character string of the target identification bit number in the current first bit identification mark and a second character string of the target identification bit number in the current last bit identification mark.
S290, ASCII codes of the first character string and the second character string are calculated respectively, and index number string ranges corresponding to the updated index libraries are generated according to the calculation results.
Specifically, the ASCII code of the first string may be used as the left value of the index number string range, and the ASCII code of the second string may be used as the right value of the index number string range.
And S2100, updating the dynamic routing information of the index library according to the index number string ranges respectively corresponding to the update index libraries.
Fig. 3 is a schematic diagram of an index number string range for constructing an index library, where the technical solution of the embodiment of the present invention is applicable. As shown in fig. 3, taking the example of generating the index number string range for the first four bits of each index identifier stored in the index library "bussinesstype_ 202204" and the index library "bussinesstype_ 202205", the specific generation process of the index number string range and the routing information item in the dynamic routing information of the index library is specifically described.
S2110, acquiring a query identifier of an image file to be queried, and serializing the query identifier into a retrieval number string.
S2120, inquiring the search digit string in the pre-established index library dynamic routing information.
The index library dynamic routing information stores the mapping relation between the index library and the index number string range, and the index library stores the mapping relation between the index identifier and the image file storage address.
S2130, if the search digit string falls into the index digit string range of the target index library, searching the query identifier in the target index library to obtain a target image file storage address matched with the query identifier.
S2140, a target image file matched with the target image file storage address is obtained, and the target image file is used as a feedback result of the query identifier.
According to the technical scheme, the query identification of the image file to be queried is obtained, and the query identification is serialized into the retrieval digital string; inquiring the retrieval digit string in the pre-established index library dynamic routing information; if the search number string falls into the index number string range of the target index library, searching the query identifier in the target index library to obtain a target image file storage address matched with the query identifier; the method comprises the steps of obtaining a target image file matched with the storage address of the target image file, using the target image file as a feedback result of the query identifier, and rapidly positioning an index library to which the query identifier belongs through simple data string range comparison, so that the image file matched with the query identifier can be efficiently and rapidly positioned. The technical scheme of the embodiment of the invention can greatly improve the query performance of the image system, reduce the query response time, effectively reduce the expenditure of the ES database on the query thread pool and the query queue, and ensure the high availability of the whole image system.
Example III
Fig. 4 is a flowchart of a query method for image files according to a third embodiment of the present invention, which is optimized based on the above embodiments. In this embodiment, the judgment branches included in the foregoing embodiments of the present invention are completed specifically.
Accordingly, as illustrated in fig. 4, the method may specifically include:
s410, acquiring a query identifier of the image file to be queried.
S420, judging whether an index library identifier matched with the query identifier is added in the query identifier: if yes, executing S430; otherwise, S440 is performed.
In this embodiment, in order to further increase the query speed of the image file, the index library may be queried for a certain query identifier, the index library stored by the query identifier is determined, and after determining the image file storage address of the image file to be queried that matches the query identifier in the index library, the identification information of the index library stored by the query identifier is fed back to the external system as an additional information in the query identifier. And then, when the external system queries the image file again aiming at the same query identifier, the corresponding index base identifier can be directly extracted from the query identifier, and the query identifier is searched in an index base matched with the index base identifier.
Accordingly, in this optional embodiment, after obtaining the query identifier of the image file to be queried, it may first detect whether an index library identifier is added in the query identifier. If the index base identifier is added, the current secondary or tertiary query of the query identifier is described, at this time, the query can be directly performed based on the index base identifier, and if the index base identifier is not added, the current first query of the query identifier is described, at this time, the index base to which the query identifier belongs needs to be determined through the implementation manner of the foregoing embodiments.
S430, searching the query identifier in an index library matched with the index library identifier, acquiring a target image file storage address matched with the query identifier, and executing S450.
S440, the query identification is serialized into a retrieval number string, and S460 is executed.
S450, obtaining a target image file matched with the target image file storage address, and taking the target image file as a feedback result of the query identifier.
S460, inquiring the retrieval digital string in the pre-established dynamic routing information of the index library, and executing S470 when the retrieval digital string falls into the index digital string range of the target index library; when the search digit string does not fall within the index digit string range of any index base, S480 is performed.
And S470, searching the query identifier in the target index library, acquiring a target image file storage address matched with the query identifier, and executing S490.
S480, searching the query identifications in all index libraries respectively, and generating feedback results matched with the query identifications according to the searching results.
In this embodiment, when the search number string does not fall within the index number string range of any index library, the query identifier needs to be searched in all the index libraries respectively. If the index library to which the query identifier belongs is found, the target image file storage address matched with the query identifier can be obtained in the found index library, then the target image file matched with the target image file storage address is obtained, and the target image file is used as a feedback result of the query identifier. And then, the index library identification of the target index library can be used as auxiliary query information to be added in the query identification, so as to obtain an updated query identification, and the updated query identification is fed back.
If the index base to which the query identifier belongs is not found, response information of the search failure can be generated as a feedback result of the query identifier.
S490, obtaining a target image file matched with the target image file storage address, and executing S4100 by taking the target image file as a feedback result of the query identifier.
S4100, adding an index library identifier of a target index library as auxiliary query information into the query identifier to obtain an updated query identifier, and feeding back the updated query identifier.
According to the technical scheme, after the query identifier of the image file to be queried is obtained, whether the index library identifier matched with the query identifier is added in the query identifier is judged, when the index library identifier matched with the query identifier is added in the query identifier, the query identifier is searched in the index library matched with the index library identifier, the target image file storage address matched with the query identifier is obtained, the target image file matched with the target image file storage address is obtained, and the target image file is used as a feedback result of the query identifier, so that the query speed of the image file can be further accelerated, the query performance of an image system is further improved, and the query response time is further reduced.
Example IV
Fig. 5 is a schematic structural diagram of an image file query device according to a fourth embodiment of the present invention. As shown in fig. 5, the apparatus includes: a serialization module 510, a numeric string query module 520, a storage address acquisition module 530, and a result feedback module 540. Wherein:
the serialization module 510 is configured to obtain a query identifier of an image file to be queried, and serialize the query identifier into a retrieval number string.
The number string query module 520 is configured to query the search number string in the pre-established dynamic routing information of the index base.
The index library dynamic routing information stores the mapping relation between the index library and the index number string range, and the index library stores the mapping relation between the index identifier and the image file storage address.
And the storage address obtaining module 530 is configured to search the query identifier in the target index library if the search number string falls within the index number string range of the target index library, and obtain a target image file storage address matched with the query identifier.
And the result feedback module 540 is configured to obtain a target image file that matches the target image file storage address, and take the target image file as a feedback result of the query identifier.
According to the technical scheme, the query identification of the image file to be queried is obtained, and the query identification is serialized into the retrieval digital string; inquiring the retrieval digit string in the pre-established index library dynamic routing information; if the search number string falls into the index number string range of the target index library, searching the query identifier in the target index library to obtain a target image file storage address matched with the query identifier; the method comprises the steps of obtaining a target image file matched with the storage address of the target image file, using the target image file as a feedback result of the query identifier, and rapidly positioning an index library to which the query identifier belongs through simple data string range comparison, so that the image file matched with the query identifier can be efficiently and rapidly positioned. The technical scheme of the embodiment of the invention can greatly improve the query performance of the image system, reduce the query response time, effectively reduce the expenditure of the ES database on the query thread pool and the query queue, and ensure the high availability of the whole image system.
On the basis of the above embodiments, the method further comprises:
An update index library obtaining unit, configured to obtain at least one update index library to be updated currently whenever an update condition of the index library dynamic routing information is satisfied;
the index number string range generation unit is used for acquiring a target identification bit number matched with the at least one updated index library and generating index number string ranges respectively corresponding to the updated index libraries according to the target identification bit number;
and the dynamic routing information updating unit is used for updating the dynamic routing information of the index library according to the index number string ranges respectively corresponding to the updating index libraries.
On the basis of the above embodiments, the index numeric string range generation unit may be specifically configured to:
acquiring adjacent first index libraries and second index libraries from all the updated index libraries;
acquiring a target last-bit identification identifier of the first index library and a target first-bit identification identifier of the second index library;
calculating the appearance position of a first different character between the target last-bit identification mark and the target first-bit identification mark, and determining the distinguishable identification digit according to the appearance position;
returning to execute the operation of acquiring the adjacent first index library and the second index library in all the updated index libraries until the distinguishable identification digits among all the adjacent index libraries are determined;
And obtaining the maximum distinguishable identification bit number as the target identification bit number.
On the basis of the above embodiments, the index numeric string range generation unit may be further specifically configured to:
respectively acquiring a current first-bit identification mark and a current last-bit identification mark from each updated index library, and intercepting a first character string of a target identification bit number in the current first-bit identification mark and a second character string of the target identification bit number in the current last-bit identification mark;
and respectively calculating ASCII codes of the first character string and the second character string, and generating index number string ranges respectively corresponding to the updated index libraries according to calculation results.
Based on the above embodiments, the serialization module 510 may be specifically configured to:
acquiring a query identifier of an image file to be queried, and serializing the query identifier into a retrieval number string when determining that an index library identifier matched with the query identifier is not added in the query identifier;
accordingly, the apparatus may further include: a query identifier updating module, configured to:
and after the target image file is used as a feedback result of the query identifier, the index library identifier of the target index library is used as auxiliary query information to be added into the query identifier, so that an updated query identifier is obtained, and the updated query identifier is fed back.
On the basis of the above embodiments, the method may further include: the simple searching module is used for:
after obtaining a query identifier of an image file to be queried, when an index base identifier matched with the query identifier is added in the query identifier, searching the query identifier in an index base matched with the index base identifier to obtain a target image file storage address matched with the query identifier;
and acquiring a target image file matched with the target image file storage address, and taking the target image file as a feedback result of the query identifier.
Based on the above embodiments, the method may further include a full index library searching module, configured to:
and after inquiring the search digit string in the pre-established index library dynamic routing information, if the search digit string does not fall into the index digit string range of any index library, searching the inquiry identifications in all index libraries respectively, and generating a feedback result matched with the inquiry identifications according to the searching result.
The query device for the image file provided by the embodiment of the invention can execute the query method for the image file provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example five
Fig. 6 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 6, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as the query method for image files described in the various embodiments of the present invention.
Namely: acquiring a query identifier of an image file to be queried, and serializing the query identifier into a retrieval number string; inquiring the retrieval digit string in the pre-established index library dynamic routing information; the index library dynamic routing information stores a mapping relation between an index library and an index number string range, and the index library stores a mapping relation between an index identifier and an image file storage address; if the search number string falls into the index number string range of the target index library, searching the query identifier in the target index library to obtain a target image file storage address matched with the query identifier; and acquiring a target image file matched with the target image file storage address, and taking the target image file as a feedback result of the query identifier.
In some embodiments, the image file querying method according to the embodiments of the present invention may be implemented as a computer program, which is tangibly embodied on a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the image file querying method described above according to the embodiments of the present invention may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the image file querying method according to embodiments of the present invention in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. The query method of the image file is characterized by comprising the following steps:
acquiring a query identifier of an image file to be queried, and serializing the query identifier into a retrieval number string;
inquiring the retrieval digit string in the pre-established index library dynamic routing information;
the index library dynamic routing information stores a mapping relation between an index library and an index number string range, and the index library stores a mapping relation between an index identifier and an image file storage address;
if the search number string falls into the index number string range of the target index library, searching the query identifier in the target index library to obtain a target image file storage address matched with the query identifier;
and acquiring a target image file matched with the target image file storage address, and taking the target image file as a feedback result of the query identifier.
2. The method as recited in claim 1, further comprising:
each time the updating condition of the dynamic routing information of the index library is met, at least one updated index library to be updated currently is obtained;
acquiring a target identification bit number matched with the at least one updated index library, and generating an index number string range corresponding to each updated index library according to the target identification bit number;
And updating the dynamic routing information of the index library according to the index number string ranges respectively corresponding to the updating index libraries.
3. The method of claim 2, wherein obtaining the number of target identification bits matching the at least one updated index store comprises:
acquiring adjacent first index libraries and second index libraries from all the updated index libraries;
acquiring a target last-bit identification identifier of the first index library and a target first-bit identification identifier of the second index library;
calculating the appearance position of a first different character between the target last-bit identification mark and the target first-bit identification mark, and determining the distinguishable identification digit according to the appearance position;
returning to execute the operation of acquiring the adjacent first index library and the second index library in all the updated index libraries until the distinguishable identification digits among all the adjacent index libraries are determined;
and obtaining the maximum distinguishable identification bit number as the target identification bit number.
4. The method of claim 2, wherein generating an index number string range corresponding to each of the updated index libraries, respectively, based on the target identification number of bits, comprises:
Respectively acquiring a current first-bit identification mark and a current last-bit identification mark from each updated index library, and intercepting a first character string of a target identification bit number in the current first-bit identification mark and a second character string of the target identification bit number in the current last-bit identification mark;
and respectively calculating ASCII codes of the first character string and the second character string, and generating index number string ranges respectively corresponding to the updated index libraries according to calculation results.
5. The method according to any one of claims 1-4, wherein obtaining a query identifier of an image file to be queried and serializing the query identifier into a search string of digits, comprises:
acquiring a query identifier of an image file to be queried, and serializing the query identifier into a retrieval number string when determining that an index library identifier matched with the query identifier is not added in the query identifier;
after the target image file is used as the feedback result of the query identifier, the method further comprises the following steps:
and adding the index library identification of the target index library as auxiliary query information in the query identification to obtain an updated query identification, and feeding back the updated query identification.
6. The method of claim 5, further comprising, after obtaining the query identifier of the image file to be queried:
when the query identifier is determined to be added with an index library identifier matched with the query identifier, searching the query identifier in an index library matched with the index library identifier to acquire a target image file storage address matched with the query identifier;
and acquiring a target image file matched with the target image file storage address, and taking the target image file as a feedback result of the query identifier.
7. The method according to any one of claims 1-4, further comprising, after querying the search string in the pre-established index base dynamic routing information:
if the index number string does not fall into the index number string range of any index library, searching the query identifications in all index libraries respectively, and generating feedback results matched with the query identifications according to the searching results.
8. An image file query device, comprising:
the serialization module is used for acquiring the query identification of the image file to be queried and serializing the query identification into a retrieval digital string;
The digital string inquiry module is used for inquiring the retrieval digital string in the pre-established dynamic routing information of the index library;
the index library dynamic routing information stores a mapping relation between an index library and an index number string range, and the index library stores a mapping relation between an index identifier and an image file storage address;
the storage address acquisition module is used for searching the query identifier in the target index library to acquire a target image file storage address matched with the query identifier if the search number string falls into the index number string range of the target index library;
and the result feedback module is used for acquiring a target image file matched with the target image file storage address and taking the target image file as a feedback result of the query identifier.
9. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the method of querying an image file as claimed in any one of claims 1 to 7.
10. A computer readable storage medium storing computer instructions for causing a processor to perform the method of querying an image file according to any one of claims 1-7.
CN202311412922.9A 2023-10-30 2023-10-30 Query method and device for image file, electronic equipment and storage medium Active CN117149709B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311412922.9A CN117149709B (en) 2023-10-30 2023-10-30 Query method and device for image file, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311412922.9A CN117149709B (en) 2023-10-30 2023-10-30 Query method and device for image file, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117149709A true CN117149709A (en) 2023-12-01
CN117149709B CN117149709B (en) 2024-02-02

Family

ID=88884730

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311412922.9A Active CN117149709B (en) 2023-10-30 2023-10-30 Query method and device for image file, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117149709B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109582643A (en) * 2018-11-20 2019-04-05 中国石油大学(华东) A kind of real-time dynamic data management system based on HBase
CN110309334A (en) * 2018-04-20 2019-10-08 腾讯科技(深圳)有限公司 Querying method, system, computer equipment and the readable storage medium storing program for executing of chart database
US20200050586A1 (en) * 2017-07-31 2020-02-13 Splunk Inc. Query execution at a remote heterogeneous data store of a data fabric service
CN113515487A (en) * 2021-09-07 2021-10-19 联想凌拓科技有限公司 Directory query method, computing device and distributed file system
US20210382896A1 (en) * 2020-06-09 2021-12-09 Walmart Apollo, Llc High Efficiency Data Querying
US20220335086A1 (en) * 2021-04-15 2022-10-20 Vesoft Inc. Full-text indexing method and system based on graph database
CN115705313A (en) * 2021-08-11 2023-02-17 腾讯科技(深圳)有限公司 Data processing method, device, equipment and computer readable storage medium
CN116647734A (en) * 2023-05-26 2023-08-25 太平金融科技服务(上海)有限公司深圳分公司 Page display method, system, computer equipment and storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200050586A1 (en) * 2017-07-31 2020-02-13 Splunk Inc. Query execution at a remote heterogeneous data store of a data fabric service
CN110309334A (en) * 2018-04-20 2019-10-08 腾讯科技(深圳)有限公司 Querying method, system, computer equipment and the readable storage medium storing program for executing of chart database
CN109582643A (en) * 2018-11-20 2019-04-05 中国石油大学(华东) A kind of real-time dynamic data management system based on HBase
US20210382896A1 (en) * 2020-06-09 2021-12-09 Walmart Apollo, Llc High Efficiency Data Querying
US20220335086A1 (en) * 2021-04-15 2022-10-20 Vesoft Inc. Full-text indexing method and system based on graph database
CN115705313A (en) * 2021-08-11 2023-02-17 腾讯科技(深圳)有限公司 Data processing method, device, equipment and computer readable storage medium
CN113515487A (en) * 2021-09-07 2021-10-19 联想凌拓科技有限公司 Directory query method, computing device and distributed file system
CN116647734A (en) * 2023-05-26 2023-08-25 太平金融科技服务(上海)有限公司深圳分公司 Page display method, system, computer equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张浩予;: "数据库与Lucene技术整合策略", 程序员, no. 08 *

Also Published As

Publication number Publication date
CN117149709B (en) 2024-02-02

Similar Documents

Publication Publication Date Title
AU2016382908B2 (en) Short link processing method, device and server
CN108961052B (en) Verification method, storage method, device, equipment and medium of block chain data
CN112015775B (en) Tag data processing method, device, equipment and storage medium
US11347787B2 (en) Image retrieval method and apparatus, system, server, and storage medium
CN107766529B (en) Mass data storage method for sewage treatment industry
CN110427386B (en) Data processing method, device and computer storage medium
WO2016070751A1 (en) Distributed cache range querying method, device, and system
CN113568938B (en) Data stream processing method and device, electronic equipment and storage medium
CN114817651B (en) Data storage method, data query method, device and equipment
WO2016070750A1 (en) Distributed buffering range querying method, device, and system
US10691669B2 (en) Big-data processing method and apparatus
CN107562762B (en) Data index construction method and device
CN109241360B (en) Matching method and device of combined character strings and electronic equipment
CN113312539B (en) Method, device, equipment and medium for providing search service
CN110855812A (en) Positioning method, device and equipment based on IP address
CN117149709B (en) Query method and device for image file, electronic equipment and storage medium
CN111400301A (en) Data query method, device and equipment
CN113568940A (en) Data query method, device, equipment and storage medium
CN115658750A (en) Service data processing method and device, electronic equipment and storage medium
CN103366014B (en) System for cloud computing data handling system and method based on cluster
CN114706890A (en) Multi-stage data query method and device, electronic equipment and storage medium
CN113297164A (en) Database system, data query method and device
CN106156166B (en) Relation chain query system, document retrieval method, index establishment method and device
CN112948246B (en) AB test control method, device and equipment of data platform and storage medium
CN111522941A (en) Text clustering method and device, electronic equipment and computer storage medium

Legal Events

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