A method and device for concurrently exporting regional remote sensing images from HBase tile storage

By determining the StartKey and EndKey of the Region in HBase, traversing and storing the data into the global Map, and using read-write separation and multi-thread concurrency, the HBase tile data is efficiently exported to SQLite, solving the write blocking problem and achieving rapid export. Large-scale map tile data.

CN113495934BActive Publication Date: 2024-10-25GEOVIS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010196940.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-03-19
Publication Date
2024-10-25
Estimated Expiration
2040-03-19

AI Technical Summary

Technical Problem

When the existing technology exports millions of map tile data, the file system and transmission protocol are inefficient. Especially when writing the tile data in HBase to the SQLite database, write blocking is easy to occur, resulting in extremely slow export speed. For example, it takes 5 years to export a global map.

Method used

By determining the StartKey and EndKey of each Region in HBase, the image data and its layer, column and row information are traversed, stored in two global variables Map, and the data is stored in the SQLite database in a read-write separation manner, using multi-thread concurrency. Read and write, use Scan API and synchronization lock mechanism, design the pattern of List array and Map collection to ensure efficient export of data.

Benefits of technology

It effectively solves the write blocking problem when writing to the SQLite database, improves the data export speed, and can export about 20T of data in one day, significantly improving efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113495934B_ABST
    Figure CN113495934B_ABST
Patent Text Reader

Abstract

The present application provides a method and device for concurrently exporting regional remote sensing images from HBase tile storage. The export method comprises the following steps: determining the StartKey and EndKey of each Region in HBase according to the region to be exported; traversing the image data and its layer column row (lcr) information according to the StartKey and EndKey, and storing them in two global variables Map; storing the data in the two global variables Map in a read-write separation manner in a SQLite database. The present invention realizes read-write separation through the design pattern of List array + Map collection, solves the blocking problem caused by writing data to the SQLite database, and improves the data import speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for concurrently exporting regional remote sensing images from HBase tile storage. Background Art

[0002] Currently, most file systems and transfer protocols are not very efficient for exporting millions of map tiles. Whether you are copying over USB or over the network, it is inefficient to handle millions of tile data.

[0003] The general way to read tile data is to access SQLite through GeoWebCache. Because SQLite provides a specification that allows millions of tile data to be stored in a file, storing tile data through SQLite is an ideal method. However, how to write tile data in HBase into SQLite is a big problem. The usual method is to use GeoWebCache's own method, but it takes about 5 years to export a global map in this way. Summary of the invention

[0004] The purpose of the present invention is to provide a method and device for concurrently exporting regional remote sensing images from HBase tile storage, so as to solve the write blocking problem caused by writing data to SQLite database and improve the data import speed.

[0005] To this end, according to a first aspect of the present invention, a method for concurrently exporting a regional remote sensing image from an HBase tile storage is provided, comprising:

[0006] Determine the StartKey and EndKey of each Region in HBase based on the region to be exported;

[0007] According to StartKey and EndKey, traverse the image data and its layer, column and row (lcr) information and store them in two global variables Map;

[0008] The data in the two global variables Map are stored in the SQLite database in a read-write separation manner.

[0009] Furthermore, the image data and its layer row and column (lcr) information are traversed according to StartKey and EndKey and stored in two global variables Map, including:

[0010] Use the HBase Scan API to retrieve the StartKey and EndKey of each Region in HBase and store them in a custom object List.

[0011] Generate multiple thread tasks according to the custom object List;

[0012] Concurrently executing the multiple thread tasks, reading the result set of each Region from HBase according to the StartKey and EndKey of each Region;

[0013] Traverse the result set of each Region to obtain lcr information and image data;

[0014] The obtained lcr information and image data are stored in the first global variable Map or the second global variable Map, where the key is the lcr combination and the value is the image byte array.

[0015] Furthermore, storing the data in the two global variables Map into the SQLite database in a read-write separation manner includes:

[0016] The flag of the global variable Map that fills the specified threshold size with data is stored in the third global variable;

[0017] Determine, according to the identifier stored in the third global variable Map, a global variable Map that is filled with a specified threshold value;

[0018] The data in the global variable that has been filled with the specified threshold size is stored in the SQLite database;

[0019] At the same time, the traversed lcr information and image data are written into the global variable that does not fill up the specified threshold size.

[0020] Furthermore, when reading and writing data, a synchronization lock is added to the first global variable Map and the second global variable Map.

[0021] Furthermore, the key of the third global variable Map is lcr, and the value is index, and the value is used to record the identifier index0 of the first global variable Map or the identifier index1 of the second global variable Map that has been filled with a specified threshold size.

[0022] According to a second aspect of the present invention, there is provided a device for concurrently exporting a regional remote sensing image from an HBase tile storage, comprising:

[0023] The determination module is used to determine the StartKey and EndKey of each Region in HBase according to the region to be exported;

[0024] The traversal module is used to traverse the image data and its layer, column and row (lcr) information according to StartKey and EndKey, and store them in two global variables Map;

[0025] The storage module is used to store the data in the two global variables Map into the SQLite database in a read-write separation manner.

[0026] Furthermore, the traversal module is specifically used to:

[0027] Use the HBase Scan API to retrieve the StartKey and EndKey of each Region in HBase and store them in a custom object List.

[0028] Generate multiple thread tasks according to the custom object List;

[0029] Concurrently executing the multiple thread tasks, reading the result set of each Region from HBase according to the StartKey and EndKey of each Region;

[0030] Traverse the result set of each Region to obtain lcr information and image data;

[0031] The obtained lcr information and image data are stored in the first global variable Map or the second global variable Map, where the key is the lcr combination and the value is the image byte array.

[0032] Furthermore, the storage module is specifically used for:

[0033] The flag of the global variable Map that fills the specified threshold size with data is stored in the third global variable;

[0034] Determine, according to the identifier stored in the third global variable Map, a global variable Map that is filled with a specified threshold value;

[0035] The data in the global variable that has been filled with the specified threshold size is stored in the SQLite database;

[0036] At the same time, the traversed lcr information and image data are written into the global variable that does not fill up the specified threshold size.

[0037] Furthermore, when reading and writing data, a synchronization lock is added to the first global variable Map and the second global variable Map.

[0038] Furthermore, the key of the third global variable Map is lcr, and the value is index, and the value is used to record the identifier index0 of the first global variable Map or the identifier index1 of the second global variable Map that has been filled with a specified threshold size.

[0039] The present invention sets three global variable Maps through the design pattern of List array + Map collection, wherein the first and second Maps are used to store data to be exported, and the third Map is used to store an identifier of a specified threshold value in the first or second Map. According to the identifier, the data in the first or second Map is stored in a SQLite database, and the data is read from the HBase end in a Scan manner, thereby realizing the separation of data reading and writing, solving the problem that only one thread can write to the same database due to locks on the SQLite end, and improving the speed of data export. It only takes one day to export about 20T of data using the method.

[0040] Additional aspects and advantages of the present invention will be given in part in the following description and, in part, will be obvious from the following description or learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0042] Figure 1 The present invention is a flowchart of a method for concurrently exporting regional remote sensing images from HBase tile storage according to an embodiment of the present invention.

[0043] Figure 2 The invention is a framework diagram of a device for concurrently exporting regional remote sensing images from HBase tile storage according to an embodiment of the present invention.

[0044] Figure 3 It is a schematic diagram of the structure of an apparatus for concurrently exporting regional remote sensing images from HBase tile storage according to an embodiment of the present invention. DETAILED DESCRIPTION

[0045] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0046] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.

[0047] like Figure 1 As shown, according to an embodiment of the present invention, a method for concurrently exporting regional remote sensing images from HBase tile storage is provided, comprising the following steps:

[0048] S11. Determine the StartKey and EndKey of each Region in HBase according to the region to be exported;

[0049] Select the tile data area to be exported in HBase, and use the HBase Scan mode to obtain the StartKey and EndKey of each Region in HBase.

[0050] S12, traverse the image data and its layer, column and row (lcr) information according to StartKey and EndKey, and store them in two global variables Map;

[0051] The StartKey and EndKey of each Region in HBase are retrieved through the HBase Scan API and stored in the custom object List. Tasks are issued to the thread pool according to the List information to generate multiple thread tasks. The multiple thread tasks read the result set of each Region from HBase in parallel according to the StartKey and EndKey of each Region, and then traverse the lcr information and image data according to each Region result set, and store the traversed lcr information and image data in the prepared first global variable Map or the second global variable Map. In the global variable Map, the key is the lcr combination, and the image byte array is used as the value. Considering the security of the data structure, the Map is ConcurrentHashMap, and the static function synchronizedList() of Collections is used to ensure the thread safety of the List.

[0052] S13, storing the data in the two global variables Map into the SQLite database in a read-write separation manner.

[0053] Design a Flag to record the current read and write Map position. At the same time, create a third global variable Map to store the identifier of the Map in the first global variable Map or the second global variable Map that is full of the specified threshold size, as the metadata query basis that can be written to SQLite for read-write separation. The key of the third global variable Map is lcr, and the value is index. The value is used to record the identifier index0 of the first global variable Map that has been full of the specified threshold size or the identifier index1 of the second global variable Map. When the data storage in the first global variable Map reaches the threshold, the index in the third global variable Map becomes index0. At this time, the second global variable Map is used to store the cached data read from HBase into the SQLite database, and the first global variable Map is used to read from HBase. Base is used for caching. When reading and writing data, the Synchronize lock is used to lock the value of the first global variable Map and the second global variable Map respectively. When all the cache in the second global variable Map is stored in the SQLite database and cleared, the synchronization lock is released, and the positions of the first global variable Map and the second global variable Map are exchanged according to the Flag. That is, the first global variable Map is used to store the cache data read from HBase into the SQLite database, and the second global variable Map is used to read data from HBase for caching until all data in HBase is stored in SQLite. From the perspective of the SQLite database, read-write separation can be guaranteed at every moment, which not only solves the problem of read-write inconsistency, but also plays a role of caching.

[0054] The embodiment of the present invention also provides a device for concurrently exporting regional remote sensing images from HBase tile storage, such as Figure 2 As shown, including:

[0055] A determination module 21 is used to determine the StartKey and EndKey of each Region in HBase according to the region to be exported;

[0056] Select the tile data area to be exported in HBase, and use the HBase Scan mode to obtain the StartKey and EndKey of each Region in HBase.

[0057] The storage module 22 is used to traverse the image data and its layer, column and row (lcr) information according to StartKey and EndKey, and store them in two global variables Map;

[0058] The StartKey and EndKey of each Region in HBase are retrieved through the HBase Scan API and stored in the custom object List. Tasks are issued to the thread pool according to the List information to generate multiple thread tasks. The multiple thread tasks read the result set of each Region from HBase in parallel according to the StartKey and EndKey of each Region, and then traverse the lcr information and image data according to each Region result set, and store the traversed lcr information and image data in the prepared first global variable Map or the second global variable Map. In the global variable Map, the key is the lcr combination, and the image byte array is used as the value. Considering the security of the data structure, ConcurrentHashMap is used in Map, and the static function synchronizedList() of Collections is used to ensure the thread safety of List.

[0059] The storage module 23 is used to store the data in the two global variables Map into the SQLite database in a read-write separation manner.

[0060] Design a Flag to record the current read and write Map position. At the same time, create a third global variable Map to store the identifier of the Map in the first global variable Map or the second global variable Map that is full of the specified threshold size, as the metadata query basis that can be written to SQLite for read-write separation. The key of the third global variable Map is lcr, and the value is index. The value is used to record the identifier index0 of the first global variable Map that has been full of the specified threshold size or the identifier index1 of the second global variable Map. When the data storage in the first global variable Map reaches the threshold, the index in the third global variable Map becomes index0. At this time, the second global variable Map is used to store the cached data read from HBase into the SQLite database, and the first global variable Map is used to read from HBase. Base is used for caching. When reading and writing data, the Synchronize lock is used to lock the value of the first global variable Map and the second global variable Map respectively. When all the cache in the second global variable Map is stored in the SQLite database and cleared, the synchronization lock is released, and the positions of the first global variable Map and the second global variable Map are exchanged according to the Flag. That is, the first global variable Map is used to store the cache data read from HBase into the SQLite database, and the second global variable Map is used to read data from HBase for caching until all data in HBase is stored in SQLite. From the perspective of the SQLite database, read-write separation can be guaranteed at every moment, which not only solves the problem of read-write inconsistency, but also plays a role of caching.

[0061] Specific implementation method Figure 3 As shown:

[0062] Select the tile data Region1, Region2 and Region3 that need to be exported in HBase. Use the HBaseScan mode to obtain the StartKey and EndKey of each Region, and retrieve the StartKey and EndKey of each Region through the HBase Scan API and store them in the custom object List. Issue tasks to the thread pool based on the List information to generate multiple thread tasks. The multiple thread tasks read the result set of each Region from HBase in parallel based on the StartKey and EndKey of each Region, and then traverse the lcr information and image data based on each Region result set, and store the traversed lcr information and image data in the prepared ConcurrentHashMap1. The key of ConcurrentHashMap1 is the lcr combination, and the image byte array is used as the value. At the same time, create an identical global variable ConcurrentHashMap2 as a replacement Map for the read-write separation cache, and use the static function synchronizedList() of Collections to ensure the security of the List thread. Design a Flag to record the positions of ConcurrentHashMap1 and ConcurrentHashMap2, and create ConcurrentHashMap3 to store the subscript of the Map filled with the specified threshold size. The value of ConcurrentHashMap3 is index, that is, the Map that is currently filled with the specified threshold can be determined according to the value. As an example, when the data stored in ConcurrentHashMap1 reaches the threshold, the value in ConcurrentHashMap3 is index1, and the thread queries ConcurrentHashMap3 to obtain the feedback value index1, then read ConcurrentHashMap2, write the data in ConcurrentHashMap2 into the SQLite database, and store the traversed lcr information and image data in ConcurrentHashMap1. When reading and writing data, use the Synchronize lock to lock ConcurrentHashMap1 and ConcurrentHashMap2 respectively. When all the cached data in ConcurrentHashMap2 is stored in the SQLite database and ConcurrentHashMap2 is cleared, release the synchronization lock, and exchange the positions of ConcurrentHashMap1 and ConcurrentHashMap2 according to the Flag.After ConcurrentHashMap1 fills up the specified threshold, the value in ConcurrentHashMap3 is index0, that is, ConcurrentHashMap1 is used to store the cached data read from HBase into the SQLite database, and ConcurrentHashMap2 is used to read data from HBase for caching, and this process is repeated until all data in HBase is stored in SQLite.

[0063] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0064] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for concurrently exporting regional remote sensing images from HBase tile storage, characterized in that: include: Determine the StartKey and EndKey of each Region in HBase based on the region to be exported; According to StartKey and EndKey, traverse the image data and its layer, column, row and lcr information and store them in two global variables Map; The data in the two global variables Map are stored in the SQLite database in a read-write separation manner; The image data and its layer row and column lcr information are traversed according to StartKey and EndKey and stored in two global variables Map, including: Use the HBase Scan API to retrieve the StartKey and EndKey of each Region in HBase and store them in a custom object List. Generate multiple thread tasks according to the custom object List; Concurrently executing the multiple thread tasks, reading the result set of each Region from HBase according to the StartKey and EndKey of each Region; Traverse the result set of each Region to obtain lcr information and image data; Store the obtained lcr information and image data in the first global variable Map or the second global variable Map, where the key is the lcr combination and the value is the image byte array; The storing of the data in the two global variables Map into the SQLite database in a read-write separation manner comprises: The identification of the global variable Map when the data fills the specified threshold size is stored in the third global variable Map; Determine, according to the identifier stored in the third global variable Map, a global variable Map that is filled with a specified threshold value; Store the data in the global variable that has filled up the specified threshold size into the SQLite database; At the same time, the traversed lcr information and image data are written into the global variable that does not fill up the specified threshold size.

2. The method according to claim 1, characterized in that When reading and writing data, a synchronization lock is added to the first global variable Map and the second global variable Map.

3. The method according to claim 1, characterized in that The key of the third global variable Map is lcr, and the value is index, and the value is used to record the identifier index0 of the first global variable Map or the identifier index1 of the second global variable Map that has been filled with the specified threshold size.

4. A device for concurrently exporting regional remote sensing images from HBase tile storage, characterized in that: include: The determination module is used to determine the StartKey and EndKey of each Region in HBase according to the region to be exported; The traversal module is used to traverse the image data and its layer, column, row and lcr information according to the StartKey and EndKey, and store them in two global variables Map; A storage module is used to store the data in the two global variables Map into the SQLite database in a read-write separation manner; The traversal module is specifically used for: Use the HBase Scan API to retrieve the StartKey and EndKey of each Region in HBase and store them in a custom object List. Generate multiple thread tasks according to the custom object List; Concurrently executing the multiple thread tasks, reading the result set of each Region from HBase according to the StartKey and EndKey of each Region; Traverse the result set of each Region to obtain lcr information and image data; Store the obtained lcr information and image data in the first global variable Map or the second global variable Map, where the key is the lcr combination and the value is the image byte array; The storage module is specifically used for: The identification of the global variable Map when the data fills the specified threshold size is stored in the third global variable Map; Determine, according to the identifier stored in the third global variable Map, a global variable Map that is filled with a specified threshold value; Store the data in the global variable that has filled up the specified threshold size into the SQLite database; At the same time, the traversed lcr information and image data are written into the global variable that does not fill up the specified threshold size.

5. The device according to claim 4, characterized in that When reading and writing data, a synchronization lock is added to the first global variable Map and the second global variable Map.

6. The device according to claim 4, characterized in that The key of the third global variable Map is lcr, and the value is index, and the value is used to record the identifier index0 of the first global variable Map or the identifier index1 of the second global variable Map that has been filled with the specified threshold size.