CN116860743A - Event query method and device - Google Patents

Event query method and device Download PDF

Info

Publication number
CN116860743A
CN116860743A CN202310679417.4A CN202310679417A CN116860743A CN 116860743 A CN116860743 A CN 116860743A CN 202310679417 A CN202310679417 A CN 202310679417A CN 116860743 A CN116860743 A CN 116860743A
Authority
CN
China
Prior art keywords
event
query
storage
time
information
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.)
Pending
Application number
CN202310679417.4A
Other languages
Chinese (zh)
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.)
Hundsun Technologies Inc
Original Assignee
Hundsun Technologies Inc
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 Hundsun Technologies Inc filed Critical Hundsun Technologies Inc
Priority to CN202310679417.4A priority Critical patent/CN116860743A/en
Publication of CN116860743A publication Critical patent/CN116860743A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • 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/23Updating
    • 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/2477Temporal data 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/24Querying
    • G06F16/248Presentation of query results
    • 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/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the specification provides an event query method and device, wherein the event query method comprises the following steps: receiving an event query request, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time; determining a current query event from a storage database according to the starting time and the event identification, wherein the storage database comprises a plurality of query events stored based on time sequence; comparing the target event information with the stored information of the candidate query events after the current query event, and obtaining a comparison result of each candidate query event under the condition that the stored information does not meet the ending time; and obtaining a query result corresponding to the event query request according to the comparison result of each candidate query event. And stopping information comparison when the stored information of the candidate query event does not meet the ending time, determining the query result corresponding to the event query request, and improving the event query efficiency without traversing all query events stored in a storage database.

Description

Event query method and device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an event query method. The present description is also directed to an event querying device, a computing device, and a computer-readable storage medium.
Background
With the continuous development of computer technology, the amount of data generated by enterprises or individual users increases explosively, and the data of time-series events are stored in a Map structure in the form of key-value pairs to a persistent storage engine, usually by utilizing the strong state management capability of a stream computing engine.
Currently, when querying data in a storage engine, the following two methods are used: one way is to traverse all graph entries (mappentry) to screen for data that meets the demand; another is to traverse all keys (keys) and filter the keys that meet the demand, and then query the data through the keys that meet the demand. However, both schemes require deserialization of the Value (Value), resulting in an extremely inefficient data query process, and thus a more efficient data query scheme.
Disclosure of Invention
In view of this, the embodiments of the present disclosure provide an event query method. The present disclosure also relates to an event query device, a computing device, and a computer-readable storage medium, which solve the technical drawbacks of the prior art.
According to a first aspect of embodiments of the present disclosure, there is provided an event query method, including:
Receiving an event query request, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time;
determining a current query event from a storage database according to the starting time and the event identification, wherein the storage database comprises a plurality of query events stored based on time sequence;
comparing the target event information with the stored information of the candidate query events after the current query event, and obtaining a comparison result of each candidate query event under the condition that the stored information does not meet the ending time;
and obtaining a query result corresponding to the event query request according to the comparison result of each candidate query event.
According to a second aspect of embodiments of the present specification, there is provided an event querying device, including:
the receiving module is configured to receive an event query request, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time;
a determining module configured to determine a current query event from a storage database according to a start time and an event identification, wherein the storage database includes a plurality of query events stored based on a time sequence;
The comparison module is configured to compare the stored information of the candidate query event after the current query event with the target event information, and obtain the comparison result of each candidate query event under the condition that the stored information does not meet the end time;
the obtaining module is configured to obtain the query result corresponding to the event query request according to the comparison result of each candidate query event.
According to a third aspect of embodiments of the present specification, there is provided a computing device comprising:
a memory and a processor;
the memory is configured to store computer-executable instructions which, when executed by the processor, implement the steps of the event query method provided in the first aspect described above.
According to a fourth aspect of embodiments of the present specification, there is provided a computer readable storage medium storing computer executable instructions which, when executed by a processor, implement the steps of the event query method provided in the first aspect described above.
According to the event query method provided by the specification, an event query request is received, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time; determining a current query event from a storage database according to the starting time and the event identification, wherein the storage database comprises a plurality of query events stored based on time sequence; comparing the target event information with the stored information of the candidate query events after the current query event, and obtaining a comparison result of each candidate query event under the condition that the stored information does not meet the ending time; and obtaining a query result corresponding to the event query request according to the comparison result of each candidate query event. By determining the current query event from the storage database according to the starting time and the event identification, comparing the target event information with the storage information of the candidate query event after the current query event, stopping information comparison when the storage information does not meet the ending time, determining the query result corresponding to the event query request, and not needing to traverse all the query events stored in the storage database, thereby saving the event query time and improving the event query efficiency.
Drawings
FIG. 1 is a flow chart of data flow processing in a distributed processing framework provided by a conventional approach;
FIG. 2 is a schematic diagram of a data flow processing procedure in a distributed processing framework provided by a conventional scheme;
FIG. 3 is a process flow diagram of a transaction event query method provided by a conventional approach;
FIG. 4 is a block diagram of an event query system according to one embodiment of the present disclosure;
FIG. 5 is a flow chart of a method for querying events according to an embodiment of the present disclosure;
FIG. 6 is a process flow diagram of a method for querying events according to one embodiment of the present disclosure;
FIG. 7 is a process flow diagram of another method for querying events provided by an embodiment of the present disclosure;
FIG. 8 is a diagram illustrating data comparison in an event query method according to an embodiment of the present disclosure;
FIG. 9 is an interface diagram of an event query interface according to one embodiment of the present disclosure;
fig. 10 is a schematic structural diagram of an event query device according to an embodiment of the present disclosure;
FIG. 11 is a block diagram of a computing device according to one embodiment of the present disclosure.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present description. This description may be embodied in many other forms than described herein and similarly generalized by those skilled in the art to whom this disclosure pertains without departing from the spirit of the disclosure and, therefore, this disclosure is not limited by the specific implementations disclosed below.
The terminology used in the one or more embodiments of the specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the specification. As used in this specification, one or more embodiments and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present specification refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that, although the terms first, second, etc. may be used in one or more embodiments of this specification to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first may also be referred to as a second, and similarly, a second may also be referred to as a first, without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
Furthermore, it should be noted that, user information (including, but not limited to, user equipment information, user personal information, etc.) and data (including, but not limited to, data for analysis, stored data, presented data, etc.) according to one or more embodiments of the present disclosure are information and data authorized by a user or sufficiently authorized by each party, and the collection, use, and processing of relevant data is required to comply with relevant laws and regulations and standards of relevant countries and regions, and is provided with corresponding operation entries for the user to select authorization or denial.
Since the input of the streaming system is an unlimited data stream, the data stream can run for a long time, and even run for days or months without stopping, and during this process, state data needs to be well managed, so state management is one of the very important characteristics of the streaming computing engine.
Referring to fig. 1, fig. 1 shows a flow chart of data flow processing in a distributed processing framework provided by a conventional scheme. As shown in fig. 1, the distributed processing framework (e.g., flink) has a strong state management capability, supporting storage into a storage database for states of the upper TB (TeraByte) level. The distributed processing framework can process input streams, distribute data streams to corresponding operator subtasks, update states in the state storage database, and when the operator subtasks process a piece of data, acquire the states from the storage database and output results.
Referring to fig. 2, fig. 2 is a schematic diagram illustrating a data flow processing procedure in a distributed processing framework provided by a conventional scheme. The keyed state (KeyedState) is one of the distributed processing framework states. The key state is maintained and accessed according to keys defined in the input data stream. The distributed processing framework maintains one state instance for each key and groups the keys according to a specific hash (hash) policy, assigns keys to corresponding operator subtasks according to the grouping result, e.g. assigns keys 1 and 2 to operator subtask 1 and key 3 to operator subtask 2. Thus, data having the same key may be partitioned into the same operator subtask that maintains and processes the keyed state corresponding to the key. When an operator subtask processes a piece of data, the access range of the keying state can be automatically limited to the key of the current data. It should be noted that the hash policies of different keys may be the same, and thus different keys may also appear in one operator subtask.
In practical applications, the key states include a value state (ValueState), a list state (ListState), a map state (MapState), and the like. Wherein the mapping state is similar to the graph structure, and stored are Key-Value pairs (Key-Value). The mapping state can be used for a storage structure in various scenes, taking stock price fluctuation in a period of time based on a transaction event as an example, in order to ensure that each event arrives and can output the peak and the trough of the stock price in real time, an operator for carrying out accumulated calculation by pushing forward for X minutes/hour/day from the current time can be provided, and in order to support storing a large number of stock price detail states, a time sequence storage database such as a RocksDB can be selected at the state back end.
Specifically, the operator needs to use MapState < Long, list < E > > to maintain a transaction event List corresponding to each time stamp, where the time stamp may be a millisecond time stamp corresponding to the event time. When a transaction event is received, the transaction event can be stored in a state, and then transaction events with the time range of [ T-X, T ] are retrieved from the state to carry out accumulated calculation, wherein T is the event time of the transaction event, and X is the time calculated forward.
Referring to fig. 3 for an exemplary illustration, fig. 3 shows a process flow diagram of a transaction event query method provided by a conventional approach. Assuming that the input includes a transaction stream of a plurality of transaction events, the transaction event information (X, Y, Z) of the transaction event includes a transaction time X, a stock code Y, a stock price field Z, a peak and a trough of which the calculation content is pushed forward by 2 milliseconds for the current time, and the output (A, B, C, D) includes a transaction time A, a stock code B, a minimum stock price field C, a maximum stock price field D. The specific flow is as follows:
the input transaction event information (1,0571,17) is stored in MapState < Long, list < E >, and only data with the transaction time of 1 is output (1,0571,17,17).
The input transaction event information (3,0571,18) is stored in MapState < Long, list < E >, the detail data with time window of [1,3] is queried, the minimum stock price field and the maximum stock price field are calculated to be 17 and 18 respectively, and output (3,0571,17,18).
Processing logic of the inputted transaction event information (5,0571,19) and (7,0571,20) is the same as that of the input transaction event information (5,0571,18,19) and (7,0571,19,20) respectively.
It follows that each time detail data within the current time window is queried from MapState < Long >, list < E >, one way is to traverse the entire graph entry and screen the data within the event time satisfaction window; the other is to traverse all keys and filter the keys within the event time satisfaction window, and then to examine the detail data through the key points. When states are stored in a storage database, each query requires deserialization of values, whether traversing the entire graph entry or all keys and then clicking on, which is very costly and inefficient, and therefore, requires a more efficient data query scheme.
In the embodiment of the present disclosure, an event query scheme is provided, and a new state type-time sequence state is introduced based on the characteristics of storing database prefix scan and key ordered storage. Support the key to search the range. And performing performance improvement on operators of which the internal operation states need to be subjected to range retrieval.
Specifically, an event query request is received, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time; determining a current query event from a storage database according to the starting time and the event identification, wherein the storage database comprises a plurality of query events stored based on time sequence; comparing the target event information with the stored information of the candidate query events after the current query event, and obtaining a comparison result of each candidate query event under the condition that the stored information does not meet the ending time; and obtaining a query result corresponding to the event query request according to the comparison result of each candidate query event. By determining the current query event from the storage database according to the starting time and the event identification, comparing the target event information with the storage information of the candidate query event after the current query event, stopping information comparison when the storage information does not meet the ending time, determining the query result corresponding to the event query request, and not needing to traverse all the query events stored in the storage database, thereby saving the event query time and improving the event query efficiency.
In the present specification, an event query method is provided, and the present specification relates to an event query apparatus, a computing device, and a computer-readable storage medium, which are described in detail in the following embodiments one by one.
Referring to fig. 4, fig. 4 shows an architecture diagram of an event query system according to an embodiment of the present specification. The event query system comprises a client 100 and a server 200;
the client 100 is configured to send an event query request to the server 200, where the event query request carries target event information, and the target event information includes an event identifier, a start time and an end time;
the server 200 is configured to determine a current query event from a storage database according to a start time and an event identifier, where the storage database includes a plurality of query events stored based on time sequence; comparing the target event information with the stored information of the candidate query events after the current query event, and obtaining a comparison result of each candidate query event under the condition that the stored information does not meet the ending time; obtaining a query result corresponding to the event query request according to the comparison result of each candidate query event; sending the query result to the client 100;
The client 100 is further configured to receive a query result sent by the server 200.
By applying the scheme of the embodiment of the specification, the current query event is determined from the storage database according to the starting time and the event identification, the target event information is compared with the storage information of the candidate query event after the current query event, and when the storage information does not meet the ending time, the information comparison is stopped, the query result corresponding to the event query request is determined, all query events stored in the storage database do not need to be traversed, the event query time is saved, and the event query efficiency is improved.
Referring to fig. 5, fig. 5 shows a flowchart of an event query method according to an embodiment of the present disclosure, which specifically includes the following steps:
step 502: and receiving an event query request, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time.
In one or more embodiments of the present disclosure, before an event query, an event query request may be received, and target event information carried by the event query request is used as a reference in an event query process to determine a query result that meets the event query request.
Specifically, the target event information refers to event query requirement information for screening target events from a storage database. The event identifier is used to identify an event, and may be an event code, an event name, etc., where the event identifier is specifically selected according to the actual situation, and the embodiment of the present disclosure is not limited in any way. The time range of the event requested by the event query request may be determined based on the start time and the end time, e.g., the start time is 1 and the end time is 4, indicating that the time range of the event requested by the event query request is [1,4].
It should be noted that, the event query request may be a request text or a request audio, and the form of the event query request is specifically selected according to the actual situation, which is not limited in any way in the embodiment of the present disclosure. If the event query request is query audio, the audio conversion tool can be utilized to convert the request audio to obtain a request text.
Step 504: determining a current query event from a storage database according to the start time and the event identification, wherein the storage database comprises a plurality of query events stored based on time sequence.
In one or more embodiments of the present description, after receiving an event query request, a current query event may be determined from a stored database based on a start time and an event identification.
Specifically, the current query event refers to a query event with the same identification as the event identification stored in the storage database and the storage time satisfying the start time. The storage time satisfying the start time means that the storage time is equal to or greater than the start time, and it can be understood that the storage time is equal to or after the start time, that is, the storage time is later than the start time in terms of timing.
The query events stored in the storage database based on time sequence can be stored in the forward direction according to the sequence from small to large in time, or can be stored in the reverse direction according to the sequence from large to small in time. The storage database at least comprises the storage time and the storage identification of the query event, and other information of the event, such as an event handler, can be also included in the storage database. The storage time includes, but is not limited to, the occurrence time of the query event, the transaction time of the query event. The storage identifier includes, but is not limited to, event code, event name of the query event.
It should be noted that, if the storage database includes multiple storage times of the query event, the target event information may carry the type of the start time. When determining the current query event from the storage database according to the start time and the event identification, the storage time which is the same as the type of the start time in the storage database can be determined according to the type of the start time, and the current query event can be determined by further comparing the start time with the storage time which is the same as the type of the start time. For example, the storage database includes the occurrence time and the transaction time of the query event, and the type of the start time in the target event information is the transaction time, and when the event query is performed in the storage database, the start time and the transaction time are compared.
In practical applications, after determining the current query event from the storage database, it may be determined whether the storage time of the current query event meets the end time, where the storage time meets the end time refers to that the storage time is less than or equal to the end time, or it may be understood that the storage time is the same as or before the end time, that is, the storage time is earlier than the end time in terms of timing before the end time. If the storage time of the current query event meets the end time, the current query event can be directly determined as a query result corresponding to the event query request.
It should be noted that, because the target event information carried by the event query request may not match with the preset storage format of the storage database, the current query event cannot be directly determined from the storage database directly according to the start time and the event identifier. Therefore, the data format of the target event information and the preset storage format of the storage database can be unified, and the current query event can be determined from the storage database directly according to the starting time and the event identification. Specifically, there are various ways of unifying the target event information and the data format and the preset storage format of the storage database, and the selection is specifically made according to the actual situation, which is not limited in any way in the embodiment of the present specification.
In one possible implementation manner of the present disclosure, a data format of the target event information may be determined, and format conversion is performed on event information of each query event stored in the storage database to obtain updated event information of each query event, where the data format of the event information of each query event after updating is the same as the data format of the target event information.
For example, assuming that the preset storage format of the storage database is a binary array and the data format of the target event information is Long type, format conversion can be performed on the event information in the binary array format to obtain the event information of each query event after the update of Long type.
Specifically, the binary representation of each byte (byte) value in a binary array may be taken from right to left every 8 bits, and then concatenated to be the binary representation of the long-type value. The 0xff operator is used to ensure that the sign bit of the byte value is correct. In practical applications, format conversion may be performed by the following codes:
longunsigned=
((((long)source.readByte())<<56)
|(((long)source.readByte()&0xff)<<48)
|(((long)source.readByte()&0xff)<<40)
|(((long)source.readByte()&0xff)<<32)
|(((long)source.readByte()&0xff)<<24)
|(((long)source.readByte()&0xff)<<16)
|(((long)source.readByte()&0xff)<<8)
|(((long)source.readByte()&0xff)));
returnunsigned^Long.MIN_VALUE;
in another possible implementation manner of the present disclosure, since the amount of data in the storage database is large, a lot of resources are consumed for format conversion of the event information of each query event in the storage database, so that the data format of the target event information may be converted into the same format as the preset storage format of the storage database, that is, before determining the current query event from the storage database according to the start time and the event identifier, the method may further include the following steps:
Determining a preset storage format of a storage database;
and converting the format of the target event information to obtain updated target event information, wherein the data format of the updated target event information is the same as a preset storage format.
Specifically, the data in the preset storage format may be stored in the storage database, and the preset storage format may be a binary number set, or may be other storage formats, which are specifically selected according to the actual situation, and the embodiment of the present disclosure is not limited in any way.
For example, assuming that the preset storage format of the storage database is a binary array and the data format of the target event information is Long type, format conversion may be performed on the Long type target event information to obtain updated target event information in the form of a binary array.
Specifically, the Long type value may be converted into a byte array with high bytes preceding and low bytes following. The binary representation of the Long value is fetched every 8 bits from left to right, which is a binary representation of a byte value. In practical applications, format conversion may be performed by the following codes:
longunsigned=record^Long.MIN_VALUE;
target.write((byte)(unsigned>>56));
target.write((byte)(unsigned>>48));
target.write((byte)(unsigned>>40));
target.write((byte)(unsigned>>32));
target.write((byte)(unsigned>>24));
target.write((byte)(unsigned>>16));
target.write((byte)(unsigned>>8));
target.write((byte)(unsigned));
by applying the scheme of the embodiment of the specification, the preset storage format of the storage database is determined; the format conversion is carried out on the target event information to obtain updated target event information, so that the processing amount of format conversion data is reduced, and the current query event is determined from the storage database directly according to the starting time and the event identification.
In practical applications, there are various ways of determining the current query event from the storage database according to the start time and the event identifier, and the embodiment of the present disclosure is not limited in any way.
In one possible implementation manner of the present disclosure, a specified query event with the same identifier as the event identifier may be screened out from a storage database, and a current query event with a storage time greater than or equal to the start time may be screened from the specified query event according to the start time and the storage time of the specified query event.
In another possible implementation manner of the present disclosure, determining the current query event from the storage database according to the start time and the event identifier may include the following steps:
generating initial combination information according to the initial time and the event identifier;
comparing the initial combination information with the storage information of each query event in the storage database to determine the current query event.
It should be noted that, because the plurality of query events in the storage database are stored based on time sequence, that is, each query event in the storage database is stored in sequence according to the sequence of the storage time. Thus, the start time and the event identification can be combined, and an iterator of the storage database is utilized to traverse each query event in the storage database according to the time sequence, so as to determine the current query event with the same start combination information and storage information.
By applying the scheme of the embodiment of the specification, initial combination information is generated according to the initial time and the event identifier; and comparing the initial combination information with the storage information of each query event in the storage database to determine the current query event, thereby improving the efficiency of determining the current query event.
In practical application, the manner of determining the current query event is various by comparing the initial combination information with the stored information of each query event in the stored database, and the selection is specifically performed according to the practical situation, which is not limited in any way in the embodiment of the present specification.
In one possible implementation manner of the present disclosure, an event identifier in initial combination information and a storage identifier of each query event may be compared first, if the event identifier and the storage identifier are different, then there is no need to compare the initial time and the storage time in the initial combination information, that is, the initial combination information and the storage information of each query event in the storage database are compared, and the current query event is determined, which may include the following steps:
comparing the event identification with the storage identifications of the query events, and under the condition that the event identification and the storage identifications are the same, comparing the starting time with the storage time of the query events, and determining the query event with the storage time meeting the starting time as the current query event.
Illustratively, as shown in table 1, table 1 is a data storage table storing a database, where the data storage table includes a storage identifier of a query event, a storage time, and the query event. X in the query event List ([ X, Y, Z ]) is the storage time, Y is the storage identification, Z is the price field, and the sequence of X, Y and Z is not limited. Assuming that the start time in the target event information is 3 and the event identification is 0571, it can be determined that the start combination information is 0571+3.
First comparison: determining that the storage information is 0500+1 according to the storage identifier 0500 and the storage time 1 of the query event List ([ 1,0500,8 ]), comparing whether the event identifier 0571 and the storage identifier 0500 are identical or not, determining that the event identifier 0571 and the storage identifier 0500 are different, and stopping the first comparison; second comparison: determining that the storage information is 0571+1 according to the storage identifier 0571 and the storage time 1 of the query event List ([ 1,0571,17 ]), comparing whether the event identifier 0571 and the storage identifier 0571 are identical or not, determining that the event identifier 0571 and the storage identifier 0571 are identical or not, comparing whether the storage time 1 meets the starting time 3 or not, and comparing the next query event if the storage time 1 does not meet the starting time; third comparison: determining that the storage information is 0500+2 according to the storage identifier 0500 and the storage time 2 of the query event List ([ 2,0500,9 ]), comparing whether the event identifier 0571 and the storage identifier 0500 are identical or not, determining that the event identifier 0571 and the storage identifier 0500 are different, and stopping third comparison; fourth comparison: and determining that the storage information is 0571+3 according to the storage identifier 0571 and the storage time 3 of the query event List ([ 3,0571,18 ]), comparing whether the event identifier 0571 and the storage identifier 0571 are identical, determining that the event identifier 0571 and the storage identifier 0571 are identical, comparing whether the storage time 3 meets the starting time 3, and determining that the event identifier and the storage time 3 meet the starting time, and determining the query event List ([ 3,0571,18 ]) as the current query event.
After the current query event is obtained, comparing the target event information with the storage information of the query event after the current query event, determining that the storage time of the query event List ([ 7,0571,20 ]) does not meet the end time 5, stopping iteration, and determining the query event List ([ 3,0571,18 ]) and the query event List ([ 5,0571,19 ]) as target query events corresponding to the event query request, wherein the specific comparison process is detailed in the following examples.
Table 1 data storage table for storing database
Storing identification Storage time Query events
0500 1 List([1,0500,8])
0571 1 List([1,0571,17])
0500 2 List([2,0500,9])
0571 3 List([3,0571,18])
0500 3 List([3,0500,10])
0571 5 List([5,0571,19])
0571 7 List([7,0571,20])
By applying the scheme of the embodiment of the specification, comparing the event identification with the storage identifications of all the query events, and under the condition that the event identification and the storage identifications are the same, comparing the starting time with the storage time of all the query events, and determining the query event with the storage time meeting the starting time as the current query event. In the process of comparing event identification with storage identification, if the event identification is different from the storage identification, the starting time and the storage time are not required to be compared, the data comparison quantity is reduced, and the efficiency of determining the current query event is improved.
In another possible implementation manner of the present disclosure, a query event whose storage time satisfies a start time may be determined in the storage database, and then a current query event is determined according to the event identifier and a storage identifier of the query event whose storage time satisfies the start time (the storage time is greater than or equal to the start time), that is, the storage information includes the storage time and the storage identifier; the comparing the initial combination information with the stored information of each query event in the stored database to determine the current query event may include the following steps:
Determining a first query event with the storage time meeting the starting time according to the time sequence comparison starting time and the storage time of each query event;
and comparing the stored information and the event identification of the first query event and the subsequent query events according to the time sequence, and determining the query event with the same stored identification as the event identification as the current query event.
Illustratively, as shown in table 2, table 2 is another data storage table storing databases, where the data storage table includes storage identifications of query events, storage times, and query events. X in the query event List ([ X, Y, Z ]) is the storage time, Y is the storage identification, Z is the price field, and the sequence of X, Y and Z is not limited. Assuming that the start time in the target event information is 3 and the event identification is 0571, it can be determined that the start combination information is 3+0571.
First comparison: according to the storage time 1 of the query event List ([ 1,0500,8 ]) and the storage identifier 0500, determining that the storage information is 1+0500, comparing whether the storage time 1 meets the starting time 3, determining that the storage time is not met, and stopping the first comparison; second comparison: determining that the storage information is 1+0571 according to the storage time 1 of the query event List ([ 1,0571,17 ]) and the storage identifier 0571, comparing whether the storage time 1 meets the starting time 3 or not, determining that the storage time 1 does not meet the starting time, and stopping the second comparison; third comparison: determining that the storage information is 2+0500 according to the storage time 2 of the query event List ([ 2,0500,9 ]) and the storage identifier 0500, comparing whether the storage time 2 meets the starting time 3 or not, determining that the storage time is not met, and stopping the third comparison; fourth comparison: according to the storage time 3 of the query event List ([ 3,0571,18 ]) and the storage identifier 0571, determining that the storage information is 3+0571, comparing whether the storage time 3 meets the starting time 3, determining that the storage time is met, taking the query event List ([ 3,0571,18 ]) as a first query event, comparing whether the event identifier 0571 and the storage identifier 0571 are identical, determining that the event identifier 0571 and the storage identifier 0571 are identical, and determining the query event List ([ 3,0571,18 ]) as a current query event.
After the current query event is obtained, comparing the target event information with the storage information of the query event after the current query event, determining that the storage time of the query event List ([ 7,0571,20 ]) does not meet the end time 5, stopping iteration, and determining the query event List ([ 3,0571,18 ]) and the query event List ([ 5,0571,19 ]) as target query events corresponding to the event query request, wherein the specific comparison process is detailed in the following examples.
Table 2 data storage table for storing database
Storage time Storing identification Query events
1 0500 List([1,0500,8])
1 0571 List([1,0571,17])
2 0500 List([2,0500,9])
3 0571 List([3,0571,18])
3 0500 List([3,0500,10])
5 0571 List([5,0571,19])
7 0571 List([7,0571,20])
By applying the scheme of the embodiment of the specification, according to the time sequence comparison starting time and the storage time of each inquiry event, determining a first inquiry event of which the storage time meets the starting time; and comparing the stored information and the event identification of the first query event and the subsequent query events according to the time sequence, and determining the query event with the same stored identification as the event identification as the current query event. In the process of comparing the starting time with the storage time, if the storage time does not meet the starting time, event identification and storage identification are not required to be compared, the data comparison quantity is reduced, and the efficiency of determining the current query event is improved.
In still another possible implementation manner of the present disclosure, the storage information of each query event may be generated according to the storage identifier and the storage time in the storage database, and the current query event may be determined directly according to the time sequence comparison starting combination information and the storage information of each query event.
Step 506: comparing the target event information with the stored information of the candidate query events after the current query event, and obtaining the comparison result of each candidate query event under the condition that the stored information does not meet the ending time.
In one or more embodiments of the present disclosure, after receiving an event query request and determining a current query event from a storage database according to a start time and an event identifier, further, target event information and storage information of candidate query events after the current query event may be compared, and if the storage information does not satisfy an end time, a comparison result of each candidate query event may be obtained.
Specifically, the candidate query event refers to a query event stored in the storage database for a time greater than or equal to the storage time of the current query event. The storage information not satisfying the end time means that the storage information includes a storage time longer than the end time, and it is also understood that the storage time is later than the end time. The comparison results of the candidate query events include the identification comparison results of the storage identification and the event identification and the comparison results of the storage time and the end time.
In practical application, the comparison between the target event information and the stored information of the candidate query event after the current query event is performed, and under the condition that the stored information does not meet the end time, the comparison result of each candidate query event is obtained in various manners, specifically, the comparison result is selected according to the practical situation, which is not limited in any way in the embodiment of the present specification.
In one possible implementation manner of the present disclosure, specified candidate query events after the current query event and the storage time not meeting the end time may be screened according to the end time in the target event information, and the comparison result of each candidate query event may be further determined according to the event identifier and the storage identifier of each candidate query event after the current query event and before the specified candidate query event, that is, the storage information includes the storage time and the storage identifier; comparing the target event information with the stored information of the candidate query event after the current query event, and obtaining a comparison result of each candidate query event if the stored information does not satisfy the end time, the method may include the steps of:
comparing the end time with the storage time of each candidate query event, and determining the designated candidate query event of which the storage time does not meet the end time;
and comparing the event identification with the storage identifications of the candidate query events before the designated candidate query event respectively to obtain the comparison result of the candidate query events.
Specifically, the storage time of the candidate query event preceding the specified candidate query event is less than the storage time of the specified candidate query event.
Illustratively, as shown in Table 1 above, assuming a start time of 3, an event identification of 0571, an end time of 5, and a current query event of List ([ 3,0571,18 ]). The candidate query events may be determined to be List ([ 3,0500,10 ]), list ([ 5,0571,19 ]), and List ([ 7,0571,20 ]). The end time 5 is compared with the storage time of each candidate query event, the designated candidate query event is determined as List ([ 7,0571,20 ]), and the candidate query event before the designated candidate query event is determined as List ([ 5,0571,19 ]) and List ([ 3,0500,10 ]). Further comparing the event identifier 0571 with a storage identifier 0500 of a List ([ 3,0500,10 ]) to obtain a comparison result that the storage identifier is different from the event identifier; the event identifier 0571 is compared with the stored identifier 0571 of the List (5,0571,19), and the comparison result is that the stored identifier is identical to the event identifier.
In another possible implementation manner of the present disclosure, the comparing the target event information with the stored information of the candidate query event after the current query event, and obtaining the comparison result of each candidate query event if the stored information does not meet the end time may include the following steps:
taking the next candidate query event of the current query event as a target candidate query event, and comparing the target event information with the storage information of the target candidate query event to obtain a comparison result;
And taking the next candidate query event of the target candidate query event as the updated target candidate query event, and returning to the step of executing the comparison of the target event information and the storage information of the target candidate query event to obtain a comparison result until the storage information of the target candidate query event does not meet the ending time to obtain the comparison result of each candidate query event.
Illustratively, as shown in Table 1 above, assuming a start time of 3, an event identification of 0571, an end time of 5, and a current query event of List ([ 3,0571,18 ]).
The next candidate query event List ([ 3,0500,10 ]) of the current query event is taken as the target candidate query event. Since the updated storage time 3 of the target candidate query event satisfies the end time 5, comparing the target event information with the storage information of the target candidate query event, and obtaining the comparison result of the candidate query event List ([ 3,0500,10 ]) that the storage time satisfies the start time and the end time but the storage identification is different from the event identification.
And taking the next candidate query event List ([ 5,0571,19) of the target candidate query event List ([ 3,0500,10 ]) as an updated target candidate query event, and comparing the target event information with the storage information of the target candidate query event List ([ 5,0571,19 ]), wherein the comparison result of the target candidate query event List ([ 5,0571,19 ]) is that the storage time satisfies the starting time and the ending time and the storage identification is the same as the event identification because the storage time 5 of the updated target candidate query event satisfies the ending time 5.
And taking the next candidate query event List (7,0571,20) of the target candidate query event List (5,0571,19) as an updated target candidate query event, and stopping iteration to obtain a comparison result of each candidate query event as the storage time 7 of the updated target candidate query event does not meet the end time 5.
By applying the scheme of the embodiment of the specification, iteration update is carried out on the target candidate query event by utilizing the next candidate query event of the target candidate query event until the stored information of the target candidate query event does not meet the end time, iteration is stopped, the comparison result of each candidate query event is obtained, the missing of the candidate query event is avoided, and the efficiency and the accuracy of event query are improved.
In practical application, there are various ways of comparing the target event information with the stored information of the target candidate query event to obtain the comparison result, and the comparison result is specifically selected according to the practical situation, which is not limited in any way in the embodiment of the present specification.
In one possible implementation manner of the present disclosure, the start time and the storage time of the target candidate query event, the comparison end time and the storage time of the target candidate query event may be compared respectively, and the event identifier and the storage identifier of the target candidate query event may be compared to obtain a comparison result.
In another possible implementation manner of the present disclosure, the comparing the target event information with the stored information of the target candidate query event to obtain a comparison result may include the following steps:
generating end combination information according to the end time and the event identifier;
and comparing the combination information with the stored information of the target candidate query event to obtain a comparison result.
It should be noted that, since the target candidate query event is a query event subsequent to the current query event, the storage time of the target candidate query event satisfies the start time, and it is not necessary to compare the start time with the storage time of the target candidate query event.
By applying the scheme of the embodiment of the specification, ending combination information is generated according to the ending time and the event identifier; and comparing the combination information with the stored information of the target candidate query event to obtain a comparison result, thereby improving the efficiency of determining the comparison result.
In practical application, there are various ways to compare the end combination information with the stored information of the target candidate query event, and the comparison result is specifically selected according to the practical situation, which is not limited in any way in the embodiment of the present specification.
In one possible implementation manner of the present disclosure, the storage information includes a storage time and a storage identifier; comparing the end combination information with the stored information of the target candidate query event to obtain a comparison result, which may include the steps of:
Comparing the event identification with the storage identification of the target candidate query event, and under the condition that the event identification and the storage identification are the same, comparing the ending time with the storage time of the target candidate query event, and determining a comparison result.
It should be noted that, under the condition that the storage identifier of the candidate query event is the same as the event identifier and the storage time satisfies the start time and the end time, the candidate query event is determined to be the query event corresponding to the event query request. Therefore, the event identification and the storage identification of the target candidate query event can be compared firstly, if the event identification and the storage identification are different, the comparison of the ending time and the storage time is not needed, and the comparison result of the target candidate query event is determined to be unmatched; if the event identification is the same as the storage identification, comparing the ending time with the storage time of the target candidate query event, and determining a comparison result.
Illustratively, as shown in the above table 1, assuming that the start time is 3, the event identification is 0571, and the end time is 5 in the target event information, it may be determined that the end combination information is 0571+5, and that the current query event is List ([ 3,0571,18 ]), and that the target candidate query event is a query event List ([ 3,0500,10 ]), a query event List ([ 5,0571,19 ]), and a query event List ([ 7,0571,20 ]), according to the above embodiments.
First comparison: determining that the storage information is 0500+3 according to the storage identifier 0500 and the storage time 3 of the query event List ([ 3,0500,10 ]), comparing whether the event identifier 0571 and the storage identifier 0500 are identical or not, determining that the event identifier 0571 and the storage identifier 0500 are different, and stopping the first comparison; second comparison: determining that the storage information is 0571+5 according to the storage identifier 0571 and the storage time 5 of the query event List ([ 5,0571,19 ]), comparing whether the event identifier 0571 and the storage identifier 0571 are identical or not, determining that the event identifier 0571 and the storage identifier 0571 are identical or not, comparing whether the storage time 5 meets the end time 5 or not, and comparing the next query event if the storage time meets the end time 5; third comparison: and determining that the storage information is 0571+7 according to the storage identifier 0571 and the storage time 7 of the query event List ([ 7,0571,20 ]), comparing whether the event identifier 0571 and the storage identifier 0571 are identical, determining that the event identifier 0571 and the storage identifier 0571 are identical, comparing whether the storage time 7 meets the end time 5, determining that the event identifier and the storage time 7 are not met, stopping iteration, and determining the query event List ([ 3,0571,18 ]) and the query event List ([ 5,0571,19 ]) as target query events corresponding to the event query request.
By applying the scheme of the embodiment of the specification, comparing the event identification with the storage identification of the target candidate query event, and under the condition that the event identification and the storage identification are the same, comparing the ending time with the storage time of the target candidate query event to determine a comparison result. Under the condition that the event identification and the storage identification are different, the end time and the storage time are not required to be compared, the data comparison quantity is reduced, and the event query efficiency is improved.
In another possible implementation manner of the present disclosure, the end time and the storage time of the target candidate query event may be compared, and if the storage time meets the end time, the event identifier and the storage identifier of the target candidate query event are compared, so as to obtain a comparison result.
Step 508: and obtaining a query result corresponding to the event query request according to the comparison result of each candidate query event.
In one or more embodiments of the present disclosure, an event query request is received, a current query event is determined from a storage database according to a start time and an event identifier, target event information is compared with storage information of candidate query events after the current query event, and after comparison results of candidate query events are obtained if the storage information does not satisfy an end time, further, query results corresponding to the event query request may be obtained according to the comparison results of candidate query events.
It is worth to describe that, according to the comparison result of each candidate query event, the target query event with the same storage identifier and event identifier and the storage time meeting the start time and the end time is screened from each candidate query event, and under the condition that the storage time of the current query event meets the end time, the target query event and the current query event are used as the query result corresponding to the event query request.
By applying the scheme of the embodiment of the specification, the current query event is determined from the storage database according to the starting time and the event identification, the target event information is compared with the storage information of the candidate query event after the current query event, and when the storage information does not meet the ending time, the information comparison is stopped, the query result corresponding to the event query request is determined, all query events stored in the storage database do not need to be traversed, the event query time is saved, and the event query efficiency is improved.
In an optional embodiment of the present disclosure, in a case of converting a data format of target event information into a preset storage format, obtaining a query result corresponding to an event query request according to the comparison result of each candidate query event may include the following steps:
determining at least one target query event corresponding to the event query request according to the comparison result of each candidate query event;
and carrying out format conversion on the event value of the at least one target query event to obtain at least one query result, wherein the data format of the at least one query result is the same as the data format of the target event information.
Illustratively, assuming that the target event information is Long type data, the event value of the target query event is a binary group. After determining at least one target query event corresponding to the event query request according to the comparison result of each candidate query event, format conversion can be performed on the event value, and the event value of the binary number group is converted into a Long type data format.
By applying the scheme of the embodiment of the specification, the data format of the event value of the target query event is converted into the data format of the event query request carrying the target event information, so that the data format of the query result fed back to the user is the same as the data format of the target event information sent by the user, the integrity of the event query process is ensured, and the user experience is improved.
In an optional embodiment of the present disclosure, after obtaining the query result corresponding to the event query request according to the comparison result of each candidate query event, the method may further include the following steps:
based on the time sequence of each candidate query event, a query result corresponding to the event query request is sent to the user.
It should be noted that, since each query event stored in the storage database corresponds to a storage time, after determining at least one target query event corresponding to the event query request, the target query event may be sent to the user according to a time sequence of the at least one target query event and a time sequence.
By applying the scheme of the embodiment of the specification, the query results corresponding to the event query requests are sent to the user based on the time sequence of each candidate query event, and the user does not need to order after obtaining at least one target query event, so that the user time is saved, and the user experience is improved.
In an alternative embodiment of the present disclosure, a plurality of query events included in a storage database are stored by:
extracting a storage identifier, a storage time and an event value of each query event from event information of a plurality of query events;
for any query event, respectively carrying out serialization processing on a storage identifier, a storage time and an event value of the query event to obtain the storage identifier, the storage time and the event value in a preset storage format;
determining the storage information of the query event according to the storage identification and the storage time of a preset storage format;
storing the storage information of each inquiry event and the event value in a preset storage format into a storage database according to time sequence.
It should be noted that, there are various ways to extract the storage identifier (GroupKey), the storage time (userekey) and the event Value (Value) of each query event from the event information of the plurality of query events, and the embodiment of the present disclosure is not limited in any way. In one possible implementation manner of the present disclosure, event information of each query event may be matched with a preset word stock, so as to determine a storage identifier, a storage time and an event value of each query event. In another possible implementation manner of the present specification, the storage identifier, the storage time and the event value may be extracted from the event information of each query event by using a pre-trained information extraction model.
Further, the stored identification, the stored time and the event value of the query event can be serialized through a serializer. In practical applications, the sequencers corresponding to the storage identifier, the storage time and the event value may be different, for example, the sequencer corresponding to the storage time is a time sequencer. The time serializer may ensure that the unsigned size order of the preset storage format data and the size order of the original format data are expected to coincide.
After the storage identifier, the storage time and the event value of the preset storage format are obtained, the serialized storage identifier and the storage time can be spliced into storage information, and the storage information and the event value of the preset storage format are stored in a storage database according to time sequence.
By applying the scheme of the embodiment of the specification, the storage identification, the storage time and the event value of each query event are extracted from the event information of a plurality of query events; for any query event, respectively carrying out serialization processing on a storage identifier, a storage time and an event value of the query event to obtain the storage identifier, the storage time and the event value in a preset storage format; determining the storage information of the query event according to the storage identification and the storage time of a preset storage format; and storing the storage information of each query event and the event value in a preset storage format into a storage database according to the time sequence, so that the event query can be efficiently and accurately carried out according to the time sequence.
Referring to fig. 6, fig. 6 shows a process flow chart of an event query method according to an embodiment of the present disclosure, specifically including the following steps:
step 602: and receiving an event query request, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time.
Step 604: a preset storage format of the storage database is determined.
Step 606: and carrying out format conversion on the target event information to obtain updated event identification, starting time and ending time, wherein the data format of the updated event identification, starting time and ending time is the same as the preset storage format.
Step 608: and generating initial combination information according to the updated initial time and the updated event identifier.
Step 610: comparing the initial combination information with the storage information of each query event in the storage database, determining the current query event, and taking the next candidate query event of the current query event as a target candidate query event.
Step 612: and comparing the target event information with the stored information of the target candidate query event to obtain a comparison result.
Step 614: and taking the next candidate query event of the target candidate query event as an updated target candidate query event, and returning to the step of executing the comparison of the target event information and the storage information of the target candidate query event to obtain a comparison result until the storage information of the target candidate query event does not meet the updated ending time to obtain the comparison result of each candidate query event.
Step 616: and obtaining a query result corresponding to the event query request according to the comparison result of each candidate query event.
It should be noted that, the specific implementation manner of step 602 to step 616 is the same as the implementation manner of the event query method provided in fig. 5, and the description of the embodiment of the present disclosure is omitted.
By applying the scheme of the embodiment of the specification, the current query event is determined from the storage database according to the starting time and the event identification, the target event information is compared with the storage information of the candidate query event after the current query event, and when the storage information does not meet the ending time, the information comparison is stopped, the query result corresponding to the event query request is determined, all query events stored in the storage database do not need to be traversed, the event query time is saved, and the event query efficiency is improved.
Referring to fig. 7, fig. 7 shows a process flow diagram of another event query method provided in accordance with an embodiment of the present specification. The event inquiry method introduces a state type-time sequence state, is used for storing time sequence events which are provided with event time and occur in time sequence in operators, and supports efficient range inquiry of events for a period of time. The range query is realized through the iterator, and the performance of the range query is optimized based on the time sequencer, the binary comparator and the buffer, and the method specifically comprises the following steps:
Binary ordered writing: binary ordering is to order the time of the time sequence inquiry event according to binary and write the time sequence inquiry event into a storage database. The method specifically comprises the following three steps:
the first step: grouping event information of the query event according to a preset field, taking the grouping field as a storage identifier, taking event time as Long storage time, and taking the whole event as an event value;
and a second step of: serializing the storage identifier and the event value into binary groups through a corresponding type of serializer, and serializing the storage time into the binary groups through a time serializer;
and a third step of: splicing the serialized storage identification and the storage time into storage information, taking the storage information as Key, and writing the serialized event Value as Value into a storage database.
Range query: the range query is a traversal query of a binary ordered write timing query event for a period of time according to a time range. The method specifically comprises the following five steps:
the first step: serializing the starting time and the ending time of the time range into binary groups through a time serializer, combining the current event identifier serving as a prefix with the starting time to form starting combination information, and combining the ending time to form ending combination information;
And a second step of: obtaining an iterator for storing the database, and positioning (Seek) to the position of the initial combination information;
and a third step of: calling an iterator (iterating plus one) for storing the database to locate a current query event greater than or equal to the starting time;
fourth step: acquiring the storage information of the current query event, wherein the storage information is a binary combination of a storage identifier and storage time, acquiring a binary prefix of the storage information, judging whether the binary prefix is matched with the event identifier, and entering a fifth step if the binary prefix is matched with the event identifier; if the first step is not matched, returning to the third step to continue iteration;
fifth step: and erasing the binary prefix in the stored information of the current query event and the binary prefix of the ending combination information to obtain the binary storage time and the binary ending time of the current query event. And comparing the storage time with the end time through a binary comparator, and judging whether iteration is finished or not. If the storage time is less than or equal to the end time, entering a third step to continue iteration; if the storage time is longer than the ending time, ending the iteration, storing the target query event obtained by the iteration into a cache, traversing the target query event from the cache, and performing deserialization processing on the target query event to finish the range query.
It should be noted that, because the iterator for creating the storage database has time overhead each time, in order to optimize the performance of the range query operation, all elements of one iteration may be cached in the first iteration, so that only one iterator for creating the storage database is needed in one iteration, and the next element is obtained directly from the cache through the created iterator.
Referring to fig. 8, fig. 8 is a schematic diagram illustrating data comparison in an event query method according to an embodiment of the present disclosure. The binary comparator is used for comparing the byte arrays x (0-7) and the byte arrays y (0-7) according to the byte ratio, as shown in fig. 8, the binary comparator is defined as comparing the bytes of the serialized data types one by one in an unsigned manner, so that the expected consistency of the size comparison before and after serialization by the key serializer is ensured, and the inverse serialization of key information during iteration is avoided, thereby bringing additional expense.
By applying the scheme of the embodiment of the specification, as the storage database is a high-performance, durable and embedded key value storage engine, the number of scanned key value pairs can be reduced by inquiring the prefix scanning method of the key value pairs with specific prefixes in the storage database, so that the inquiring efficiency is improved. In addition, the time sequence state introduced by the embodiment of the specification supports time sequence event inquiry according to a time range, ensures that the inquired events are ordered according to time, avoids searching events which are not in the time range, avoids redundant reverse serialization expenditure, and improves inquiry performance.
In practical application, the performance of the event query method provided in the embodiment of the present disclosure may be increased by more than 200% compared with that of the conventional scheme, and the following is a comparison result of the performance test of the event query method provided in the embodiment of the present disclosure and the conventional scheme, specifically referring to table 3, and table 3 is a comparison table of query performance. The test data specifically contains 1000 storage identifiers, 100 keys, value is a single POJO type sequence (List), and POJO contains 7 fields. The Key range of 10-50 values can be respectively inquired for 1000 storage identifiers by one operation, the performance represents the time consumption condition of each operation, and the repeated operation times are 15 times:
table 3 lookup performance versus table
Referring to fig. 9, fig. 9 illustrates an interface diagram of an event query interface provided in accordance with one embodiment of the present description.
The event inquiry interface is divided into a request input interface and a result display interface. The request input interface includes a request input box, a "determine" control, and a "cancel" control. The result display interface comprises a query result display frame. The user inputs an event query request through a request input box displayed by the client, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time. The user clicks a 'determining' control, the server receives an event inquiry request sent by the client, and determines a current inquiry event from a storage database according to the starting time and the event identifier, wherein the storage database comprises a plurality of inquiry events stored on the basis of time sequence; comparing the target event information with the stored information of the candidate query events after the current query event, and obtaining a comparison result of each candidate query event under the condition that the stored information does not meet the ending time; and obtaining a query result corresponding to the event query request according to the comparison result of each candidate query event. The server sends the query result to the client so that the client displays the query result corresponding to the event query request in the query result display frame.
It should be noted that, the manner in which the user operates the control includes any manner such as clicking, double clicking, touch control, mouse hovering, sliding, long pressing, voice control or shaking, and the embodiment of the present disclosure does not limit the foregoing.
Corresponding to the method embodiment, the present disclosure further provides an event query device embodiment, and fig. 10 shows a schematic structural diagram of an event query device according to an embodiment of the present disclosure. As shown in fig. 10, the apparatus includes:
a receiving module 1002 configured to receive an event query request, wherein the event query request carries target event information, the target event information including an event identifier, a start time, and an end time;
a determining module 1004 configured to determine a current query event from a storage database according to a start time and an event identification, wherein the storage database includes a plurality of query events stored based on time sequence;
a comparison module 1006 configured to compare the stored information of the candidate query event after the current query event with the target event information, and obtain a comparison result of each candidate query event if the stored information does not satisfy the end time;
The obtaining module 1008 is configured to obtain a query result corresponding to the event query request according to the comparison result of each candidate query event.
Optionally, the apparatus further comprises: the query event storage module is configured to extract storage identification, storage time and event value of each query event from event information of a plurality of query events; for any query event, respectively carrying out serialization processing on a storage identifier, a storage time and an event value of the query event to obtain the storage identifier, the storage time and the event value in a preset storage format; determining the storage information of the query event according to the storage identification and the storage time of a preset storage format; storing the storage information of each inquiry event and the event value in a preset storage format into a storage database according to time sequence.
Optionally, the comparing module 1006 is further configured to take a next candidate query event of the current query event as a target candidate query event, and compare the target event information with the stored information of the target candidate query event to obtain a comparison result; and taking the next candidate query event of the target candidate query event as the updated target candidate query event, and returning to the step of executing the comparison of the target event information and the storage information of the target candidate query event to obtain a comparison result until the storage information of the target candidate query event does not meet the ending time to obtain the comparison result of each candidate query event.
Optionally, the comparing module 1006 is further configured to generate end combination information according to the end time and the event identifier; and comparing the combination information with the stored information of the target candidate query event to obtain a comparison result.
Optionally, the storage information includes a storage time and a storage identifier; the comparing module 1006 is further configured to compare the event identifier with the stored identifier of the target candidate query event, and determine a comparison result by comparing the end time with the stored time of the target candidate query event if the event identifier and the stored identifier are the same.
Optionally, the storage information includes a storage time and a storage identifier; a comparison module 1006 further configured to compare the end time with the storage time of each candidate query event, determine that the storage time does not satisfy the specified candidate query event for the end time; and comparing the event identification with the storage identifications of the candidate query events before the designated candidate query event respectively to obtain the comparison result of the candidate query events.
Optionally, the determining module 1004 is further configured to generate initial combination information according to the initial time and the event identifier; comparing the initial combination information with the storage information of each query event in the storage database to determine the current query event.
Optionally, the storage information includes a storage time and a storage identifier; a comparison module 1006, further configured to determine a first query event whose storage time satisfies the start time according to the time sequence comparison start time and the storage time of each query event; and comparing the stored information and the event identification of the first query event and the subsequent query events according to the time sequence, and determining the query event with the same stored identification as the event identification as the current query event.
Optionally, the apparatus further comprises: the conversion module is configured to determine a preset storage format of the storage database; and converting the format of the target event information to obtain updated target event information, wherein the data format of the updated target event information is the same as a preset storage format.
Optionally, the obtaining module 1008 is further configured to determine at least one target query event corresponding to the event query request according to the comparison result of each candidate query event; and carrying out format conversion on the event value of the at least one target query event to obtain at least one query result, wherein the data format of the at least one query result is the same as the data format of the target event information.
Optionally, the apparatus further comprises: and the sending module is configured to send the query result corresponding to the event query request to the user based on the time sequence of each candidate query event.
By applying the scheme of the embodiment of the specification, the current query event is determined from the storage database according to the starting time and the event identification, the target event information is compared with the storage information of the candidate query event after the current query event, and when the storage information does not meet the ending time, the information comparison is stopped, the query result corresponding to the event query request is determined, all query events stored in the storage database do not need to be traversed, the event query time is saved, and the event query efficiency is improved.
The above is an exemplary scheme of an event query device of the present embodiment. It should be noted that, the technical solution of the event query device and the technical solution of the event query method belong to the same concept, and details of the technical solution of the event query device, which are not described in detail, can be referred to the description of the technical solution of the event query method.
FIG. 11 illustrates a block diagram of a computing device provided in accordance with an embodiment of the present specification. The components of computing device 1100 include, but are not limited to, a memory 1110 and a processor 1120. Processor 1120 is coupled to memory 1110 via bus 1130, and database 1150 is used to hold data.
The computing device 1100 also includes an access device 1140, the access device 1140 enabling the computing device 1100 to communicate via one or more networks 1160. Examples of such networks include a public switched telephone network (PSTN, publicSwitchedTelephoneNetwork), a local area network (LAN, localAreaNetwork), a wide area network (WAN, wideAreaNetwork), a personal area network (PAN, personalAreaNetwork), or a combination of communication networks such as the internet. The Access device 1140 may comprise one or more of any type of network interface, wired or wireless, such as a network interface card (NIC, networkInterfaceCard), such as an IEEE802.11 wireless local area network (WLAN, wirelessLocalAreaNetworks) wireless interface, a worldwide interoperability for microwave Access (Wi-MAX, worldInteroperabilityforMicrowave Access) interface, an ethernet interface, a universal serial bus (USB, universalSerialBus) interface, a cellular network interface, a bluetooth interface, a near-field communication (NFC, nearFieldCommunication) interface, and so forth.
In one embodiment of the present description, the above components of computing device 1100, as well as other components not shown in FIG. 11, may also be connected to each other, such as by a bus. It should be understood that the block diagram of the computing device illustrated in FIG. 11 is for exemplary purposes only and is not intended to limit the scope of the present description. Those skilled in the art may add or replace other components as desired.
Computing device 1100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), mobile phone (e.g., smart phone), wearable computing device (e.g., smart watch, smart glasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or personal computer (PC, personalComputer). Computing device 1100 may also be a mobile or stationary server.
Wherein the processor 1120 is configured to execute computer-executable instructions:
receiving an event query request, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time;
determining a current query event from a storage database according to the starting time and the event identification, wherein the storage database comprises a plurality of query events stored based on time sequence;
comparing the target event information with the stored information of the candidate query events after the current query event, and obtaining a comparison result of each candidate query event under the condition that the stored information does not meet the ending time;
And obtaining a query result corresponding to the event query request according to the comparison result of each candidate query event.
The foregoing is a schematic illustration of a computing device of this embodiment. It should be noted that, the technical solution of the computing device and the technical solution of the query sentence generating method belong to the same concept, and details of the technical solution of the computing device, which are not described in detail, can be referred to the description of the technical solution of the query sentence generating method.
An embodiment of the present disclosure also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, are configured to:
receiving an event query request, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time;
determining a current query event from a storage database according to the starting time and the event identification, wherein the storage database comprises a plurality of query events stored based on time sequence;
comparing the target event information with the stored information of the candidate query events after the current query event, and obtaining a comparison result of each candidate query event under the condition that the stored information does not meet the ending time;
And obtaining a query result corresponding to the event query request according to the comparison result of each candidate query event.
The above is an exemplary version of a computer-readable storage medium of the present embodiment. It should be noted that, the technical solution of the storage medium and the technical solution of the query sentence generating method belong to the same concept, and details of the technical solution of the storage medium which are not described in detail can be referred to the description of the technical solution of the query sentence generating method.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The computer instructions include computer program code that may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a Read-only memory (ROM), a random access memory (RAM, randomAccessMemory), an electrical carrier signal, a telecommunication signal, a software distribution medium, and so forth.
It should be noted that, for the sake of simplicity of description, the foregoing method embodiments are all expressed as a series of combinations of actions, but it should be understood by those skilled in the art that the present description is not limited by the order of actions described, as some steps may be performed in other order or simultaneously in accordance with the present description. Further, those skilled in the art will appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily all necessary in the specification.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to the related descriptions of other embodiments.
The preferred embodiments of the present specification disclosed above are merely used to help clarify the present specification. Alternative embodiments are not intended to be exhaustive or to limit the invention to the precise form disclosed. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the disclosure and the practical application, to thereby enable others skilled in the art to best understand and utilize the disclosure. This specification is to be limited only by the claims and the full scope and equivalents thereof.

Claims (14)

1. An event query method, comprising:
receiving an event query request, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time;
determining a current query event from a storage database according to the starting time and the event identification, wherein the storage database comprises a plurality of query events stored on the basis of time sequence;
comparing the target event information with the stored information of the candidate query events after the current query event, and obtaining a comparison result of each candidate query event under the condition that the stored information does not meet the ending time;
and obtaining a query result corresponding to the event query request according to the comparison result of each candidate query event.
2. The method of claim 1, wherein the storage database includes a plurality of query events stored by:
extracting a storage identifier, a storage time and an event value of each query event from event information of a plurality of query events;
for any query event, respectively carrying out serialization processing on a storage identifier, a storage time and an event value of the query event to obtain the storage identifier, the storage time and the event value in a preset storage format;
Determining the storage information of the query event according to the storage identification and the storage time of the preset storage format;
and storing the storage information of each inquiry event and the event value in a preset storage format into the storage database according to time sequence.
3. The method according to claim 1, wherein comparing the target event information with stored information of candidate query events subsequent to the current query event, and obtaining a comparison result of each candidate query event if the stored information does not satisfy the end time, comprises:
taking the next candidate query event of the current query event as a target candidate query event, and comparing the target event information with the stored information of the target candidate query event to obtain a comparison result;
and taking the next candidate query event of the target candidate query event as an updated target candidate query event, and returning to the step of executing the comparison of the target event information and the storage information of the target candidate query event to obtain a comparison result until the storage information of the target candidate query event does not meet the ending time to obtain the comparison result of each candidate query event.
4. The method of claim 3, wherein comparing the stored information of the target event information and the target candidate query event to obtain a comparison result comprises:
generating end combination information according to the end time and the event identifier;
and comparing the ending combination information with the stored information of the target candidate query event to obtain a comparison result.
5. The method of claim 4, wherein the stored information includes a storage time and a storage identification;
and comparing the end combination information with the stored information of the target candidate query event to obtain a comparison result, wherein the comparison result comprises:
and comparing the event identification with the storage identification of the target candidate query event, and comparing the ending time with the storage time of the target candidate query event under the condition that the event identification is the same as the storage identification, so as to determine a comparison result.
6. The method of claim 1, wherein the stored information includes a storage time and a storage identification;
the comparing the target event information with the stored information of the candidate query event after the current query event, and obtaining a comparison result of each candidate query event under the condition that the stored information does not meet the ending time, includes:
Comparing the ending time with the storage time of each candidate query event, and determining the designated candidate query event of which the storage time does not meet the ending time;
and comparing the event identification with the storage identification of each candidate query event before the designated candidate query event respectively to obtain a comparison result of each candidate query event.
7. The method of claim 1, wherein determining the current query event from a stored database based on the start time and the event identification comprises:
generating initial combination information according to the initial time and the event identifier;
and comparing the initial combination information with the storage information of each query event in the storage database to determine the current query event.
8. The method of claim 7, wherein the stored information includes a storage time and a storage identification;
the step of comparing the initial combination information with the stored information of each query event in the stored database to determine the current query event comprises the following steps:
determining a first query event with storage time meeting the starting time according to the time sequence comparison of the starting time and the storage time of each query event;
And comparing the stored information of the first query event and the subsequent query events with the event identification according to the time sequence, and determining the query event with the same stored identification as the event identification as the current query event.
9. The method of claim 1, wherein prior to determining a current query event from a stored database based on the start time and the event identification, further comprising:
determining a preset storage format of a storage database;
and carrying out format conversion on the target event information to obtain updated target event information, wherein the data format of the updated target event information is the same as the preset storage format.
10. The method according to claim 1, wherein the obtaining the query result corresponding to the event query request according to the comparison result of each candidate query event includes:
determining at least one target query event corresponding to the event query request according to the comparison result of each candidate query event;
and carrying out format conversion on the event value of the at least one target query event to obtain at least one query result, wherein the data format of the at least one query result is the same as the data format of the target event information.
11. The method according to claim 1, wherein after obtaining the query result corresponding to the event query request according to the comparison result of each candidate query event, the method further comprises:
and sending a query result corresponding to the event query request to a user based on the time sequence of each candidate query event.
12. An event query device, comprising:
the system comprises a receiving module, a processing module and a processing module, wherein the receiving module is configured to receive an event query request, wherein the event query request carries target event information, and the target event information comprises an event identifier, a starting time and an ending time;
a determining module configured to determine a current query event from a stored database according to the start time and the event identification, wherein the stored database includes a plurality of query events stored based on time sequence;
the comparison module is configured to compare the stored information of the candidate query event after the current query event with the target event information, and obtain a comparison result of each candidate query event under the condition that the stored information does not meet the ending time;
and the obtaining module is configured to obtain the query result corresponding to the event query request according to the comparison result of each candidate query event.
13. A computing device, comprising:
a memory and a processor;
the memory is configured to store computer executable instructions, the processor being configured to execute the computer executable instructions, which when executed by the processor, implement the steps of the method of any one of claims 1 to 11.
14. A computer readable storage medium, characterized in that it stores computer instructions which, when executed by a processor, implement the steps of the method of any of claims 1 to 11.
CN202310679417.4A 2023-06-08 2023-06-08 Event query method and device Pending CN116860743A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310679417.4A CN116860743A (en) 2023-06-08 2023-06-08 Event query method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310679417.4A CN116860743A (en) 2023-06-08 2023-06-08 Event query method and device

Publications (1)

Publication Number Publication Date
CN116860743A true CN116860743A (en) 2023-10-10

Family

ID=88225829

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310679417.4A Pending CN116860743A (en) 2023-06-08 2023-06-08 Event query method and device

Country Status (1)

Country Link
CN (1) CN116860743A (en)

Similar Documents

Publication Publication Date Title
US9043348B2 (en) System and method for performing set operations with defined sketch accuracy distribution
CN111459985A (en) Identification information processing method and device
CN105164674A (en) Queries involving multiple databases and execution engines
US8620946B2 (en) Storage and searching of temporal entity information
CN111258978A (en) Data storage method
CN113297269A (en) Data query method and device
CN105786941B (en) Information mining method and device
CN110928917A (en) Target user determination method and device, computing equipment and medium
CN113326363A (en) Searching method and device, prediction model training method and device, and electronic device
CN110515979B (en) Data query method, device, equipment and storage medium
CN116860743A (en) Event query method and device
CN115422270A (en) Information processing method and device
CN111291042B (en) Power data processing system and method for power supply service
CN114168589A (en) Index construction method and device
CN113626571A (en) Answer sentence generating method and device, computer equipment and storage medium
CN107180072B (en) Method and device for processing time sequence data
CN113515504B (en) Data management method, device, electronic equipment and storage medium
CN115438236B (en) Unified hybrid search method and system
CN111475742A (en) Address extraction method and device
CN114143279B (en) Interactive recording sampling method and device and storage medium
CN113515494B (en) Database processing method based on distributed file system and electronic equipment
KR102279109B1 (en) Distributed system and method for integrating knowledge
CN114756573B (en) Data processing method, device and system
CN111079391B (en) Report generation method and device
CN114691051B (en) Data processing method and device

Legal Events

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