Character string processing method and system applied to freight rate search system
By constructing character array template classes and generating template objects in the international freight search system, the freight data and freight-related data are structured and template operations are solved, and the freight search system is inefficient when processing string data, and string processing with high performance and low memory overhead is achieved.
Patent Information
- Application Number
- CN202411864892.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-04-18
AI Technical Summary
The existing international freight search system is inefficient when processing freight data and freight-related data strings, and cannot meet the performance indicators of high-performance freight search engines.
By constructing a character array template class, multiple template objects are generated, and the strings of these template objects are structured and templated, achieving efficient string processing.
It significantly improves the performance of string data processing, reduces memory overhead, speeds up string processing, and improves processing speed by 35%, meeting the needs of high-performance freight search engines.
Smart Images

Figure CN119848307A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular relates to a character string processing method and system applied to a freight rate search system. Background Art
[0002] As a medium between airlines and users, the international freight rate search system provides services to airlines and customers. With the rapid increase in demand for international routes, high requirements are placed on the performance of the international freight rate search system. Freight rate data and freight rate-related data, as basic data for air transportation, are the basis for international freight rate search engines to search, verify, calculate and display freight rates. At present, the sources of freight rate data and freight rate-related data of the international freight rate search system are mainly two parts. One part comes from ATPCO (Airline Tariff Publishing Company). ATPCO data mainly provides basic freight rates, freight rate rules, and additional service-related data required by the search engine. The other part comes from third parties, which mainly provides data required for additional functions of the international freight rate search engine. The above two parts of data are stored in the form of data files. Since the above two parts of data have different string formats and are different from the string formats requested by users, when the search engine processes string data, it will involve operations such as adding, deleting, modifying, checking, and comparing data. A search engine query operation will perform millions of string operations on the string data. If traditional string operations are used to perform millions of operations, the performance cannot meet the performance indicators of high-performance international freight search engines. How to make the search engine use the data in the data file quickly and efficiently has become an important factor in building a high-performance international freight search engine. Summary of the invention
[0003] To solve the above problems, the present invention provides a string processing method and system applied to a freight rate search system to solve the problem that the existing freight rate search engine has low efficiency in processing string data and cannot meet the performance indicators of a high-performance freight rate search engine.
[0004] A string processing method applied to a freight rate search system, comprising:
[0005] Get strings from freight rate data and freight rate related data from multiple data sources;
[0006] Construct a character array template class based on a string and generate multiple template objects;
[0007] Based on the character array template class, multiple template object strings are structured to obtain multiple structured strings, and
[0008] Based on the character array template class, perform template operations on strings of multiple template objects and return the operation results.
[0009] According to a specific embodiment of the present invention, obtaining the freight rate data and the character string of freight rate related data from multiple data sources includes:
[0010] Get the freight rate data and freight rate related data strings from the atpco data source and third-party data source, as well as the strings of user input requests.
[0011] According to a specific embodiment of the present invention, constructing a character array template class based on a string and generating multiple template objects includes:
[0012] Define character array template class and related parameters based on strings from multiple data sources. Related parameters include freight rate data from multiple data sources and the string length of freight rate related data;
[0013] Template objects corresponding to multiple data sources are generated based on a character array template class, wherein the template objects include an empty template object with a preset string length, a template object with a preset string length constructed based on a character array, a template object with a preset string length constructed based on a standard string, and a template object with a preset string length constructed based on a character array template class.
[0014] According to a specific embodiment of the present invention, based on the character array template class, the character strings of multiple template objects are structured to obtain multiple structured character strings including:
[0015] The freight rate data and freight rate related data strings from multiple data sources are read into a character array template class to generate multiple structured strings, wherein the contents and lengths of the multiple structured strings are the same.
[0016] According to a specific embodiment of the present invention, performing template operations on strings of multiple template objects based on a character array template class and returning operation results includes:
[0017] Assign strings to multiple template objects based on the character array template class and return the assignment results, and
[0018] Compare strings of multiple template objects based on the character array template class and return the comparison results, and
[0019] Based on the character array template class, perform addition operations on strings of multiple template objects and return the addition results, and
[0020] Based on the character array template class, perform a null operation on the strings of multiple template objects and return the result of the judgment, and
[0021] Performs length calculation on multiple template objects based on the character array template class and returns the length calculation results.
[0022] A string processing system applied to a freight rate search system, comprising:
[0023] An acquisition unit, used to acquire character strings from freight rate data and freight rate-related data from multiple data sources;
[0024] A template class construction unit, used to construct a character array template class based on a string and generate multiple template objects;
[0025] A structured processing unit, used for performing structured processing on strings of multiple template objects based on a character array template class to obtain multiple structured strings, and
[0026] The template operation unit is used to perform template operations on strings of multiple template objects based on the character array template class and return the operation results.
[0027] According to a specific embodiment of the present invention, the template class construction unit includes:
[0028] A template class definition unit, used to define a character array template class and related parameters based on character strings from multiple data sources, wherein the related parameters include the freight rate data from multiple data sources and the length of the character string of the freight rate related data;
[0029] A template object generation unit is used to generate template objects corresponding to multiple data sources based on a character array template class, wherein the template objects include an empty template object with a preset string length, a template object with a preset string length constructed based on a character array, a template object with a preset string length constructed based on a standard string, and a template object with a preset string length constructed based on a character array template class.
[0030] According to a specific embodiment of the present invention, the template operation unit includes:
[0031] The assignment operation unit is used to perform assignment operations on strings of multiple template objects based on the character array template class and return the assignment results;
[0032] A comparison operation unit is used to compare strings of multiple template objects based on the character array template class and return the comparison result;
[0033] The addition operation unit is used to perform addition operations on strings of multiple template objects based on the character array template class and return the addition results;
[0034] A null operation judgment unit, used for performing null operation judgment on strings of multiple template objects based on the character array template class and returning the judgment result;
[0035] The length calculation unit is used to perform length calculation operations on multiple template objects based on the character array template class and return the length calculation results.
[0036] A computer device includes a processor and a memory. The memory stores a computer program. The computer program is loaded and executed by the processor to implement the above-mentioned character string processing method applied to a freight rate search system.
[0037] A computer-readable storage medium stores a computer program, which is loaded and executed by a processor to implement the above-mentioned character string processing method applied to a freight rate search system.
[0038] Compared with the prior art, the string processing method and system provided by the present invention for use in a freight rate search system have the following advantages:
[0039] 1. Eliminates the data string differences between ATPCO data sources, third-party data sources, and user input requests, providing convenience for subsequent search engine processing.
[0040] 2. The performance of string data processing is significantly improved. The present invention utilizes a character array template class to process freight rate data strings, uses fixed-length characters to store each type of freight rate data, and uses template parameters to specify the length of each type of freight rate data. Under string operations based on the character array template class, the performance of traditional standard string processing is significantly improved, and the string processing speed is accelerated. The method for processing strings is 35% faster than that of traditional methods.
[0041] 3. Reduced memory overhead. Since the storage character array of this method determines the size according to the template parameter, and the traditional character array storage method needs to use "\0" to determine the end of the string array, the memory overhead can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0043] Figure 1 The present invention is a flowchart of a method for processing a character string applied to a fare search system according to an embodiment of the present invention.
[0044] Figure 2 It is a flow chart of a method for constructing a character array template class based on a string and generating multiple template objects according to an embodiment of the present invention.
[0045] Figure 3 It is a flow chart of a method for performing template operations on strings of multiple template objects based on a character array template according to an embodiment of the present invention.
[0046] Figure 4 The structure diagram of a string processing system applied to a fare search system according to an embodiment of the present invention is shown in FIG.
[0047] Figure 5 It is a structural diagram of a template class construction unit provided according to an embodiment of the present invention.
[0048] Figure 6 is a structural diagram of a template operation unit provided according to an embodiment of the present invention.
[0049] Figure 7 It is a structural schematic diagram of a computer device provided according to an embodiment of the present invention.
[0050] Reference numerals:
[0051] 01-acquisition unit; 02-template class construction unit; 03-structured processing unit; 04-template operation unit;
[0052] 021-Template class definition unit; 022-Template object generation unit;
[0053] 041-assignment operation unit; 042-comparison operation unit; 043-addition operation unit; 044-empty operation judgment unit; 045-length calculation unit. DETAILED DESCRIPTION
[0054] In order to make those skilled in the art understand the concept and thought of the present invention more clearly, the present invention is described in detail below in conjunction with specific embodiment.It should be understood that the embodiment provided herein is only a part of all embodiments that the present invention may have.Those skilled in the art, after reading the specification of the application, have the ability to make improvements, transformations, or replacements to part or the whole of the following embodiments, and these improvements, transformations, or replacements are also included in the scope of the present invention.
[0055] In this article, the terms "first", "second" and other similar words are not intended to imply any order, quantity and importance, but are only used to distinguish different elements. In this article, the terms "one", "an" and other similar words are not intended to indicate that there is only one thing, but to indicate that the relevant description is only for one of the things, and the thing may have one or more. In this article, the terms "comprise", "include" and other similar words are intended to indicate logical mutual relations, and cannot be regarded as indicating spatial structural relations. For example, "A includes B" is intended to indicate that B belongs to A logically, but does not mean that B is located inside A in space. In addition, the meanings of the terms "comprise", "include" and other similar words should be regarded as open, rather than closed. For example, "A includes B" is intended to indicate that B belongs to A, but B does not necessarily constitute the whole of A, and A may also include other elements such as C, D, and E.
[0056] In this document, the terms "embodiment", "this embodiment", "one embodiment", and "an embodiment" do not mean that the relevant description is only applicable to a specific embodiment, but rather that the description may also be applicable to one or more other embodiments. Those skilled in the art should understand that in this document, any description of a certain embodiment can be replaced, combined, or combined in other ways with the relevant descriptions in one or more other embodiments, and the new embodiments generated by the replacement, combination, or combination in other ways are easily conceivable by those skilled in the art and fall within the scope of protection of the present invention.
[0057] Example 1
[0058] Additional aspects and advantages of embodiments of the present invention will be described in part in the following description, and will become apparent from the following description, or will be learned through practice of embodiments of the present invention. Figure 1-Figure 3 , an embodiment of the present invention provides a string processing method applied to a freight rate search system, comprising:
[0059] S1: Obtaining a character string from freight rate data and freight rate related data from multiple data sources.
[0060] S2: Construct a character array template class based on a string and generate multiple template objects.
[0061] S3: Based on the character array template class, the strings of multiple template objects are structured to obtain multiple structured strings.
[0062] S4: Perform template operations on strings of multiple template objects based on the character array template class and return the operation results.
[0063] The present invention processes freight rate data strings of multiple data sources by constructing a character array template class. The template class uses a fixed-length character array to store the freight rate data of each data source, and uses template parameters to set the length of each freight rate data. The template class is used to perform template operations on each template object, which can significantly improve system processing performance and reduce memory consumption.
[0064] Specifically, step S1 acquires the freight rate data and the character string of freight rate related data from multiple data sources, including:
[0065] Get the freight rate data and freight rate related data strings from the atpco data source and third-party data source, as well as the strings of user input requests.
[0066] The atpco data source is a platform that provides airfare and related service data to airlines and their partners. In the embodiment of the present invention, the atpco data source mainly provides the fare data and fare-related data required by the fare search engine, such as fare rule data and additional service-related data. The third-party data source is a platform that obtains data from outside the enterprise. The acquired data is not data collected or generated by the enterprise itself, but provided by external enterprises or organizations. It mainly provides data required for the additional functions of the fare search engine. The string of user input request refers to the string of user request input received by the fare search system. The two parts of data provided by the atpco data source and the third-party data source are both stored in the data file in the form of strings. There are differences in the string formats of the two data sources, and they are different from the string formats of the user input request.
[0067] Specifically, step S2 constructs a character array template class based on the string and generates multiple template objects including:
[0068] S21: defining a character array template class and related parameters based on the character strings of multiple data sources, wherein the related parameters include the freight rate data of multiple data sources and the character string length of the freight rate related data.
[0069] A character array template class is a template class used in the C++ programming language, which allows the creation of a class that can store and operate character arrays. This template class can store different types of character arrays as needed, such as integer types, character types, single-precision floating-point types, and double-precision floating-point types. The character array template class defined in the embodiment of the present invention is used to store and operate the freight rate data and freight rate-related data strings provided by the atpco data source and the third-party data source, as well as the string of the user input request. In the process of defining the character array template class, the length of each string data required by the freight rate search engine is defined in the template declaration to achieve the setting of template-related parameters. The data returned by the character array template class is the actual length of the string, and the end of the character array does not contain the end symbol "\0" of the traditional string array.
[0070] S22: Generate template objects corresponding to multiple data sources based on the character array template class, wherein the template objects include an empty template object with a preset string length, a template object with a preset string length constructed based on a character array, a template object with a preset string length constructed based on a standard string, and a template object with a preset string length constructed based on the character array template class.
[0071] The embodiment of the present invention creates a corresponding template object for each data source. Due to the diversity of data sources, the character array template class provides multiple categories of template objects, including:
[0072] An empty template object with a preset string length. An empty template object is an instance of a template class without any properties or methods. An empty template object can be used as a placeholder or when an object is needed but its specific implementation is not required. In a function definition, an empty template object can be used as a parameter or return value type to indicate that the function can accept or return any type of object. In an embodiment of the present invention, the template parameters of the empty template object can be set according to actual needs.
[0073] A template object with a preset string length constructed based on a character array, where the template parameters can be set according to actual needs. For character arrays of any length, the string length returned by this template object is the preset string length.
[0074] A template object based on a preset string length of a standard string, where the template parameters can be set according to actual needs. For standard strings of any length, the string length returned by this template object is the preset string length.
[0075] A template object with a preset string length based on the character array template class, where the template parameters can be set according to actual needs. For character array template objects with fixed-length strings, the string length returned by this template object is the preset string length.
[0076] For example:
[0077] 1. Perform string processing on the airline code of the atpco data source
[0078] The airline code in the atpco data source is 3 characters, such as "CA", and the string length is 3. Therefore, when constructing the character array template object, call the template SizedString <3> cxr('CA'); Since the template parameter is set to 3, the function template performs the following operations when processing the string: First, it traverses from the 0th character to the 2nd character of the input string, and copies the 0th, 1st, and 2nd characters in the string to the character array charm_value[3] of the template class in sequence. At this time, the content of the character array charm_value[3] is "CA", and the end does not include the terminator '\0' in the traditional character array.
[0079] 2. Perform string processing on airline codes from third-party data sources
[0080] The airline code from the third-party data source is 2 characters, such as "CA", and the string length is 2. Therefore, when constructing the character array template object, call the template SizedString <3> cxr('CA'); Since the template parameter is set to 3, the template function performs the following operations when processing the string: First, it traverses from the 0th character to the 2nd character of the input string. When it traverses to the 0th character and the 1st character, it copies the characters 'C' and 'A' to the character array char m_value[3] respectively. At this time, the first two characters in the character array char m_value[3] are C and A respectively. When it traverses to the 2nd character, since the length of the input string is 2, the input character has reached the end character '\0'. At this time, the null character '' is added to the template member of the character array char m_value[3]. Therefore, the content of the character array char m_value[3] is 'CA', and the end does not include the end character '\0' in the traditional character array.
[0081] 3. Perform string processing on the airline code requested by the user
[0082] Since the airline code in the user input request is free text and its string length is not fixed, for example, 'CA' has a string length of 8, the template SizedString is called when constructing the character array template object. <3> cxr('CA'); Since the template parameter is set to 3, the template function performs the following operations when processing the string: traverse from the 0th character of the input string to the 2nd character, and copy the 0th, 1st, and 2nd characters in the string to the character array char m_value[3] of the template class in sequence. At this time, the content of the character array charm_value[3] is 'CA', and the end does not include the terminator '\0' in the traditional character array. Although the input string has not been traversed yet, since the template parameter is defined as 3, the data after the 3rd digit of the string length is deleted.
[0083] From the analysis of the above three data source string processing examples, it can be seen that by creating a corresponding template object for each data source, the length and related parameter definitions of multiple data source strings can be realized. Even if the string lengths received by the search engine are different, after the template object is generated by the character array template class, the string content and string length in its character array remain consistent, providing a guarantee for subsequent engine processing.
[0084] Specifically, step S3 performs structured processing on the strings of multiple template objects based on the character array template class to obtain multiple structured strings including:
[0085] The freight rate data and freight rate related data strings from multiple data sources are read into the character array template class to generate multiple structured strings, wherein the multiple structured strings have the same content and length. The freight rate search engine reads the freight rate data and freight rate related data strings from multiple data sources into the program to form structured data with the same content and length.
[0086] Specifically, step S4 performs template operations on strings of multiple template objects based on the character array template class and returns the operation results, including:
[0087] S41: Based on the character array template class, the character strings of multiple template objects are assigned and the assignment results are returned.
[0088] In the embodiment of the present invention, character array template objects can be overloaded by the operator '=', and the assignment operation of the character array template object can be implemented by constructing corresponding overload operation instructions.
[0089] For example: SizedString <8> fbc("NHR6R1RX");
[0090] SizedString <8> basis = fbc;
[0091] The operation process is as follows:
[0092] Since the template length of both fbc and basis objects is 8, a memory copy of the character array members of the two objects with a string length of 8 is performed. After the program is executed, the return value of the basis object is also "NHR6R1RX".
[0093] S42: Based on the character array template class, a comparison operation is performed on the strings of multiple template objects and the comparison result is returned.
[0094] In the embodiment of the present invention, character array template objects can be overloaded by the operator '==', and corresponding overloaded operation instructions are constructed to determine whether two SizedString template objects are equal. If they are equal, true is returned, otherwise false is returned.
[0095] For example: SizedString <8> fbc1("abcd");
[0096] SizedString <3> fbc2("abc");
[0097] fbc2==fbc1;
[0098] The operation process is as follows:
[0099] Select the value with the smallest string length in the two template objects, that is, the length is 3, compare the first 3 bits of the two template objects, the first 3 bits of the two template objects are both "abc", if they are equal, continue to compare, select the value with the largest string length in the two template objects, that is, the length is 8, traverse from the 3rd character to the 8th character of the string of the fbc1 template object, check whether the remaining characters in the fbc1 template object are all empty characters, if they are all empty characters, they are equal, otherwise they are not equal. In the implementation of the present invention, after executing fbc2==fbc1, the return result is false, the return value of fbc1 is "abcd", 8 bits in length, and the return value of fbc2 is "abc", 3 bits in length. If the return value of fbc1 is "abc", the two object values are considered equal.
[0100] S43: Based on the character array template class, perform an addition operation on the character strings of multiple template objects and return the addition result.
[0101] In the embodiment of the present invention, character array template objects can be overloaded by the operator '+', and the addition operation between character array template objects of different string lengths can be implemented by constructing corresponding overloaded operation instructions.
[0102] For example:
[0103] SizedString <3> cxr("CA");
[0104] SizedString <2> ft("F");
[0105] SizedString <5> cxrFt=cxr+ft;
[0106] The operation process is as follows:
[0107] First, copy the value of cxr to cxrFt. After the copying is completed, the value of cxrFt is "CA". Since the length of cxr is 3, the values of the first three digits in cxrFt are the values of cxr. Start copying the value of ft from the fourth digit. The copy length is 2, the length of ft. After the addition operation is performed, the return value of cxrFt is "CA F".
[0108] S44: Based on the character array template class, a no-operation judgment is performed on the character strings of the multiple template objects and the judgment result is returned.
[0109] In the embodiment of the present invention, it is possible to determine whether the character array template object is a no-operation, and to implement the no-operation determination by constructing a corresponding operation instruction.
[0110] For example: SizedString <3> cxr(“”)
[0111] The operation process is as follows:
[0112] First, traverse from the 0th character to the 2nd character of the string of cxr to check whether each bit of cxr is empty. If all are empty, return true; if it contains non-empty characters, return false. In the embodiment of the present invention, after executing the operation, the value of cxr is "" and the length is 3.
[0113] S45: performing length calculation operation on multiple template objects based on the character array template class and returning the length calculation result, where the length calculation result is a parameter of the template object.
[0114] In the embodiment of the present invention, the size of the character array template object can be calculated, and the length calculation of the character array template object can be implemented by constructing corresponding operation instructions.
[0115] For example: SizedString <3> cxr1("CA");
[0116] SizedString <3> cxr2("CA");
[0117] SizedString <3> cxr3("C");
[0118] SizedString <3> cxr4("CAAA");
[0119] The operation process is as follows:
[0120] Since the parameter of each character array template object is 3, the character length is not calculated and the template parameter is directly returned. In the embodiment of the present invention, the execution results of cxr1, cxr2, cxr3 and cxr4 are all 3.
[0121] Example 2
[0122] Based on the above method, an embodiment of the present invention further provides a string processing system applied to a freight rate search system, comprising:
[0123] The acquisition unit 01 is used to acquire a character string from freight rate data and freight rate related data from multiple data sources.
[0124] The template class construction unit 02 is used to construct a character array template class based on a character string and generate multiple template objects.
[0125] The structured processing unit 03 is used to perform structured processing on the character strings of multiple template objects based on the character array template class to obtain multiple structured character strings.
[0126] The template operation unit 04 is used to perform template operations on the character strings of multiple template objects based on the character array template class and return the operation results.
[0127] The embodiment of the present invention provides a string processing system applied to a freight rate search system. First, a character string is obtained from freight rate data and freight rate related data of multiple data sources by an acquisition unit 01. Then, a character array template class is constructed by a template class construction unit 02 to process the freight rate data character strings of multiple data sources. The template class uses a fixed-length character array to store the freight rate data of each data source, and uses template parameters to set the length of each freight rate data. Then, a structured processing unit 03 is used to perform structured processing on the character string of each template object to obtain multiple structured character strings. The template operation unit 04 is used to perform template operation on the character string of each template object and return the operation result. Compared with the traditional character string processing method, the present invention can significantly improve the system processing performance and reduce memory consumption.
[0128] Specifically, the template class construction unit 02 includes:
[0129] The template class definition unit 021 is used to define a character array template class and related parameters based on the character strings of multiple data sources. The related parameters include the freight rate data of multiple data sources and the character string length of the freight rate related data.
[0130] The character array template class defined in the embodiment of the present invention is used to store and operate the freight data and freight-related data character strings provided by the ATPCO data source and the third-party data source, as well as the character strings of the user input requests. In the process of defining the character array template class, the length of each character string data required by the freight search engine is defined in the template declaration to achieve the setting of template-related parameters. The data returned by the character array template class is the actual length of the character string, and the end of the character array does not contain the end symbol "\0" of the traditional character string array.
[0131] The template object generating unit 022 is used to generate template objects corresponding to multiple data sources based on the character array template class, wherein the template objects include an empty template object with a preset string length, a template object with a preset string length constructed based on a character array, a template object with a preset string length constructed based on a standard string, and a template object with a preset string length constructed based on the character array template class.
[0132] The embodiment of the present invention creates a corresponding template object for each data source. Due to the diversity of data sources, the character array template class provides multiple categories of template objects, including:
[0133] Constructs an empty template object with a preset string length. An empty template object is an instance of a template class without any attributes or methods. An empty template object can be used as a placeholder or when an object is needed but its specific implementation is not required. In a function definition, an empty template object can be used as a parameter or return value type to indicate that the function can accept or return any type of object.
[0134] Constructs a template object with a preset string length based on a character array. The template parameters can be set according to actual needs. For character arrays of any length, the string length returned by this template object is the preset string length.
[0135] Constructs a template object with a preset string length based on a standard string. The template parameters can be set according to actual needs. For standard strings of any length, the string length returned by this template object is the preset string length.
[0136] Constructs a template object with a preset string length based on the character array template class. The template parameters can be set according to actual needs. For the string of the character array template of a fixed-length string, the string length returned by this template object is the preset string length.
[0137] Specifically, the template operation unit 04 includes:
[0138] The assignment operation unit 041 is used to perform assignment operations on the strings of multiple template objects based on the character array template class and return the assignment results.
[0139] The embodiment of the present invention implements the assignment operation of the string array template object through the assignment operation unit 041.
[0140] For example: SizedString <8> fbc("NHR6R1RX");
[0141] SizedString <8> basis = fbc;
[0142] The operation process is as follows:
[0143] Since the template length of both fbc and basis objects is 8, a memory copy of the character array members of the two objects with a string length of 8 is performed. After the program is executed, the return value of the basis object is also "NHR6R1RX".
[0144] The comparison operation unit 042 is used to perform a comparison operation on the character strings of multiple template objects based on the character array template class and return the comparison result.
[0145] The embodiment of the present invention determines whether two character array template objects are equal through the comparison operation unit 042, and returns true if they are equal, otherwise returns false.
[0146] For example: SizedString <8> fbc1("abcd");
[0147] SizedString <3> fbc2("abc");
[0148] fbc2==fbc1;
[0149] The operation process is as follows:
[0150] Select the value with the smallest string length in the two template objects, that is, the length is 3, compare the first 3 bits of the two template objects, the first 3 bits of the two template objects are both "abc", if they are equal, continue to compare, select the value with the largest string length in the two template objects, that is, the length is 8, traverse from the 3rd character to the 8th character of the string of the fbc1 template object, check whether the remaining characters in the fbc1 template object are all empty characters, if they are all empty characters, they are equal, otherwise they are not equal. In the implementation of the present invention, after executing fbc2==fbc1, the return result is false, the return value of fbc1 is "abcd", 8 bits in length, and the return value of fbc2 is "abc", 3 bits in length. If the return value of fbc1 is "abc", the two object values are considered equal.
[0151] The addition operation unit 043 is used to perform an addition operation on the character strings of multiple template objects based on the character array template class and return the addition result.
[0152] The embodiment of the present invention implements the addition operation between character array template objects of different character string lengths through the addition operation unit 043.
[0153] For example:
[0154] SizedString <3> cxr("CA");
[0155] SizedString <2> ft("F");
[0156] SizedString <5> cxrFt=cxr+ft;
[0157] The operation process is as follows:
[0158] First, copy the value of cxr to cxrFt. After the copying is completed, the value of cxrFt is "CA". Since the length of cxr is 3, the values of the first three digits in cxrFt are the values of cxr. Start copying the value of ft from the fourth digit. The copy length is 2, the length of ft. After the addition operation is performed, the return value of cxrFt is "CA F".
[0159] The no-operation judgment unit 044 is used to perform no-operation judgment on the character strings of multiple template objects based on the character array template class and return the judgment result.
[0160] The embodiment of the present invention determines whether the character array template object is a no-operation by means of the no-operation determination unit 044 .
[0161] For example: SizedString <3> cxr(“”)
[0162] The operation process is as follows:
[0163] First, traverse from the 0th character to the 2nd character of the string of cxr to check whether each bit of cxr is empty. If all are empty, return true; if it contains non-empty characters, return false. In the embodiment of the present invention, after executing the operation, the value of cxr is "" and the length is 3.
[0164] The length calculation unit 045 is used to perform length calculation operations on multiple template objects based on the character array template class and return the length calculation results, and the length calculation results are parameters of the template objects.
[0165] The embodiment of the present invention implements the length calculation of the character array template object through the length calculation unit 045.
[0166] For example: SizedString <3> cxr1("CA");
[0167] SizedString <3> cxr2("CA");
[0168] SizedString <3> cxr3("C");
[0169] SizedString <3> cxr4("CAAA");
[0170] The operation process is as follows:
[0171] Since the parameter of each character array template object is 3, the character length is not calculated and the template parameter is directly returned. In the embodiment of the present invention, the execution results of cxr1, cxr2, cxr3 and cxr4 are all 3.
[0172] Example 3
[0173] like Figure 7 As shown, an embodiment of the present invention further provides a computer device, the computer device includes a processor and a memory, the memory stores a computer program, and the computer program is loaded and executed by the processor to implement the above-mentioned string processing method applied to the freight rate search system. The device in the present invention can be a server, a PC, a PAD, a mobile phone, etc.
[0174] Furthermore, an embodiment of the present invention also provides a computer-readable storage medium, in which a computer program is stored. The computer program is loaded and executed by a processor to implement the above-mentioned string processing method applied to the freight rate search system.
[0175] Furthermore, an embodiment of the present invention also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program initialized with the steps of the string processing method applied to a freight rate search system as described above.
[0176] In summary, the string processing method and system provided by the present invention for use in a freight rate search system have the following advantages:
[0177] 1. Eliminates the data string differences between ATPCO data sources, third-party data sources, and user input requests, providing convenience for subsequent search engine processing.
[0178] 2. The performance of string data processing is significantly improved. The present invention utilizes a character array template class to process freight rate data strings, uses fixed-length characters to store each type of freight rate data, and uses template parameters to specify the length of each type of freight rate data. Under string operations based on the character array template class, the performance of string processing is significantly improved compared to traditional standard strings, and the string processing speed is accelerated. According to statistics, the processing speed of strings processed using this method is 35% faster than that of traditional methods.
[0179] 3. Reduced memory overhead. Since the storage character array of this method determines the size according to the template parameter, and the traditional character array storage method needs to use "\0" to determine the end of the string array, the memory overhead can be reduced.
[0180] The above describes in detail the concepts, principles and ideas of the present invention in conjunction with specific implementation methods (including embodiments and examples). Those skilled in the art should understand that the implementation methods of the present invention are not limited to the forms given above. After reading this application document, those skilled in the art can make any possible improvements, substitutions and equivalent forms to the steps, methods, systems and components in the above implementation methods. These improvements, substitutions and equivalent forms should be deemed to fall within the scope of the present invention, and the protection scope of the present invention is subject only to the claims.
Claims
1. A character string processing method applied to a freight rate search system, characterized in that: include: Get strings from freight rate data and freight rate related data from multiple data sources; Construct a character array template class based on the string and generate multiple template objects; Based on the character array template class, the character strings of the multiple template objects are structured to obtain multiple structured character strings, and Based on the character array template class, template operations are performed on the strings of multiple template objects and the operation results are returned.
2. The character string processing method applied to the freight rate search system according to claim 1, characterized in that: The character string for obtaining freight rate data and freight rate related data from multiple data sources includes: Get the freight rate data and freight rate related data strings from the atpco data source and third-party data source, as well as the strings of user input requests.
3. The character string processing method applied to the freight rate search system according to claim 1, characterized in that: The constructing a character array template class based on the character string and generating a plurality of template objects comprises: Defining a character array template class and related parameters based on the character strings of multiple data sources, wherein the related parameters include the freight rate data of multiple data sources and the character string length of the freight rate related data; Based on the character array template class, template objects corresponding to multiple data sources are generated, wherein the template objects include an empty template object with a preset string length, a template object with a preset string length constructed based on a character array, a template object with a preset string length constructed based on a standard string, and a template object with a preset string length constructed based on the character array template class.
4. The character string processing method applied to the freight rate search system according to claim 1, characterized in that: The character array template class is used to perform structured processing on the character strings of the multiple template objects to obtain multiple structured character strings including: The freight rate data and the character strings of freight rate related data from multiple data sources are read into the character array template class to generate multiple structured character strings, wherein the contents and lengths of the multiple structured character strings are the same.
5. The character string processing method applied to the freight rate search system according to claim 1, characterized in that: The performing of template operation on the strings of multiple template objects based on the character array template class and returning the operation results comprises: Based on the character array template class, the character strings of multiple template objects are assigned and the assignment results are returned; and Compare the strings of multiple template objects based on the character array template class and return the comparison result; and Based on the character array template class, an addition operation is performed on the strings of multiple template objects and the addition result is returned, and Performing a null operation judgment on the strings of multiple template objects based on the character array template class and returning the judgment result, and Based on the character array template class, a length calculation operation is performed on multiple template objects and the length calculation result is returned.
6. A string processing system applied to a freight rate search system, characterized in that: include: An acquisition unit, used to acquire character strings from freight rate data and freight rate-related data from multiple data sources; A template class construction unit, used to construct a character array template class based on the character string and generate multiple template objects; a structured processing unit, configured to perform structured processing on the strings of the plurality of template objects based on the character array template class to obtain a plurality of structured strings, and The template operation unit is used to perform template operations on character strings of multiple template objects based on the character array template class and return the operation results.
7. The character string processing method applied to the freight rate search system according to claim 6, characterized in that: The template class construction unit comprises: A template class definition unit, used to define a character array template class and related parameters based on the character strings of multiple data sources, wherein the related parameters include the freight rate data of multiple data sources and the character string length of the freight rate related data; A template object generating unit is used to generate template objects corresponding to multiple data sources based on the character array template class, wherein the template objects include an empty template object with a preset string length, a template object with a preset string length constructed based on a character array, a template object with a preset string length constructed based on a standard string, and a template object with a preset string length constructed based on a character array template class.
8. The character string processing method applied to the freight rate search system according to claim 6, characterized in that: The template operation unit comprises: An assignment operation unit, used for performing assignment operation on strings of multiple template objects based on the character array template class and returning the assignment result; A comparison operation unit, used for performing comparison operations on the character strings of multiple template objects based on the character array template class and returning the comparison result; An addition operation unit, used for performing an addition operation on strings of multiple template objects based on the character array template class and returning the addition result; A null operation judgment unit, used for performing null operation judgment on the character strings of multiple template objects based on the character array template class and returning the judgment result; The length calculation unit is used to perform length calculation operations on multiple template objects based on the character array template class and return the length calculation results.
9. A computer device, characterized in that: The computer device includes a processor and a memory, wherein a computer program is stored in the memory, and the computer program is loaded and executed by the processor to implement the string processing method applied to the freight rate search system as described in any one of claims 1 to 5 above.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is loaded and executed by a processor to implement the string processing method applied to a freight rate search system as described in any one of claims 1 to 5.