Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to do paging query when reading the report of CSV/TXT

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will introduce to you how to do paging query when reading CSV/TXT report. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.

It is easy to think of a way to pour text data into RDB and use the database paging mechanism to do it, but this will have a great impact on the database (capacity and performance), after all, the amount of data to be paged is not too small. And if the CSV/TXT data is exported from the database, then this approach basically won't work.

Hard writing with JAVA is also a way, but it is more troublesome. In addition to being able to complete set operations such as filtering and grouping, but also consider the efficiency of asynchronous queries. If the query scope of each page is determined by the line number (traversing the data), the efficiency is very low. It is much faster to determine the data to be read on each page by the number of bytes, but it is necessary to ensure that the data read each time is the whole. If the last piece of data read is truncated, there should be a "tail-filling" mechanism, and the next page should be "decapitated". There are a lot of questions to consider.

It is relatively simple to directly use the report tools that support text paging query, such as the implementation process described here: the implementation of massive lists and grouped reports, the creation of file cursors and data filtering with two-line scripts, and the report completes asynchronous paging rendering based on cursors. Here, two asynchronous threads are used. The fetching thread caches the data locally by returning the query cursor through the encapsulated text interface, and the rendering thread calculates the number of rows according to the number of pages to the local cache to get the data display. The problems of page turning efficiency and eliminating the beginning and the end have been solved here.

Draw a picture and feel it:

② and ③ are two threads respectively, the former thread is responsible for fetching the number cache from the text in batches, and the latter rendering thread is responsible for reading the cache for report rendering.

After doing this, in addition to the report can be asynchronous query, but also support the export of Excel and printing, more convenient.

The above is to read CSV/TXT report how to do paging query all the content, more and read CSV/TXT report how to do paging query related content can search the previous article or browse the following article to learn ha! I believe the editor will add more knowledge to you. I hope you can support it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report