A reading and writing separation method based on text data

By adopting the reading and writing separation method in text data processing and using thread pools and message parsers for batch processing, the problem of low reading and writing efficiency of unstructured text data in the existing technology is solved, and efficient data processing and speed improvement are achieved. .

CN111880954BActive Publication Date: 2024-09-06SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010765520.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-03
Publication Date
2024-09-06
Estimated Expiration
2040-08-03

AI Technical Summary

Technical Problem

When the existing technology processes unstructured text data, the separation efficiency of reading and writing is low, and there is a lack of efficient solutions to achieve fast reading and writing of data.

Method used

Adopting a reading and writing separation method based on text data, by encapsulating text data into message types, using thread pools and message parsers for batch processing, efficient reading and writing of data is achieved. Combined with the high throughput characteristics of MQ, decoupled reading Write operations are separated during the data preparation phase.

Benefits of technology

It realizes efficient reading and writing of text data, improves the data processing speed, and converts unstructured data into structured database data, which meets the needs of applications and speeds up the reading and writing of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0002614421430000051
    Figure BDA0002614421430000051
  • Figure BDA0002614421430000061
    Figure BDA0002614421430000061
  • Figure BDA0002614421430000071
    Figure BDA0002614421430000071
Patent Text Reader

Abstract

The present invention relates to the field of data read-write separation, and specifically provides a read-write separation method based on text data. In the data preparation stage, at the data reading end, a type of text data is encapsulated as a corresponding message type according to the type of text, and a message corresponding to the message type is sent out by batch reading multiple lines of data and packaging a message body; at the data writing end, each of the message types corresponds to a message parser, and the received message type is distributed to the corresponding message parser for processing. Compared with the prior art, the read-write separation method based on text data of the present invention utilizes the high throughput characteristics of MQ to achieve application decoupling of efficient reading of text data and writing into a relational database, providing a new solution for later parsing and formatting of text data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data read-write separation, and specifically provides a read-write separation method based on text data. Background Art

[0002] With the development of Internet technology, the amount and scale of data are increasing. A single data writing method and a single data storage model can no longer meet the increasingly high requirements for performance and timeliness.

[0003] In order to meet the needs of faster data writing and faster data reading, various read-write separation solutions have emerged. At present, the mainstream read-write separation is mainly aimed at the master-write slave-read at the database level, while for unstructured data (mostly text data), the main implementation method is still read-while-write. A more efficient solution may use a buffer method when reading, but there is no specific implementation method. How to read and write data faster has become a problem that needs to be solved urgently by those skilled in the art. Summary of the invention

[0004] The present invention aims at the above-mentioned deficiencies of the prior art and provides a highly practical reading and writing separation method based on text data.

[0005] The technical solution adopted by the present invention to solve its technical problem is:

[0006] A read-write separation method based on text data. In the data preparation stage, the data reading end encapsulates a type of text data into a corresponding message type according to the type of text, and sends out the message corresponding to the message type by batch reading multiple lines of data and packing a message body.

[0007] At the data writing end, each of the message types corresponds to a message parser, and the received message type is distributed to the corresponding message parser for processing.

[0008] Furthermore, at the text data reading end, the text reading task is usually started in the form of a thread pool, and at the same time, the specific text processing service is cooperated to complete the data reading and distribution work.

[0009] Furthermore, the data reading and distribution work is completed, further including:

[0010] 1) Initialize a thread pool and set the thread pool initialization parameters;

[0011] 2) ScheduleFile corresponds to a type of text, and obtains the specific service for parsing the text from the cache according to the specific type of the text;

[0012] 3) Pass the text and the service that parses the text as parameters to the thread pool, which is responsible for the specific parsing work.

[0013] Preferably, in step S1, the task type processed is IO type.

[0014] Furthermore, after the specific text type corresponding to the parsing service is passed to the thread pool, the thread pool will open a specific task thread to parse the specific text. The specific operations are:

[0015] 1) After receiving the task, the thread pool calls the parsing method of the service according to the incoming parsing tool service and the parsing text scheduleFile to trigger the text parsing work;

[0016] 2) CountDownLatch is used as a shared parameter of multiple threads to mark the number of files processed and the time when the processing is completed.

[0017] Furthermore, the marked part is the beginning of the specific parsing process, and the specific parsing process is:

[0018] 1) execute() is used as the startup method of the specific parsing tool and is called by the thread pool to start;

[0019] 2) The execute method will call the prepare(), parse() or ending() methods in sequence to complete the preparation work before processing the data, the parsing work, and the callback work after the data processing is completed;

[0020] 3) Implement customized requirements in prepare(), and so on. Other methods can add user-defined business processing logic.

[0021] Furthermore, the process of sending a message is:

[0022] 1) According to the text line, encapsulate the corresponding PO in the corresponding program, that is, one PO per line;

[0023] 2) Parse the specific text, batchCount is the number of corresponding data stored in the body of the message, and one batch encapsulates one message;

[0024] 3) When the number of messages in the body reaches batchCount, the message corresponding to the data is sent.

[0025] Furthermore, the text data writing operation includes:

[0026] 1) Corresponding to the text parsing tool, a corresponding monitoring tool is set for each type of text to monitor the corresponding type of message;

[0027] 2) According to the processing tool corresponding to the message, process the specific message, that is, obtain the body result from the message, that is, the specific PO set, and then call the corresponding DAO to complete the writing work.

[0028] Compared with the prior art, the text data-based read-write separation method of the present invention has the following outstanding beneficial effects:

[0029] The present invention utilizes the high throughput characteristics of MQ to achieve efficient reading of text data and decoupling of applications that write to relational databases, providing a new solution for later parsing and formatting text data. At the same time, based on the read-write separation of traditional database storage writing and reading applications, the data read-write separation is achieved in the data preparation stage, that is, the unstructured text data is converted into structured database data, which meets the application's demand for data use and speeds up the reading and writing of data. DETAILED DESCRIPTION

[0030] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than 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.

[0031] A best embodiment is given below:

[0032] The read-write separation method based on text data in this embodiment realizes the read-write separation of data in the data preparation stage to complete the data preparation time as quickly as possible, that is, converting unstructured text data into structured database data, thereby meeting the application's data usage requirements.

[0033] The overall plan is:

[0034] On the data reading side, depending on the type of text, usually based on the idea of ​​one text per type (i.e., multiple texts per type), one type of text data is encapsulated as a message type, and the message corresponding to this message type is sent by batch reading multiple lines of data and packaging them into a message body.

[0035] On the data writing side, depending on the type of text, usually based on the idea of ​​one text per type (i.e. multiple texts per type), a message parser is defined for each message type, and the corresponding parser is distributed according to the received message type to process the message.

[0036] The specific implementation method is:

[0037] 1. The text data reader usually starts the text reading task in the form of a thread pool, and cooperates with the specific text processing service to finally complete the data reading and distribution work, as follows:

[0038] 1) Initialize a thread pool. The specific thread pool initialization parameters need to be determined according to the type of text, etc. Note that the task processed here is of IO type;

[0039] 2) scheduleFile corresponds to a type of text, and obtains the specific service for parsing the text from the cache according to the specific type of the text;

[0040] 3) Then, pass the text and the service that parses the text as parameters to the thread pool, and let the thread pool be responsible for the specific parsing startup work.

[0041] 2. After the parsing service corresponding to the specific text type is passed to the thread pool, the thread pool will open a specific task thread to parse the specific text, as follows:

[0042] 1) After the thread pool receives the task, it calls the parsing method of the service according to the incoming parsing tool service and the parsing text scheduleFile to trigger the parsing of the text;

[0043] 2) CountDownLatch is used as a shared parameter of multiple threads to mark the number of files processed and the time when the processing is completed.

[0044] 3. The marking part is the beginning of the specific parsing process, as follows:

[0045] 1) execute() is used as the startup method of the specific parsing tool and is called by the thread pool to start;

[0046] 2) The execute method will call prepare(), parse(), ending() and other methods in sequence to complete the preparation work before processing data, the parsing work, and the callback work after the data processing is completed;

[0047] 3) Custom requirements can be implemented in prepare(), and so on. Other methods can add user-defined business processing logic;

[0048] 4. The entire process can be defined in the FileService interface. The next step is how to send specific messages. When the conditions for batch sending are met, the data is sent, as follows:

[0049] 1) According to the text line, encapsulate the corresponding PO in the corresponding program, that is, one PO per line;

[0050] 2) Parse the specific text, batchCount is used as the number of corresponding data stored in the body of the message, and one batch encapsulates one message;

[0051] 3) When the number of messages in the body reaches batchCount, the message corresponding to the data is sent.

[0052] 5. On the consumer side of text data, for each text type, a message parser is defined to handle the specific text data writing operation, as follows:

[0053] 1) Corresponding to the text parsing tool, we define a corresponding monitoring tool for each type of text to monitor the corresponding type of message;

[0054] 2) According to the processing tool corresponding to the message, process the specific message, that is, obtain the body result from the message, that is, the specific PO set, and then call the corresponding DAO to complete the writing work.

[0055] This concludes the entire process description.

[0056] The execution code is as follows:

[0057]

[0058]

[0059]

[0060]

[0061]

[0062] The above-mentioned specific implementations are only specific cases of the present invention. The patent protection scope of the present invention includes but is not limited to the above-mentioned specific implementations. Any appropriate changes or substitutions made by any ordinary technician in the technical field that conform to the claims of the present invention for a read-write separation method based on text data shall fall within the patent protection scope of the present invention.

[0063] 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 read-write separation method based on text data, characterized in that: In the data preparation stage, the data reading end encapsulates a type of text data into a corresponding message type according to the text type, and sends out the message corresponding to the message type by batch reading multiple lines of data and packaging them into a message body; At the data writing end, each message type corresponds to a message parser, and the received message type is distributed to the corresponding message parser for processing; On the reading side of text data, the text reading task is usually started in the form of a thread pool, and at the same time, the specific text processing service is coordinated to complete the data reading and distribution work; Completing the data reading and distribution work further includes: 1) Initialize a thread pool, set the thread pool initialization parameters, and process the task type as IO type; 2) ScheduleFile corresponds to a type of text, and obtains the specific service for parsing the text from the cache according to the specific type of the text; 3) Pass the text and the service that parses the text as parameters to the thread pool, which is responsible for the specific parsing work; After passing the specific text type corresponding to the parsing service to the thread pool, the thread pool will open a specific task thread to parse the specific text. The specific operations are: 1) After receiving the task, the thread pool calls the parsing method of the service according to the incoming parsing tool service and the parsing text scheduleFile to trigger the text parsing work; 2) CountDownLatch is used as a shared parameter of multiple threads to mark the number of files processed and the time when the processing is completed; The marked part is the beginning of the specific parsing process, and the specific parsing process is: 1) execute() is used as the startup method of the specific parsing tool and is called by the thread pool to start; 2) The execute method will call the prepare(), parse() or ending() methods in sequence to complete the preparation work before processing the data, the parsing work, and the callback work after the data processing is completed; 3) Implement customized requirements in prepare(), and so on. Other methods can add user-defined business processing logic; The process of sending a message is: 1) According to the text line, encapsulate the corresponding PO in the corresponding program, that is, one PO per line; 2) Parse the specific text, batchCount is the number of corresponding data stored in the body of the message, and one batch encapsulates one message; 3) When the number of messages in the body reaches batchCount, the message corresponding to the data is sent; When writing text data, it includes: 1) Corresponding to the text parsing tool, a corresponding monitoring tool is set for each type of text to monitor the corresponding type of message; 2) According to the processing tool corresponding to the message, process the specific message, that is, obtain the body result from the message, that is, the specific PO set, and then call the corresponding DAO to complete the writing work.