Some computing environments provide parallel processing and shared memory. These features may be leveraged by processing large data sets in two distinct phases. During a first (“working”) phase, a set of records is split into smaller working packages. The working packages are processed by execution units (e.g., “threads”) independently and in parallel to generate intermediate results, and each intermediate result is associated with a partition. Next, in a second (“merging”) phase, the intermediate results of each partition are merged by execution units which are dedicated to the various partitions.
In some working phases, records having a same key value are processed in order to generate a single result associated with the key value. For examples, a key value may be a date, each record may represent a sale occurring on a particular date, and the single results may comprise totals of all sales on each date. It is therefore desirable to identify records associated with identical key values and to associate each record having a particular key value with a particular result slot (i.e., memory location).
The fourth record is associated with key value A and no result slot 150 is initialized therefor because a result slot 150a has already been initialized for key value A. Once all records 100 have been traversed, each of records 100 is mapped to the result slot 150 associated with its key value. The desired operations are then applied to each record, wherein the mapping is applied separately to each operation to allow cache-local execution.
Since the records may be randomly distributed within the working packages, the memory locations of intermediate results associated with one partition are typically interleaved with memory locations of intermediate results associated with other partitions, as shown in
The following description is provided to enable any person in the art to make and use the described embodiments. Various modifications, however, will remain readily apparent to those in the art.
Server 210 may comprise a hardware server for managing data stored in database 215. In some embodiments, server 210 executes processor-executable program code of a database management system to store data to and retrieve data from database 215. Server 210 may provide alternative or additional services, including but not limited to the methods described herein, query processing, business applications, Web hosting, etc.
Database 215 may be implemented in Random Access Memory (e.g., cache memory for storing recently-used data) and one or more fixed disks (e.g., persistent memory for storing their respective portions of the full database). Alternatively, database 215 may implement an “in-memory” database, in which volatile (e.g., non-disk-based) memory (e.g., Random Access Memory) is used both for cache memory and for storing the full database. In some embodiments, the data of database 215 may comprise one or more of conventional tabular data, row-based data, column-based data, and object-based data. Database 215 may also or alternatively support multi-tenancy by providing multiple logical database systems which are programmatically isolated from one another.
According to system 200, server 210 may receive data from server 220, data warehouse 230 and/or desktop computer 240 for storage within database 215. Server 220, data warehouse 230 and desktop computer 240 are illustrated merely to provide examples of the type of systems from which server 210 may receive data. Generally, data may be received from any type of hardware over any one or more communication networks.
Some embodiments may operate to efficiently process each record of table 300 and to store the results associated with each license plate number in a respective memory location in a cache-efficient format. Some embodiments perform such processing using operations executed in parallel. Accordingly, some embodiments may be particularly suited for execution using multiple processing units. A processing unit as described herein may comprise any processing entity capable of operating in parallel with other processing entities. Examples of processing units include but are not limited to threads, processor cores, and processors.
Prior to S405, various records of a database table are assigned to respective ones of two or more processing units. For example,
At S405, a processing unit determines the records which have been assigned to it. For example, an execution thread of the present example determines that records 500 have been assigned to it. Next, at S410, a key value of a first assigned record is identified. Continuing with the present example, the execution thread identifies the key value “A” in Record 1 of assigned records 500.
Next, at S415, it is determined whether a record having the key value has been mapped to a result slot (i.e., a memory location for storing intermediate results). No mappings have been established at this point of the example, so flow proceeds to S425. A partition is determined at S425 based on the key value.
Any criteria may be used to determine a partition based on a key value. For example, in a case that the key values are dates, then records having key values within a first time period may be assigned to a first partition, records having key values within a second time period may be assigned to a second partition, records having key values within a third time period may be assigned to a third partition, and so on.
In the present example, it will be assumed that records having a key value of “A” are assigned to Partition 1. At S430, it is determined whether free memory locations of a memory block associated with the partition exist. No memory locations have been allocated at this point of process 400 and therefore no free memory locations exist. Consequently, flow proceeds to S435.
A new memory block associated with the partition is allocated at S435.
The current record is mapped to a memory location of the new memory block at S440. For example, a mapping is created between Record 1 and memory location 512a. The indication “(A)” in
It is determined at S450 whether more records are assigned to the processing unit. If so, flow returns to S410. Again, a key value of a record is identified at S410. Continuing the present example, the key value “B” of Record 2 is identified at S410, and it is determined at S415 that no record having the key value is mapped to a memory location.
In the present example, it is determined at S425 that the key value “B” is associated with Partition 2. Embodiments are not limited to the determination of a Partition which is different from the previously-determined Partition. That is, the key value “B” may be determined to be associated with Partition 1 in some examples.
At S430, it is determined that no free memory locations of a memory block associated with Partition 2 exist. Accordingly, a new memory block associated with Partition 2 is allocated at S435.
Embodiments are not limited to four result slots per memory block, nor to an equal number of result slots per memory block. Embodiments are also not limited to equally-sized memory blocks.
Record 2 is mapped to memory location 514a at S440, by creating a mapping between Record 2 and memory location 514a. Again, the indication “(B)” in
Flow returns to S410 to identify the key value “C” of Record 3, and it is again determined at S415 that no record having this key value is mapped to a memory location. According to the present example, it is determined at S425 that the key value “C” is associated with Partition 1. At S430, it is determined that memory block 512 is associated with Partition 1 and that memory locations 512b-512d of memory block 512 are free. Accordingly, as shown in
Flow returns to S410 to identify the key value “A” of Record 4. It is then determined at S415 that a record having this key value (i.e., Record 1) has been mapped to a memory location (i.e., location 512a). Accordingly, at S420, a mapping is generated to map Record 4 to location 512a.
Flow proceeds through S450 and returns to S410 to identify the key value “D” of Record 5. Flow then continues as described above with respect to Record 3 to map Record 5 to memory location 514b at S445, as shown in
Flow continues as described above with respect to Records 6 through 13 to map each of these records to various ones of locations 512a-512d and 514a-514d, as depicted in
Similarly, during subsequent processing of Record 15, it is determined at S425 that Partition 2 is associated with the key value L and, at S430, that no free memory locations of a memory block associated with Partition 2 exist. Memory block 518 is therefore allocated at S435 and a mapping of Record 15 to location 518a is generated at S440, as illustrated in
For example, processing of Record 1 may include generating a value based on the values of Record 1 and using the mapping of Record 1 to store the generated value in memory location 512a. Processing of Record 2 may include generating a value based on the values of Record 2 and using the mapping of Record 2 to store the generated value in memory location 514a. In the case of Record 4, a value may be generated based on the values of Record 4. The associated mapping is then used to generate a composite value based on the value already stored in memory location 512a (i.e., due to the processing of Record 1), and to store the composite value in memory location 512a. According to some embodiments, the key value is a date, and memory location 512a initially stores a value of a Sales field of Record 1. Record 4 shares the same key value (i.e., date), and processing at S455 adds the value of the Sales field of Record 4 to the value currently stored in memory location 512a. As a result, memory location 512a contains a running total of the Sales field for all records having the same data as key value.
At the conclusion of S455, the memory locations of memory area 510 include intermediate results associated with each key value, as shown in
Turning to process 600, an intermediate result associated with a partition is determined at S605. S605 is intended to ensure that the current processing unit operates only on results which are associated with a same partition. This allows other processing units to simultaneously operate on results which are associated with other partitions. For purposes of the present example, it will be assumed that the intermediate results stored in memory blocks 512, 516, 702 and 714 are associated with Partition 1 and the intermediate results stored in memory blocks 514, 518, 704 and 712 are associated with Partition 2.
The first intermediate result of block 512 may be determined at S605, and its key value (i.e., “A”) may be determined at S610. It is then determined whether a result associated with this key value has been mapped to a memory location for storing a merged result associated with this key value. If not, as in the present example, a new memory location is allocated and the intermediate result is mapped to the new memory location.
Flow proceeds through S630 and returns to S605 to determine another intermediate result. Flow therefore continues through S605 to S630 to allocate new memory locations and map intermediate results to the new memory locations if key values associated with the results have not yet been mapped to a memory location for storing a merged result, and to simply map intermediate results to appropriate memory locations if key values associated with the results have already been mapped to a memory location for storing a merged result.
After all intermediate results associated with the partition have been mapped to a memory location, the results are merged at S635. As illustrated by memory area 720 of
Communication device 820 may be used to communicate, for example, with one or more devices and to transmit data to and receive data from these devices. System 800 further includes an input device 825 (e.g., a mouse and/or keyboard to enter content) and an output device 830 (e.g., a computer monitor to display a user interface element).
Processing units 805, 810, and 815 communicate with shared memory 835 via system bus 875. Shared memory 835 may store intermediate results as described above, for retrieval by any of processing units 805, 810, and 815. System bus 875 also provides a mechanism for processing units 805, 810, and 815 to communicate with storage device 840. Storage device 840 may include any appropriate non-transitory information storage device, including combinations of magnetic storage devices (e.g., a hard disk drive), a CD-ROM, a DVD-ROM, a Flash drive, and/or semiconductor memory devices for storing data and programs.
Storage device 840 may store processor-executable program code 845 independently executable by processing units 805, 810, and 815 to cause system 800 to operate in accordance with any of the embodiments described herein. Program code 845 and other instructions may be stored in a compressed, uncompiled and/or encrypted format. In some embodiments, hard-wired circuitry may be used in place of, or in combination with, program code for implementation of processes according to some embodiments. Embodiments are therefore not limited to any specific combination of hardware and software.
In some embodiments, storage device 840 includes database 855 storing data as described herein. Database 855 may include relational row-based data tables, column-based data tables, and other data structures (e.g., index hash tables) that are or become known.
System 800 represents a logical architecture for describing some embodiments, and actual implementations may include more, fewer and/or different components arranged in any manner. The elements of system 800 may represent software elements, hardware elements, or any combination thereof. For example, system 800 may be implemented using any number of computing devices, and one or more processors within system 800 may execute program code to cause corresponding computing devices to perform processes described herein.
Generally, each logical element described herein may be implemented by any number of devices coupled via any number of public and/or private networks. Two or more of such devices may be located remote from one another and may communicate with one another via any known manner of network(s) and/or via a dedicated connection.
Embodiments described herein are solely for the purpose of illustration. Those in the art will recognize other embodiments may be practiced with modifications and alterations to that described above.