The systems, methods, devices, and non-transitory media of the various embodiments enable query execution plan graphs to be compared to determine whether all or portions of two or more queries define data sets that are structurally equivalent. Two data sets may be structurally equivalent when each data set may be composed with a bijective relation that yields the other. Proof of structural equivalence of two data sets may be discovered without inspection of the data by inspecting the expressions that define each data set when there is a bijection that transforms one of the expressions such that it satisfies the definition of the other data set. Such a transformation is said to be structure preserving. In the various embodiments, when all or a portion of a first query that has been previously run defines a data set that is structurally equivalent to a data set defined by all or a portion of a second query that is to be run, the structure preserving transform may be applied to the corresponding portion of the second query to transform that portion of the second query into the corresponding portion of the first query, thereby allowing the results from previously running the first query to be reused. In this manner, the various embodiments enable reuse of results among queries defining structurally equivalent data sets to reduce computational costs and improve query response speed, especially for dense data sets. In the various embodiments, structure preserving transformations may be applied to (but not limited to) relational data sets, graphical data sets, and the schema describing such data sets. Examples of structurally equivalent data sets may include data sets that only differ in the naming or ordinal positions of attributes or that differ in the values of identifying metadata, such as a data set's provenance.
The accompanying drawings, which are incorporated herein and constitute part of this specification, illustrate exemplary embodiments of the invention, and together with the general description given above and the detailed description given below, serve to explain the features of the invention.
The various embodiments will be described in detail with reference to the accompanying drawings. Wherever possible, the same reference numbers will be used throughout the drawings to refer to the same or like parts. References made to particular examples and implementations are for illustrative purposes, and are not intended to limit the scope of the invention or the claims.
The word “exemplary” is used herein to mean “serving as an example, instance, or illustration.” Any implementation described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other implementations.
As used herein, the term “computing device” is used to refer to any one or all of servers, desktop computers, personal data assistants (PDA's), laptop computers, tablet computers, smart books, palm-top computers, smart phones, and similar electronic devices which include a programmable processor and memory and circuitry configured to provide the functionality described herein.
The various embodiments are described herein using the term “server.” The term “server” is used to refer to any computing device capable of functioning as a server, such as a master exchange server, web server, mail server, document server, or any other type of server. A server may be a dedicated computing device or a computing device including a server module (e.g., running an application which may cause the computing device to operate as a server). A server module (e.g., server application) may be a full function server module, or a light or secondary server module (e.g., light or secondary server application) that is configured to provide synchronization services among the dynamic databases on computing devices. A light server or secondary server may be a slimmed-down version of server type functionality that can be implemented on a computing device, such as a laptop computer, thereby enabling it to function as a server (e.g., an enterprise e-mail server) only to the extent necessary to provide the functionality described herein.
The various embodiments provide systems and methods for data storage and processing and algebraic optimization. In one example, a universal data model based on data algebra may be used to capture scalar, structural and temporal information from data provided in a wide variety of disparate formats. For example, data in fixed format, comma separated value (CSV) format, Extensible Markup Language (XML) and other formats may be captured and efficiently processed without loss of information. These encodings are referred to as physical formats. The same logical data may be stored in any number of different physical formats. Example embodiments may seamlessly translate between these formats while preserving the same logical data.
By using a rigorous mathematical data model, example embodiments can maintain algebraic integrity of data and their interrelationships, provide temporal invariance and enable adaptive data restructuring.
Algebraic integrity enables manipulation of algebraic relations to be substituted for manipulation of the information it models. For example, a query may be processed by evaluating algebraic expressions at processor speeds rather than requiring various data sets to be retrieved and inspected from storage at much slower speeds.
Temporal invariance may be provided by maintaining a constant value, structure and location of information until it is discarded from the system. Standard database operations such as “insert,” “update” and “delete” functions create new data defined as algebraic expressions which may, in part, contain references to data already identified in the system. Since such operations do not alter the original data, example embodiments provide the ability to examine the information contained in the system as it existed at any time in its recorded history.
Adaptive data restructuring in combination with algebraic integrity allows the logical and physical structures of information to be altered while maintaining rigorous mathematical mappings between the logical and physical structures. Adaptive data restructuring may be used in example embodiments to accelerate query processing and to minimize data transfers between persistent storage and volatile storage.
Example embodiments may use these features to provide dramatic efficiencies in accessing, integrating and processing dynamically-changing data, whether provided in XML, relational or other data formats.
The mathematical data model allows example embodiments to be used in a wide variety of computer architectures and systems and naturally lends itself to massively-parallel computing and storage systems. Some example computer architectures and systems that may be used in connection with example embodiments will now be described.
As shown in
In some embodiments, system 100 may include an accelerator card 122 attached to the peripheral bus 118. The accelerator may include field programmable gate arrays (FPGAs), graphics processing units (GPUs), or other hardware for accelerating certain processing. For example, an accelerator may be used for adaptive data restructuring or to evaluate algebraic expressions used in extended set processing.
Software and data are stored in external storage 124 and may be loaded into RAM 110 and/or cache 104 for use by the processor. The system 100 includes an operating system for managing system resources, such as Linux or other operating system, as well as application software running on top of the operating system for managing data storage and optimization in accordance with the various embodiments.
In this example, system 100 also includes network interface cards (NICs) 120 and 121 connected to the peripheral bus for providing network interfaces to external storage such as Network Attached Storage (NAS) and other computer systems that can be used for distributed parallel processing.
In example embodiments, processors may maintain separate memory spaces and transmit data through network interfaces, back plane or other connectors for parallel processing by other processors. In other embodiments, some or all of the processors may use a shared virtual address memory space.
The above computer architectures and systems are examples only and a wide variety of other computer architectures and systems can be used in connection with example embodiments, including systems using any combination of general processors, co-processors, FPGAs and other programmable logic devices, system on chips (SOCs), application specific integrated circuits (ASICs) and other processing and logic elements. It is understood that all or part of the data management and optimization system may be implemented in software or hardware and that any variety of data storage media may be used in connection with example embodiments, including random access memory, hard drives, flash memory, tape drives, disk arrays, Network Attached Storage (NAS) and other local or distributed data storage devices and systems.
In example embodiments, the data management and optimization system may be implemented using software modules executing on any of the above or other computer architectures and systems. In other embodiments, the functions of the system may be implemented partially or completely in firmware, programmable logic devices such as field programmable gate arrays (FPGAs) as referenced in
In this example embodiment, data natively stored in one or more various physical formats may be presented to the system. The system creates a mathematical representation of the data based on extended set theory and may assign the mathematical representation a Globally Unique Identifier (GUID) for unique identification within the system. In this example embodiment, data is internally represented in the form of algebraic expressions applied to one or more data sets, where the data may or may not be defined at the time the algebraic expression is created. The data sets include sets of data elements, referred to as members of the data set. In an example embodiment, the elements may be data values or algebraic expressions formed from combinations of operators, values and/or other data sets. In this example, the data sets are the operands of the algebraic expressions. The algebraic relations defining the relationships between various data sets are stored and managed by a Set Manager 402 software module. Algebraic integrity is maintained in this embodiment, because all of the data sets are related through specific algebraic relations. A particular data set may or may not be stored in the system. Some data sets may be defined solely by algebraic relations with other data sets and may need to be calculated in order to retrieve the data set from the system. Some data sets may even be defined by algebraic relations referencing data sets that have not yet been provided to the system and cannot be calculated until those data sets are provided at some future time.
In an example embodiment, the algebraic relations and GUIDs for the data sets referenced in those algebraic relations are not altered once they have been created and stored in the Set Manager 402. This provides temporal invariance which enables data to be managed without concerns for locking or other concurrency-management devices and related overheads. Algebraic relations and the GUIDs for the corresponding data sets are only appended in the Set Manager 402 and not removed or modified as a result of new operations. This results in an ever-expanding universe of operands and algebraic relations, and the state of information at any time in its recorded history may be reproduced. In this embodiment, a separate external identifier may be used to refer to the same logical data as it changes over time, but a unique GUID is used to reference each instance of the data set as it exists at a particular time. The Set Manager 402 may associate the GUID with the external identifier and a time stamp to indicate the time at which the GUID was added to the system. The Set Manager 402 may also associate the GUID with other information regarding the particular data set. This information may be stored in a list, table or other data structure in the Set Manager 402 (referred to as the Set Universe in this example embodiment). The algebraic relations between data sets may also be stored in a list, table or other data structure in the Set Manager 402 (for example, an Algebraic Cache 452 within the Set Manager 402 in this example embodiment).
In some embodiments, Set Manager 402 can be purged of unnecessary or redundant information, and can be temporally redefined to limit the time range of its recorded history. For example, unnecessary or redundant information may be automatically purged and temporal information may be periodically collapsed based on user settings or commands. This may be accomplished by removing all GUIDs from the Set Manager 402 that have a time stamp before a specified time. All algebraic relations referencing those GUIDs are also removed from the Set Manager 402. If other data sets are defined by algebraic relations referencing those GUIDs, those data sets may need to be calculated and stored before the algebraic relation is removed from the Set Manager 402.
In one example embodiment, data sets may be purged from storage and the system can rely on algebraic relations to recreate the data set at a later time if necessary. This process is called virtualization. Once the actual data set is purged, the storage related to such data set can be freed but the system maintains the ability to identify the data set based on the algebraic relations that are stored in the system. In one example embodiment, data sets that are either large or are referenced less than a certain threshold number of times may be automatically virtualized. Other embodiments may use other criteria for virtualization, including virtualizing data sets that have had little or no recent use, virtualizing data sets to free up faster memory or storage or virtualizing data sets to enhance security (since it is more difficult to access the data set after it has been virtualized without also having access to the algebraic relations). These settings could be user-configurable or system-configurable. For example, if the Set Manager 402 contained a data set A as well as the algebraic relation that A equals the intersection of data sets B and C, then the system could be configured to purge data set A from the Set Manager 402 and rely on data sets B and C and the algebraic relation to identify data set A when necessary. In another example embodiment, if two or more data sets are equal to one another, all but one of the data sets could be deleted from the Set Manager 402. This may happen if multiple sets are logically equal but are in different physical formats. In such a case, all but one of the data sets could be removed to conserve physical storage space.
When the value of a data set needs to be calculated or provided by the system, an Optimizer 418 may retrieve algebraic relations from the Set Manager 402 that define the data set. The Optimizer 418 can also generate additional equivalent algebraic relations defining the data set using algebraic relations from the Set Manager 402. Then the most efficient algebraic relation can then be selected for calculating the data set.
A Set Processor 404 software module provides an engine for performing the arithmetic and logical operations and functions required to calculate the values of the data sets represented by algebraic expressions and to evaluate the algebraic relations. The Set Processor 404 also enables adaptive data restructuring. As data sets are manipulated by the operations and functions of the Set Processor 404, they are physically and logically processed to expedite subsequent operations and functions. The operations and functions of the Set Processor 404 are implemented as software routines in one example embodiment. However, such operations and functions could also be implemented partially or completely in firmware, programmable logic devices such as field programmable gate arrays (FPGAs) as referenced in
The software modules shown in
In the example embodiment of
Model Interface 416 provides a single point of entry for all statements from the connectors. The statements are provided from SQL Translator 408, XML Translator 414, SPARQL Translator 415, or Algebraic Connector 410 in an XSN format. The Model Interface 416 provides a parser that converts the text description into an internal representation that is used by the system. In one example, the internal representation uses a graph data structure, as described further below. As the statements are parsed, the Model Interface 416 may call the Set Manager 402 to assign GUIDs to the data sets referenced in the statements. The overall algebraic relation representing the statement may also be parsed into components that are themselves algebraic relations. In an example embodiment, these components may be algebraic relations with an expression composed of a single operation that reference from one to three data sets. Each algebraic relation may be stored in the Algebraic Cache (e.g., Algebraic Cache 452) in the Set Manager 402. A GUID may be added to the Set Universe for each new algebraic expression, representing a data set defined by the algebraic expression. The Model Interface 416 thereby composes a plurality of algebraic relations referencing the data sets specified in statements presented to the system as well as new data sets that may be created as the statements are parsed. In this manner, the Model Interface 416 and Set Manager 402 capture information from the statements presented to the system. These data sets and algebraic relations can then be used for algebraic optimization when data sets need to be calculated by the system.
The Set Manager 402 provides a data set information store for storing information regarding the data sets known to the system, referred to as the Set Universe in this example. The Set Manager 402 also provides a relation store for storing the relationships between the data sets known to the system, referred to as the Algebraic Cache (e.g., Algebraic Cache 452) in this example.
As shown in
As shown in
The Set Manager 402 may be accessed by other modules to add new GUIDS for data sets and retrieve known relationships between data sets for use in optimizing and evaluating other algebraic relations. For example, the system may receive a query language statement specifying a data set that is the intersection of a first data set A and a second data set B. The resulting data set C may be determined and may be returned by the system. In this example, the modules processing this request may call the Set Manager 402 to obtain known relationships from the Algebraic Cache 452 for data sets A and B that may be useful in evaluating the intersection of data sets A and B. It may be possible to use known relationships to determine the result without actually retrieving the underlying data for data sets A and B from the storage system. The Set Manager 402 may also create a new GUID for data set C and store its relationship in the Algebraic Cache 452 (i.e., data set C is equal to the intersection of data sets A and B). Once this relationship is added to the Algebraic Cache 452, it is available for use in future optimizations and calculations. All data sets and algebraic relations may be maintained in the Set Manager 402 to provide temporal invariance. The existing data sets and algebraic relations are not deleted or altered as new statements are received by the system. Instead, new data sets and algebraic relations are composed and added to the Set Manager 402 as new statements are received. For example, if data is requested to be removed from a data set, a new GUID can be added to the Set Universe and defined in the Algebraic Cache 452 as the difference of the original data set and the data to be removed.
The Optimizer 418 receives algebraic expressions from the Model Interface 416 and optimizes them for calculation. When a data set needs to be calculated (e.g., for purposes of realizing it in the storage system or returning it in response to a request from a user), the Optimizer 418 retrieves an algebraic relation from the Algebraic Cache 452 that defines the data set. The Optimizer 418 can then generate a plurality of collections of other algebraic relations that define an equivalent data set. Algebraic substitutions may be made using other algebraic relations from the Algebraic Cache 452 and algebraic operations may be used to generate relations that are algebraically equivalent. In one example embodiment, all possible collections of algebraic relations are generated from the information in the Algebraic Cache 452 that define a data set equal to the specified data set.
The Optimizer 418 may then determine an estimated cost for calculating the data set from each of the collections of algebraic relations. The cost may be determined by applying a costing function to each collection of algebraic relations, and the lowest cost collection of algebraic relations may be used to calculate the specified data set. In one example embodiment, the costing function determines an estimate of the time required to retrieve the data sets from storage that are required to calculate each collection of algebraic relations and to store the results to storage. If the same data set is referenced more than once in a collection of algebraic relations, the cost for retrieving the data set may be allocated only once since it will be available in memory after it is retrieved the first time. In this example, the collection of algebraic relations requiring the lowest data transfer time is selected for calculating the requested data set.
The Optimizer 418 may generate different collections of algebraic relations that refer to the same logical data stored in different physical locations over different data channels and/or in different physical formats. While the data may be logically the same, different data sets with different GUIDs may be used to distinguish between the same logical data in different locations or formats. The different collections of algebraic relations may have different costs, because it may take a different amount of time to retrieve the data sets from different locations and/or in different formats. For example, the same logical data may be available over the same data channel but in a different format. Example formats may include comma separated value (CSV) format, binary-string encoding (BSTR) format, fixed-offset (FIXED) format, type-encoded data (TED) format and markup language format. Other formats may also be used. If the data channel is the same, the physical format with the smallest size (and therefore the fewest number of bytes to transfer from storage) may be selected. For instance, a comma separated value (CSV) format is often smaller than a fixed-offset (FIXED) format. However, if the larger format is available over a higher speed data channel, it may be selected over a smaller format. In particular, a larger format available in a high speed, volatile memory such as a DRAM would generally be selected over a smaller format available on lower speed non-volatile storage such as a disk drive or flash memory.
In this way, the Optimizer 418 takes advantage of high processor speeds to optimize algebraic relations without accessing the underlying data for the data sets from data storage. Processor speeds for executing instructions are often higher than data access speeds from storage. By optimizing the algebraic relations before they are calculated, unnecessary data access from storage can be avoided. The Optimizer 418 can consider a large number of equivalent algebraic relations and optimization techniques at processor speeds and take into account the efficiency of data accesses that will be required to actually evaluate the expression. For instance, the system may receive a query requesting data that is the intersection of data sets A, B and D. The Optimizer 418 can obtain known relationships regarding these data sets from the Set Manager 402 and optimize the expression before it is evaluated. For example, it may obtain an existing relation from the Algebraic Cache 452 indicating that data set C is equal to the intersection of data sets A and B. Instead of calculating the intersection of data sets A, B and D, the Optimizer 418 may determine that it would be more efficient to calculate the intersection of data sets C and D to obtain the equivalent result. In making this determination, the Optimizer 418 may consider that data set C is smaller than data sets A and B and would be faster to obtain from storage or may consider that data set C had been used in a recent operation and has already been loaded into higher speed memory or cache.
The Optimizer 418 may also continually enrich the information in the Set Manager 402 via submissions of additional relations and sets discovered through analysis of the sets and Algebraic Cache 452. This process is called comprehensive optimization. For instance, the Optimizer 418 may take advantage of unused processor cycles to analyze relations and data sets to add new relations to the Algebraic Cache 452 and sets to the Set Universe that are expected to be useful in optimizing the evaluation of future requests. Once the relations have been entered into the Algebraic Cache 452, even if the calculations being performed by the Set Processor 404 are not complete, the Optimizer 418 can make use of them while processing subsequent statements. There are numerous algorithms for comprehensive optimization that may be useful. These algorithms may be based on the discovery of repeated calculations on a limited number of sets that indicate a pattern or trend of usage emerging over a recent period of time.
The Set Processor 404 actually calculates the selected collection of algebraic relations after optimization. The Set Processor 404 provides the arithmetic and logical processing required to realize data sets specified in algebraic extended set expressions. In an example embodiment, the Set Processor 404 provides a collection of functions that can be used to calculate the operations and functions referenced in the algebraic relations. The collection of functions may include functions configured to receive data sets in a particular physical format. In this example, the Set Processor 404 may provide multiple different algebraically equivalent functions that operate on data sets and provide results in different physical formats. The functions that are selected for calculating the algebraic relations correspond to the format of the data sets referenced in those algebraic relations (as may be selected during optimization by the Optimizer 418). In example embodiments, the Set Processor 404 is capable of parallel processing of multiple simultaneous operations, and, via the Storage Manager 420, allows for pipelining of data input and output to minimize the total amount of data that is required to cross the persistent/volatile storage boundary. In particular, the algebraic relations from the selected collection may be allocated to various processing resources for parallel processing. These processing resources may include processor 102 and accelerator 122 shown in
The Executive 422 performs overall scheduling of execution, management and allocation of computing resources, and proper startup and shutdown.
Administrator Interface 424 provides an interface for managing the system. In example embodiments, this may include an interface for importing or exporting data sets. While data sets may be added through the connectors, the Administrator Interface 424 provides an alternative mechanism for importing a large number of data sets or data sets of very large size. Data sets may be imported by specifying the location of the data sets through the interface. The Set Manager 402 may then assign a GUID to the data set. However, the underlying data does not need to be accessed until a request is received that requires the data to be accessed. This allows for a very quick initialization of the system without requiring data to be imported and reformatted into a particular structure. Rather, relationships between data sets are defined and added to the Algebraic Cache 452 in the Set Manager 402 as the data is actually queried. As a result, optimizations are based on the actual way the data is used (as opposed to predefined relationships built into a set of tables or other predefined data structures).
Example embodiments may be used to manage large quantities of data. For instance, the data store may include more than a terabyte, one hundred terabytes or a petabyte of data or more. The data store may be provided by a storage array or distributed storage system with a large storage capacity. The data set information store may, in turn, define a large number of data sets. In some cases, there may be more than a million, ten million or more data sets defined in the data information store. In one example embodiment, the software may scale to 264 data sets, although other embodiments may manage a smaller or larger universe of data sets. Many of these data sets may be virtual and others may be realized in the data store. The entries in the data set information store may be scanned from time to time to determine whether additional data sets should be virtualized or whether to remove data sets to temporally redefine the data sets captured in the data set information store. The relation store may also include a large number of algebraic relations between data sets. In some cases, there may be more than a million, ten million or more algebraic relations included in the relation store. In some cases, the number of algebraic relations may be greater than the number of data sets. The large number of data sets and algebraic relations represent a vast quantity of information that can be captured about the data sets in the data store and allow processing and algebraic optimization to be used to efficiently manage extremely large amounts of data. The above are examples only and other embodiments may manage a different number of data sets and algebraic relations.
Most data management systems may be based on malleable data sets. That is, when an insertion or deletion occurs the data set may be modified. An alternative approach may be to use immutable data sets. That is, when an insertion or deletion occurs, the original data set may be untouched and a new data set may be created that is the result of the insertion or deletion. The immutable data set approach may be used in A2DB and SPARQL Server because in the immutable data set approach it may be easy to maintain an expression universe where the expressions are never invalidated by mutations to their constituent data sets. With immutable data sets, as more queries are run, the Algebraic Cache 452 becomes richer and richer, and the probability of encountering reusable expressions grows. This may be advantageous because it permits the substitution of an already calculated (enumerated) data set for one that has yet to be calculated (enumerated), thereby avoiding computation. However, the usefulness of this rich universe of expressions becomes diminished due to insertions and deletions.
Restriction promotion/demotion optimizations may assume that the data is constant and the query varies. As such, the query optimization attempts to push restrictions down toward the leaf nodes to eliminate as much data as fast as possible and the global optimization attempts to pull the restriction as high as possible toward the root node to make invariant as much of the computation as possible. In contrast insertions, deletions, and streaming queries cause the data to change, and especially in the case of streaming queries, the query becomes the invariant part.
The systems, methods, devices, and non-transitory media of the various embodiments provided enable query execution plan graphs to be compared to determine whether all or portions of two or more queries or algebraic expressions define data sets that are structurally equivalent. Expressions may define two data sets that are structurally equivalent when there is a bijection that transforms one expression so that it satisfies the definition of the other data set. Examples of structurally equivalent data sets may include data sets that only differ in the naming or ordinal positions of attributes or that differ in the values of identifying metadata, such as a data set's provenance. In the various embodiments, all or a portion of a first expression (e.g., database query) that has been previously run defines a first data set that may be structurally equivalent to a second data set defined by all or a portion of a second query that is to be run. All or a portion of the second query may be transformed into all or a portion of the first query defining the structural equivalency, thereby allowing the results from previously running the first query to be reused. In this manner, the various embodiments enable reuse of results among structurally equivalent data sets to reduce computational costs and improve query response speed.
The various embodiments may provide a mechanism that given all or a portion of an expression can discover candidate data sets in an algebraic cache that may be structurally equivalent to the data set defined by that expression. Candidates for structural equivalence matching may be chosen in a way such that only a subset of the data sets described in the algebraic cache that have a high likelihood of testing positive for structural equivalence may be examined, thereby reducing the computational and communication costs of look-ups into the algebraic cache and reducing the computational costs of evaluating structural equivalence relationships. For example, heuristic pattern matching may be used to identify candidate expressions given all or a portion of an input expression. A heuristic pattern match looks for expressions in the algebraic cache that transform a shared data set using an operation that may be structure preserving, such as a rename or swizzle operation on top of an already reusable data set.
An example of a structure preserving transformation is illustrated in
The various embodiments may additionally use, for example, a heuristic pattern match that given all or a portion of an expression looks for expressions in the algebraic cache using an operation that may accept an operand defined by a transformation of a shared data set that may be structure preserving if the operations were reordered such that the structure preserving transform were applied last. An example of such a transformation is a join or filter operation through which a rename or swizzle in the new query could be pushed up, such as illustrated in
The matching expressions may constitute a set of candidates that have a high likelihood of testing positive for structural equivalence. The result of heuristic pattern matching or other search strategy on the algebraic cache is a set of candidate expressions in the algebraic cache that define data sets that are likely to be structurally equivalent to the data set defined by the input expression. The system may then check whether there is actual structural equivalence between the data set defined by the input expression and each data set defined by the set of candidate expressions. Structural equivalency may be verified by applying a transformation to a candidate expression based on algebraic identities to attempt to prove the structural equivalence.
If one of the candidate expressions defines a data set that is found to be structurally equivalent to the data set defined by the input expression, then all or a portion of the input expression may be transformed into all or a portion of the candidate expression that defines structurally equivalent data sets. For example,
The various embodiments may recursively apply the above mentioned techniques for structural equivalence discovery, testing, and transformation to the result of a successful application of those methods. In other words, once the input expression is transformed, additional candidate expressions may be identified for the transformed expression. In this manner, transformations may be pushed further up the expression, matching the largest possible expression. The various embodiments may also recursively apply reuse techniques not related to structural equivalence to the result of a successful application of the methods for structural equivalence reuse. In this manner, the various embodiments may match successively larger expressions from previous queries that may maximize the benefits of reuse.
The various embodiments may also be used in the Optimizer 418 to optimize query execution plan graphs or to compare data defined by different execution plan graphs. Two execution plan graphs define data sets that are structurally equivalent when there is a bijection that transforms one graph into the other graph. Examples of execution plan graphs that define structurally equivalent data sets may include graphs that represent data sets that only differ in the naming or ordinal positions of attributes or that differ in the values of identifying metadata, such as a data set's provenance. In various embodiments, in query planning the Optimizer 418 may substitute previously realized results from a first query if it is structurally equivalent to the current query plan and avoid work. One advantage of the various embodiments may be that the transformation of the graph into another graph defining a structurally equivalent data set incurs almost no cost and permits the system to reuse realized results that it wouldn't otherwise be able to use. For example in SPARQL databases, during testing structural equivalence may be used to determine if two graphs defining data sets containing different blank node names are equivalent.
In block 602 a processor may receive an expression defining a data set. For example, the expression may be an algebraic query for data in one or more databases stored in the system that is input by a user.
In block 604 the processor may identify a plurality of candidate expressions that match all or a portion of the expression. The system may include an algebraic cache that stores expressions (e.g., prior database queries) that define data sets. The system may compare the input expression with all of the expressions to identify the candidate expressions, each of which may be all or a portion of the stored expressions. The processor may utilize heuristic pattern matching or some other method to identify the candidate expressions from the set of all expressions stored in the algebraic cache. Identifying the candidate expressions narrows down the number data sets the system may check for structural equivalency with the data set defined by the input expression.
In determination block 606 the processor may determine whether any of the data sets defined by the set of candidate expressions are structurally equivalent to the data set defined by the input expression. Examples of data sets that are structurally equivalent may include, but are not limited to, when the data sets differ only in the naming of attributes, in ordinal positions of attributes, or in values of identifying metadata, such as illustrated in
In response to determining that no data sets defined by the set of candidate expressions are structurally equivalent to the data set defined by the input expression (i.e., determination block 606=“No”), the processor may obtain the data set defined by the expression in block 610. In other words, if no prior expressions/queries define structurally equivalent data sets, then the unchanged input expression is executed by the system to obtain the data set. The data set and/or the expression may be stored in the algebraic cache and associated with a GUID.
In response to determining that a data set defined by one of the set of candidate expressions is structurally equivalent to the data set defined by the input expression (i.e., determination block 606=“Yes”), the processor may transform all or a portion of the expression into the candidate expression in block 608. The processor may perform multiple iterations to further transform or simplify the processing of the expression. For example, the processor may identify a plurality of candidate expressions that match all or a portion of the transformed expression, and determine if any of the candidate expressions define data sets that are structurally equivalent to the data set defined by the transformed expression (i.e., return to the operations in blocks 604 and 606). The processor may iteratively optimize the expression until the processor cannot identify any further structural equivalencies stored in the algebraic cache.
Once no further structural equivalencies are found, the processor may obtain the data set defined by the final transformed expression in block 610. Obtaining the data set may include utilizing previously computed and cached data sets defined by the candidate expressions that were used to transform the input expression. For example, the entire input expression may be transformed into a candidate expression defining a structurally equivalent data set. This data set may be stored in the algebraic cache. The processor may retrieve the data set from the algebraic cache and output it as the result of the input expression without having to actually run the input expression. In another example, a portion of the input expression may be transformed into a candidate expression defining a structurally equivalent data set stored in the algebraic cache. The processor may retrieve the data set from the algebraic cache and apply the remaining portion of the input expression to the data set to obtain the final result. In this manner, the method 600 optimizes database queries by reusing prior queries defining structurally equivalent data sets.
The various embodiments may be implemented in any of a variety of computing devices, an example of which is illustrated in
The various embodiments may also be implemented on any of a variety of commercially available server devices, such as the server 1300 illustrated in
The processors 1201 and 1301 may be any programmable microprocessor, microcomputer or multiple processor chip or chips that can be configured by software instructions (applications) to perform a variety of functions, including the functions of the various embodiments described above. In some devices, multiple processors may be provided, such as one processor dedicated to wireless communication functions and one processor dedicated to running other applications. Typically, software applications may be stored in the internal memory 1202, 1205, 1302, and 1303 before they are accessed and loaded into the processors 1201 and 1301. The processors 1201 and 1301 may include internal memory sufficient to store the application software instructions. In many devices the internal memory may be a volatile or nonvolatile memory, such as flash memory, or a mixture of both. For the purposes of this description, a general reference to memory refers to memory accessible by the processors 1201 and 1301 including internal memory or removable memory plugged into the device and memory within the processor 1201 and 1301 themselves.
The foregoing method descriptions and the process flow diagrams are provided merely as illustrative examples and are not intended to require or imply that the steps of the various embodiments must be performed in the order presented. As will be appreciated by one of skill in the art the order of steps in the foregoing embodiments may be performed in any order. Words such as “thereafter,” “then,” “next,” etc. are not intended to limit the order of the steps; these words are simply used to guide the reader through the description of the methods. Further, any reference to claim elements in the singular, for example, using the articles “a,” “an” or “the” is not to be construed as limiting the element to the singular.
The various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The hardware used to implement the various illustrative logics, logical blocks, modules, and circuits described in connection with the aspects disclosed herein may be implemented or performed with a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general-purpose processor may be a microprocessor, but, in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration. Alternatively, some steps or methods may be performed by circuitry that is specific to a given function.
In one or more exemplary aspects, the functions described may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored as one or more instructions or code on a non-transitory computer-readable medium or non-transitory processor-readable medium. The steps of a method or algorithm disclosed herein may be embodied in a processor-executable software module which may reside on a non-transitory computer-readable or processor-readable storage medium. Non-transitory computer-readable or processor-readable storage media may be any storage media that may be accessed by a computer or a processor. By way of example but not limitation, such non-transitory computer-readable or processor-readable media may include RAM, ROM, EEPROM, FLASH memory, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that may be used to store desired program code in the form of instructions or data structures and that may be accessed by a computer. Disk and disc, as used herein, includes compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk, and blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above are also included within the scope of non-transitory computer-readable and processor-readable media. Additionally, the operations of a method or algorithm may reside as one or any combination or set of codes and/or instructions on a non-transitory processor-readable medium and/or computer-readable medium, which may be incorporated into a computer program product.
The preceding description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the following claims and the principles and novel features disclosed herein.
This application claims the benefit of priority to U.S. Provisional Application No. 62/198,217 entitled “Structural Equivalence” filed Jul. 29, 2015, the entire contents of which are hereby incorporated by reference.
Number | Date | Country | |
---|---|---|---|
62198217 | Jul 2015 | US |