Co-sharding and randomized co-sharding
By co-sharding the index table, the problem of low data retrieval efficiency and hot spots in the distributed storage system is solved, and more efficient data retrieval and processing balance are achieved.
Patent Information
- Application Number
- CN202080005621.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2019-03-20
- Filing Date
- 2020-03-18
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2040-03-18
AI Technical Summary
In a distributed storage system, table sharding may lead to reduced data retrieval efficiency, requiring frequent distributed operations to locate and retrieve data, and a single server may be overburdened by hot spots, resulting in unbalanced processing tasks.
By co-sharding the index table, the index table is split into multiple shards using the keys of the data table or another index table, and these shards are stored in different parts of the distributed storage system to reduce the complexity of distributed operations. quantity and avoid hot spots.
It improves data retrieval speed, reduces the number of distributed operations, avoids overloading a single server, and achieves more balanced task distribution and processing efficiency.
Smart Images

Figure CN112805695B_ABST
Abstract
Description
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims the benefit of U.S. Provisional Application No. 62 / 821,156, filed on March 20, 2019, entitled Cosharding and Randomized Cosharding, the disclosure of which is incorporated herein by reference. Background Art
[0003] Relational databases typically operate with data arranged in tables for efficient storage and retrieval. As tables grow, data is typically distributed across many database servers. However, separating tables across different database servers may reduce the efficiency of the relational database in retrieving data. In this regard, distributed operations (i.e., operations that require communication between different database servers or components within a database center) may be required to locate and retrieve the data being retrieved. Summary of the invention
[0004] The present disclosure generally relates to cosharding a table. One aspect of the technology is directed to a method for cosharding a table within a distributed storage system. The method may include: receiving, by one or more processors, a data table including one or more rows, wherein each row includes an identifier key and a data segment; indexing, by one or more processors, each data segment in the data table into a separate row of an index table, wherein each row in the index table includes data associated with an identifier key of the data table from which the data segment in the corresponding row was indexed; sharding, by one or more processors, the index table into splits, wherein the sharding includes assigning each row of the index table to one of the splits based on an identifier key of the data table from which the data segment in the corresponding row was indexed; and storing, by one or more processors, the splits into two or more portions of the distributed storage system.
[0005] In some examples, one or more rows from a data table may be sharded along with one or more index table rows to which data segments of corresponding rows of the data table are indexed. In some instances, one or more rows from a data table may be stored in the same split as one or more index table rows to which data segments of corresponding rows of the data table are indexed.
[0006] In some examples, the data in the data table may be in one or more columns of the data table.
[0007] In some examples, wherein the identifier key may include a randomly generated number. In some instances, the identifier key may include a timestamp. In some examples, the shards may be sorted by timestamp.
[0008] In some examples, the identifier key may include a monotonically increasing or decreasing value. In some instances, the splits may be ordered by monotonically increasing or decreasing value.
[0009] In some examples, the entire index table can be sharded into shards.
[0010] In some examples, storing the splits in two or more portions of the distributed storage system may include storing a first split in a first portion of the two or more portions of the distributed storage system and storing a second split in a second portion of the two or more portions of the distributed storage system.
[0011] In some examples, the method may include: receiving a request to retrieve one or more keys associated with an indexed data segment; in response to receiving the request, identifying one or more keys associated with the indexed data segment in a first split via a first server of a distributed data system, and identifying one or more keys associated with the indexed data segment in a second split via a second server of the distributed data system; merging the keys identified from the first split and the second split; and outputting the merged keys via the distributed data system.
[0012] In some examples, each row in a data table is indexed into an index table in a transactional manner in a relational online database stored in a distributed storage system.
[0013] Another aspect of the technology is directed to a system for co-sharding a table. The system may include: a distributed storage system; and one or more processors, wherein the one or more processors are configured to: receive a data table including one or more rows, wherein each row includes an identifier key and a data segment; index each data segment in the data table into a separate row of an index table, wherein each row in the index table includes data associated with an identifier key of the data table from which the data segment in the corresponding row was indexed; shard the index table into splits, wherein the sharding includes assigning each row of the index table to one of the splits based on an identifier key of the data table from which the data segment in the corresponding row was indexed; and store the splits in two or more portions of the distributed storage system.
[0014] In some examples, the one or more processors may be further configured to: shard the one or more rows from the data table together with the one or more index table rows to which the data segments of the corresponding rows of the data table are indexed. In some instances, the one or more rows from the data table may be stored in the same split as the one or more index table rows to which the data segments of the corresponding rows of the data table are indexed.
[0015] In some examples, the data in the data table may be in one or more columns of the data table.
[0016] In some examples, the identifier key can include a timestamp. In some instances, the splits can be sorted by timestamp.
[0017] In some examples, storing the splits in two or more parts of the distributed storage system may include: storing the first split in a first part of the two or more parts of the distributed storage system, and storing the second split in a second part of the two or more parts of the distributed storage system. In some instances, in response to receiving a request to retrieve one or more keys associated with an indexed data segment, identifying the one or more keys associated with the indexed data segment in the first split by a first server of the distributed data system, and identifying the one or more keys associated with the indexed data segment in the second split by a second server of the distributed data system; merging the keys identified from the first split and the second split; and outputting the merged keys by the distributed data system.
[0018] In some examples, each row in a data table is indexed into an index table in a transactional manner in a relational online database stored in a distributed storage system.
[0019] Another aspect of the technology is directed to a method for co-sharding a table within a distributed storage system. The method may include: receiving, by one or more processors, a data table including one or more rows and a plurality of columns, wherein each row corresponding to a first column of the plurality of columns includes an identifier key, and a second column and a third column of the plurality of columns each include a data segment; indexing, by the one or more processors, each data segment in the second column of the data table into a separate row and column of a first index table, wherein each row in the index table includes data associated with an identifier key of the data table from which the data segment in the corresponding row is indexed; indexing, by the one or more processors, each data segment in the third column of the data table into a separate row and column of a second index table, wherein each row in the index table includes data associated with an identifier key of the data table from which the data segment in the corresponding row is indexed; sharding, by the one or more processors, the first index table and the second index into splits, wherein the sharding includes assigning each row of the first index table and the second index table to one of the splits based on an identifier key of the data table from which the data segment in the corresponding row is indexed; and storing, by the one or more processors, the splits in two or more parts of a distributed storage system.
[0020] The methods described herein may be implemented using one or more computing devices and / or systems. The methods may be stored in a computer-readable medium such as a non-transitory computer-readable medium. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 is a block diagram of an example system within a distributed storage system according to various aspects of the present disclosure.
[0022] Figure 2 is an illustration of generating an index table from a data table according to various aspects of the present disclosure.
[0023] Figure 3A is an illustration of sharding an index table based on a key of the index table according to various aspects of the present disclosure.
[0024] Figure 3B is a diagram showing how keys in an index table map back to rows in a data table in accordance with various aspects of the present disclosure.
[0025] Figure 4A is a diagram of sharding an index table based on a key of a data table according to various aspects of the present disclosure.
[0026] Figure 4B is a diagram showing how keys in an index table map back to rows in a data table in accordance with various aspects of the present disclosure.
[0027] Figure 5 is a diagram illustrating an example of searching for splits in a distributed data store according to various aspects of the present disclosure.
[0028] Figure 6 is a diagram illustrating an example of searching for splits in a distributed data store according to various aspects of the present disclosure.
[0029] Figure 7 is an illustration of data distributed to servers for processing according to various aspects of the present disclosure.
[0030] Figure 8 is an illustration of generating an index table from a data table having randomized identifiers according to various aspects of the present disclosure.
[0031] Fig. 9 is an illustration of co-sharding an index table generated from a data table with randomized identifiers according to various aspects of the present disclosure.
[0032] Fig.10 is a flow chart according to various aspects of the present disclosure. DETAILED DESCRIPTION
[0033] Overview
[0034] The technique generally involves sharding (i.e., splitting) an index table so that entries are stored in shards based on the keys of another table, and maintaining the indexes of these common shards in a relational online database in a transactional manner. Maintaining the index in a relational online database in a transactional manner may include: for each new data row added to the storage system, the row is indexed atomically (transactionally) using an operation of adding a document so that both the row and the index can become visible to the query when the transaction is completed. As the amount of data increases, the distributed storage system may store data from a data table in an index table that indexes data from rows in the data table to respective keys in the index table. Each row in the index table may include a key and data that maps the key back to the row in the data table from which it is indexed. The index table may be sharded into multiple shards by row based on the keys of the rows in the index table. The shards may be stored in different parts of the distributed storage system (e.g., servers, storage devices, etc.). However, sharding the index table by the keys of the rows in the index table may cause the keys corresponding to a single data table row to be scattered in multiple parts of the distributed storage system. Thus, when searching an index table, distributed operations (i.e., operations that require communication between different parts of the distributed storage system) may be required, such as connecting the search results from each part of the distributed storage system to determine whether the data to be searched is located within a single row of the data table.
[0035] In order to reduce the number of distributed operations required to determine whether the data to be searched is located within a row of a data table, the index can be sharded by the key of the data table or another index table. In this way, the rows in the index table can be sharded into splits so that all index table keys corresponding to a data table row can be found in a single split. Therefore, it can be determined locally (i.e., on a portion of the distributed storage system) whether a given data table row matches a query. Although the examples herein describe indexing a data table into a single index table, a data table can be indexed into more than one index table, and these index tables can be sharded by the keys of the data table or other index tables.
[0036] Example System
[0037] Figure 1 An example system 100 including a distributed storage system is illustrated. Multiple data centers 160, 170, 180 may be communicatively coupled, for example, via a network 150. The data centers 160, 170, 180 may further communicate with one or more client devices (e.g., client computing device 110) via the network 150. Thus, for example, the client computing device 110 may perform operations in the "cloud." In some examples, the data centers 160, 170, 180 may further communicate with a server / controller 190.
[0038] Each client computing device 110 may be a personal computer for use by a person having all the internal components typically found in a personal computer, such as a central processing unit (CPU), a CD-ROM, a hard drive, and a display device (e.g., a monitor with a screen, a projector, a touch screen, a small LCD screen, a television, or another device such as an electrical device operable to display information processed by the processor 120), speakers, a modem and / or a network interface device, a user input (such as a mouse, keyboard, touch screen, or microphone), and all components for connecting these elements to each other. In addition, a computer according to the systems and methods described herein may include devices capable of processing instructions and sending data between a person and other computers, including general purpose computers, PDAs, tablet computers, mobile phones, smart watches, network computers lacking local storage capabilities, set-top boxes for televisions, and other networked devices.
[0039] The client computing device 110 may include a processor 120, a memory 130, and other components typically found in a general-purpose computer. The memory 130 may store information accessible to the processor 120, including instructions 132 that may be executed by the processor 120. The memory 130 may also include data 134 that may be retrieved, manipulated, or stored by the processor 120. The memory 130 is a type of non-transitory computer-readable medium capable of storing information accessible to the processor 120, such as a hard drive, solid-state drive, tape drive, optical storage, memory card, ROM, RAM, DVD, CD-ROM, writeable read-only memory. The processor 120 may be a well-known processor or other lesser-known types of processors. Alternatively, the processor 120 may be a dedicated controller, such as an ASIC.
[0040] The instructions 132 may be a set of instructions directly executed by the processor 120, such as machine code, or instructions indirectly executed, such as a script. In this regard, the terms "instructions," "steps," and "programs" may be used interchangeably herein. The instructions 132 may be stored in an object code format to be directly processed by the processor 120, or in other types of computer languages, including scripts or collections of independent source code modules that are interpreted on demand or pre-compiled.
[0041] Data 134 may be retrieved, stored, or modified by processor 120 in accordance with instructions 132. For example, although the systems and methods are not limited to a particular data structure, data 134 may be stored in a computer register, in a distributed storage system as a structure having a plurality of different fields and records, in a file, or in a buffer. Data 134 may also be formatted in a computer readable format, such as, but not limited to, binary values, ASCII, or Unicode. In addition, data 134 may include information sufficient to identify the relevant information, such as numbers, descriptive text, proprietary codes, pointers, references to data stored in other storage (including other network locations), or information used by functions for calculating the relevant data.
[0042] although Figure 1 The processor 120 and memory 130 are functionally shown as being within the same block, but the processor 120 and memory 130 may actually include multiple processors and memories that may or may not be stored within the same physical housing. For example, some instructions 132 and data 134 may be stored on a removable CD-ROM, while others may be stored in a read-only computer chip. Some or all of the instructions and data may be stored in a location physically remote from the processor 120 but still accessible to the processor 120. Similarly, the processor 120 may actually include a collection of processors that may or may not operate in parallel.
[0043] Data centers 160, 170, 180 may be located at a considerable distance from each other. For example, data centers may be located in various countries around the world. Each data center 160, 170, 180 may include one or more computing devices, such as processors, servers, shards, etc. For example, Figure 1 As shown, data center 160 includes computing devices 162, 164, data center 170 includes computing device 172, and data center 180 includes computing devices 181-186. According to some examples, the computing devices may include one or more virtual machines running on a host. For example, computing device 162 may be a host that supports multiple virtual machines 166, 167 running operating systems and applications. Figure 1 Only a few virtual machines 166, 167 are shown in the figure, but it should be understood that any number of virtual machines can be supported by any number of host computing devices. In addition, it should be understood that Figure 1 The configurations shown are merely examples, and the computing devices in each of the example data centers 160 , 170 , 180 may have various structures and components that may be the same or different from each other.
[0044] Programs can be executed across these computing devices, for example, so that some operations are performed by one or more computing devices in a first data center, while other operations are performed by one or more computing devices in a second data center. In some examples, the computing devices in various data centers can have different capacities. For example, different computing devices can have different processing speeds, workloads, etc. Although only a few of these computing devices are shown, it should be understood that each data center 160, 170, 180 can include any number of computing devices, and the number of computing devices in the first data center can be different from the number of computing devices in the second data center. Moreover, it should be understood that the number of computing devices in each data center 160, 170, 180 can change over time, for example, as hardware is removed, replaced, upgraded, or expanded.
[0045] In addition, various backend systems can be built on the distributed storage system. For example, an identity management system, a domain name server (DNS) setting management system, etc. Such backend systems may be related to each other to some extent. For example, a user of the DNS setting management system can log in using an identity managed by the identity management system.
[0046] In some examples, each data center 161, 170, 180 may also include a plurality of storage devices (not shown), such as hard disk drives, random access memory, disks, disk arrays, tape drives, or any other type of storage device. The data centers 160, 170, 180 may implement any of a variety of architectures and technologies, including but not limited to direct attached storage (DAS), network attached storage (NAS), storage area network (SAN), Fibre Channel (FC), Fibre Channel over Ethernet (FCoE), hybrid architecture networks, etc. In addition to storage devices, the data center may also include many other devices, such as cables, routers, etc. In addition, in some examples, the data centers 160, 170, 180 may be virtualized environments. In addition, although only a few data centers 1160, 170, 180 are shown, several data centers may be coupled via the network 150 and / or additional networks.
[0047] In some examples, controller 190 can communicate with computing devices in data centers 160, 170, 180 and can facilitate the execution of programs. For example, controller 190 can track the capacity, status, workload, or other information of each computing device and use such information to assign tasks. Similar to the above-mentioned client computing device 110, controller 190 may include processor 120 and memory 191, including data 194 and instructions 192. Controller 190 can be configured to populate changes affecting authorization parameters to various components of the distributed storage system without shutting down service to users. For example, controller 190 may have knowledge of the organizational structure and perform mapping to populate changes affecting authorization parameters throughout the organizational structure.
[0048] The client computing device 110, the data center 160, 170, 180, and the controller 190 can communicate directly and indirectly, such as through the network 150. For example, using Internet sockets, the client computing device 110 can connect to a service operating on a remote server through the Internet protocol suite. The server can set up a listening socket that can accept an initial connection for sending and receiving information. The network 150 and the intermediate nodes can include various configurations and protocols, including the Internet, the World Wide Web, an intranet, a virtual private network, a wide area network, a local area network, a private network using a communication protocol proprietary to one or more companies, Ethernet, WiFi (e.g., 702.71, 702.71b, g, n or other such standards) and HTTP, and various combinations of the above. Devices capable of sending data with other computers, such as modems (e.g., dial-up, cable or fiber optic) and wireless interfaces, can facilitate such communications.
[0049] The client computing device 110 may request to access a program using one of the backend systems in the cloud. Such requests may be processed by the controller 190 and / or one or more computing devices in the data centers 160, 170, 180. When changes that affect authorization are made, such as changing access rights to a particular role, such changes may be permeated through the distributed storage system using inference, reasoning, and transmission without shutting down the backend system or interrupting service to the client computing device 110.
[0050] Example Method
[0051] The data input into the distributed storage system may be in the form of a data table. In this regard, the data table may include one or more identifier keys (IDs) for each row and data corresponding to each identifier key. Figure 22 . An exemplary data table 201 is shown in FIG. Data table 201 includes three identifier keys '1', '2', and '3'. The data in row 210 of ID'1' includes data 'ab c', the data in row 212 of ID'2' includes data 'b c', and the data in row 214 of ID'3' includes data 'b'. Data 'a', 'b', and 'c' can represent different data segments, such as individual words in a text entry, an entire text entry, a portion of a file, an entire file, etc. Although the data corresponding to each identifier key is shown as being in a single column in data table 201, the data associated with the identifier key can be in multiple columns in the row. In addition, for row entries with more than one identifier key, the identifier keys can be distributed over multiple columns in the row. For example, the data in the row of ID'1' can be included in three columns, wherein data 'a' is in the first column, data 'b' is in the second column, and data 'c' is in the third column. Any number of columns can exist in a row.
[0052] Each data segment in data table 201 may be indexed into a separate row of the index table. In this regard, a server or controller (such as controller 190) may index each data segment into a corresponding key within a row of the index table. For example, Figure 2 It is further illustrated that the data associated with ID '1' in row 210 of data table 201 (i.e., 'a', 'b', and 'c') is indexed into rows 213, 215, and 221 corresponding to keys 'a', 'b', and 'c', respectively, in index table 203. The data associated with ID '2' in row 212 of data table 201 (i.e., 'b' and 'c') and the data associated with ID '3' in row 214 of data table 201 (i.e., 'b') are indexed into rows 217, 223, and 219 corresponding to keys 'b', 'c', and 'b', respectively, in index table 203. For a data table having multiple identifier keys, one or more of these identifier keys may be used to index the corresponding data.
[0053] Each key in index table 203 may correspond to data indicating an identifier key of a data table where data indexed into the key of the index table is located. For example, the rows corresponding to keys 'a' (row 213), 'b' (row 215), and 'c' (row 221) in index table 203 include data '1' indicating an identifier key corresponding to row 210 in data table 201 where data indexed into keys 'a', 'b', and 'c' is located. Similarly, the rows of keys 'b' (row 217) and 'c' (row 223) include data '2' indicating an identifier key corresponding to row 212 in data table 201. The row of key 'b' (row 219) includes "3", indicating an identifier key corresponding to row 214 in data table 201. In an instance where an index table (a first index table) is created from another index table (a second index table), the first index table may include data indicating the key of the second index table to which the data indexed into the key of the first index table corresponds. Although the data from data table 201 is shown to be indexed into the key column of index table 203, some or all of the data from data table 201 may be placed in the data column of the index table. Similarly, although the ID of data table 201 is shown to be indexed into the data column of index table 203, some or all of the ID may be placed in the key column of index table 203.
[0054] The index table may be sharded into shards by key range. Sharding the index table may include splitting the index table into multiple shards and storing the shards in different parts of the distributed storage system. In a typical distributed storage system, the index table may be sharded by row based on the key of the index table. Figure 3A An example is shown of sharding the index table 203 by row into Split 1 and Split 2 according to the key of the index table 203. In this regard, Split 1 includes row 213 of the index table with key 'a', and Split 2 includes rows 215-223 of the index table with keys 'b' and 'c'.
[0055] Sharding an index table by its key may result in the key corresponding to a single data table row being scattered across multiple parts of the distributed storage system. Figure 3B As shown, split 1 of index table 203 includes row 213 with key 'a', which indexes data 'a' of the data in the data table row (row 210) identified by identifier key '1'. Split 2 includes rows 215 and 221 with keys 'b' and 'c', respectively, which index data 'b' and 'c', i.e., the remaining data in the data table row (row 210) identified by identifier key '1'. Each data split can be stored in a different part of the distributed storage system. For example, split 1 can be stored in a first part of the distributed storage system, and split 2 can be stored in a second part of the distributed storage system.
[0056] In contrast to sharding by the key of an index table, sharding of an index table can be based on an identifier key of a data table and / or another index table. Sharding an index table based on an identifier key of a data table and / or another index table is referred to as co-sharding. By co-sharding the rows of an index table corresponding to an identifier key of a data table, all index entries in a data table corresponding to the same row in the data table can be arranged in the same split. For example, Figure 4A As shown, the index table can be sharded into two splits: Split 1 and Split 2 based on the identifier key of the data table 201. In this regard, the rows in the index table having the key of data '1' (including rows 213, 215, and 221, which indicate the identifier key corresponding to row 210 of the data table (not shown)) are sharded into Split 1. The rows in the index table having the key of data '2' (including rows 217 and 223, which indicate the identifier key corresponding to row 212 of the data table) and the rows having the key of data '3' (including row 219, which indicates the identifier key corresponding to row 214 of the data table) are sharded into Split 2.
[0057] like Figure 4B As shown, split 1 of index table 203 includes rows with keys 'a' 213, 'b' 215, and 'c' 221, which index all data in data table row 210 identified by identifier key '1'. Split 2 of index table 203 includes rows with keys 'b' 217, 'c' 223, and 'b' 219, which index all data in data table rows (212 and 214) identified by identifier keys '2' and '3'. Each data split can be stored in a different part of the distributed storage system.
[0058] In some instances, a data table (or another index table) may be sharded along with an index table. In this regard, rows from a data table may be sharded along with one or more index table rows corresponding to them. In other words, data from one or more indexes of a data table may be sharded along with the data table itself. For example, row 210 of data table 201 identified by ID '1' may be sharded into Split 1, and rows 212 and 214 of data table 201 identified by IDs '2' and '3', respectively, may be sharded into Split 2, as shown in FIG. Figure 4B As further shown, sharding a data table together with its corresponding index table (ie, an index table that indexes the data of the data table) is optional; the corresponding index tables can be sharded together.
[0059] Sharding the index table into multiple shards by the key of the index table can allow more than one server (such as a server of data center 160, 170 and / or 180) or other computing device to retrieve, search and / or access the index table at the same time. This can reduce the load that would otherwise fall on a single server and reduce the amount of processing time.
[0060] For large indexes, the index table can be sharded into splits so that multiple distributed operations may be required to retrieve a non-duplicate result set from the splits. Figure 5 As shown, the index table 203 is sharded into two splits: Split 1 and Split 2 by the key of the index table. These splits can be searched for keys corresponding to index entries of data. For example, the search can include a search for the text "abc". A server (such as server 60) can determine from the data associated with the key in Split 2 that the row of the data table 201 (not shown) identified with ID'1' and '2' includes data "bc" and ID'3' includes data "b", as shown in box 512. Another server (such as server 170) can determine from the data associated with the key in Split 1 that the row of the table 201 identified with ID'1' includes "b". However, since server 160 does not know the contents of Split 1 and server 170 does not know the contents of Split 2, additional distributed operations may be performed, such as a 'join' operation, as shown in box 514. The distributed operation can combine the results output by servers 160 and 170, as shown in box 516. Based on the combined results, one or more servers or another computing device may determine that the data associated with ID ' 1 ' satisfies the search request, as shown in block 518 .
[0061] Sharding an index table based on the key of another data table and / or index table can reduce the number and cost of distributed operations required to retrieve, search and / or access the index table. Figure 6As shown, the index table 203 is sharded based on the keys of the data table 201 (not shown). A search request may be made for the keys corresponding to the index entries of the data containing the text "abc". A server (such as server 160) may determine that the keys in the split 1 associated with the data in the row of the data table 201 identified by ID '1' meet the search criteria, as shown in block 610. Another server (such as server 170 and / or 180) may determine that the keys in the split 2 associated with the data in the row of the data table 201 identified by ID '2' and '3' do not meet the search criteria. Since the server searching for the keys corresponding to the index entries of the data containing the text "abc" in split 2 knows that all the data corresponding to ID '2' and '3' are in split 2, if a complete result set cannot be found, the server may determine that ID '2' and '3' do not meet the search criteria. The results of the server's search may be merged together, and only the IDs (e.g., ID '1') that meet the search criteria may be output, as shown in block 618. By sharding the index table based on the key of another data table and / or index table, all data in the row of the data table is indexed in the same split. In this way, the number of distributed operations to search the entire index table can be reduced.
[0062] Another aspect of the technology involves co-sharding index tables to reduce hot spots by assigning random keys to data tables or other index tables. In this regard, when the identifier key of the data table is monotonically increasing (such as, in instances where the ID corresponds to a timestamp or the identifier is monotonically decreasing), new incoming data can be directed to a single server because the assigned identifiers can all be within the key range of a single server. As a result, a single server may be burdened with processing tasks while other servers remain underutilized or unutilized. A similar burden may be placed on a single server when data within a particular key value range is requested simultaneously.
[0063] To address this problem, the identifier values can be randomized. In this regard, a random number generator can be used to generate numbers that fall within two or more key ranges. These random numbers can be assigned to data when it is entered into the distributed storage system as an identifier key (ID) in a data table. By assigning identifiers within key ranges, processing tasks can be distributed across multiple servers. For example, Figure 7As shown, the first server 710 may have a key range of 1-10, while the second server 712 may have a key range of 11-20. The data within the data table 701 may be received by the distributed storage system, and a processor, such as the controller 190 (not shown), may allocate a portion of the data to a server for processing based on the ID of the data. For example, data associated with ID 1 may be allocated to the first server 710 because 1 falls within the key range of 1-10 of the first server. Data associated with ID 3 may also be allocated to the first server 710. Data associated with ID 14 and 12 may also be allocated to the second server 712 because IDs 14 and 12 fall within the key range of 11-20. Although Figure 7 Two key ranges are illustrated, but any number of key ranges are possible. In addition, random numbers may not be limited to any particular key range, but may be randomly generated so that they are well distributed over a larger integer space (such as the entire integer 64-bit space).
[0064] The data in the data table 801 may be indexed into an index table with multiple keys per row. Figure 8 Data associated with ID 1, Time1 in data table 801 is indexed into rows 813, 815, and 823 of keys 'a, Time1', 'b, Time1', and 'c, Time1' of index table 803. Data associated with ID 14, Time2 may be indexed into rows 817 and 825 of keys 'b, Time2' and 'c, Time2', respectively. Data associated with ID 12, Time3 may be indexed into row 819 of key 'b, Time3', and data associated with ID 3, Time4 may be indexed into row 821 of key 'b, Time4'. Data associated with each key in the index table may correspond to data of an identifier key indicating the data table where the data indexed into the key of the index table is located.
[0065] The index may be jointly sharded by a random identifier key assigned to the data table 801. For example, Fig. 9 As shown, rows corresponding to keys 'a', 'b', and 'c' having data corresponding to ID 1 of table 801 may be sharded into shard 1, and rows corresponding to keys 'b' and 'c' having data corresponding to IDs 3, 14, and 12 may be sharded into shard 2.
[0066] In some examples, each split can be arranged in a specific order, such as by an identifier key or a timestamp value. Fig. 9 As further shown, the rows of the splits may be arranged by a “time” identifier key that is stored in the index table data and corresponds to a timestamp of the data in the data table 801 .
[0067] By arranging the rows of split data in order, retrieval, searching, and / or accessing portions of the index table may be performed more quickly because only a portion of the split may need to be traversed. For example, if a query is made for a key in index table 803 having data associated with "Time2," the distributed storage system may stop traversing the second split after reaching the row corresponding to key 'b' and having time "Time3" because keys having data associated with Time2 are grouped together. Similarly, the distributed storage system may traverse the row corresponding to key 'c' and stop once no more entries are found or another time (e.g., Time3) is reached.
[0068] Fig.10 A flowchart 1000 of a method for co-sharding a table within a distributed storage system is illustrated. In this regard, in block 1002, one or more processors (such as processor 120) may receive a data table including one or more rows, wherein each row includes an identifier key and a data segment. As shown in block 1004, each data segment in the data table may be indexed into a separate row of an index table, wherein each row in the index table includes data associated with an identifier key of the data table from which the data segment in the corresponding row was indexed. As shown in block 1006, the index table may be sharded into shards, wherein the sharding includes assigning each row of the index table to one of the shards based on an identifier key of the data table from which the data segment in the corresponding row was indexed. The shards may be stored in two or more portions of the distributed storage system, as shown in block 1008.
[0069] The features described herein allow for improved retrieval speed of data dispersed across shards. In this regard, time-consuming join operations can be performed locally by sharding the index into shards by source so that all data corresponding to one source is found in a single shard. The features described herein also avoid the formation of hot spots on a particular server during input and retrieval of data while maintaining the desired on-disk sort order.
[0070] Unless otherwise stated, the foregoing alternative examples are not mutually exclusive, but may be implemented in various combinations to achieve unique advantages. Since these and other variations and combinations of the features discussed above may be utilized without departing from the subject matter defined by the claims, the foregoing description of the embodiments should be made by way of illustration rather than by way of limitation of the subject matter defined by the claims. In addition, the provision of the examples described herein and the phrases expressed as "such as", "including", etc. should not be interpreted as limiting the subject matter of the claims to specific examples; on the contrary, these examples are intended only to illustrate one of many possible embodiments. In addition, the same reference numerals in different figures may identify the same or similar elements.
Claims
1. A method for co-sharding a table in a distributed storage system, the method comprising: receiving, by one or more processors, a data table comprising one or more rows, wherein each row comprises an identifier key and a data segment, wherein a random number generator is used to generate random numbers that fall within two or more key ranges, and wherein the random numbers are assigned to the data as corresponding identifier keys in the data table when the data is input into the distributed storage system; indexing, by the one or more processors, each data segment in the data table into a separate row in an index table, wherein each row in the index table includes data associated with the identifier key of the data table from which the data segment in the corresponding row was indexed; sharding, by the one or more processors, the index table into splits, wherein the sharding comprises: assigning each row of the index table to one of the splits based on the identifier key of the data table from which the data segment in the corresponding row is indexed; as well as The splits are stored, by the one or more processors, into two or more portions of the distributed storage system.
2. The method according to claim 1, further comprising: The one or more rows from the data table are sharded together with the one or more index table rows into which the data segments of the corresponding rows of the data table are indexed.
3. The method according to claim 2, wherein: The one or more rows from the data table are stored in the same split as the one or more index table rows into which the data segments of the corresponding rows of the data table are indexed.
4. The method according to claim 1, wherein: The data in the data table is in one or more columns of the data table.
5. The method according to claim 1, wherein: The identifier key includes a timestamp, and The splits are ordered by the timestamp.
6. The method according to claim 1, wherein: The identifier key comprises a monotonically increasing or decreasing value, and The splits are ordered by the monotonically increasing or decreasing value.
7. The method according to claim 1, wherein: Storing the splits in two or more portions of the distributed storage system includes storing a first split in a first portion of the two or more portions of the distributed storage system and storing a second split in a second portion of the two or more portions of the distributed storage system.
8. The method according to claim 7, further comprising: receiving a request to retrieve one or more keys associated with an indexed data segment; In response to receiving the request, identifying, in the first split, by a first server of the distributed storage system, the one or more keys associated with the indexed data segment, and identifying, in the second split, by a second server of the distributed storage system, the one or more keys associated with the indexed data segment; merging the identified keys from the first split and the second split; And the merged key is outputted through the distributed storage system.
9. The method according to claim 1, wherein: In the relational online database stored in the distributed storage system, each row in the data table is indexed into the index table in a transactional manner.
10. A system for co-sharding a table, the system comprising: Distributed storage systems; as well as One or more processors, wherein the one or more processors are configured to: receiving a data table comprising one or more rows, wherein each row comprises an identifier key and a data segment, wherein a random number generator is used to generate random numbers that fall within two or more key ranges, and wherein the random numbers are assigned to the data as corresponding identifier keys in the data table when the data is input into the distributed storage system; indexing each data segment in the data table into a separate row in an index table, wherein each row in the index table includes data associated with the identifier key of the data table from which the data segment in the corresponding row was indexed; sharding the index table into splits, wherein the sharding comprises: assigning each row of the index table to one of the splits based on the identifier key of the data table from which the data segment in the corresponding row was indexed; and The splits are stored in two or more portions of the distributed storage system.
11. The system according to claim 10, wherein: The one or more processors are further configured to shard the one or more rows from the data table together with the one or more index table rows into which the data segments of the corresponding rows of the data table are indexed.
12. The system according to claim 11, wherein: The one or more rows from the data table are stored in the same split as the one or more index table rows into which the data segments of the corresponding rows of the data table are indexed.
13. The system according to claim 10, wherein: The data in the data table is in one or more columns of the data table.
14. The system according to claim 10, wherein: The identifier key includes a timestamp, and The splits are ordered by the timestamp.
15. The system according to claim 10, wherein: Storing the splits in two or more portions of the distributed storage system includes storing a first split in a first portion of the two or more portions of the distributed storage system and storing a second split in a second portion of the two or more portions of the distributed storage system.
16. The system of claim 15, wherein: In response to receiving a request to retrieve one or more keys associated with the indexed data segment, identifying, in the first split by a first server of the distributed storage system, the one or more keys associated with the indexed data segment, and identifying, in the second split by a second server of the distributed storage system, the one or more keys associated with the indexed data segment; merging the identified keys from the first split and the second split; And the merged key is outputted through the distributed storage system.
17. The system according to claim 10, wherein: Each row in the data table is indexed into the index table in a transactional manner in a relational online database stored in the distributed storage system.
18. A non-transitory computer readable medium storing instructions that, when executed by one or more processors, cause the one or more processors to: A data table including one or more rows and a plurality of columns is received, wherein: each row corresponding to a first column of the plurality of columns includes an identifier key, and a second column and a third column of the plurality of columns each include a data segment, wherein a random number generator is used to generate random numbers that fall within two or more key ranges, and wherein the random numbers are assigned to the data as corresponding identifier keys in the data table when the data is input into the distributed storage system; indexing each data segment in the second column in the data table into a separate row and column of a first index table, wherein each row in the index table includes data associated with the identifier key of the data table from which the data segment in the corresponding row was indexed; indexing each data segment in the third column in the data table into a separate row and column of a second index table, wherein each row in the index table includes data associated with the identifier key of the data table from which the data segment in the corresponding row was indexed; sharding the first index table and the second index table into splits, wherein the sharding comprises: assigning each row of the first index table and the second index table to one of the splits based on the identifier key of the data table from which the data segment in the corresponding row is indexed; and The splits are stored in two or more parts of a distributed storage system.
Citation Information
Patent Citations
Data storage method and device
CN105740405A
ES-based method for realizing HBase two-level index
CN107506464A
Device and method for data load balancing
EP2395710A1
Database-transparent near online archiving and retrieval of data
US20120084316A1
Partitioning database data in a sharded database
US20140108421A1
