CN111310076B - Geographic position query method, geographic position query device, geographic position query medium and electronic equipment - Google Patents

Geographic position query method, geographic position query device, geographic position query medium and electronic equipment Download PDF

Info

Publication number
CN111310076B
CN111310076B CN202010114519.8A CN202010114519A CN111310076B CN 111310076 B CN111310076 B CN 111310076B CN 202010114519 A CN202010114519 A CN 202010114519A CN 111310076 B CN111310076 B CN 111310076B
Authority
CN
China
Prior art keywords
address
index
resident memory
memory block
query
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
CN202010114519.8A
Other languages
Chinese (zh)
Other versions
CN111310076A (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.)
Tongdun Holdings Co Ltd
Original Assignee
Tongdun Holdings 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 Tongdun Holdings Co Ltd filed Critical Tongdun Holdings Co Ltd
Priority to CN202010114519.8A priority Critical patent/CN111310076B/en
Publication of CN111310076A publication Critical patent/CN111310076A/en
Application granted granted Critical
Publication of CN111310076B publication Critical patent/CN111310076B/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/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/953Querying, e.g. by the use of web search engines
    • G06F16/9537Spatial or temporal dependent retrieval, e.g. spatiotemporal queries
    • 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/29Geographical information databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/951Indexing; Web crawling techniques

Abstract

The embodiment of the disclosure provides a geographic position query method, a geographic position query device, a computer-readable storage medium and electronic equipment, and relates to the technical field of computers, wherein the method comprises the following steps: acquiring an ip address; acquiring a resident memory block and an index in a query state in a system memory, wherein the system memory comprises two resident memory blocks, and the states of the resident memory blocks are converted between the following three states: updating, inquiring and idling, wherein the indexes comprise a primary index and a secondary index; inquiring the secondary index according to the ip address to obtain a primary index corresponding to the ip address; and inquiring the primary index according to the ip address to obtain the address offset of the geographic position data matched with the ip address. According to the technical scheme, by setting the two resident memory blocks and designing the secondary index structure, a large amount of memory can be prevented from being occupied when ip data are updated, and query efficiency is improved.

Description

Geographic position query method, geographic position query device, geographic position query medium and electronic equipment
Technical Field
The disclosure relates to the technical field of computers, and in particular relates to a geographic position query method, a geographic position query device, a computer readable storage medium and electronic equipment.
Background
With the rapid development of communication technology and the popularization of mobile internet, some lawbreakers bypass the conventional wind control system detection by using technical means such as ip address replacement, so as to perform lawless actions such as weeding and the like which damage the rights and interests of merchants.
The ip address is called an internet protocol address, and is an address of a device in a network, and the real location of the device can be queried through the ip address, for example, the location of the address of 10.10.10.10 is found to be China, zhejiang, hangzhou, the remaining Hangzhou area and xx streets. The technology of inquiring the geographic position through the ip address can be applied to the aspects of anti-fraud, network performance optimization, network security, social networking, electronic commerce targeted marketing and the like.
The traditional method for inquiring the geographic position data is to construct a binary search tree through the ip address, but the binary search tree needs to be updated because the geographic position corresponding to the ip address is changed frequently. When updating the binary search tree, a large number of objects can be generated, so that garbage collection is frequent, and the query efficiency can be reduced due to long garbage collection time and frequent garbage collection.
How to improve the efficiency of geographic location query is a technical problem that needs to be solved currently.
It should be noted that the information disclosed in the above background section is only for enhancing understanding of the background of the present disclosure and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
An embodiment of the disclosure aims to provide a geographic position query method, a geographic position query device, a computer-readable storage medium and electronic equipment, so that the efficiency of geographic position query is improved at least to a certain extent.
Other features and advantages of the present disclosure will be apparent from the following detailed description, or may be learned in part by the practice of the disclosure.
According to a first aspect of an embodiment of the present disclosure, there is provided a geographic location query method, including: acquiring an ip address; acquiring a resident memory block and an index in a query state in a system memory, wherein the system memory comprises two resident memory blocks, and the states of the resident memory blocks are converted between the following three states: updating, inquiring and idling, wherein the indexes comprise a primary index and a secondary index; inquiring the secondary index according to the ip address to obtain a primary index corresponding to the ip address; and inquiring the primary index according to the ip address to obtain the address offset of the geographic position data matched with the ip address.
In some embodiments, the method comprises: acquiring a current resident memory block in an idle state in the system memory, and setting the state of the current resident memory block as update; storing ip data into the current resident memory block, wherein the ip data comprises an ip address and geographic position data corresponding to the ip address; establishing the index for the ip data stored in the current resident memory block, wherein the index comprises a primary index and a secondary index; and setting the state of the current resident memory block as a query, and setting the state of another resident memory block in the system memory as idle.
In some embodiments, after querying the primary index from the ip address, the method further comprises: acquiring an original byte array of the geographic position data according to the address offset; and analyzing the original byte array, and returning the geographic position data corresponding to the ip address to the client.
In some embodiments, the indexing of ip data stored in the current resident memory block includes: and establishing the index for the ip data stored in the current resident memory block by adopting a B+ tree data structure.
In some embodiments, the method comprises: the size of the resident memory block is 700MB.
In some embodiments, the key of the primary index is an ip address, and the value of the primary index is an address at which the geographic location data corresponding to the ip address starts and ends in the resident memory block where the geographic location data is located.
In some embodiments, the key of the secondary index is an ip address, and the value of the secondary index is a memory address of the primary index.
In some embodiments, the storing ip data into the current resident memory block includes: storing the ip data into the current resident memory block in a byte array mode.
In some embodiments, the returning, to the client, the geographic location data corresponding to the ip address further includes: and after JSON encapsulation is carried out on the geographic position data, returning to the client.
According to a second aspect of embodiments of the present disclosure, there is provided a geographic location query device, including: an ip address acquisition unit configured to acquire an ip address; the memory acquisition unit is used for acquiring resident memory blocks and indexes in a query state in a system memory, wherein the system memory comprises two resident memory blocks, and the states of the resident memory blocks are converted between the following three states: updating, inquiring and idling, wherein the indexes comprise a primary index and a secondary index; the second-level query unit is used for querying the second-level index according to the ip address to obtain a first-level index corresponding to the ip address; and the primary query unit is used for querying the primary index according to the ip address to obtain the address offset of the geographic position data matched with the ip address.
According to a third aspect of embodiments of the present disclosure, there is provided a computer readable storage medium having stored thereon a computer program which when executed by a processor implements the geographic location query method as described in the first aspect of the above embodiments.
According to a fourth aspect of embodiments of the present disclosure, there is provided an electronic device, comprising: one or more processors; and a storage device for storing one or more programs, which when executed by the one or more processors, cause the one or more processors to implement the geographic location query method as described in the first aspect of the embodiments.
The technical scheme provided by the embodiment of the disclosure can comprise the following beneficial effects:
in the technical schemes provided by some embodiments of the present disclosure, by setting two resident memory blocks and designing a secondary index structure, it is possible to query geographic location data corresponding to an ip address without analyzing the ip data, avoiding occupying a large amount of memory when updating the ip data, and improving query efficiency.
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. It will be apparent to those of ordinary skill in the art that the drawings in the following description are merely examples of the disclosure and that other drawings may be derived from them without undue effort. In the drawings:
FIG. 1 schematically illustrates a flow chart of a geographic location query method according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a schematic diagram of a transition of a resident memory block between three states, in accordance with an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow chart of updating ip data according to an embodiment of the present disclosure;
FIG. 4 schematically illustrates a schematic diagram of a B+ tree data structure in accordance with an embodiment of the present disclosure;
FIG. 5 schematically illustrates a schematic diagram of B+ tree storage data, according to an embodiment of the present disclosure;
FIG. 6 schematically illustrates a schematic diagram of a primary retrieval structure in accordance with an embodiment of the present disclosure;
FIG. 7 schematically illustrates a schematic diagram of a secondary retrieval structure in accordance with an embodiment of the present disclosure;
FIG. 8 schematically illustrates a schematic diagram of state transitions of two resident memory blocks, in accordance with an embodiment of the present disclosure;
FIG. 9 schematically illustrates a block diagram of a geographic location querying device in accordance with one embodiment of the present disclosure;
fig. 10 schematically illustrates a block diagram of a computer system suitable for use in implementing embodiments of the present disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments may be embodied in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the disclosed aspects may be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the disclosure.
The block diagrams depicted in the figures are merely functional entities and do not necessarily correspond to physically separate entities. That is, the functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
The flow diagrams depicted in the figures are exemplary only, and do not necessarily include all of the elements and operations/steps, nor must they be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the order of actual execution may be changed according to actual situations.
In the related art, when an ip address is queried according to the queried ip address, the ip data needs to be analyzed in advance, and the analyzed ip data is stored in a memory for query. Thus, a large number of objects in the resident memory are generated when the ip data is updated, so that the system triggers garbage collection, and the query efficiency is reduced.
How to improve the efficiency of geographic location query is a technical problem that needs to be solved currently.
In order to solve the above-mentioned problems, an embodiment of the present disclosure provides a geographic location query method, so as to improve the efficiency of querying geographic locations.
Fig. 1 schematically illustrates a geographic location query method of an exemplary embodiment of the present disclosure. The method provided by the embodiments of the present disclosure may be performed by any electronic device, such as a terminal device and/or a server, having computer processing capabilities. Referring to fig. 1, a geographic location query method provided by an embodiment of the present disclosure may include the following steps:
step S102, obtain ip address.
Step S104, acquiring resident memory blocks and indexes in a query state in a system memory, wherein the system memory comprises two resident memory blocks, and the states of the resident memory blocks are converted between the following three states: updating, inquiring and idling, wherein the indexes comprise a primary index and a secondary index.
And S106, inquiring the secondary index according to the ip address to obtain a primary index corresponding to the ip address.
Step S108, inquiring the primary index according to the ip address to obtain the address offset of the geographic position data matched with the ip address.
In the technical scheme of the embodiment of the disclosure, two resident memory blocks are established in the system memory, and one resident memory block is in a query state and the other resident memory block is in an update or idle state by converting the states of the two resident memory blocks, which is equivalent to adopting a copy-on-write strategy, so that occupation of an application memory is reduced, and high-efficiency query efficiency is still maintained when ip data is updated. In addition, the technical scheme of the embodiment of the disclosure also establishes a secondary index for the data stored in the resident memory block, thereby accelerating the query efficiency.
Copy-on-write (COW) is an optimization strategy in the field of computer programming. The core idea is that if multiple callers (callers) request the same resource, such as memory or data storage on disk, they will commonly acquire the same pointer to the same resource, until a caller attempts to modify the content of the resource, the system will not actually copy a private copy to the caller, while the original resource seen by other callers remains unchanged. This process is transparent to the other callers. The main advantage of this approach is that if the caller does not modify the resource, no copy (private copy) will be created, so multiple callers can share the same resource when they are just read.
Before step S102, two larger resident memory blocks need to be established, where the size of the resident memory block is selected according to the size of the ip data amount, for example, the size of the resident memory block may be 700MB. The resident memory block can transition between three states. Wherein the idle state indicates that the resident memory block is not in use, the update state indicates that the resident memory block is in an ip data update process, and the query state indicates that the resident memory block is used for an ip data query service. Here, the inquiry state belongs to an available state, and the idle state and the update state belong to an unavailable state. The three states of the resident memory block are transformed as shown in fig. 2.
After the resident memory block is established, the ip data needs to be stored into the resident memory. The ip data includes an ip address and geographic location data corresponding to the ip address. Ip data is generally provided by related Ip manufacturers, and has the characteristics of high updating frequency and general full data volume. According to the ip data, the ip geographic position information can be effectively inquired. In the embodiment of the present disclosure, IP data is generated based on IPv4, and IPv4 is a fourth version of the internet protocol (Internet Protocol, abbreviated IP).
As shown in fig. 3, when ip data needs to be updated, the ip data may be stored into a resident memory block in an idle state according to the following steps:
step S302, a current resident memory block in an idle state in the system memory is obtained, and the state of the current resident memory block is set to be updated.
Step S304, storing the ip data into the current resident memory block.
Step S306, an index is established for the ip data stored in the current resident memory block, wherein the index comprises a primary index and a secondary index.
In step S308, the state of the current resident memory block is set as a query, and the state of another resident memory block in the system memory is set as idle.
In step S304, when storing ip data into the current resident memory block, the ip data is stored into the current resident memory block in a byte array manner.
In step S306, after storing the ip data in the current resident memory block, a b+ tree data structure may be used to create a two-level index for the ip data stored in the current resident memory block.
The b+ tree is a tree data structure commonly used in database and operating system file systems. The B+ tree is characterized by being capable of keeping data stable and orderly, and has relatively stable logarithmic time complexity in insertion and modification. The time complexity of the query is O (logn), the time complexity of the inserted data is O (logn), where n is the number of nodes.
Nodes in a b+ tree are typically represented as an ordered set of elements and child pointers. If the order of this B+ tree is m, there are at most m child pointers for any node. The number of child pointers is always the same as the number of elements for all internal nodes. As shown in fig. 4, all leaves are at the same height, and the leaf nodes themselves are linked from small to large in key size.
When inserting data into the b+ tree, the position of the node to be inserted therein is first found, and then the value is inserted into this node. If no node is in the offending state, the process ends. If a node has too many elements, it is split into two nodes, each with a minimum number of elements. This process continues recursively up the tree until the root node is reached, creating a new root node if the root node is split. In order for it to work, the minimum and maximum numbers of elements typically must be chosen such that the minimum number is not less than half the maximum number.
When querying data in the B+ tree, starting from a root node, traversing the tree from top to bottom, and selecting child pointers with separate values on any side of the value to be searched. Binary search is typically used inside a node to determine the data location.
The embodiment of the disclosure combines the copy-on-write technology and the B+ tree search, optimizes the index structure, provides two-stage index establishment, and accelerates the query efficiency.
When the index is established for the ip data, first a first level index is established. The data structure adopted by the primary index is a B+ tree, and the node number of each tree is fixed. The key of the primary index is an ip address, and the value of the primary index is the address at which the geographic position data corresponding to the ip address starts and ends in the memory block where the geographic position data is located.
For example, for ip segment 000.000.000-000.255.255.255, we can obtain the structure shown in FIG. 5 (0 and n are the array indices), where 0, start is 0, and end is n.
After the primary index is built for all ips, a plurality of b+ trees as shown in fig. 6 are obtained, the keys of the nodes are ip addresses, the value is the start and end addresses of the ips in the memory address, and it should be noted that the ip address of each root node is the smallest value in the tree.
When a certain ip needs to be queried, the tree where the ip is located needs to be quickly determined, and if a traversal method is used, the efficiency is low. According to the characteristic of the B+ tree, when a certain ip address marked as x needs to be queried, the ip address is converted into an integer with the value of 50. Since the root node value of the B tree of the upper graph is 100 and the root node value of the A tree is 0, x must be specified in the A tree.
From this feature, a secondary index as shown in fig. 7 can be built on the basis of the primary index.
The data structure of the secondary index can also be a B+ tree, the key of the secondary index is an ip address, and the value of the secondary index is a memory address of the primary index.
In step S308, as shown in fig. 8, the state of the updated resident memory block is modified to be queried, and the state of another resident memory block is modified to be idle, so that the updated resident memory block can provide the query service. The process is repeated, and the two resident memory blocks can be alternately used, so that the purpose of reducing resource utilization is achieved. As shown in fig. 8, memory block-a and memory block-B represent two resident memory blocks that are alternately used, wherein a vertical-stripe filled memory block indicates that the resident memory block is in a query state, a non-filled memory block indicates that the resident memory block is in an idle state, and a horizontal-stripe filled memory block indicates that the resident memory block is in an update state.
After step S108, the original byte array of the geographic location data may be obtained according to the address offset, and the original byte array may be parsed, and the geographic location data corresponding to the ip address may be returned to the client.
When the geographical position data corresponding to the ip address is returned to the client, the geographical position data can be returned to the client after JSON encapsulation. JSON encapsulation is JSON serialization.
According to the geographic position query method, by setting the two resident memory blocks and designing the secondary index structure, geographic position data corresponding to the ip address can be queried without analyzing the ip data, a large amount of memory is prevented from being occupied when the ip data is updated, and query efficiency is improved.
The following describes an embodiment of an apparatus of the present disclosure that may be used to perform the geographic location query method described above in the present disclosure. As shown in fig. 9, a geographic location query device 600 provided according to an embodiment of the present disclosure may include:
an ip address obtaining unit 602, configured to obtain an ip address.
The memory obtaining unit 604 is configured to obtain a resident memory block and an index in a query state in a system memory, where the system memory includes two resident memory blocks, and the states of the resident memory blocks are converted between the following three states: updating, inquiring and idling, wherein the indexes comprise a primary index and a secondary index.
The secondary query unit 606 is configured to query the secondary index according to the ip address, and obtain a primary index corresponding to the ip address.
And the primary query unit 608 is configured to query the primary index according to the ip address, and obtain an address offset of the geographic location data that matches the ip address.
In the technical scheme of the embodiment of the disclosure, two resident memory blocks are established in the system memory, and one resident memory block is in a query state and the other resident memory block is in an update or idle state by converting the states of the two resident memory blocks, which is equivalent to adopting a copy-on-write strategy, so that occupation of an application memory is reduced, and high-efficiency query efficiency is still maintained when ip data is updated. In addition, the technical scheme of the embodiment of the disclosure also establishes a secondary index for the data stored in the resident memory block, thereby accelerating the query efficiency.
In another embodiment of the present application, the geographic location query device includes not only the ip address obtaining unit 302, the memory obtaining unit 304, the secondary query unit 306, and the primary query unit 308 in the geographic location query device 600, but also a status updating unit, an ip data storing unit, an index establishing unit, and a returning unit, where:
the state updating unit is used for acquiring a current resident memory block in an idle state in the system memory and setting the state of the current resident memory block as updating.
The ip data storage unit is used for storing the ip data into the current resident memory block.
The index establishing unit is used for establishing an index for the ip data stored in the current resident memory block, and the index comprises a primary index and a secondary index.
The state updating unit is further configured to set the state of the current resident memory block to be a query, and set the state of another resident memory block in the system memory to be idle.
The return unit is used for acquiring an original byte array of the geographic position data according to the address offset, analyzing the original byte array and returning the geographic position data corresponding to the ip address to the client.
Since each functional module of the geographic location query device according to the exemplary embodiment of the present disclosure corresponds to a step of the exemplary embodiment of the geographic location query method described above, for details not disclosed in the embodiments of the device of the present disclosure, please refer to the embodiments of the geographic location query method described above in the present disclosure.
According to the geographic position query device disclosed by the embodiment of the disclosure, by setting the two resident memory blocks and designing the secondary index structure, the geographic position data corresponding to the ip address can be queried without analyzing the ip data, so that a large amount of memory is prevented from being occupied when the ip data is updated, and the query efficiency is improved.
Referring now to FIG. 10, there is illustrated a schematic diagram of a computer system 700 suitable for use in implementing an electronic device of an embodiment of the present disclosure. The computer system 700 of the electronic device shown in fig. 10 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 10, the computer system 700 includes a Central Processing Unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data required for the system operation are also stored. The CPU 701, ROM 702, and RAM 703 are connected to each other through a bus 704. An input/output (I/O) interface 707 is also connected to bus 704.
The following components are connected to the I/O interface 707: an input section 706 including a keyboard, a mouse, and the like; an output portion 707 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 708 including a hard disk or the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. The drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read therefrom is mounted into the storage section 708 as necessary.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 709, and/or installed from the removable medium 711. The above-described functions defined in the system of the present application are performed when the computer program is executed by a Central Processing Unit (CPU) 701.
It should be noted that the computer readable storage medium shown in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having 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. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable storage medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware, and the described units may also be provided in a processor. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.
As another aspect, the present application also provides a computer-readable storage medium that may be contained in the electronic device described in the above embodiment; or may exist alone without being incorporated into the electronic device. The computer-readable storage medium carries one or more programs which, when executed by the electronic device, cause the electronic device to implement the geographic location query method as described in the above embodiments.
For example, the electronic device may implement the method as shown in fig. 1: step S102, an ip address is obtained; step S104, acquiring a resident memory block and an index in a query state in a system memory, wherein the system memory comprises two resident memory blocks, and the states of the resident memory blocks are converted between the following three states: updating, inquiring and idling, wherein the indexes comprise a primary index and a secondary index; step S106, inquiring the secondary index according to the ip address to obtain a primary index corresponding to the ip address; and step S108, inquiring the primary index according to the ip address to obtain the address offset of the geographic position data matched with the ip address.
It should be noted that although in the above detailed description several modules or units of a device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit in accordance with embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into a plurality of modules or units to be embodied.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, and includes several instructions to cause a computing device (may be a personal computer, a server, a touch terminal, or a network device, etc.) to perform the method according to the embodiments of the present disclosure.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. 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 (12)

1. A method of geographic location query, the method comprising:
acquiring an ip address;
acquiring a resident memory block and an index in a query state in a system memory, wherein the system memory comprises two resident memory blocks, one resident memory block is in an update or idle state when the other resident memory block is in the query state, and the index comprises a primary index and a secondary index;
inquiring the secondary index according to the ip address to obtain a primary index corresponding to the ip address;
and inquiring the primary index according to the ip address to obtain the address offset of the geographic position data matched with the ip address.
2. The method according to claim 1, characterized in that the method comprises:
acquiring a current resident memory block in an idle state in the system memory, and setting the state of the current resident memory block as update;
storing ip data into the current resident memory block, wherein the ip data comprises an ip address and geographic position data corresponding to the ip address;
establishing the index for the ip data stored in the current resident memory block, wherein the index comprises a primary index and a secondary index;
and setting the state of the current resident memory block as a query, and setting the state of another resident memory block in the system memory as idle.
3. The method of claim 1, wherein after said querying the primary index from the ip address, the method further comprises:
acquiring an original byte array of the geographic position data according to the address offset;
and analyzing the original byte array, and returning the geographic position data corresponding to the ip address to the client.
4. The method of claim 2, wherein the indexing the ip data stored in the current resident memory block comprises:
and establishing the index for the ip data stored in the current resident memory block by adopting a B+ tree data structure.
5. The method of claim 1, wherein the size of the resident memory block is 700MB.
6. The method of claim 1, wherein the key of the primary index is an ip address, and the value of the primary index is an address at which geographic location data corresponding to the ip address starts and ends in a resident memory block where the geographic location data is located.
7. The method of claim 1, wherein the step of determining the position of the substrate comprises,
and the key of the secondary index is an ip address, and the value of the secondary index is a memory address of the primary index.
8. The method of claim 2, wherein storing ip data into the current resident memory block comprises:
storing the ip data into the current resident memory block in a byte array mode.
9. A method according to claim 3, wherein the returning of the geographical location data corresponding to the ip address to the client further comprises:
and after JSON encapsulation is carried out on the geographic position data, returning to the client.
10. A geographic location query device, comprising:
an ip address acquisition unit configured to acquire an ip address;
the memory acquisition unit is used for acquiring resident memory blocks and indexes in a query state in a system memory, wherein the system memory comprises two resident memory blocks, one resident memory block is in an update or idle state when the resident memory block is in the query state, and the indexes comprise a primary index and a secondary index;
the second-level query unit is used for querying the second-level index according to the ip address to obtain a first-level index corresponding to the ip address;
and the primary query unit is used for querying the primary index according to the ip address to obtain the address offset of the geographic position data matched with the ip address.
11. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when executed by a processor, implements the geographical location query method of any one of claims 1 to 9.
12. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs which when executed by the one or more processors cause the one or more processors to implement the geographic location query method of any of claims 1 to 9.
CN202010114519.8A 2020-02-25 2020-02-25 Geographic position query method, geographic position query device, geographic position query medium and electronic equipment Active CN111310076B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010114519.8A CN111310076B (en) 2020-02-25 2020-02-25 Geographic position query method, geographic position query device, geographic position query medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010114519.8A CN111310076B (en) 2020-02-25 2020-02-25 Geographic position query method, geographic position query device, geographic position query medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN111310076A CN111310076A (en) 2020-06-19
CN111310076B true CN111310076B (en) 2023-10-03

Family

ID=71161881

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010114519.8A Active CN111310076B (en) 2020-02-25 2020-02-25 Geographic position query method, geographic position query device, geographic position query medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN111310076B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112948376B (en) * 2021-02-02 2022-06-14 厦门服云信息科技有限公司 IP geographical position information query method, terminal equipment and storage medium
CN115396395B (en) * 2022-08-25 2023-05-12 北京发现角科技有限公司 Method and device for determining geographic position of IP address

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001044987A2 (en) * 1999-12-16 2001-06-21 Gligorov, Monika Parallel data access procedure for b-tree structures
CN101183369A (en) * 2007-12-11 2008-05-21 中山大学 Embedded electronic dictionary word stock structure
CN103561133A (en) * 2013-11-19 2014-02-05 中国科学院计算机网络信息中心 IP address ownership information indexing and fast querying method
CN105159895A (en) * 2014-05-28 2015-12-16 国际商业机器公司 Method and system for storing and inquiring data
CN110633296A (en) * 2018-05-31 2019-12-31 北京京东尚科信息技术有限公司 Data query method, device, medium and electronic equipment

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20190134115A (en) * 2018-05-25 2019-12-04 주식회사 티맥스데이터 Method and apparatus for providing efficient indexing and computer program included in computer readable medium therefor

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001044987A2 (en) * 1999-12-16 2001-06-21 Gligorov, Monika Parallel data access procedure for b-tree structures
CN101183369A (en) * 2007-12-11 2008-05-21 中山大学 Embedded electronic dictionary word stock structure
CN103561133A (en) * 2013-11-19 2014-02-05 中国科学院计算机网络信息中心 IP address ownership information indexing and fast querying method
CN105159895A (en) * 2014-05-28 2015-12-16 国际商业机器公司 Method and system for storing and inquiring data
CN110633296A (en) * 2018-05-31 2019-12-31 北京京东尚科信息技术有限公司 Data query method, device, medium and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
喻波等.一种基于共享前缀的两级索引结构.计算机工程与科学.2010,第32卷(第12期),第113-116页. *

Also Published As

Publication number Publication date
CN111310076A (en) 2020-06-19

Similar Documents

Publication Publication Date Title
CN106407303A (en) Data storage method and apparatus, and data query method and apparatus
US10073876B2 (en) Bloom filter index for device discovery
US20170116244A1 (en) Bloom filter index for device discovery
CN111310076B (en) Geographic position query method, geographic position query device, geographic position query medium and electronic equipment
CN109308300B (en) Logic operation processing method and device, conversion plug-in and storage medium
CN114077680B (en) Graph data storage method, system and device
CN111309868B (en) Knowledge graph construction and retrieval method and device
CN110764748B (en) Code calling method, device, terminal and storage medium
CN106095698A (en) OO caching write, read method and device
CN110807028B (en) Method, apparatus and computer program product for managing a storage system
CN116756253B (en) Data storage and query methods, devices, equipment and media of relational database
CN107977381B (en) Data configuration method, index management method, related device and computing equipment
CN113254470B (en) Data modification method, device, computer equipment and storage medium
CN113535803B (en) Block chain efficient retrieval and reliability verification method based on keyword index
CN110908996A (en) Data processing method and device
CN114020789A (en) Bill data query method, system, device and storage medium
CN112261168A (en) Multi-IP port user information searching method, terminal equipment and storage medium
US20120089611A1 (en) Method of updating an inverted index, and a server implementing the method
CN115454354B (en) Data processing method, system, electronic device and storage medium
CN115396395B (en) Method and device for determining geographic position of IP address
JP2014503916A (en) Universal plug and play search condition conversion
CN110019336B (en) Method and device for querying data
CN116028526A (en) Storage query method, equipment and medium suitable for RBC system maintenance data
CN113495894A (en) Data synchronization method, device, equipment and storage medium
CN115391363A (en) Database index updating method, storage medium and computer equipment

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