CN106970964B - GPS data information query method and system based on shared memory - Google Patents

GPS data information query method and system based on shared memory Download PDF

Info

Publication number
CN106970964B
CN106970964B CN201710171845.0A CN201710171845A CN106970964B CN 106970964 B CN106970964 B CN 106970964B CN 201710171845 A CN201710171845 A CN 201710171845A CN 106970964 B CN106970964 B CN 106970964B
Authority
CN
China
Prior art keywords
gps data
data information
current
information
memory area
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
CN201710171845.0A
Other languages
Chinese (zh)
Other versions
CN106970964A (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.)
Shenzhen Guanglian Saixun Co ltd
Original Assignee
Shenzhen Guanglian Saixun 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 Shenzhen Guanglian Saixun Co ltd filed Critical Shenzhen Guanglian Saixun Co ltd
Priority to CN201710171845.0A priority Critical patent/CN106970964B/en
Publication of CN106970964A publication Critical patent/CN106970964A/en
Application granted granted Critical
Publication of CN106970964B publication Critical patent/CN106970964B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Remote Sensing (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Software Systems (AREA)
  • Position Fixing By Use Of Radio Waves (AREA)
  • Navigation (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a GPS data information query method based on a shared memory, and also discloses a GPS data information query system based on the shared memory, belonging to the technical field of shared memory computers. According to the invention, the device identification and the target position information are obtained from the information query request by responding to the information query request sent by the terminal device, the memory area corresponding to the device identification in the shared memory is searched according to the device identification, the GPS data information corresponding to the target position information is extracted from the memory area, and the extracted GPS data information is sent to the terminal device, so that the reading and writing of a persistent database cluster are reduced, and the service performance is improved.

Description

GPS data information query method and system based on shared memory
Technical Field
The invention relates to the technical field of shared memory computers, in particular to a GPS data information query method and system based on a shared memory.
Background
At present, GPS data of equipment is stored in a persistent database cluster (a Mysql relational database management system, an Hbase distributed and column-oriented open source database), and the persistent database cluster is large in capacity and capable of storing mass data.
However, this solution has the following drawbacks:
(1) the large amount of read-write persistent databases can cause high input/output (I/O) load of a server disk and large performance loss, and can affect other services of the server;
(2) the condition that the persistent database cluster is restarted or crashed can lead to the breakdown of the whole service system and the failure of providing service normally.
The above is only for the purpose of assisting understanding of the technical aspects of the present invention, and does not represent an admission that the above is prior art.
Disclosure of Invention
The invention mainly aims to provide a method and a system for inquiring GPS data information based on a shared memory, aiming at solving the technical problems that a service system is paralyzed and the service cannot be normally provided due to a large amount of read-write persistent databases in the prior art.
In order to achieve the above object, the present invention provides a GPS data information query method based on a shared memory, the method comprising the steps of:
responding to an information query request sent by terminal equipment, and acquiring equipment identification and target position information from the information query request;
searching a memory area corresponding to the equipment identifier in the shared memory according to the equipment identifier;
extracting GPS data information corresponding to the target position information from the memory area;
and sending the extracted GPS data information to the terminal equipment.
Preferably, before the responding to the information query request sent by the terminal device and extracting the device identifier and the target location information from the information query request, the method further includes:
responding to current GPS data information reported by terminal equipment, and extracting a current equipment identifier from the current GPS data information;
finding out a corresponding current memory area in the shared memory according to the current equipment identifier;
and storing the current GPS data information in the current memory area.
Preferably, the memory area comprises a position cursor and a corresponding memory unit, the memory unit is used for storing GPS data information, and the GPS data information further comprises data acquisition time;
correspondingly, the storing the current GPS data information in the current memory area specifically includes:
traversing the GPS data information in the current memory area according to the sequence of the position cursor from large to small;
comparing the traversed data acquisition time written with the GPS data information with the data acquisition time of the current GPS data information;
if the data acquisition time of the written GPS data information is earlier than the data acquisition time of the current GPS data information, inserting a target memory unit adjacent to the memory unit in which the written GPS data information is located, and writing the current GPS data information into the target memory unit;
and if the data acquisition time written with the GPS data information is later than the data acquisition time of the current GPS data information, returning to the step of traversing the GPS data information in the current memory area according to the sequence of the position cursor from large to small.
Preferably, before inserting a target memory unit adjacent to the memory unit in which the GPS data information has been written, the method further includes:
and judging whether the memory units written with the GPS data information in the current memory area exceed a preset number, if so, replacing the current GPS data information with the earliest data acquisition time in the current memory area, and sequencing the GPS data information in the current memory area according to the data acquisition time.
Preferably, before the responding to the current GPS data information reported by the terminal device and extracting the current device identifier from the current GPS data information, the method further includes:
and calculating the space size of the shared memory according to the number of preset terminal equipment, the number of preset GPS data information and the size of a single piece of GPS data information, and distributing the shared memory according to the space size of the shared memory.
In addition, in order to achieve the above object, the present invention further provides a GPS data information query system based on a shared memory, the system including:
the first information acquisition module is used for responding to an information query request sent by terminal equipment and acquiring equipment identification and target position information from the information query request;
the first memory area searching module is used for searching a memory area corresponding to the equipment identifier in the shared memory according to the equipment identifier;
the information extraction module is used for extracting the GPS data information corresponding to the target position information from the memory area;
and the information sending module is used for sending the extracted GPS data information to the terminal equipment.
Preferably, the system further comprises:
the second information acquisition module is used for responding to the current GPS data information reported by the terminal equipment and acquiring a current equipment identifier from the current GPS data information;
the second memory area searching module is used for searching the corresponding current memory area in the shared memory according to the current equipment identifier;
and the information storage module is used for storing the current GPS data information in the current memory area.
Preferably, the memory area comprises a position cursor and a corresponding memory unit, the memory unit is used for storing GPS data information, and the GPS data information further comprises data acquisition time;
the information storage module includes:
the first information traversal submodule is used for traversing the GPS data information in the current memory area according to the sequence of the position cursor from large to small;
the acquisition time comparison submodule is used for comparing the traversed data acquisition time written with the GPS data information with the data acquisition time of the current GPS data information;
the information writing submodule is used for inserting a target memory cell adjacent to the memory cell in which the written GPS data information is located and writing the current GPS data information into the target memory cell if the data acquisition time of the written GPS data information is earlier than the data acquisition time of the current GPS data information;
and the second information traversing submodule is used for returning to the step of traversing the GPS data information in the current memory area according to the descending order of the position cursor if the data acquisition time of the written GPS data information is later than the data acquisition time of the current GPS data information.
Preferably, the system further comprises:
and the quantity judgment module is used for judging whether the memory units written with the GPS data information in the current memory area exceed the preset quantity, if so, replacing the current GPS data information with the earliest data acquisition time in the current memory area, and sequencing the GPS data information in the current memory area according to the data acquisition time.
Preferably, the system further comprises:
and the shared memory allocation module is used for calculating the space size of the shared memory according to the number of the preset terminal devices, the number of the preset GPS data information and the size of the single GPS data information, and allocating the shared memory according to the space size of the shared memory.
According to the invention, the device identification and the target position information are obtained from the information query request by responding to the information query request sent by the terminal device, the memory area corresponding to the device identification in the shared memory is searched according to the device identification, the GPS data information corresponding to the target position information is extracted from the memory area, and the extracted GPS data information is sent to the terminal device, so that the reading and writing of a persistent database cluster are reduced, and the service performance is improved.
Drawings
FIG. 1 is a flowchart illustrating a method for querying GPS data information based on a shared memory according to a first embodiment of the present invention;
FIG. 2 is a diagram illustrating a data storage structure according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating multi-threaded data transmission in accordance with one embodiment of the present invention;
FIG. 4 is a flowchart illustrating a method for querying GPS data information based on a shared memory according to a second embodiment of the present invention;
FIG. 5 is a flow chart illustrating a single GPS data write to a shared memory according to an embodiment of the present invention;
FIG. 6 is a flowchart illustrating a third embodiment of a method for querying GPS data information based on a shared memory according to the present invention;
FIG. 7 is a flowchart illustrating a method for querying GPS data information based on a shared memory according to a fourth embodiment of the present invention;
FIG. 8 is a flowchart illustrating a fifth embodiment of a method for querying GPS data information based on a shared memory according to the present invention;
FIG. 9 is a functional block diagram of a shared memory based GPS data query system according to a first embodiment of the present invention;
FIG. 10 is a functional block diagram of a GPS data information query system based on a shared memory according to a second embodiment of the present invention;
FIG. 11 is a functional block diagram of a GPS data information query system based on a shared memory according to a third embodiment of the present invention;
FIG. 12 is a functional block diagram of a GPS data information query system based on a shared memory according to a fourth embodiment of the present invention;
fig. 13 is a functional block diagram of a GPS data information query system based on a shared memory according to a fifth embodiment of the present invention.
The implementation, functional features and advantages of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, a first embodiment of the present invention provides a method for querying GPS data information based on a shared memory, where the method includes:
s10: responding to an information query request sent by terminal equipment, and acquiring equipment identification and target position information from the information query request;
it should be noted that the main execution body of the method of the present embodiment is a data server for storing GPS data information, and of course, other devices with similar functions may also be used, and the present embodiment is not limited to this.
It can be understood that the terminal device is a device which needs to query GPS data information, for example: the device such as a smart phone, a tablet computer, a notebook computer, a PC, a navigator or a server that needs to query GPS data information may also be a dedicated device capable of implementing the above functions, which is not limited in this embodiment.
In a specific implementation, the device identifier is an identifier for reflecting the identity of the terminal device, and is used for distinguishing the terminal device from other terminal devices, and the device identifier has uniqueness and may be referred to as UID for short.
It should be understood that the target location information may include a location information, i.e. corresponding to a piece of GPS data information, and referring to fig. 2, the data server may provide an external query interface, i.e. the GetLastGpsData interface function in fig. 2, which may be used to obtain the latest piece of GPS data information;
of course, the target location information may include a plurality of pieces of location information, that is, corresponding to a plurality of pieces of GPS data information, and refer to fig. 2, that is, the getgpdatas interface function in fig. 2, for acquiring the latest plurality of pieces of GPS data information.
S20: searching a memory area corresponding to the equipment identifier in the shared memory according to the equipment identifier;
it should be noted that the device identifier corresponds to a segment of memory area in the shared memory, the memory area is identified by using a shared memory index, a mapping relationship table exists between the device identifier and the shared memory index to reflect the correspondence between the device identifier and the memory area, and the correspondence between the device identifier and the memory area has uniqueness, that is, the device identifier of one terminal device corresponds to one memory area.
S30: and extracting the GPS data information corresponding to the target position information from the memory area.
It should be noted that "UID" indicates a device identifier of the terminal device, as shown in fig. 2, "CurrentIndex" indicates a position cursor of a head of the memory area, and "GpsOne" indicates a single piece of GPS data information, for example, when a single piece of GPS data information is extracted, first, the device identifier of the terminal device to be queried is obtained, a memory index corresponding to the device identifier is obtained according to a mapping table of a relationship between the device identifier and the memory area index, a corresponding memory area is found according to the memory index, the memory area is a memory area with a head position cursor of 75, and according to a query input parameter, the GPS data information in a GpsOne storage unit corresponding to the latest position cursor 75 is queried through a GetLastGpsData interface function.
Accordingly, as shown in fig. 2, a plurality of pieces of GPS data information are extracted, that is, the GPS data information in the 1000 GpsOne storage units corresponding to the latest position cursors 1 to 1000 is queried through the GetGpsDatas (1000) interface function.
It is understood that the data server provides RFC Remote Procedure Call (RFC) services externally and provides a service interface externally, so that the external query is performed using a command line through an application program or other servers of different memory spaces coupled with the servers of the information system.
In a specific implementation, referring to fig. 3, fig. 3 is a multi-thread flow schematic diagram in a GPS data information query method based on a shared memory, where a data server provides an Ice interface to the outside, where the Ice is a high-performance middleware and supports distributed deployment management, a user may use an application program to read shared memory data through the Ice interface, where the application program may be third-party software, or may also be other software with similar functions, such as performing data query through a GetLastGpsData interface function; data queries and service status queries, such as select from, etc., may also be performed using the Linux system command line through other servers that are linked.
S40: and sending the extracted GPS data information to the terminal equipment.
In the embodiment, the device identifier and the target position information are acquired from the information query request in response to the information query request sent by the terminal device, the memory area corresponding to the device identifier in the shared memory is searched according to the device identifier, the GPS data information corresponding to the target position information is extracted from the memory area, and the extracted GPS data information is sent to the terminal device, so that the reading and writing of the persistent database cluster are reduced, and the service performance is improved.
Referring to fig. 4, fig. 4 is a flowchart illustrating a second embodiment of the method for querying GPS data information based on a shared memory according to the present invention, and the second embodiment of the method for querying GPS data information based on a shared memory according to the present invention is provided based on the embodiment illustrated in fig. 1.
In this embodiment, before step S10, the method further includes:
s01: responding to current GPS data information reported by terminal equipment, and extracting a current equipment identifier from the current GPS data information;
s02: finding out a corresponding current memory area in the shared memory according to the current equipment identifier;
s03: and storing the current GPS data information in the current memory area.
As shown in fig. 5, the terminal device reports the device identifier uid and the corresponding GPS location information, searches a corresponding memory area in the shared memory according to the device identifier, the segment of memory area is identified by the shared memory index, and is searched by establishing a mapping relationship between the device identifier and the shared memory index, for example, a mapping relationship corresponding to the shared memory index y when uid is x, finding out the corresponding memory area according to the shared memory index, wherein the memory area is identified by a head cursor currentIndex, for example, find the memory area corresponding to the head cursor currentIndex j when uid is x, in addition, before searching, whether a mapping relation table of the device identifier and the shared memory index exists is firstly inquired, if yes, the corresponding memory area is searched, and if the device identifier does not exist, allocating a new shared memory index to the device identifier, and inserting the relationship between the device identifier and the new shared memory index into a relational mapping table.
It should be noted that, the GPS data information reported by the terminal device is received, and the reported GPS data information is processed in two parts, one part stores all the received GPS data information in the persistent data database cluster and judges the reported GPS data information, and the other part stores the hot GPS data information in the shared memory.
It can be understood that the reported GPS data information is judged, the stored GPS hot spot data information is determined according to the time of the received GPS data information, and the latest GPS hot spot data information may also be stored according to the service requirement, which is not limited herein.
In the specific implementation, the query of the hot GPS data information only needs to access the shared memory for query, but does not need to access the persistent data database cluster, and the persistent data database cluster is queried under the condition that the shared memory cannot be queried, so that the dependence on the persistent database cluster is reduced, and the stability of the system is improved.
Continuing to refer to fig. 3, where "Kafka cluster" indicates a distributed message queue for the device to report GPS data, for example, Part0 indicates that the device reports GPS data information, the Kafka cluster is indicated in pb format, "ReadThread" indicates a thread for the reading device to report GPS data, and "current _ hash _ map" indicates a relationship mapping table between uid and memory index, for example, a relationship mapping table that a memory index is 1 when uid1:1 is 1, and "gpscord" indicates a memory area where each device stores GPS data, and the terminal device reports GPS data information and manages the GPS data information by the Kafka cluster, that is, performs distributed message queue on the data, and the thread for the system to report GPS data, for example, writes the GPS data information into a shared memory.
Referring to fig. 6, fig. 6 is a flowchart illustrating a third embodiment of the method for querying GPS data information based on a shared memory according to the present invention, and the third embodiment of the method for querying GPS data information based on a shared memory according to the present invention is provided based on the embodiment illustrated in fig. 4.
The memory area comprises a position cursor and a corresponding memory unit, the memory unit is used for storing GPS data information, and the GPS data information also comprises data acquisition time;
correspondingly, the storing the current GPS data information in the current memory area specifically includes:
s04: and judging the position of the GPS data information to be written and sequencing the written GPS data information.
Traversing the GPS data information in the current memory area according to the sequence of the position cursor from large to small;
comparing the traversed data acquisition time written with the GPS data information with the data acquisition time of the current GPS data information;
and if the data acquisition time of the written GPS data information is earlier than that of the current GPS data information, inserting a target memory unit adjacent to the memory unit in which the written GPS data information is located, and writing the current GPS data information into the target memory unit.
It should be noted that, in the present embodiment, a binary search method is adopted to search a position where current GPS data information is to be inserted;
and if the data acquisition time written with the GPS data information is later than the data acquisition time of the current GPS data information, returning to the step of traversing the GPS data information in the current memory area according to the sequence of the position cursor from large to small.
It should be noted that after the GPS data information is stored, the current position cursor is updated to wait for the next piece of GPS data to be written.
Referring to fig. 7, fig. 7 is a flowchart illustrating a fourth embodiment of the method for querying GPS data information based on a shared memory according to the present invention, and the fourth embodiment of the method for querying GPS data information based on a shared memory according to the present invention is provided based on the embodiment illustrated in fig. 6.
In this embodiment, before the step S04, the method further includes:
s05: and judging whether the memory units written with the GPS data information in the current memory area exceed a preset number, if so, replacing the current GPS data information with the earliest data acquisition time in the current memory area, and sequencing the GPS data information in the current memory area according to the data acquisition time.
It should be noted that the preset number is a number that is configured reasonably, and the number is determined, which is beneficial to improving the utilization rate of the memory, on one hand, if the stored GPS data information is too much, the whole server system may be paralyzed and the service cannot be provided normally, on the other hand, if the reserved GPS data information is stored in a large number, the memory space is wasted, and the memory utilization rate is reduced.
In a specific implementation, after the GPS data information in the current memory area is sorted according to the data acquisition time, the index newly recorded in the memory area is recorded by using a cursor, and the cursor is a cursor searched in the memory area index.
Referring to fig. 8, fig. 8 is a flowchart illustrating a fifth embodiment of the GPS data information query method based on a shared memory according to the present invention, and the fifth embodiment of the GPS data information query method based on a shared memory according to the present invention is provided based on the embodiment illustrated in fig. 7.
In this embodiment, before the step S01, the method further includes:
s00: and calculating the space size of the shared memory according to the number of preset terminal equipment, the number of preset GPS data information and the size of a single piece of GPS data information, and distributing the shared memory according to the space size of the shared memory.
It should be noted that the number of pieces of preset GPS data information may be configured, and is represented by the formula: and (3) calculating the size of the allocated shared space, wherein the size of the shared memory space is equal to the preset number of the terminal equipment multiplied by the number (N) of the preset GPS data information multiplied by the size of a single GPS data.
It can be understood that memory read and write is much more efficient than a magnetic disk, not only reducing system I/O, but also improving service performance, and the shared memory life cycle is longer than that of a process, so that memory data loss cannot be caused by service restart.
In a specific implementation, the Linux system is adopted to provide a shared memory to store the GPS hotspot data (the latest N pieces of GPS data are stored according to service requirements), and provide an RPC service to the outside to query the shared memory to obtain the GPS hotspot data.
Referring to fig. 9, a first embodiment of the present invention provides a GPS data information query system based on a shared memory, where the system includes:
a first information obtaining module 10, configured to respond to an information query request sent by a terminal device, and obtain a device identifier and target location information from the information query request;
it should be noted that the system of the present embodiment is deployed on a data server for storing GPS data information, and of course, may also be deployed on other devices with similar functions, which is not limited in this embodiment.
It can be understood that the terminal device is a device which needs to query GPS data information, for example: the device such as a smart phone, a tablet computer, a notebook computer, a PC, a navigator or a server that needs to query GPS data information may also be a dedicated device capable of implementing the above functions, which is not limited in this embodiment.
In a specific implementation, the device identifier is an identifier for reflecting the identity of the terminal device, and is used for distinguishing the terminal device from other terminal devices, and the device identifier has uniqueness and may be referred to as UID for short.
It should be understood that the target location information may include a location information, i.e. corresponding to a piece of GPS data information, and referring to fig. 2, the data server may provide an external query interface, i.e. the GetLastGpsData interface function in fig. 2, which may be used to obtain the latest piece of GPS data information;
of course, the target location information may include a plurality of pieces of location information, that is, corresponding to a plurality of pieces of GPS data information, and refer to fig. 2, that is, the getgpdatas interface function in fig. 2, for acquiring the latest plurality of pieces of GPS data information.
A first memory area searching module 20, configured to search, according to the device identifier, a memory area corresponding to the device identifier in the shared memory;
it should be noted that the device identifier corresponds to a segment of memory area in the shared memory, the memory area is identified by using a shared memory index, a mapping relationship table exists between the device identifier and the shared memory index to reflect the correspondence between the device identifier and the memory area, and the correspondence between the device identifier and the memory area has uniqueness, that is, the device identifier of one terminal device corresponds to one memory area.
An information extraction module 30, configured to extract GPS data information corresponding to the target location information from the memory area;
it should be noted that as shown in fig. 2, UID indicates a device identifier of a terminal device, CurrentIndex indicates a position cursor at the head of a memory area, and GpsOne indicates a single piece of GPS data information, for example, when a single piece of GPS data information is extracted, first, a device identifier of a terminal device to be queried is obtained, a memory index corresponding to the device identifier is obtained according to a mapping table of a relationship between the device identifier and the memory area index, a corresponding memory area is found according to the memory index, the memory area is a memory area with a head position cursor of 75, and according to a query input parameter, GPS data information in a GpsOne storage unit corresponding to a latest position cursor 75 is queried through a GetLastGpsData interface function.
Accordingly, as shown in fig. 2, a plurality of pieces of GPS data information are extracted, that is, the GPS data information in the 1000 GpsOne storage units corresponding to the latest position cursors 1 to 1000 is queried through the GetGpsDatas (1000) interface function.
It is understood that the data server provides RFC Remote Procedure Call (RFC) services externally and provides a service interface externally, so that the external query is performed using a command line through an application program or other servers of different memory spaces coupled with the servers of the information system.
In a specific implementation, referring to fig. 3, fig. 3 is a multi-thread flow schematic diagram in a GPS data information query method based on a shared memory, where a data server provides an Ice interface to the outside, where the Ice is a high-performance middleware and supports distributed deployment management, a user may use an application program to read shared memory data through the Ice interface, where the application program may be third-party software, or may also be other software with similar functions, such as performing data query through a GetLastGpsData interface function; data queries and service status queries, such as select from, etc., may also be performed using the Linux system command line through other servers that are linked.
And the information sending module 40 is used for sending the extracted GPS data information to the terminal equipment.
In the embodiment, the device identifier and the target position information are acquired from the information query request in response to the information query request sent by the terminal device, the memory area corresponding to the device identifier in the shared memory is searched according to the device identifier, the GPS data information corresponding to the target position information is extracted from the memory area, and the extracted GPS data information is sent to the terminal device, so that the reading and writing of the persistent database cluster are reduced, and the service performance is improved.
Referring to fig. 10, fig. 10 is a functional module diagram of a GPS data information query system based on a shared memory according to a second embodiment of the present invention, and the second embodiment of the GPS data information query system based on a shared memory according to the present invention is provided based on the embodiment shown in fig. 9.
In this embodiment, the system includes:
the second information acquisition module 01 is configured to respond to current GPS data information reported by the terminal device, and acquire a current device identifier from the current GPS data information;
a second memory area searching module 02, configured to search, according to the current device identifier, a current memory area corresponding to the shared memory;
and the information storage module 03 is configured to store the current GPS data information in the current memory area.
As shown in fig. 5, the terminal device reports the device identifier uid and the corresponding GPS location information, searches a corresponding memory area in the shared memory according to the device identifier, the segment of memory area is identified by the shared memory index, and is searched by establishing a mapping relationship between the device identifier and the shared memory index, for example, a mapping relationship corresponding to the shared memory index y when uid is x, finding out the corresponding memory area according to the shared memory index, wherein the memory area is identified by a head cursor currentIndex, for example, find the memory area corresponding to the head cursor currentIndex j when uid is x, in addition, before searching, whether a mapping relation table of the device identifier and the shared memory index exists is firstly inquired, if yes, the corresponding memory area is searched, and if the device identifier does not exist, allocating a new shared memory index to the device identifier, and inserting the relationship between the device identifier and the new shared memory index into a relational mapping table.
It should be noted that, the GPS data information reported by the terminal device is received, and the reported GPS data information is processed in two parts, one part stores all the received GPS data information in the persistent data database cluster and judges the reported GPS data information, and the other part stores the hot GPS data information in the shared memory.
It can be understood that the reported GPS data information is judged, the stored GPS hot spot data information is determined according to the time of the received GPS data information, and the latest GPS hot spot data information may also be stored according to the service requirement, which is not limited herein.
In the specific implementation, the query of the hot GPS data information only needs to access the shared memory for query, but does not need to access the persistent data database cluster, and the persistent data database cluster is queried under the condition that the shared memory cannot be queried, so that the dependence on the persistent database cluster is reduced, and the stability of the system is improved.
Continuing to refer to fig. 3, where "Kafka cluster" indicates a distributed message queue for the device to report GPS data, for example, Part0 indicates that the device reports GPS data information, the Kafka cluster is indicated in pb format, "ReadThread" indicates a thread for the reading device to report GPS data, and "current _ hash _ map" indicates a relationship mapping table between uid and memory index, for example, a relationship mapping table that a memory index is 1 when uid1:1 is 1, and "gpscord" indicates a memory area where each device stores GPS data, and the terminal device reports GPS data information and manages the GPS data information by the Kafka cluster, that is, performs distributed message queue on the data, and the thread for the system to report GPS data, for example, writes the GPS data information into a shared memory.
Referring to fig. 11, fig. 11 is a schematic diagram of specific functional sub-modules of an information storage module in a third embodiment of the GPS data information query system based on a shared memory according to the present invention, and the third embodiment of the GPS data information query system based on a shared memory according to the present invention is provided based on the embodiment shown in fig. 10.
The memory area comprises a position cursor and a corresponding memory unit, the memory unit is used for storing GPS data information, and the GPS data information also comprises data acquisition time;
the information storage module 03 includes:
the first information traversal submodule 301 is configured to traverse the GPS data information in the current memory area according to a sequence from a large position cursor to a small position cursor;
the acquisition time comparison submodule 302 is configured to compare the traversed data acquisition time written with the GPS data information with the data acquisition time of the current GPS data information;
the information writing submodule 303 is configured to insert a target memory cell adjacent to the memory cell in which the written GPS data information is located, and write the current GPS data information into the target memory cell, if the data acquisition time of the written GPS data information is earlier than the data acquisition time of the current GPS data information;
it should be noted that, in the present embodiment, a binary search method is adopted to search a position where current GPS data information is to be inserted;
and a second information traversal submodule 304, configured to return to the step of traversing the GPS data information in the current memory area according to the descending order of the position cursor if the data acquisition time of the written GPS data information is later than the data acquisition time of the current GPS data information.
It should be noted that after the GPS data information is stored, the current position cursor is updated to wait for the next piece of GPS data to be written.
Referring to fig. 12, fig. 12 is a functional block diagram of a GPS data information query system based on a shared memory according to a fourth embodiment of the present invention, and the fourth embodiment of the GPS data information query system based on a shared memory according to the present invention is provided based on the embodiment shown in fig. 10.
In this embodiment, the system further includes:
the quantity judgment module 04 is configured to judge whether the number of memory units written with the GPS data information in the current memory area exceeds a preset number, and if yes, replace the current GPS data information with the earliest data acquisition time in the current memory area, and sort the GPS data information in the current memory area according to the data acquisition time.
It should be noted that the preset number is a number that is configured reasonably, and the number is determined, which is beneficial to improving the utilization rate of the memory, on one hand, if the stored GPS data information is too much, the whole server system may be paralyzed and the service cannot be provided normally, on the other hand, if the reserved GPS data information is stored in a large number, the memory space is wasted, and the memory utilization rate is reduced.
In a specific implementation, after the GPS data information in the current memory area is sorted according to the data acquisition time, the index newly recorded in the memory area is recorded by using a cursor, and the cursor is a cursor searched in the memory area index.
Referring to fig. 13, fig. 13 is a functional block diagram of a GPS data information query system based on a shared memory according to a fifth embodiment of the present invention, and the fifth embodiment of the GPS data information query system based on a shared memory according to the present invention is provided based on the embodiment shown in fig. 12.
In this embodiment, the system further includes:
the shared memory allocation module 00 is configured to calculate the space size of the shared memory according to the number of preset terminal devices, the number of preset GPS data information, and the size of a single piece of GPS data information, and allocate the shared memory according to the space size of the shared memory.
It should be noted that the number of pieces of preset GPS data information may be configured, and is represented by the formula: and (3) calculating the size of the allocated shared space, wherein the size of the shared memory space is equal to the preset number of the terminal equipment multiplied by the number (N) of the preset GPS data information multiplied by the size of a single GPS data.
It can be understood that memory read and write is much more efficient than a magnetic disk, not only reducing system I/O, but also improving service performance, and the shared memory life cycle is longer than that of a process, so that memory data loss cannot be caused by service restart.
In a specific implementation, the Linux system is adopted to provide a shared memory to store the GPS hotspot data (the latest N pieces of GPS data are stored according to service requirements), and provide an RPC service to the outside to query the shared memory to obtain the GPS hotspot data.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Equivalent structures or equivalent processes performed by the contents of the specification and the drawings are directly or indirectly applied to other related technical fields, and the same principle is included in the scope of the invention.

Claims (10)

1. A GPS data information query method based on a shared memory is characterized by comprising the following steps:
responding to an information query request sent by terminal equipment, and acquiring equipment identification and target position information from the information query request;
searching a memory area corresponding to the equipment identifier in the shared memory according to a preset mapping relation table;
extracting GPS data information corresponding to the target position information from the memory area;
and sending the extracted GPS data information to the terminal equipment.
2. The method of claim 1, wherein before extracting the device identifier and the target location information from the information query request in response to the information query request sent by the terminal device, the method further comprises:
responding to current GPS data information reported by terminal equipment, and extracting a current equipment identifier from the current GPS data information;
finding out a corresponding current memory area in the shared memory according to the current equipment identifier;
and storing the current GPS data information in the current memory area.
3. The method of claim 2, wherein the memory area includes a position cursor and a corresponding memory cell for storing GPS data information, the GPS data information further including data acquisition time;
correspondingly, the storing the current GPS data information in the current memory area specifically includes:
traversing the GPS data information in the current memory area according to the sequence of the position cursor from large to small;
comparing the traversed data acquisition time written with the GPS data information with the data acquisition time of the current GPS data information;
if the data acquisition time of the written GPS data information is earlier than the data acquisition time of the current GPS data information, inserting a target memory unit adjacent to the memory unit in which the written GPS data information is located, and writing the current GPS data information into the target memory unit;
and if the data acquisition time written with the GPS data information is later than the data acquisition time of the current GPS data information, returning to the step of traversing the GPS data information in the current memory area according to the sequence of the position cursor from large to small.
4. The method of claim 3, wherein prior to inserting a target memory location adjacent to the memory location in which the GPS data information has been written, the method further comprises:
and judging whether the memory units written with the GPS data information in the current memory area exceed a preset number, if so, replacing the current GPS data information with the earliest data acquisition time in the current memory area, and sequencing the GPS data information in the current memory area according to the data acquisition time.
5. The method of claim 4, wherein before said extracting a current device identifier from current GPS data information in response to current GPS data information reported by a terminal device, the method further comprises:
and calculating the space size of the shared memory according to the number of preset terminal equipment, the number of preset GPS data information and the size of a single piece of GPS data information, and distributing the shared memory according to the space size of the shared memory.
6. A GPS data information query system based on a shared memory, the system comprising:
the first information acquisition module is used for responding to an information query request sent by terminal equipment and acquiring equipment identification and target position information from the information query request;
the first memory area searching module is used for searching a memory area corresponding to the equipment identifier in the shared memory according to a preset mapping relation table;
the information extraction module is used for extracting the GPS data information corresponding to the target position information from the memory area;
and the information sending module is used for sending the extracted GPS data information to the terminal equipment.
7. The system of claim 6, wherein the system further comprises:
the second information acquisition module is used for responding to the current GPS data information reported by the terminal equipment and acquiring a current equipment identifier from the current GPS data information;
the second memory area searching module is used for searching the corresponding current memory area in the shared memory according to the current equipment identifier;
and the information storage module is used for storing the current GPS data information in the current memory area.
8. The system of claim 7, wherein the memory area includes a position cursor and a corresponding memory cell for storing GPS data information, the GPS data information further including a data acquisition time;
the information storage module includes:
the first information traversal submodule is used for traversing the GPS data information in the current memory area according to the sequence of the position cursor from large to small;
the acquisition time comparison submodule is used for comparing the traversed data acquisition time written with the GPS data information with the data acquisition time of the current GPS data information;
the information writing submodule is used for inserting a target memory cell adjacent to the memory cell in which the written GPS data information is located and writing the current GPS data information into the target memory cell if the data acquisition time of the written GPS data information is earlier than the data acquisition time of the current GPS data information;
and the second information traversing submodule is used for returning to the step of traversing the GPS data information in the current memory area according to the descending order of the position cursor if the data acquisition time of the written GPS data information is later than the data acquisition time of the current GPS data information.
9. The system of claim 8, wherein the system further comprises:
and the quantity judgment module is used for judging whether the memory units written with the GPS data information in the current memory area exceed the preset quantity, if so, replacing the current GPS data information with the earliest data acquisition time in the current memory area, and sequencing the GPS data information in the current memory area according to the data acquisition time.
10. The system of claim 9, wherein the system further comprises:
and the shared memory allocation module is used for calculating the space size of the shared memory according to the number of the preset terminal devices, the number of the preset GPS data information and the size of the single GPS data information, and allocating the shared memory according to the space size of the shared memory.
CN201710171845.0A 2017-03-21 2017-03-21 GPS data information query method and system based on shared memory Active CN106970964B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710171845.0A CN106970964B (en) 2017-03-21 2017-03-21 GPS data information query method and system based on shared memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710171845.0A CN106970964B (en) 2017-03-21 2017-03-21 GPS data information query method and system based on shared memory

Publications (2)

Publication Number Publication Date
CN106970964A CN106970964A (en) 2017-07-21
CN106970964B true CN106970964B (en) 2021-01-19

Family

ID=59328718

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710171845.0A Active CN106970964B (en) 2017-03-21 2017-03-21 GPS data information query method and system based on shared memory

Country Status (1)

Country Link
CN (1) CN106970964B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109063121B (en) * 2018-08-01 2024-04-05 平安科技(深圳)有限公司 Data storage method, device, computer equipment and computer storage medium
CN111815404B (en) * 2020-06-23 2024-05-28 维沃移动通信有限公司 Virtual article sharing method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7366499B1 (en) * 2005-08-22 2008-04-29 Avaya Technology Corp. Announcement service for the visually impaired
CN102750377A (en) * 2012-06-21 2012-10-24 深圳市谷米科技有限公司 Massive data storage and retrieval method
CN103064890A (en) * 2012-12-11 2013-04-24 泉州豪杰信息科技发展有限公司 Global position system (GPS) mass data processing method
CN105242882A (en) * 2015-10-13 2016-01-13 东方网力科技股份有限公司 Frame storage method and apparatus for timing data and query method and apparatus for timing data

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7366499B1 (en) * 2005-08-22 2008-04-29 Avaya Technology Corp. Announcement service for the visually impaired
CN102750377A (en) * 2012-06-21 2012-10-24 深圳市谷米科技有限公司 Massive data storage and retrieval method
CN103064890A (en) * 2012-12-11 2013-04-24 泉州豪杰信息科技发展有限公司 Global position system (GPS) mass data processing method
CN105242882A (en) * 2015-10-13 2016-01-13 东方网力科技股份有限公司 Frame storage method and apparatus for timing data and query method and apparatus for timing data

Also Published As

Publication number Publication date
CN106970964A (en) 2017-07-21

Similar Documents

Publication Publication Date Title
CN106294190B (en) Storage space management method and device
CN107015985B (en) Data storage and acquisition method and device
US7610468B2 (en) Modified buddy system memory allocation
CN107092439B (en) Data storage method and equipment
US20160364407A1 (en) Method and Device for Responding to Request, and Distributed File System
CN111198856B (en) File management method, device, computer equipment and storage medium
KR20180008774A (en) Method and system for implementing indexing when saving files
CN110580246B (en) Method, device, computer equipment and storage medium for migrating data
CN111061752B (en) Data processing method and device and electronic equipment
CN109766318B (en) File reading method and device
US11775480B2 (en) Method and system for deleting obsolete files from a file system
CN109240607B (en) File reading method and device
WO2020215580A1 (en) Distributed global data deduplication method and device
CN106970964B (en) GPS data information query method and system based on shared memory
CN109522311B (en) Data storage method, device, server and storage medium
CN112306957A (en) Method and device for acquiring index node number, computing equipment and storage medium
US20150309929A1 (en) Computer system, data management method, and recording medium for storing program
US10241927B2 (en) Linked-list-based method and device for application caching management
CN102724301A (en) Cloud database system and method and equipment for reading and writing cloud data
CN111581247B (en) Data manager, time sequence database and information processing system
CN110825953B (en) Data query method, device and equipment
CN110825732A (en) Data query method and device, computer equipment and readable storage medium
CN108241710A (en) A kind of file creating method, device and file polling method, apparatus
CN113905252B (en) Data storage method and device for live broadcasting room, electronic equipment and storage medium
CN107632944B (en) Method and device for reading data

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 518000 1402, building 1, Chongwen Park, Nanshan wisdom Park, 3370 Liuxian Avenue, Fuguang community, Taoyuan Street, Nanshan District, Shenzhen, Guangdong Province

Applicant after: Shenzhen Guanglian Saixun Co.,Ltd.

Address before: Room 701, unit 3, building C, Kexing Science Park, No. 15, Keyuan Road, high tech park, Nanshan District, Shenzhen City, Guangdong Province

Applicant before: SHENZHEN AUTONET Co.,Ltd.

GR01 Patent grant
GR01 Patent grant