A Java-based real-time calculation method for memory data custom scripts
By implementing the real-time calculation method of memory data custom scripts in Java, the problem of difficulty in Java to achieve efficient custom script calculations is solved, and the timeliness and efficiency of data calculations in real-time data processing in the industrial Internet field is realized.
Patent Information
- Application Number
- CN202211283973.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-20
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2042-10-20
AI Technical Summary
Existing Java technologies are difficult to implement efficient custom script computing functions, especially in real-time data processing in the industrial Internet field, resulting in untimely data calculations.
By implementing real-time calculation methods for custom scripts for memory data in Java, including system initialization, memory database creation, user-defined script algorithm initialization, data measurement point update and custom script calculation, we realize flexible and fast calculation of user-defined algorithms.
It realizes efficient custom script computing function in Java development, which can update a large amount of real-time data in seconds, improves computing efficiency, saves system resources, and is suitable for systems with smaller resources.
Smart Images

Figure CN115658226B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of industrial Internet, and in particular to a Java-based memory data custom script real-time calculation method. Background Art
[0002] In the current industrial Internet field, more and more products are developed using Java technology for industrial Internet platforms. Most of them use open source Redis or other NoSQL databases to process large amounts of real-time data at industrial sites. In the process of calculating real-time data, the timing algorithm is mainly used to implement the data calculation method.
[0003] However, the source and processing of industrial field data require immediate response when data is acquired. The use of timing logic will cause fast data to fail to be triggered for calculation, resulting in some data being calculated in a delayed manner. When streaming computing is introduced, the computing engine of streaming computing can realize basic data calculation. The streaming computing engine is more convenient to implement fixed algorithms. However, it is difficult to achieve the algorithm requirements of user-defined algorithms. In addition, due to the introduction of multiple third-party open source products, the system will become too large. At this time, it can only rely on the clustering of multiple servers to meet the efficiency of large-scale data calculation. Therefore, in the current industrial Internet field, there is a common cognitive misunderstanding that Java technology cannot achieve efficient custom script calculation functions. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] In view of the deficiencies in the prior art, the present invention provides a Java-based real-time calculation method for memory data custom scripts, which solves the problem that Java is difficult to implement efficient custom script calculation functions.
[0006] (II) Technical solution
[0007] To achieve the above objectives, the present invention is implemented by the following technical scheme: a Java-based memory data custom script real-time calculation method, comprising the following steps:
[0008] S1. System initialization
[0009] The Java virtual machine initializes the system virtual machine and initializes member variables to default values;
[0010] S2. Open up memory blocks, create memory databases and data indexes
[0011] Establish a memory pool, allocate a certain number of memory blocks in the memory pool, the memory block size is fixed, the header information of the memory pool, including the memory pool node list and the large block memory list, create a memory database, data measurement points and fast indexing of data measurement points;
[0012] S3. Initialize the user-defined script algorithm and accept the editing of the user algorithm
[0013] The system initializes the called user-defined script algorithm, initializes the memory calculation points based on the custom script calculation, assigns initial values to local variables, and the memory database accepts the editing of the user-defined script algorithm, and establishes the measurement point change mark corresponding to the data measurement point in the memory database;
[0014] S4. Update data measurement points and update measurement point change marks
[0015] The system receives data packets transmitted from the data transceiver equipment on site, unpacks the data packets, obtains the machine number and real-time update data, determines the data type according to the machine number, updates the corresponding data measurement points in the memory database through fast indexing, and compares the real-time update data with the data measurement points. If the data measurement point changes, the measurement point change mark is updated synchronously.
[0016] S5. Trigger script algorithm for calculating measurement points referenced by the script
[0017] When the measuring point change mark changes, an indicator calculation trigger instruction is generated, which triggers the user-defined script in time. The script references the custom script algorithm for calculating the measuring point, performs real-time calculation based on the updated data measuring point, and obtains the measured indicator data in real time.
[0018] S6. Update the in-memory database
[0019] According to the measurement indicator data, the measurement indicators in the database are updated in a timely manner through fast indexing.
[0020] Preferably, the member variables include basic type variables of integer type, basic type variables of single-precision floating point type, basic type variables of double-precision floating point type, basic type variables of character type, basic type variables of Boolean type and variables of reference type, the default value of the basic type variable of integer type is 0, the default value of the basic type variable of single-precision floating point type is 0.0f, the default value of the basic type variable of double-precision floating point type is 0.0d, the default value of the basic type variable of character type is '\u0000', the default value of the basic type variable of Boolean type is false, and the default value of the variable of reference type is null.
[0021] Preferably, the fast index in S2 is a B+ tree, an AVL tree or a red-black tree.
[0022] Preferably, while creating the memory database in S2, a data measurement point database and a measurement index database are also created.
[0023] Preferably, in said S4, while updating the corresponding data measuring points in the memory database, the data measuring points are written into the measuring point database, the historical measuring point data are constructed, and the basic data of the measuring point dynamic change diagram is obtained.
[0024] Preferably, while updating the calculation indicators in the database in S6, the calculation indicators are written into the calculation indicator database, historical calculation indicators are constructed, and basic data of the calculation indicator change chart are obtained.
[0025] Preferably, after obtaining the machine number in S4, the system transmits a feedback signal to the corresponding data transceiver device on site, and the data transceiver device on site does not repeatedly send the previous data packet after receiving the feedback signal.
[0026] Preferably, when obtaining the measured index data in S5, the measured index data is compared with a set threshold value. When the measured index data reaches the threshold value, the system sends a control instruction to a buzzer on site to make the buzzer issue a prompt.
[0027] (III) Beneficial effects
[0028] The present invention provides a Java-based real-time calculation method for memory data custom scripts. It has the following beneficial effects:
[0029] 1. The present invention creates a memory database that accommodates a large amount of data, creates a fast index of memory data measurement points, and realizes the second-level update of a large amount of real-time data. The latest data can be quickly updated to the memory database, and the storage and fast query of memory data can be directly realized in Java development. It saves system resources compared to the Redis method, reduces the data interaction between the two service processes, and is more efficient.
[0030] 2. The present invention is based on a custom script algorithm freely written by the user. During the data update process, a large amount of data calculated by the custom algorithm is simultaneously calculated in real time, thereby realizing flexible and fast calculation of data according to the user-defined algorithm during the process of updating the memory library, thereby improving calculation efficiency.
[0031] 3. The calculation method adopted by the present invention does not need to introduce a third-party algorithm library, and all functions are implemented in the Java language, which saves system overhead and can be used in systems with smaller resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 This is a flow chart of updating the memory database of the present invention. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0034] Example:
[0035] like Figure 1 As shown, an embodiment of the present invention provides a Java-based memory data custom script real-time calculation method, comprising the following steps:
[0036] S1. System initialization
[0037] The Java virtual machine initializes the system virtual machine and initializes member variables to default values;
[0038] S2. Open up memory blocks, create memory databases and data indexes
[0039] Establish a memory pool, open a certain number of memory blocks in the memory pool, the size of the memory block is fixed, the header information of the memory pool, including the memory pool node list and the large block memory list, create a memory database, data measurement points and fast index of data measurement points. The memory database can accommodate a large amount of data. The fast index can ensure the uniqueness of the data in the memory database, speed up the data retrieval process, and reduce the time of grouping and sorting during the query process, thereby improving system performance;
[0040] S3. Initialize the user-defined script algorithm and accept the editing of the user algorithm
[0041] The system initializes the called user-defined script algorithm, initializes the memory calculation points based on the custom script calculation, assigns initial values to local variables, and the memory database accepts the editing of the user-defined script algorithm, and establishes the measurement point change mark corresponding to the data measurement point in the memory database;
[0042] S4. Update data measurement points and update measurement point change marks
[0043] The system receives data packets transmitted from the data transceiver equipment on site, unpacks the data packets, obtains the machine number and real-time update data, determines the data type according to the machine number, updates the corresponding data measurement points in the memory database through fast indexing, and compares the real-time update data with the data measurement points. If the data measurement point changes, the measurement point change mark is updated synchronously.
[0044] S5. Trigger script algorithm for calculating measurement points referenced by the script
[0045] When the measuring point change mark changes, an indicator measurement trigger instruction is generated, which triggers the user-defined script in time. The script references the custom script algorithm for calculating the measuring point, performs real-time calculations based on the updated data measuring point, and obtains the measured indicator data in real time. During the data update process, a large amount of data calculated by the custom algorithm is calculated in real time, which realizes the flexible and fast calculation of data according to the user-defined algorithm in the process of updating the memory library, thereby improving the calculation efficiency.
[0046] S6. Update the in-memory database
[0047] According to the measurement index data, the measurement index in the database is updated in time through fast indexing, and memory is applied for through the memory pool during the process of updating data measurement points, updating measurement point change marks, updating measurement indexes, and running script algorithms. When applying for memory, it is determined whether the memory block to be allocated is a small block of memory or a large block of memory. When it is determined to be a large block of memory, it is allocated by the operating system. When it is determined to be a small block of memory, memory is allocated through the memory pool node, and the existing memory pool is traversed to allocate to a memory block of a suitable size. If there is no memory block of a suitable size, a new small block of memory is created. The present invention can realize the second-level update of a large amount of real-time data, and the latest data can be quickly updated to the memory database. The storage and fast query of memory data can be directly realized in Java development, which saves system resources compared to the Redis method, reduces the data interaction between the two service processes, is more efficient, does not need to introduce a third-party algorithm library, and all functions are implemented in the Java language, saving system overhead. The present invention can be used in systems with relatively small resources.
[0048] Member variables include basic type variables of integer type, basic type variables of single-precision floating point type, basic type variables of double-precision floating point type, basic type variables of character type, basic type variables of Boolean type and variables of reference type. The default value of basic type variables of integer type is 0, the default value of basic type variables of single-precision floating point type is 0.0f, the default value of basic type variables of double-precision floating point type is 0.0d, the default value of basic type variables of character type is '\u0000', the default value of basic type variables of Boolean type is false, and the default value of variables of reference type is null.
[0049] The fast index in S2 is a B+ tree, AVL tree, or red-black tree.
[0050] When creating the memory database in S2, a data measurement point database and a measurement indicator database are also created.
[0051] While updating the corresponding data measurement points in the memory database in S4, the data measurement points are written into the measurement point database, the historical measurement point data is constructed, and the basic data of the dynamic change diagram of the measurement point is obtained.
[0052] While updating the measurement indicators in the database in S6, the measurement indicators are written into the measurement indicator database, the historical measurement indicators are constructed, and the basic data of the measurement indicator change chart is obtained.
[0053] After obtaining the machine number in S4, the system transmits a feedback signal to the corresponding data transceiver device on site. After receiving the feedback signal, the data transceiver device on site no longer repeatedly sends the previous data packet.
[0054] When obtaining the measured index data in S5, the measured index data is compared with the set threshold value. When the measured index data reaches the threshold value, the system sends a control instruction to the buzzer on site, so that the buzzer sounds a prompt to remind the system administrator to check the real-time data on site.
[0055] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A Java-based real-time calculation method for memory data custom scripts , The method comprises the following steps: S1. System initialization The Java virtual machine initializes the system virtual machine and initializes member variables to default values; S2. Open up memory blocks, create memory databases and data indexes Establish a memory pool, allocate a certain number of memory blocks in the memory pool, the memory block size is fixed, the header information of the memory pool, including the memory pool node list and the large block memory list, create a memory database, data measurement points and fast indexing of data measurement points; S3. Initialize the user-defined script algorithm and accept the editing of the user algorithm The system initializes the called user-defined script algorithm, initializes the memory calculation points based on the custom script calculation, assigns initial values to local variables, and the memory database accepts the editing of the user-defined script algorithm, and establishes the measurement point change mark corresponding to the data measurement point in the memory database; S4. Update data measurement points and update measurement point change marks The system receives data packets transmitted from the data transceiver equipment on site, unpacks the data packets, obtains the machine number and real-time update data, determines the data type according to the machine number, updates the corresponding data measurement points in the memory database through fast indexing, and compares the real-time update data with the data measurement points. If the data measurement point changes, the measurement point change mark is updated synchronously. S5. Trigger script algorithm for calculating measurement points referenced by the script When the measuring point change mark changes, an indicator calculation trigger instruction is generated, which triggers the user-defined script in time. The script references the custom script algorithm for calculating the measuring point, performs real-time calculation based on the updated data measuring point, and obtains the measured indicator data in real time. S6. Update the in-memory database According to the measurement indicator data, the measurement indicators in the database are updated in a timely manner through fast indexing.
2. The real-time calculation method of memory data custom script according to claim 1, Features: The member variables include basic type variables of integer type, basic type variables of single-precision floating point type, basic type variables of double-precision floating point type, basic type variables of character type, basic type variables of Boolean type and variables of reference type. The default value of the basic type variable of integer type is 0, the default value of the basic type variable of single-precision floating point type is 0.0f, the default value of the basic type variable of double-precision floating point type is 0.0d, the default value of the basic type variable of character type is '\u0000', the default value of the basic type variable of Boolean type is false, and the default value of the variable of reference type is null.
3. The real-time calculation method of memory data custom script according to claim 1, Features: The fast index in S2 is a B+ tree, an AVL tree or a red-black tree.
4. The real-time calculation method of memory data custom script according to claim 1, Features: When the memory database is created in S2, a data measurement point database and a measurement index database are also created.
5. The real-time calculation method of memory data custom script according to claim 4, Features: In the above S4, while updating the corresponding data measuring points in the memory database, the data measuring points are written into the measuring point database, the historical measuring point data are constructed, and the basic data of the measuring point dynamic change diagram is obtained.
6. The real-time calculation method of memory data custom script according to claim 4, Features: While updating the calculation indicators in the database in S6, the calculation indicators are written into the calculation indicator database, the historical calculation indicators are constructed, and the basic data of the calculation indicator change chart is obtained.
7. The real-time calculation method of memory data custom script according to claim 1, Features: After obtaining the machine number in S4, the system transmits a feedback signal to the corresponding data transceiver device on site. After receiving the feedback signal, the data transceiver device on site no longer repeatedly sends the previous data packet.
8. The real-time calculation method of memory data custom script according to claim 1, Features: When obtaining the measurement index data in S5, the measurement index data is compared with the set threshold value. When the measurement index data reaches the threshold value, the system sends a control instruction to the buzzer on site to make the buzzer issue a prompt.
Citation Information
Patent Citations
Java virtual machine monitoring method
CN112783723A
Scripting engine and implementations
US20190308104A1