A data model describes how data can be stored and accessed. More formally, data models define data entities and relationships between the data entities. The primary objective of a data model is to provide a definition and format of data to facilitate management and processing of vast quantities of data. One application of data models is database models, which define how a database or other store is structured and utilized. A database model can be relational or non-relational.
In a relational model, or more particularly a relational database, data is structured in terms of one or more tables. Tables are relations that comprise a number of columns and rows, wherein the named columns are referred to as attributes and rows capture data for specific entity instances. For example, a table can capture information about a particular entity such as a book in rows, also called tuples, and columns. The columns identify various attributes of an entity such as the title, author, and year of publication of a book. The rows capture an instance of an entity such as a particular book. In other words, each row in the table represents attributes of a particular book. Further yet, a table can include primary and foreign keys that enable two or more tables to be linked together.
Amongst many implementations a non-relational model, a key-value model is one of the most popular. Key-value databases or stores represent a simple data model that maps unique keys to a set of one or more values. More specifically, the key-value store stores values and an index to facilitate location of the stored values based on a key. For example, a key be located that identifies one of a title, author, or publication of a data of a book.
Relational databases are often referred to as SQL databases while some non-relational databases are called NoSQL databases or stores. SQL stands for Structured Query Language, which is the primary language utilized to query and update data in a relational database. When SQL is utilized in conjunction with a relational database, the database can be referred to as a SQL-based relational database. However, more often a SQL-based relational database is simply referred to as a SQL database and used as a synonym for a relational database. NoSQL is a term utilized to designate databases that differ from SQL-based relational databases. In other words, the term NoSQL is used as a synonym for a non-relational database or store such as but not limited to a key-value store.
SQL databases and NoSQL stores have a number of advantages and disadvantages that are captured at a high level by the CAP theorem, which states that of consistency (C), availability (A), and partition tolerance (P) only two can be guaranteed at any one time. Consistency refers to a characteristic of a system to remain in a consistent state after an operation such as an update. Availability concerns remaining operational over a period of time, even with the presence of failures, and partition tolerance refers to the ability of a system to operate across network partitions. Typically, the design choice for SQL databases is to choose consistency and availability over partition tolerance, and for NoSQL stores to drop consistency in favor or partition tolerance and availability. In other words, NoSQL stores sacrifice consistency for scalability or alternatively SQL databases sacrifice scalability for consistency.
The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed subject matter. This summary is not an extensive overview. It is not intended to identify key/critical elements or to delineate the scope of the claimed subject matter. Its sole purpose is to present some concepts in a simplified form as a prelude to the more detailed description that is presented later.
Briefly described, the subject disclosure generally pertains to employing a homomorphism lemma for efficient querying of databases. A representation of a language-integrated query (LINQ) can be created that is based upon a homomorphism characteristic of the query such as Bird's Homomorphism Lemma Such a representation of the LINQ query can be subsequently utilized to execute the query over a database such as but not limited to a key-value store. By way of example and not limitation, the LINQ query can be transformed into a representation with the employment of a first LINQ operator and a second LINQ operator in which the first LINQ operator is at least one of a “Select,” a “SelectMany,” or a “GroupBy” and the second LINQ operator is at least one of a “Reduce” or an “Aggregate.”
To the accomplishment of the foregoing and related ends, certain illustrative aspects of the claimed subject matter are described herein in connection with the following description and the annexed drawings. These aspects are indicative of various ways in which the subject matter may be practiced, all of which are intended to be within the scope of the claimed subject matter. Other advantages and novel features may become apparent from the following detailed description when considered in conjunction with the drawings.
Details below are generally directed toward database querying. A representation of a query such as a language-integrated query (LINQ or LINQ query) can be generated based upon a homomorphism characteristic of the query. The representation of the LINQ query can be utilized to execute the LINQ query efficiently on a database such as a key-value store. Conventionally, LINQ queries have been employed with respect to relational databases (e.g., SQL). However, LINQ queries can be extended to operate with respect non-relational stores (e.g., NoSQL, key-value store). Moreover, a representation of the LINQ query can be generated that is utilized to execute such query efficiently over a relational and/or non-relational store, for example utilizing parallel processing or more specifically distributed parallel processing.
Various aspects of the subject disclosure are now described in more detail with reference to the annexed drawings, wherein like numerals refer to like or corresponding elements throughout. It should be understood, however, that the drawings and detailed description relating thereto are not intended to limit the claimed subject matter to the particular form disclosed. Rather, the intention is to cover all modifications, equivalents, and alternatives falling within the spirit and scope of the claimed subject matter.
Referring initially to
LINQ, and supporting technology, provide a convenient and declarative shorthand query syntax (e.g., SQL-like) to facilitate specification of queries within a programming language (e.g., C#®, Visual Basic® . . . ). More specifically, query operators are provided that map to lower-level language constructs or primitives such as methods and lambda expressions. Query operators are provided for various families of operations (e.g., filtering, projection, joining, grouping, ordering . . . ), and can include but are not limited to “where” and “select” operators that map to methods that implement the operators that these names represent. By way of example, a user can specify a query in a form such as “from n in numbers where n<10 select n,” wherein “numbers” is a data source and the query returns integers from the data source that are less than ten. Further, query operators can be combined in various ways to generate queries of arbitrary complexity.
Conventionally, LINQ queries have be specified and executed with respect to a relational store. However, LINQ queries can be extended to support execution over non-relational data such as key-value stores. More specifically, by utilizing the homomorphism characteristic of the LINQ query, a representation of such LINQ query can be generated and utilized to execute the LINQ query on a key-value store. Stated differently, a representation of the LINQ query is created based upon Bird's First Homomorphism Lemma, wherein such representation allows execution of the LINQ query on a key-value store.
The database querying system 100 includes a conversion component 102 that generates a representation of a LINQ query based upon a homomorphism characteristic of such LINQ query. The conversion component 102 transforms the LINQ query into a representation by implementing functions, algorithms, and/or operators (discussed in more detail below, in particular
By way of example and not limitation, a homomorphism characteristic is a structure-preserving map between two algebraic structures (such as groups, collections, sets, etc.). Additionally, a homomorphism is a function between two algebraic objects (e.g., groups, collections, sets, etc.) that respects the algebraic structure. In general, a query that includes a homomorphism characteristic will maintain such property of homomorphism, or, in other words, remain homomorphic. Furthermore, it is to be appreciated that queries can be homomorphisms, because the queries are created from homomorphic parts. In other words, homomorphism characteristics are enforced in order to generate representations that enable querying on various databases, stores, etc.
The querying system 200 depicts the conversion component 102 incorporated into the query processor component 104 by way of example and not by limitation. It is to be appreciated that the conversion component 102 can be a stand-alone component, incorporated into the query processor component 104, incorporated into the key-value store 106, and/or any combination thereof.
In particular, the database front-end housing system 204 can manage incoming query requests on the key-value store 106. Thus, the query processor component 104 can provide the representation of the LINQ query to the database front-end housing system 204 in which the database front-end housing system 204 utilizes the representation to execute the LINQ query on the key-value store 106. For example, the database front-end housing system 204 can include an internal query processor (not shown) that performs queries and returns results. Such internal query processor (not shown) can utilize the representation of the LINQ query to execute such query on the key-value store 106. In another example but not in limitation, the query processor component 104 can utilize a combination of directly executing the representation on the key-value store 106 and communicating at least a portion of the representation to the database front-end housing system 204 to execute internally (e.g., internal query processor). In such a situation the query processor component 104 can perform translation of the query from a first form to a second form executable by the database front-end housing system.
The querying system 200 and 202 can be employed for any suitable key-value store 106. In general, the query processor component 104 can execute the representation on the key-value store 106 regardless of a data connection there between. For instance, the key-value store 106 can be cloud-based, server-based, wireless, hard-wired, and the like. In other words, the query processor component 104 can directly execute the representation on the key-value store 106 independent of a physical location (e.g., remote, local, any combination thereof, etc.) and/or data connection (e.g., cloud, wireless, local area network (LAN), any combination thereof, etc.).
The following is high-level discussion of an exemplary transformation of a LINQ query to a representation based upon a homomorphism characteristic that can be carried out by the conversion component 102 of
The collection 300 is fragmented into at least two sub-collections. A group of sub-collections 302 illustrates a first sub-collection XS0, a second sub-collection XS1, and a third collection XS2. A first LINQ operator can be performed on each of the sub-collections to create a result 304 that includes a first collection ZS0, a second collection ZS1, and a third collection ZS2. For instance, the first LINQ operator can be, but is not limited to, a “Select,” a “SelectMany” or a “GroupBy.” It is to be appreciated that the “SelectMany” operator can be a generalization of the relation “CrossApply” operator.
A second LINQ operator can be performed on the result 304 to create a result 306 that includes a first collection Z0, a second collection Z1, and a third collection Z2 {[Z0, Z1, Z2]} For instance, the second LINQ operator can be at least one of a “Reduce,” or an “Aggregate.” The second LINQ operator can be performed on the result 306 to create a result 308 to the LINQ query that includes {Z0⊕Z1⊕Z2}. It is to be appreciated that the first LINQ operator and the second LINQ operator can be performed in parallel based upon the fragmenting into sub-collections. In other words, the LINQ query can be executed in parallel based upon the generated representation.
Furthermore, it is to be appreciated that the first LINQ operator performed and the subsequent second LINQ operator(s) performed can replicate a map-reduce functionality. The map portion segments an input from a master node across various worker nodes in order to allow the worker nodes to individually process the sub-portions. Subsequently, individual results of the worker nodes can be combined, or reduced, and passed back to the master node as the result. Such efficient parallel process is significant with respect to NoSQL stores, house vast quantities of data across multiple stores or machines.
The database querying system 400 further includes a translation component 402 that can translate the representation of the LINQ query generated based upon the homomorphism characteristic into a second representation. The second representation is a command or instruction that is acceptable to any suitable to a particular store or managing entity. In other words, the translation component 402 can configure the first representation (e.g., the representation of the LINQ query based upon a homomorphism characteristic) into a second representation that is utilized to execute the query. By way of example and not limitation, the translation component 402 can be configured to generate Transact-SQL (T-SQL) from a first representation to facilitate execution with respect to the relational store 404. Similar translations can also be made to facilitate interactions with particular interfaces with the key-value store 106.
The algorithm component 502 can employ algorithms, functions, and operators in order to generate a representation of the LINQ query that is utilized to execute such query on the key-value store 106. By way of example and not limitation, the algorithm component 502 can leverage LINQ operators such as a “Select,” a “SelectMany,” a “GroupBy,” a “Reduce,” and an “Aggregate.” Additionally, the algorithm component 502 creates the representation of the LINQ query based upon a homomorphism characteristic and/or Bird's Homomorphism Lemma.
The following is high-level discussion of an exemplary generation of a representation of a LINQ query that can be carried out by the conversion component 102 and/or the algorithm component 502.
The claimed subject matter exploits the fact that both NoSQL (as well as coSQL) and SQL stores are monads, and that queries can be defined as homomorphisms over monads. In other words, Bird's Homomorphism Lemma can be generalized to homomorphisms over monads. Additionally, Bird's Homomorphism Lemma can be generalized to employ “GroupBy” and “Aggregate” query operators on a store. Accordingly, any homomorphic query can be factored into a “GroupBy” and an “Aggregate” (e.g., LINQ operators), and can be executed in parallel including distributed parallel execution. This especially significant with respect to NoSQL, because vast amounts of data are typically split across multiple machines.
LINQ is a generalization of the relational algebra where instead using sets of rows, monads are used. Just like SQL is expanded from regular syntax into relational algebra expressions, LINQ or monad comprehensions are de-sugared by the compiler into algebraic expressions over primitive query operators. Stated differently, simple programmer-friendly syntax is transformed into complicated less-user-friendly math.
The generalization of the relational algebra operators is as follows where “M” is an abstract notion of collection (instead of “set” in SQL) and “T” represents generic collection elements (e.g., key-value pairs).
So-called correlated subqueries are implemented using the “SelectMany” or “Bind” operator:
SelectMany::M<A>x (A→M<B>)→M<B>
Using this operator and “{_},” the rest can be defined as follows:
Also provided is an intensional representation of functions, written as “A→B” or as “Expr<A→B>” as follows:
SelectMany::M<A>x (A→M<B>)→M<B>
In many cases, a “map” function can be utilized with the following signature (plus a corresponding one that takes an intensional representation of the function):
Select::M<A>x (A→B)→M<B>
Further, instead of “SelectMany,” a flatten function can be utilized with the following signature:
Join::M<M<A>>→M<A>
It is to be appreciated that the above is not natural in the relational context where nesting is not allowed.
Certain functions of type “h::M<A>→B,” or queries, can be also be factored into simpler functions by recursive decomposition of the argument to the function, as follows:
h({a,b,c})=h({a}∪{b}∪{c})={f(a)}⊕{f(b)}⊕{f(c)}
That is any homomorphism on collection “M<A>” can be defined as:
H as =as.Select(f).Reduce(⊕)
Where “Select” is as above and “Reduce” is defined as follows:
Reduce ({a}∪{b}∪{c})=a⊕b⊕c
For example, “SelectMany(as,f)=as.Select(f).Join( )” and “Join” can be defined as:
Join as =Reduce(∪)
In other words, all homomorphic queries of type “M<A>→B” can be converted in the form “h(as)=as.Select(f).Reduce(⊕)” for some function “f::A→B” and operation “⊕::BxB→B.” Further algebraic properties of “∪” or combinations can be exploited to break collections into various fragments in different ways, such as assuming “∪” is associative as follows:
{a,b,c,d}=({a}∪{b})∪({c}∪{d})
Now, a homomorphic query “h({a,b,c,d})” can be evaluated in parallel in the following way:
(f(a)⊕f(b))⊕(f(c)⊕f(d))
The key-value model associated with NoSQL and coSQL provides a natural partitioning of a collection “M<A>” into sub-collection, based on their key, also, the map function can be generalized to return a collection itself For instance, the key-value store “{K:a, L:b,}” can be split into a nested store as follows:
{{P:w,Q:x},{P:y,Q:z}}
Next, the key-value pairs can be grouped or joined into a single key-value store “{P:{w,y}, Q:{x,z}},” and reduced to “{w⊕y, x|z}.”
Stated more simply, Birds Homomorphism Lemma can be generalized to show that any homomorphic query over a key-value store can be written as a “Select” or a “SelectMany” followed by a “Reduce,” or equivalently by a “GroupBy” followed by an “Aggregate.”
The aforementioned systems, architectures, environments, and the like have been described with respect to interaction between several components. It should be appreciated that such systems and components can include those components or sub-components specified therein, some of the specified components or sub-components, and/or additional components. Sub-components could also be implemented as components communicatively coupled to other components rather than included within parent components. Further yet, one or more components and/or sub-components may be combined into a single component to provide aggregate functionality. The components may also interact with one or more other components not specifically described herein for the sake of brevity, but known by those of skill in the art.
Furthermore, as will be appreciated, various portions of the disclosed systems above and methods below can include or consist of artificial intelligence, machine learning, or knowledge or rule-based components, sub-components, processes, means, methodologies, or mechanisms (e.g., support vector machines, neural networks, expert systems, Bayesian belief networks, fuzzy logic, data fusion engines, classifiers . . . ). Such components, inter alia, can automate certain mechanisms or processes performed thereby to make portions of the systems and methods more adaptive as well as efficient and intelligent. By way of example and not limitation, the conversion component 102 or one or more sub-components thereof can employ such mechanisms to efficiently determine or otherwise infer conversion techniques related to generating a representation of a LINQ query based upon a homomorphism characteristic.
In view of the exemplary systems described supra, methodologies that may be implemented in accordance with the disclosed subject matter will be better appreciated with reference to the flow charts of
Referring to
As used herein, the terms “component” and “system,” as well as forms thereof are intended to refer to a computer-related entity, either hardware, a combination of hardware and software, software, or software in execution. For example, a component may be, but is not limited to being, a process running on a processor, a processor, an object, an instance, an executable, a thread of execution, a program, and/or a computer. By way of illustration, both an application running on a computer and the computer can be a component. One or more components may reside within a process and/or thread of execution and a component may be localized on one computer and/or distributed between two or more computers.
The word “exemplary” or various forms thereof are used herein to mean serving as an example, instance, or illustration. Any aspect or design described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other aspects or designs. Furthermore, examples are provided solely for purposes of clarity and understanding and are not meant to limit or restrict the claimed subject matter or relevant portions of this disclosure in any manner It is to be appreciated a myriad of additional or alternate examples of varying scope could have been presented, but have been omitted for purposes of brevity.
As used herein, the term “inference” or “infer” refers generally to the process of reasoning about or inferring states of the system, environment, and/or user from a set of observations as captured via events and/or data. Inference can be employed to identify a specific context or action, or can generate a probability distribution over states, for example. The inference can be probabilistic—that is, the computation of a probability distribution over states of interest based on a consideration of data and events. Inference can also refer to techniques employed for composing higher-level events from a set of events and/or data. Such inference results in the construction of new events or actions from a set of observed events and/or stored event data, whether or not the events are correlated in close temporal proximity, and whether the events and data come from one or several event and data sources. Various classification schemes and/or systems (e.g., support vector machines, neural networks, expert systems, Bayesian belief networks, fuzzy logic, data fusion engines . . . ) can be employed in connection with performing automatic and/or inferred action in connection with the claimed subject matter.
Furthermore, to the extent that the terms “includes,” “contains,” “has,” “having” or variations in form thereof are used in either the detailed description or the claims, such terms are intended to be inclusive in a manner similar to the term “comprising” as “comprising” is interpreted when employed as a transitional word in a claim.
In order to provide a context for the claimed subject matter,
While the above disclosed system and methods can be described in the general context of computer-executable instructions of a program that runs on one or more computers, those skilled in the art will recognize that aspects can also be implemented in combination with other program modules or the like. Generally, program modules include routines, programs, components, data structures, among other things that perform particular tasks and/or implement particular abstract data types. Moreover, those skilled in the art will appreciate that the above systems and methods can be practiced with various computer system configurations, including single-processor, multi-processor or multi-core processor computer systems, mini-computing devices, mainframe computers, as well as personal computers, hand-held computing devices (e.g., personal digital assistant (PDA), phone, watch . . . ), microprocessor-based or programmable consumer or industrial electronics, and the like. Aspects can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. However, some, if not all aspects of the claimed subject matter can be practiced on stand-alone computers. In a distributed computing environment, program modules may be located in one or both of local and remote memory storage devices.
With reference to
The processor(s) 920 can be implemented 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 processor, controller, microcontroller, or state machine. The processor(s) 920 may also be implemented as a combination of computing devices, for example a combination of a DSP and a microprocessor, a plurality of microprocessors, multi-core processors, one or more microprocessors in conjunction with a DSP core, or any other such configuration.
The computer 910 can include or otherwise interact with a variety of computer-readable media to facilitate control of the computer 910 to implement one or more aspects of the claimed subject matter. The computer-readable media can be any available media that can be accessed by the computer 910 and includes volatile and nonvolatile media and removable and non-removable media. By way of example, and not limitation, computer-readable media may comprise computer storage media and communication media.
Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to memory devices (e.g., random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM) . . . ), magnetic storage devices (e.g., hard disk, floppy disk, cassettes, tape . . . ), optical disks (e.g., compact disk (CD), digital versatile disk (DVD) . . . ), and solid state devices (e.g., solid state drive (SSD), flash memory drive (e.g., card, stick, key drive . . . ) . . . ), or any other medium which can be used to store the desired information and which can be accessed by the computer 910.
Communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. The term “modulated data signal” means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, RF, infrared and other wireless media. Combinations of any of the above should also be included within the scope of computer-readable media.
Memory 930 and mass storage 950 are examples of computer-readable storage media. Depending on the exact configuration and type of computing device, memory 930 may be volatile (e.g., RAM), non-volatile (e.g., ROM, flash memory . . . ) or some combination of the two. By way of example, the basic input/output system (BIOS), including basic routines to transfer information between elements within the computer 910, such as during start-up, can be stored in nonvolatile memory, while volatile memory can act as external cache memory to facilitate processing by the processor(s) 920, among other things.
Mass storage 950 includes removable/non-removable, volatile/non-volatile computer storage media for storage of large amounts of data relative to the memory 930. For example, mass storage 950 includes, but is not limited to, one or more devices such as a magnetic or optical disk drive, floppy disk drive, flash memory, solid-state drive, or memory stick.
Memory 930 and mass storage 950 can include, or have stored therein, operating system 960, one or more applications 962, one or more program modules 964, and data 966. The operating system 960 acts to control and allocate resources of the computer 910. Applications 962 include one or both of system and application software and can exploit management of resources by the operating system 960 through program modules 964 and data 966 stored in memory 930 and/or mass storage 950 to perform one or more actions. Accordingly, applications 962 can turn a general-purpose computer 910 into a specialized machine in accordance with the logic provided thereby.
All or portions of the claimed subject matter can be implemented using standard programming and/or engineering techniques to produce software, firmware, hardware, or any combination thereof to control a computer to realize the disclosed functionality. By way of example and not limitation, the conversion component 102 can be, or form part, of an application 962, and include one or more modules 964 and data 966 stored in memory and/or mass storage 950 whose functionality can be realized when executed by one or more processor(s) 920, as shown.
In accordance with one particular embodiment, the processor(s) 920 can correspond to a system-on-a-chip (SOC) or like architecture including, or in other words integrating, both hardware and software on a single integrated circuit substrate. Here, the processor(s) 920 can include one or more processors as well as memory at least similar to processor(s) 920 and memory 930, among other things. Conventional processors include a minimal amount of hardware and software and rely extensively on external hardware and software. By contrast, an SOC implementation of processor is more powerful, as it embeds hardware and software therein that enable particular functionality with minimal or no reliance on external hardware and software. For example, the conversion component 102, and/or associated functionality can be embedded within hardware in a SOC architecture.
The computer 910 also includes one or more interface components 970 that are communicatively coupled to the system bus 940 and facilitate interaction with the computer 910. By way of example, the interface component 970 can be a port (e.g., serial, parallel, PCMCIA, USB, FireWire . . . ) or an interface card (e.g., sound, video . . . ) or the like. In one example implementation, the interface component 970 can be embodied as a user input/output interface to enable a user to enter commands and information into the computer 910 through one or more input devices (e.g., pointing device such as a mouse, trackball, stylus, touch pad, keyboard, microphone, joystick, game pad, satellite dish, scanner, camera, other computer . . . ). In another example implementation, the interface component 970 can be embodied as an output peripheral interface to supply output to displays (e.g., CRT, LCD, plasma . . . ), speakers, printers, and/or other computers, among other things. Still further yet, the interface component 970 can be embodied as a network interface to enable communication with other computing devices (not shown), such as over a wired or wireless communications link.
What has been described above includes examples of aspects of the claimed subject matter. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the claimed subject matter, but one of ordinary skill in the art may recognize that many further combinations and permutations of the disclosed subject matter are possible. Accordingly, the disclosed subject matter is intended to embrace all such alterations, modifications, and variations that fall within the spirit and scope of the appended claims.