WO2019015364A1 - Method and device for executing structured query language (sql) instruction - Google Patents

Method and device for executing structured query language (sql) instruction Download PDF

Info

Publication number
WO2019015364A1
WO2019015364A1 PCT/CN2018/083411 CN2018083411W WO2019015364A1 WO 2019015364 A1 WO2019015364 A1 WO 2019015364A1 CN 2018083411 W CN2018083411 W CN 2018083411W WO 2019015364 A1 WO2019015364 A1 WO 2019015364A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
attribute
identifier
sql
index value
Prior art date
Application number
PCT/CN2018/083411
Other languages
French (fr)
Chinese (zh)
Inventor
陈志标
陆军
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2019015364A1 publication Critical patent/WO2019015364A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/289Object oriented databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2452Query translation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2452Query translation
    • G06F16/24526Internal representations for queries

Definitions

  • the present application relates to the field of communications, and in particular, to a method and apparatus for executing a Structured Query Language (SQL) instruction.
  • SQL Structured Query Language
  • Network Function Virtualization (NFV) architecture realizes the separation of business data and business processing.
  • the business data is distributed storage
  • object storage is the mainstream storage method in distributed storage.
  • OQL Object Query Language
  • ORM Object Relation Mapping
  • OQL Object Query Language
  • OQL Object Query Language
  • its statement adopts the method of object expression, and its function is completely based on object-oriented entity query.
  • OQL is a non-standard SQL interface
  • applications developed based on standard SQL interfaces cannot be used, and system openness is insufficient.
  • different OQL languages need to be developed for different object differences, and it is difficult to implement function migration.
  • grammar it can't be more succinct than SQL, and can't implement complex queries.
  • Embodiments of the present application provide a method and apparatus for executing SQL instructions for supporting standard SQL access objects.
  • a method for executing a structured query language SQL instruction comprising: receiving a SQL instruction, the SQL instruction is used to query an attribute data of an object from an object data; and parsing the SQL instruction to obtain an object
  • the identifier, the key value attribute of the object, and the query condition are used to indicate the type of the object, the key value attribute of the object is used to generate an index value, the index value corresponds to the data of the object, and the query condition is used in the data of the object.
  • Query attribute data according to the identifier of the object, and the mapping relationship between the object identifier and the object pattern, obtain the object pattern and the relational data table corresponding to the object, and the object pattern is used to define a tree data structure of a type of object, a tree shape
  • the data structure includes at least one first node, the first node is used to define attributes of the attributes of such objects that can be used to generate index values, the relational data table is a two-dimensional table, and the two-dimensional table is in accordance with the node relationship indicated in the object pattern.
  • Attribute data of the storage object according to the key value attribute of the object and the attribute defined in the object pattern for generating the index value Determining an index value corresponding to the data object; the data object corresponding to the index value obtained data object, and query condition according to the object and relational data tables, a query attribute data obtained from the data object.
  • the method for executing the SQL instruction is used to parse the identifier of the object in the SQL instruction to obtain the corresponding object schema and the relational data table, and the key value attribute of the object in the SQL instruction is used to generate the data corresponding to the object.
  • the index value, and the object data is obtained according to the index value, and the query condition in the parsing SQL instruction is used to query the attribute data of the object from the data of the object.
  • the identifier of the object in the above SQL instruction, the key value attribute of the object, and the query condition are not the object class data, but the valid data such as variables and identifiers that can be passed by the standard SQL instruction, and the above valid data obtained by parsing the SQL instruction.
  • the data of the mapping object and the attribute data of the object are implemented to support standard SQL access objects.
  • the method before receiving an SQL instruction, the method further includes: defining an object mode of the object and a relational data table; receiving a write request for the object, wherein the write request includes an identifier and an attribute of the object; The identifier of the object in the request, and the mapping relationship between the identifier of the object and the object pattern, obtaining the object schema and the relational data table of the object; converting the attribute in the write request into the object having the complete storage structure according to the object pattern of the object, And constructing an attribute in the write request as an index value according to an attribute for generating an index value defined in the object schema, wherein the object having the complete storage structure refers to an object stored in a storage space allocated according to all attributes of the object pattern, and writing The attributes in the request are stored in the storage space; the object with the complete storage structure is converted into the data of the object according to the relational data table of the object, and the data of the object is stored according to the index value.
  • This design provides a way to store data for an object through an object
  • the method further comprises: receiving a read request for the object, wherein the read request includes an identifier of the object and a key value attribute; according to the identifier of the object in the read request, and the identifier of the object and the object mode The mapping relationship is obtained, and the corresponding object pattern is obtained; according to the key value attribute of the object and the attribute that can be used to generate the index value defined in the object pattern, the index value corresponding to the data of the object is determined; and the data of the object is obtained according to the index value.
  • This design provides a way to read the data of an object through the object interface.
  • the tree data structure of the object includes at least one parent node, and the parent node includes an identifier and a domain, wherein the identifier of the parent node is used to indicate the category of the object corresponding to the parent node, and the domain of the parent node is used for Contains child nodes.
  • each node of the relational data table includes a parent table identifier, a root table identifier, and a foreign key
  • the parent table identifier is a two-dimensional table for the parent node of the child node
  • the root table identifier is used to point A two-dimensional table of the root node of a tree-shaped data structure with a foreign key pointing to the primary key of the object schema.
  • a second aspect provides an apparatus for executing a structured query language SQL instruction, the apparatus comprising: a SQL interface unit, a relational SQL access processing unit, an object relational conversion unit, a metadata management unit, and an object storage unit, wherein
  • the SQL interface unit is configured to receive an SQL instruction, and the SQL instruction is used to query the attribute data of the object from the data of the object;
  • the relational SQL access processing unit is configured to parse the SQL instruction received by the SQL interface unit to obtain the identifier of the object, The key value attribute of the object and the query condition.
  • the identifier of the object is used to indicate the type of the object.
  • the key value attribute of the object is used to generate an index value.
  • the index value corresponds to the data of the object, and the query condition is used to query the attribute from the data of the object.
  • Data an object-relational conversion unit, configured to obtain an object identifier corresponding to an object according to a relationship between an identifier of an object obtained by the relational SQL access processing unit and an identifier of the object stored by the metadata management unit, and an object mode corresponding to the object Relational data table, object schema is used to define the tree data structure of a class of objects, the number of trees
  • the structure includes at least one first node, the first node is used to define attributes of the attributes of such objects that can be used to generate index values, the relational data table is a two-dimensional table, and the two-dimensional table is stored according to the node relationship indicated in the object pattern.
  • the attribute data of the object; the object relational conversion unit is further configured to determine an index value corresponding to the data of the object according to the key value attribute of the object and the attribute for generating the index value defined in the object pattern; the object relation type conversion unit further The data of the object is obtained according to the index value corresponding to the data of the object, and the attribute data is obtained from the data of the object stored in the object storage unit according to the query condition and the relational data table of the object.
  • a third aspect provides an apparatus for executing a structured query language SQL instruction, including: a processor, a memory, a bus, and a communication interface; the memory is configured to store a computer execution instruction, and the processor and the memory are connected through a bus when the system is running The processor executes the memory stored computer to execute the instructions to perform the method as in the first aspect and any of its possible designs.
  • a computer storage medium comprising instructions that, when run on a computer, cause the computer to perform a method as in the first aspect and any of its possible designs.
  • a computer program product comprising instructions which, when run on a computer, cause the computer to perform a method as in the first aspect and any of its possible designs.
  • FIG. 1 is a schematic structural diagram of an apparatus for executing an SQL instruction according to an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a method for writing an object by using an object interface unit according to an embodiment of the present application
  • FIG. 3 is a schematic diagram of an object mode provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of an object storage structure provided by an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of a method for executing an SQL instruction by using an SQL interface unit according to an embodiment of the present application
  • FIG. 6 is a schematic diagram of a common SQL query operation required to perform a combined operation according to an embodiment of the present application
  • FIG. 7 is a schematic diagram of a method for executing an SQL instruction according to an embodiment of the present application to reduce a combined operation
  • FIG. 8 is a schematic flowchart of a method for reading an object by using an object interface unit according to an embodiment of the present application
  • FIG. 9 is a schematic structural diagram of another apparatus for executing an SQL instruction according to an embodiment of the present application.
  • FIG. 10 is a schematic structural diagram of another apparatus for executing an SQL instruction according to an embodiment of the present application.
  • a class of objects described in the embodiments of the present application refers to an abstract description having a common data structure and attribute data.
  • the data structure or attribute data of different types of objects are different.
  • the attribute data describing the scientist object and the customer object are different.
  • the age, the working age, the affiliation, and the like can be described; and for the customer object, The age, contact information, address, purchase history, etc. can be described, so the scientist object and the customer object belong to different classes of objects.
  • Attribute data is data that defines its attributes for the convenience of distinguishing between different objects. It can be described from the perspective of a class of objects or for the data of a specific object. For example, for an object such as a scientist, age, length of service, affiliated institution, etc.
  • the embodiment of the present application provides an apparatus for executing an SQL instruction, so that data is stored in units of objects, supports an efficient object access interface, and object-based distributed storage, and the device also supports standard SQL interface access.
  • the apparatus 11 includes: an object interface unit 1101, an object access processing unit 1102, a metadata management unit 1103, an object storage unit 1104, an object relation type conversion unit 1105, a relational SQL access processing unit 1106, and SQL. Interface unit 1107.
  • the above-mentioned units may use the same or different processes or threads to perform the corresponding functions, and the embodiments of the present application are not limited herein.
  • the methods provided by the embodiments of the present application may be implemented by program code in a memory, or by a chip on a router or a server, or by a simulator. It can also be implemented in a chip, such as Field-Programmable Gate Array (FPGA), Digital Signal Processing (DSP), or by software in heterogeneous acceleration hardware such as tensor processing. Implemented on a Tensor Processing Unit (TPU), a Graphics Processing Unit (GPU), or implemented by software on a Central Processing Unit (CPU), or by a software/hardware simulator.
  • FPGA Field-Programmable Gate Array
  • DSP Digital Signal Processing
  • TPU Tensor Processing Unit
  • GPU Graphics Processing Unit
  • CPU Central Processing Unit
  • the object interface unit 1101 provides a transceiving function of different forms of objects in an application scenario.
  • objects include, but are not limited to, objects represented by Java Object Notation (JSON), objects represented by Extensible Mark-up Language (XML), which are related to the actual needs of the application scenario. Is a non-standard interface.
  • the object interface unit 1101 has a function of predefining an object schema (Schema) and a relational data table (object relational schema).
  • the object schema described in this paper is an abstract description of the common data structure and attribute data that a class of objects has, including the Field node and the Keys node.
  • the Field node describes the attribute data of the object, and the key value.
  • the (Keys) node describes the index of the lookup object.
  • the attributes in the index key in the Keys node must come from the domain node.
  • the relational data table describes the associations and constraints between different nodes in the class. These two modes can be collectively referred to as object patterns in this paper.
  • Object schemas and relational data tables can also be defined in a variety of ways, such as JSON, XML, and so on. Only the data of the object defined in the object interface unit 1101 can be parsed.
  • the object with complete structure in the device includes the data of a specific object and the mode of the object (object mode and relational data table), the data of the object is unique, and the mode of the object can be shared for a class of objects.
  • the object access processing unit 1102 provides a standardized conversion function of the non-standard object representation, making it an object that can be processed by the system, and processing the object information by the object mode and the relational data table provided by the metadata management unit 1103, so that the object
  • the data is stored in the object storage unit 1104 in an agreed manner.
  • the object mode is used to match the attribute data of the object, and is used to obtain a corresponding index key according to the definition of the key value Keys in the object mode and the attribute data of the object.
  • the relational data table processes the association relationship between the parent and child nodes, and can not only guide the data of the object to be saved in the object storage unit 1104, but also provide support and optimization for the relational SQL operation.
  • the metadata management unit 1103 manages the object schema and the relational data table.
  • the object access processing unit 1102 decomposes the transformation of the object, relying on the object schema and the relational data table in the metadata management unit 1103.
  • the object storage unit 1104 provides data of the object converted according to the mode, and is a result of serialization of the data of the object.
  • the object relation type conversion unit 1105 is responsible for the conversion between the relational data and the object type data, and depends on the object mode and the relational data table in the metadata management unit 1103.
  • the object-relational conversion unit 1105 is a hub for the device to provide standard SQL access.
  • the relational SQL access processing unit 1106 is responsible for parsing the optimized SQL query language.
  • the SQL interface unit 1107 provides acceptance of the SQL query language and return of the result data.
  • the method of writing an object by the object interface unit 1101 includes:
  • the object schema of the object and the relational data table can be defined by calling the corresponding function of the object interface unit 1101. The result is stored in the metadata management unit 1103.
  • the object schema is used to define a tree data structure of a class of objects.
  • the tree data structure includes at least one node, which is used to define attributes of such objects that can be used to generate index values, and the relational data table is two-dimensional.
  • the table, the two-dimensional table stores the attribute data of the object according to the node relationship indicated in the object schema.
  • the left image is an example of a consumer object
  • the right image is an example of an object mode in the form of a JSON whose mode name is "consumer”.
  • a consumer may have no order or multiple orders, and each order includes at least one item, that is, the consumer object contains the order object, and the order object contains the item object. Therefore, in the tree-shaped object pattern formed, the consumer object is the root node, the order object is the leaf node of the consumer object, and the commodity object is the leaf node of the order object.
  • the consumer, the order, and the commodity are no longer separate objects, and they form a tree-shaped object pattern having a root node according to the nested relationship as a parent node.
  • an index is a storage structure that sorts the values of one or more columns in a database table by a unique value, which can be a collection of values in one or more columns of the table and a page pointing to the values in the table.
  • a list of logical pointers to the table. The role of the index is equivalent to the directory of the book, you can quickly find the content you need based on the page number in the directory.
  • the key and the value are in one-to-one correspondence, which limits the diversification of the data of the object to a certain extent. Therefore, we provide a variety of keys for the object through the object mode. Enhance data operability and provide support for query optimization.
  • the object mode is a tree data structure composed of nodes nested with each other, and the associated sub-objects correspond to respective nodes of the tree data structure, the tree data structure includes at least one parent node, and the object mode is described in the root node.
  • Representation that is, the schema name.
  • Each node may include three attributes: a name, a type, and a field.
  • the name and type are required attributes, and the identifier is used to indicate that the corresponding object belongs to the node.
  • Kind such as consumer, merchandise order number, etc.; type is used to indicate the data type of the node, such as integer, record, and the like.
  • Fields appear only in the parent node of a one-to-many parent child node, similar to the form of an array.
  • the fields of the parent node are used to contain child nodes (that is, the child nodes are nested in the parent node's domain (fields). )in).
  • the root node of the tree data structure also includes keys, and multiple index keys can be defined in the key value, but there is only one primary key, which is used to uniquely identify the object, each Index keys can consist of single or multiple domains in the same node.
  • the primary key points to the storage location of the object, and the index key of the non-primary key points to the primary key.
  • the key value example in Figure 3 only includes one primary key. It can also create other index keys according to the actual needs of the business. Its function is similar to the index in the relational database. A reasonable number of index keys are beneficial for query optimization.
  • the metadata management unit 1103 automatically generates a relational data table based on the object mode and related information input by the user.
  • the relational data table corresponds to the object pattern, and the relational data table can be automatically derived from the object pattern.
  • the relational data table essentially decomposes each object node in the object schema into a two-dimensional table, including the parent table identifier, the root table identifier, and the foreign key in the two-dimensional table corresponding to the child node, and the parent table identifier is used to point A two-dimensional table of the child nodes of the child nodes, the root table identifies a two-dimensional table that points to the root node of the tree data structure, and the foreign key points to the primary key of the object schema. Relationship maintenance of nodes within an object is achieved by inheriting the identity fields of the parent and root tables and creating dependencies (such as foreign keys). Relational data representations such as the following:
  • Each node customer, orders, and items are broken down into a two-dimensional table.
  • the ID (customers.id) in the customer is the primary key of the root table and its own primary key.
  • Orders are child nodes of the customer, inherit the root table (root_field integer inherit) primary key customers.id, inherit the parent table (parent_field integer inherit) primary key customers.id, foreign key dependencies (FOREIGN KEY) customers.id .
  • the items are the children of the orders, inherit the root table's primary key customers.id, inherit the parent table's primary key oders.id, and the foreign keys depend on the customers.id.
  • the other content is the attribute of each node.
  • the relational data table causes each node in the object to generate a table, and the relationship between the nodes is embodied by the child nodes (tables) inheriting the identification fields of the parent node (table) and the root node (table), and creating a dependency relationship.
  • the foreign key guarantees strong dependency; the object mode key defines the attribute of the index key, and supports one object with multiple index keys.
  • additional information can be added to the relational data table to optimize query access and improve query performance.
  • the object schema and the relational data table of all objects can be stored in the metadata management unit 1103.
  • S102 Receive a write request for an object, where the write request includes an identifier and an attribute of the object.
  • the object interface unit 1101 Since the data representation in the write request may be JSON format or XML format, etc., the object interface unit 1101 parses the identifier and key value attribute of the object obj into a unified form that the system can process, and sends it to the object access processing unit. 1102 processing.
  • the identity of the object is used to indicate the type of the object.
  • "customer" in (1) is the identifier of the object, and the other content in (1) is the key value attribute of the object.
  • the object access processing unit 1102 can query the metadata management unit 1103 to obtain the name (name) shown in FIG. 2 as “consumer” according to the mode name "customer” shown in FIG.
  • the object mode and the corresponding relational data table can be query the metadata management unit 1103 to obtain the name (name) shown in FIG. 2 as "consumer” according to the mode name "customer” shown in FIG.
  • the object mode and the corresponding relational data table can query the metadata management unit 1103 to obtain the name (name) shown in FIG. 2 as "consumer” according to the mode name "customer” shown in FIG.
  • the object mode and the corresponding relational data table can be searched.
  • S104 Convert an attribute in the write request to an object having a complete storage structure according to an object mode of the object, and construct an attribute in the write request as an index value according to an attribute defined in the object pattern for generating an index value, where
  • An object of a complete storage structure refers to an object stored in a storage space allocated according to all attributes of the object mode, and attributes in the write request are stored in the storage space.
  • the object access processing unit 1102 encapsulates the attribute data into an object of the complete storage structure of the object pattern according to the object mode of the object, and refers to the size of the opened storage space as the size of the entire object mode, and the write request for the received object.
  • the included attribute data is filled in the storage space according to the object mode, and the attribute data not included in the write request of the received object is null (NULL).
  • NULL null
  • Constructing an index value according to the attribute data and the definition of the key value in the object schema means that one of the key values shown in FIG. 2 is a consumer ID, and therefore, the consumer in the attribute data of the object received in FIG. ID (Customer.id) 2 calculates a hash value as an index value (first key value).
  • the query is performed in this way, the object can be queried according to the first key value.
  • the embodiment of the present application does not limit the number of key values and the index relationship, for example, the first key value is a primary key, and the second key value is an indirect key.
  • the second key value can index the first key value and so on.
  • the object access processing unit 1102 stores the above data to the object storage unit 1104.
  • (3) is the data of the object obtained by splitting the object having the complete storage structure in (2) according to the relational data table, from which it can be seen that each node Separate storage, parent-child relationship between nodes is maintained by a pair of bidirectional pointers Ptr.
  • the object storage unit 1104 feeds back the write status identifier to the object interface unit 1101 through the object access processing unit 1102, and the identifier is used to indicate whether the write is successful.
  • the method of executing the SQL instruction by the SQL interface unit 1107 includes:
  • S201 Receive an SQL instruction, where the SQL instruction is used to query attribute data of the object from data of an object.
  • this step can receive standard SQL operations for the object through the SQL interface unit 1107.
  • the SQL operation can be an SQL query operation for querying attribute data in a corresponding object.
  • S202 Parse the SQL instruction to obtain an identifier of the object to be queried, a key value attribute of the object, and a query condition.
  • the identifier of the object is used to indicate the type of the object
  • the key value attribute of the object is used to generate an index value, the index value and the storage.
  • the data of the object corresponds to the query condition for querying the corresponding attribute data from the data of the object.
  • the object's identity is used to query the object's two-dimensional table information and can be mapped to a unique object pattern.
  • the key-value attribute refers to an attribute that can be used to generate the index value according to the attribute in which the object is defined in the mapped object pattern, and the key value (index value) is obtained by hash calculation. For example, suppose an object has ten attributes named F0 ⁇ F9. In the object mode of the object, key indexes (Keys) define two indexes, Key1 and Key2, where Key1 is the primary key, Key2 is the secondary index, and Key2 points. The value of Key1.
  • Key1 is obtained by hashing the values of the objects F0 and F1 of the object
  • Key2 is obtained by hashing the values of the attributes F2 and F3 of the object.
  • F0, F1, F2, and F3 are the key value attributes of the object
  • other attributes F4 to F9 are non-key value attributes.
  • the object-relational conversion unit 1105 maps to the mode name customers according to the identifier of the object, and then searches for the corresponding object schema and the relational data table from the metadata management unit 1103.
  • the object-relational conversion unit 1105 looks up the corresponding node in the object schema by customers.items in the valid data, and uses product_id as the key-value attribute in the node.
  • the key value can be defined by some sort of hashing of the product_id to get the index value.
  • the object-relational conversion unit 1105 simultaneously generates an execution plan according to the operation of the SQL. If the attribute product_id included in the key-value attribute is a key-value attribute, and the index value can be constructed, the object-relational conversion unit 1105 can directly pass the index value. The corresponding object is indexed from the object storage unit 1104.
  • the object relational type conversion unit 1105 traverses all the object queries to obtain a corresponding object.
  • the object-relational conversion unit 1105 converts the data of the optimized object into a relationship according to the relational operator.
  • the type data is returned to the location where the request is initiated by the relational SQL access processing unit 1106 and the SQL interface unit 1107, and the relationship operator can be processed without modification.
  • the SQL operation is a SQL query operation
  • the traditional SQL query operation is:
  • This operation performs an Object-Oriented Language (OML) operation within the object as shown in FIG. 6.
  • OML Object-Oriented Language
  • the data items of items.product belonging to x, y, z are queried in the items table by Filter items_filter where items.product_id in(x, y, z);
  • the data set of id orders.customer_id.
  • the three sets of data sets are joined in the order of the SQL query, and finally the qualified query result set is returned to the relational operator.
  • the SQL access object method of the present application is used to query the items.product belonging to x, y, z through the Filter items_filter where items.product_id in(x, y, z) only during the initial OML operation. data set. Then you can rely on the parent key of the parent node inherited in the relational data table to query the parent node information. According to this method, the entire object information can be queried, which greatly reduces the number of join operations.
  • the object storage unit 1104 returns to the SQL interface unit 1107 via the relational SQL access processing unit 1106.
  • the method for executing the SQL instruction is used to parse the identifier of the object in the SQL instruction to obtain the corresponding object schema and the relational data table, and the key value attribute of the object in the SQL instruction is used to generate the data corresponding to the object.
  • the index value, and the object data is obtained according to the index value, and the query condition in the parsing SQL instruction is used to query the attribute data from the object data.
  • the identifier of the object in the above SQL instruction, the key value attribute of the object, and the query condition are not the object class data, but the valid data such as variables and identifiers that can be passed and parsed by the standard SQL interface, and the above validated by the SQL command parsing.
  • the data of the data mapping object and the attribute data of the object implement the standard SQL access object.
  • the method of reading an object by the object interface unit 1101 includes:
  • S301 Receive a read request for an object, where the read request includes an identifier of the object and a key value attribute.
  • This step differs from S202 in that it is not necessary to remove the relational operator in the SQL operation, and the read request explicitly includes the mode name and the key value attribute.
  • the object interface unit 1101 parses the object's schema name and key value attribute into a unified form that the system can handle, and The processing is sent to the object access processing unit 1102.
  • This step is different from step S203 in that it is not necessary to query to obtain a relational data table.
  • step S204 This step is similar to step S204, and details are not described herein again.
  • This step is similar to S205, except that the query gets the data of the entire object, not the attribute data in the data of the object.
  • the object storage unit 1104 returns the data of the object to the object interface unit 1101 through the object access processing unit 1102.
  • the foregoing method and apparatus provided by the embodiments of the present application first solve the problem that a system using object storage cannot provide standard relational SQL access; the reason is that the device simultaneously provides an object interface and a SQL interface, and the object is Pattern and relational data tables enable objects to be stored in associations in the device. Not only do the object storage attributes with stored values of keys have relational attributes, they can provide standard relational SQL access in the system where the objects are stored. Secondly, through automatic conversion, it is possible to optimize and execute related technologies using relational SQL that is already very mature; the reason is that relational databases have many excellent features, which not only maintain data consistency, but also rely on standardization. Data update has a small overhead and can perform complex queries such as joins.
  • FIG. 9 shows a possible structural diagram of an apparatus for executing an SQL instruction involved in the above embodiment.
  • the apparatus 11 that executes the SQL instruction includes a processing module 1122 and a communication module 1123.
  • the processing module 1122 is configured to control and manage the action of the apparatus 11 that executes the SQL instruction.
  • the processing module 1122 is configured to support the apparatus 11 that executes the SQL instruction to execute the processes S101-S106 in FIG. 2, the process S201-S206 in FIG. , the process S301-S305 in FIG.
  • Communication module 1123 is used to support communication of devices executing SQL instructions with other entities.
  • the apparatus 11 executing the SQL instructions may further include a storage module 1121 for storing program codes and data of the apparatus that executes the SQL instructions.
  • the apparatus for executing the SQL instruction may be a device for executing the SQL instruction as described below.
  • the apparatus 11 for executing an SQL command includes a processor 1132, a network port 1133, a memory 1131, and a bus 1134.
  • the network port 1133, the processor 1132, and the memory 1131 are connected to each other through a bus 1134.
  • the bus 1134 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. Wait.
  • PCI Peripheral Component Interconnect
  • EISA Extended Industry Standard Architecture
  • Wait The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in the figure, but it does not mean that there is only one bus or one type of bus.
  • the size of the sequence numbers of the foregoing processes does not mean the order of execution sequence, and the order of execution of each process should be determined by its function and internal logic, and should not be applied to the embodiment of the present application.
  • the implementation process constitutes any limitation.
  • the disclosed systems, devices, and methods may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be electrical, mechanical or otherwise.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above embodiments it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • a software program it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer program instructions When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present application are generated in whole or in part.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
  • the computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be from a website site, computer, server or data center Transmission to another website site, computer, server, or data center by wire (eg, coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.).
  • the computer readable storage medium can be any available media that can be accessed by a computer or a data storage device that includes one or more servers, data centers, etc. that can be integrated with the media.
  • the usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (such as a Solid State Disk (SSD)) or the like.
  • a magnetic medium eg, a floppy disk, a hard disk, a magnetic tape
  • an optical medium eg, a DVD
  • a semiconductor medium such as a Solid State Disk (SSD)

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application discloses a method and a device for executing a structured query language (SQL) instruction, relating to the field of communications, used for supporting a standard SQL access object. The method comprises: receiving an SQL instruction, the SQL instruction being used for querying attribute data of an object from data of the object; parsing the SQL instruction to obtain the identifier of the object, the key value attribute of the object and a query condition; according to the identifier of the object and the mapping relationship between the identifier of the object and an object mode, obtaining the object mode and a relational data table corresponding to the object; according to the key value attribute of the object and the attribute for generating an index value defined in the object mode, determining the index value corresponding to the data of the object; and obtaining the data of the object according to the index value corresponding to the data of the object, and according to the query condition and the relational data table of the object, querying the data of the object to obtain attribute data. The embodiments of the present application can be applicable to object data access.

Description

执行结构化查询语言SQL指令的方法和装置Method and apparatus for executing structured query language SQL instructions
本申请要求于2017年7月20日提交中国专利局、申请号为201710598140.7、申请名称为“执行结构化查询语言SQL指令的方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese Patent Application filed on Jan. 20, 2017, filed on Jan. 20, 2017, filed Jan. In this application.
技术领域Technical field
本申请涉及通信领域,尤其涉及一种执行结构化查询语言(Structured Query Language,SQL)指令的方法和装置。The present application relates to the field of communications, and in particular, to a method and apparatus for executing a Structured Query Language (SQL) instruction.
背景技术Background technique
网络功能虚拟化(Network Function Virtualization,NFV)架构实现了业务数据与业务处理的分离,其中的业务数据采用分布式存储,而对象存储是分布式存储中主流的存储方式。Network Function Virtualization (NFV) architecture realizes the separation of business data and business processing. The business data is distributed storage, and object storage is the mainstream storage method in distributed storage.
常用的对象访问方式包括类SQL语言操作方式和对象关系映射(Object Relation Mapping,ORM)方式等。其中,类SQL语言也被称为对象查询语言(Object Query Language,OQL),其语句采用对象表达式的方式,并且功能上完全基于面向对象的实体查询。OQL由于是非标准SQL接口,使得基于标准SQL接口开发的应用无法使用,系统开放性不足。另外针对不同对象差别,需要开发不同OQL语言,难以实现功能迁移。并且在语法上,无法做到比SQL更简洁,无法实现复杂的查询。Commonly used object access methods include SQL-like language operations and Object Relation Mapping (ORM). Among them, the SQL-like language is also called Object Query Language (OQL), its statement adopts the method of object expression, and its function is completely based on object-oriented entity query. Because OQL is a non-standard SQL interface, applications developed based on standard SQL interfaces cannot be used, and system openness is insufficient. In addition, different OQL languages need to be developed for different object differences, and it is difficult to implement function migration. And in terms of grammar, it can't be more succinct than SQL, and can't implement complex queries.
发明内容Summary of the invention
本申请的实施例提供一种执行SQL指令的方法和装置,用于支持标准SQL访问对象。Embodiments of the present application provide a method and apparatus for executing SQL instructions for supporting standard SQL access objects.
为达到上述目的,本申请的实施例采用如下技术方案:To achieve the above objective, the embodiment of the present application adopts the following technical solutions:
第一方面,提供了一种执行结构化查询语言SQL指令的方法,该方法包括:接收一SQL指令,SQL指令用于从一对象的数据中查询对象的属性数据;解析SQL指令以得到对象的标识、对象的键值属性以及查询条件,对象的标识用于指示对象的类型,对象的键值属性用于生成索引值,索引值与对象的数据相对应,查询条件用于从对象的数据中查询属性数据;根据对象的标识,以及对象的标识与对象模式之间的映射关系,得到对象对应的对象模式和关系型数据表,对象模式用于定义一类对象的树形数据结构,树形数据结构包括至少一个第一节点,第一节点用于定义此类对象的属性中能够用于生成索引值的属性,关系型数据表是二维表,二维表按照对象模式中指示的节点关系存储对象的属性数据;根据对象的键值属性以及对象模式中定义的用于生成索引值的属性,确定对象的数据对应的索引值;根据对象的数据对应的索引值获得对象的数据,并根据查询条件和对象的关系型数据表,从对象的数据中查询得到属性数据。本申请实施例通过上述执行SQL指令的方法,解析SQL指令中的对象的标识用于获取对应的对象模式和关系型数据表,解析SQL指令中的对象的键值属性用于生成对象的数据对应的索引值,并根据索引值得到对象的数据,解析SQL指令中查询条件用于从对象的数据中查询得到对象的属性数据。上述SQL指令中的对象的标识、对象 的键值属性以及查询条件均不是对象类数据,而是标准的SQL指令可传递的变量、标识等有效数据,通过对该SQL指令解析得到的上述有效数据映射对象的数据及对象的属性数据,实现了支持标准SQL访问对象。In a first aspect, a method for executing a structured query language SQL instruction is provided, the method comprising: receiving a SQL instruction, the SQL instruction is used to query an attribute data of an object from an object data; and parsing the SQL instruction to obtain an object The identifier, the key value attribute of the object, and the query condition. The identifier of the object is used to indicate the type of the object, the key value attribute of the object is used to generate an index value, the index value corresponds to the data of the object, and the query condition is used in the data of the object. Query attribute data; according to the identifier of the object, and the mapping relationship between the object identifier and the object pattern, obtain the object pattern and the relational data table corresponding to the object, and the object pattern is used to define a tree data structure of a type of object, a tree shape The data structure includes at least one first node, the first node is used to define attributes of the attributes of such objects that can be used to generate index values, the relational data table is a two-dimensional table, and the two-dimensional table is in accordance with the node relationship indicated in the object pattern. Attribute data of the storage object; according to the key value attribute of the object and the attribute defined in the object pattern for generating the index value Determining an index value corresponding to the data object; the data object corresponding to the index value obtained data object, and query condition according to the object and relational data tables, a query attribute data obtained from the data object. In the embodiment of the present application, the method for executing the SQL instruction is used to parse the identifier of the object in the SQL instruction to obtain the corresponding object schema and the relational data table, and the key value attribute of the object in the SQL instruction is used to generate the data corresponding to the object. The index value, and the object data is obtained according to the index value, and the query condition in the parsing SQL instruction is used to query the attribute data of the object from the data of the object. The identifier of the object in the above SQL instruction, the key value attribute of the object, and the query condition are not the object class data, but the valid data such as variables and identifiers that can be passed by the standard SQL instruction, and the above valid data obtained by parsing the SQL instruction. The data of the mapping object and the attribute data of the object are implemented to support standard SQL access objects.
在一种可能的设计中,在接收一SQL指令之前,该方法还包括:定义对象的对象模式以及关系型数据表;接收针对对象的写请求,写请求中包括对象的标识和属性;根据写请求中的对象的标识,以及对象的标识与对象模式之间的映射关系,得到对象的对象模式和关系型数据表;根据对象的对象模式将写请求中属性转换为具有完整存储结构的对象,并根据对象模式中定义的用于生成索引值的属性将写请求中的属性构建为索引值,其中,具有完整存储结构的对象指按照对象模式的所有属性分配的存储空间所存储的对象,写请求中的属性存储在存储空间中;根据对象的关系型数据表将具有完整存储结构的对象转换为对象的数据,并将对象的数据按照索引值进行存储。该设计提供了通过对象接口存储对象的数据的方法。In a possible design, before receiving an SQL instruction, the method further includes: defining an object mode of the object and a relational data table; receiving a write request for the object, wherein the write request includes an identifier and an attribute of the object; The identifier of the object in the request, and the mapping relationship between the identifier of the object and the object pattern, obtaining the object schema and the relational data table of the object; converting the attribute in the write request into the object having the complete storage structure according to the object pattern of the object, And constructing an attribute in the write request as an index value according to an attribute for generating an index value defined in the object schema, wherein the object having the complete storage structure refers to an object stored in a storage space allocated according to all attributes of the object pattern, and writing The attributes in the request are stored in the storage space; the object with the complete storage structure is converted into the data of the object according to the relational data table of the object, and the data of the object is stored according to the index value. This design provides a way to store data for an object through an object interface.
在一种可能的设计中,该方法还包括:接收针对对象的读请求,读请求中包括对象的标识和键值属性;根据读请求中的对象的标识,以及对象的标识与对象模式之间的映射关系,得到对应的对象模式;根据对象的键值属性以及对象模式中定义的能够用于生成索引值的属性,确定对象的数据对应的索引值;根据索引值查询得到对象的数据。该设计提供了通过对象接口读取对象的数据的方法。In a possible design, the method further comprises: receiving a read request for the object, wherein the read request includes an identifier of the object and a key value attribute; according to the identifier of the object in the read request, and the identifier of the object and the object mode The mapping relationship is obtained, and the corresponding object pattern is obtained; according to the key value attribute of the object and the attribute that can be used to generate the index value defined in the object pattern, the index value corresponding to the data of the object is determined; and the data of the object is obtained according to the index value. This design provides a way to read the data of an object through the object interface.
在一种可能的设计中,对象的树形数据结构中包括至少一个父节点,父节点包括标识和域,其中,父节点的标识用于指示父节点对应对象所属种类,父节点的域用于包含子节点。该设计提供了一种对象的树形数据结构的构成方式。In a possible design, the tree data structure of the object includes at least one parent node, and the parent node includes an identifier and a domain, wherein the identifier of the parent node is used to indicate the category of the object corresponding to the parent node, and the domain of the parent node is used for Contains child nodes. This design provides a way to structure a tree's data structure.
在一种可能的设计中,关系型数据表的每个节点包括父表标识、根表标识和外键,父表标识用于指向子节点的父节点的二维表,根表标识用于指向树形数据结构的根节点的二维表,外键指向对象模式的主键。该设计提供了一种关系型数据表的构成方式。In one possible design, each node of the relational data table includes a parent table identifier, a root table identifier, and a foreign key, the parent table identifier is a two-dimensional table for the parent node of the child node, and the root table identifier is used to point A two-dimensional table of the root node of a tree-shaped data structure with a foreign key pointing to the primary key of the object schema. This design provides a way to structure a relational data table.
第二方面,提供了一种执行结构化查询语言SQL指令的装置,该装置包括:SQL接口单元、关系型SQL访问处理单元、对象关系型转换单元、元数据管理单元、对象存储单元,其中,SQL接口单元,用于接收一SQL指令,SQL指令用于从一对象的数据中查询对象的属性数据;关系型SQL访问处理单元,用于解析SQL接口单元接收的SQL指令以得到对象的标识、对象的键值属性以及查询条件,对象的标识用于指示对象的类型,对象的键值属性用于生成索引值,索引值与对象的数据相对应,查询条件用于从对象的数据中查询属性数据;对象关系型转换单元,用于根据关系型SQL访问处理单元得到的对象的标识,以及元数据管理单元所存储的对象的标识与对象模式之间的映射关系,得到对象对应的对象模式和关系型数据表,对象模式用于定义一类对象的树形数据结构,树形数据结构包括至少一个第一节点,第一节点用于定义此类对象的属性中能够用于生成索引值的属性,关系型数据表是二维表,二维表按照对象模式中指示的节点关系存储对象的属性数据;对象关系型转换单元,还用于根据对象的键值属性以及对象模式中定义的用于生成索引值的属性,确定对象的数据对应的索引值;对象关系型转换单元,还用于根据对象的数据对应的索引值获得对象的数据,并根据查询条件和对象的关系型数据表,从对象存储单元中所存储的对象的数据中查询得到属性数据。基于同一发明构思,由于该装置解决问题的原理以及有益效果可以 参见上述第一方面和第一方面的各可能的方法实施方式以及所带来的有益效果,因此该装置的实施可以参见上述第一方面和第一方面的各可能的方法的实施方式,重复之处不再赘述。A second aspect provides an apparatus for executing a structured query language SQL instruction, the apparatus comprising: a SQL interface unit, a relational SQL access processing unit, an object relational conversion unit, a metadata management unit, and an object storage unit, wherein The SQL interface unit is configured to receive an SQL instruction, and the SQL instruction is used to query the attribute data of the object from the data of the object; the relational SQL access processing unit is configured to parse the SQL instruction received by the SQL interface unit to obtain the identifier of the object, The key value attribute of the object and the query condition. The identifier of the object is used to indicate the type of the object. The key value attribute of the object is used to generate an index value. The index value corresponds to the data of the object, and the query condition is used to query the attribute from the data of the object. Data; an object-relational conversion unit, configured to obtain an object identifier corresponding to an object according to a relationship between an identifier of an object obtained by the relational SQL access processing unit and an identifier of the object stored by the metadata management unit, and an object mode corresponding to the object Relational data table, object schema is used to define the tree data structure of a class of objects, the number of trees The structure includes at least one first node, the first node is used to define attributes of the attributes of such objects that can be used to generate index values, the relational data table is a two-dimensional table, and the two-dimensional table is stored according to the node relationship indicated in the object pattern. The attribute data of the object; the object relational conversion unit is further configured to determine an index value corresponding to the data of the object according to the key value attribute of the object and the attribute for generating the index value defined in the object pattern; the object relation type conversion unit further The data of the object is obtained according to the index value corresponding to the data of the object, and the attribute data is obtained from the data of the object stored in the object storage unit according to the query condition and the relational data table of the object. Based on the same inventive concept, the principle and the beneficial effects of the device can be referred to the first aspect and the possible method embodiments of the first aspect and the beneficial effects. Therefore, the implementation of the device can be referred to the first The aspects and implementations of the various possible methods of the first aspect are not repeated here.
第三方面,提供了一种执行结构化查询语言SQL指令的装置,包括:处理器、存储器、总线和通信接口;存储器用于存储计算机执行指令,处理器与存储器通过总线连接,当其运行时,处理器执行存储器存储的计算机执行指令,以使其执行如第一方面及其任一种可能的设计的方法。A third aspect provides an apparatus for executing a structured query language SQL instruction, including: a processor, a memory, a bus, and a communication interface; the memory is configured to store a computer execution instruction, and the processor and the memory are connected through a bus when the system is running The processor executes the memory stored computer to execute the instructions to perform the method as in the first aspect and any of its possible designs.
第四方面,提供了一种计算机存储介质,包括指令,当其在计算机上运行时,使得计算机执行如第一方面及其任一种可能的设计的方法。In a fourth aspect, a computer storage medium is provided, comprising instructions that, when run on a computer, cause the computer to perform a method as in the first aspect and any of its possible designs.
第五方面,提供了一种包括指令的计算机程序产品,当其在计算机上运行时,使得该计算机执行如第一方面及其任一种可能的设计的方法。In a fifth aspect, there is provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform a method as in the first aspect and any of its possible designs.
需要说明的是,第三方面至第五方面所带来的技术效果可参见对应方法所带来的技术效果,此处不再赘述。It should be noted that the technical effects brought by the third aspect to the fifth aspect can be referred to the technical effects brought by the corresponding method, and details are not described herein again.
附图说明DRAWINGS
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings to be used in the embodiments or the prior art description will be briefly described below.
图1为本申请的实施例提供的一种执行SQL指令的装置的结构示意图;FIG. 1 is a schematic structural diagram of an apparatus for executing an SQL instruction according to an embodiment of the present application;
图2为本申请的实施例提供的通过对象接口单元写对象的方法的流程示意图;2 is a schematic flowchart of a method for writing an object by using an object interface unit according to an embodiment of the present application;
图3为本申请的实施例提供的对象模式的示意图;FIG. 3 is a schematic diagram of an object mode provided by an embodiment of the present application; FIG.
图4为本申请的实施例提供的对象存储结构的示意图;4 is a schematic diagram of an object storage structure provided by an embodiment of the present application;
图5为本申请的实施例提供的通过SQL接口单元执行SQL指令的方法的流程示意图;FIG. 5 is a schematic flowchart of a method for executing an SQL instruction by using an SQL interface unit according to an embodiment of the present application;
图6为本申请的实施例提供的普通SQL查询操作需要进行结合操作的示意图;FIG. 6 is a schematic diagram of a common SQL query operation required to perform a combined operation according to an embodiment of the present application;
图7为本申请的实施例提供的执行SQL指令的方法减少结合操作的示意图;FIG. 7 is a schematic diagram of a method for executing an SQL instruction according to an embodiment of the present application to reduce a combined operation;
图8为本申请的实施例提供的通过对象接口单元读对象的方法的流程示意图;FIG. 8 is a schematic flowchart of a method for reading an object by using an object interface unit according to an embodiment of the present application;
图9为本申请的实施例提供的另一种执行SQL指令的装置的结构示意图;FIG. 9 is a schematic structural diagram of another apparatus for executing an SQL instruction according to an embodiment of the present application;
图10为本申请的实施例提供的又一种执行SQL指令的装置的结构示意图。FIG. 10 is a schematic structural diagram of another apparatus for executing an SQL instruction according to an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。The technical solutions in the embodiments of the present application will be clearly and completely described in the following with reference to the accompanying drawings in the embodiments.
本申请实施例所述的一类对象是指具有共同数据结构以及属性数据的抽象描述。不同类对象的数据结构或属性数据是不同的,例如描述科学家对象、顾客对象的属性数据不同,对于科学家对象来说,可以描述其年龄、工龄、所属机构、等;而对于顾客对象来说,可以描述其年龄、联系方式、住址、采购历史记录等,因此科学家对象和顾客对象属于不同类的对象。属性数据是为方便区分不同对象而限定其属性的数据,可以从一类对象的角度来描述或者针对一具体对象的数据来描述。例如对于科学家这类对象来说,年龄、工龄、所属机构等即为其属性数据,而对于存储具体的一个科学家对象来说,年龄=30、工龄=5、所属机构=“中科院”即为其属性数据。本申请实施例以顾客为对象进行描述,可以理解其并不意在限定具体对象类型。A class of objects described in the embodiments of the present application refers to an abstract description having a common data structure and attribute data. The data structure or attribute data of different types of objects are different. For example, the attribute data describing the scientist object and the customer object are different. For the scientist object, the age, the working age, the affiliation, and the like can be described; and for the customer object, The age, contact information, address, purchase history, etc. can be described, so the scientist object and the customer object belong to different classes of objects. Attribute data is data that defines its attributes for the convenience of distinguishing between different objects. It can be described from the perspective of a class of objects or for the data of a specific object. For example, for an object such as a scientist, age, length of service, affiliated institution, etc. is its attribute data, and for a specific scientist object, age=30, length of service=5, affiliated institution=“Chinese Academy of Sciences” Attribute data. The embodiment of the present application is described by the customer, and it can be understood that it is not intended to limit the specific object type.
本申请实施例提供了一种执行SQL指令的装置,使得数据以对象为单位进行存储,支持高效的对象访问接口以及基于对象的分布式存储,同时,该装置也支持标准的SQL接口访问。参照图1中所示,该装置11包括:对象接口单元1101、对象访问处理单元1102、元数据管理单元1103、对象存储单元1104、对象关系型转换单元1105、关系型SQL访问处理单元1106、SQL接口单元1107。上述各单元可以采用相同或不同的进程或线程来执行对应功能,本申请实施例在此不作限定。The embodiment of the present application provides an apparatus for executing an SQL instruction, so that data is stored in units of objects, supports an efficient object access interface, and object-based distributed storage, and the device also supports standard SQL interface access. Referring to FIG. 1, the apparatus 11 includes: an object interface unit 1101, an object access processing unit 1102, a metadata management unit 1103, an object storage unit 1104, an object relation type conversion unit 1105, a relational SQL access processing unit 1106, and SQL. Interface unit 1107. The above-mentioned units may use the same or different processes or threads to perform the corresponding functions, and the embodiments of the present application are not limited herein.
本申请实施例提供的各方法,可以通过存储器中的程序代码来实现,或者由路由器、服务器上的芯片来实现,或者由模拟器实现。还可以固化在芯片中得以实现,如现场可编程门阵列(Field-Programmable Gate Array,FPGA)、数字信号处理(DSP,Digital Signal Processing)中实现,或者由软件在异构加速硬件如张量处理单元(Tensor Processing Unit,TPU)、图形处理器(Graphics Processing Unit,GPU)上实现,或者由软件在中央处理器(Central Processing Unit,CPU)上实现,或者由软件/硬件模拟器实现。The methods provided by the embodiments of the present application may be implemented by program code in a memory, or by a chip on a router or a server, or by a simulator. It can also be implemented in a chip, such as Field-Programmable Gate Array (FPGA), Digital Signal Processing (DSP), or by software in heterogeneous acceleration hardware such as tensor processing. Implemented on a Tensor Processing Unit (TPU), a Graphics Processing Unit (GPU), or implemented by software on a Central Processing Unit (CPU), or by a software/hardware simulator.
对象接口单元1101提供了应用场景中不同形式对象的收发功能。不同形式的对象包括但不限于Java脚本目标表示法(JavaScript Object Notation,JSON)表示的对象、可扩展标记语言(Extensible Mark-up Language,XML)表示的对象,其与应用场景的实际需求相关,是一套非标准的接口。对象接口单元1101同时具有预先定义对象模式(Schema)、关系型数据表(对象关系模式)的功能。本文所述的对象模式是对一类对象具有的共同数据结构以及属性数据的抽象描述,包括域(Field)节点和键值(Keys)节点,域(Field)节点描述对象的属性数据,键值(Keys)节点描述查找对象的索引,Keys节点中索引键中的属性必须来自域节点。关系型数据表描述了该类对象中不同节点间的关联关系以及约束条件等,这两种模式在本文可以统称为对象的模式。对象模式和关系型数据表同样能够用多种方式定义,如JSON、XML等。只有在对象接口单元1101中定义的对象的数据才能够被解析处理。本装置中具有完整结构的对象包括某一具体对象的数据和该类对象的模式(对象模式和关系型数据表),对象的数据是唯一的,对象的模式对于一类对象可以共享。The object interface unit 1101 provides a transceiving function of different forms of objects in an application scenario. Different forms of objects include, but are not limited to, objects represented by Java Object Notation (JSON), objects represented by Extensible Mark-up Language (XML), which are related to the actual needs of the application scenario. Is a non-standard interface. The object interface unit 1101 has a function of predefining an object schema (Schema) and a relational data table (object relational schema). The object schema described in this paper is an abstract description of the common data structure and attribute data that a class of objects has, including the Field node and the Keys node. The Field node describes the attribute data of the object, and the key value. The (Keys) node describes the index of the lookup object. The attributes in the index key in the Keys node must come from the domain node. The relational data table describes the associations and constraints between different nodes in the class. These two modes can be collectively referred to as object patterns in this paper. Object schemas and relational data tables can also be defined in a variety of ways, such as JSON, XML, and so on. Only the data of the object defined in the object interface unit 1101 can be parsed. The object with complete structure in the device includes the data of a specific object and the mode of the object (object mode and relational data table), the data of the object is unique, and the mode of the object can be shared for a class of objects.
对象访问处理单元1102提供了非标准对象表示形式的标准化转换功能,使之成为系统可处理的对象,并通过元数据管理单元1103提供的对象模式和关系型数据表对对象信息加工处理,使对象的数据按照约定的方式存储在对象存储单元1104中。其中,对象模式用于匹配对象的属性数据,以及用于根据对象模式中键值Keys的定义以及对象的属性数据,得到相应的索引键。关系型数据表通过对父子节点的关联关系进行处理,既能指导对象的数据在对象存储单元1104中保存,也为关系型SQL操作提供支持和优化。The object access processing unit 1102 provides a standardized conversion function of the non-standard object representation, making it an object that can be processed by the system, and processing the object information by the object mode and the relational data table provided by the metadata management unit 1103, so that the object The data is stored in the object storage unit 1104 in an agreed manner. The object mode is used to match the attribute data of the object, and is used to obtain a corresponding index key according to the definition of the key value Keys in the object mode and the attribute data of the object. The relational data table processes the association relationship between the parent and child nodes, and can not only guide the data of the object to be saved in the object storage unit 1104, but also provide support and optimization for the relational SQL operation.
元数据管理单元1103管理着对象模式和关系型数据表。对象访问处理单元1102对对象的变换分解,依赖的就是元数据管理单元1103中的对象模式和关系型数据表。The metadata management unit 1103 manages the object schema and the relational data table. The object access processing unit 1102 decomposes the transformation of the object, relying on the object schema and the relational data table in the metadata management unit 1103.
对象存储单元1104提供了根据模式转换后的对象的数据,是对象的数据序列化后的结果。The object storage unit 1104 provides data of the object converted according to the mode, and is a result of serialization of the data of the object.
对象关系型转换单元1105负责关系型数据与对象型数据之间的转换,依赖于元数据管理单元1103中的对象模式和关系型数据表。对象关系型转换单元1105是本装置 提供标准SQL访问的枢纽。The object relation type conversion unit 1105 is responsible for the conversion between the relational data and the object type data, and depends on the object mode and the relational data table in the metadata management unit 1103. The object-relational conversion unit 1105 is a hub for the device to provide standard SQL access.
关系型SQL访问处理单元1106负责解析优化SQL查询语言。The relational SQL access processing unit 1106 is responsible for parsing the optimized SQL query language.
SQL接口单元1107提供了SQL查询语言的接受以及结果数据的返回。The SQL interface unit 1107 provides acceptance of the SQL query language and return of the result data.
参照图2中所示,通过对象接口单元1101写对象的方法包括:Referring to FIG. 2, the method of writing an object by the object interface unit 1101 includes:
S101、定义对象的对象模式以及关系型数据表。S101. Define an object mode of the object and a relational data table.
可以通过调用对象接口单元1101的相应函数定义对象的对象模式以及关系型数据表。并将结果存储至元数据管理单元1103。The object schema of the object and the relational data table can be defined by calling the corresponding function of the object interface unit 1101. The result is stored in the metadata management unit 1103.
对象模式用于定义一类对象的树形数据结构,树形数据结构包括至少一个节点,该节点用于定义此类对象的属性中能够用于生成索引值的属性,关系型数据表是二维表,二维表按照对象模式中指示的节点关系存储对象的属性数据。The object schema is used to define a tree data structure of a class of objects. The tree data structure includes at least one node, which is used to define attributes of such objects that can be used to generate index values, and the relational data table is two-dimensional. The table, the two-dimensional table stores the attribute data of the object according to the node relationship indicated in the object schema.
参照图3中所示,左图为消费者(Customers)对象的一种示例,右图为模式名称为“消费者”的JSON形式的对象模式的示例。Referring to FIG. 3, the left image is an example of a consumer object, and the right image is an example of an object mode in the form of a JSON whose mode name is "consumer".
一个消费者可以没有下订单或者有多个订单,每一个订单至少包括一件商品,即消费者对象包含订单对象,订单对象包含商品对象。因此形成的树形的对象模式中,消费者对象为根节点,订单对象作为消费者对象的叶子节点,商品对象作为订单对象的叶子节点。在本申请实施例中,消费者、订单、商品不再是单独的对象,他们根据嵌套关系作为父子节点共同组成一个具有根节点的树形的对象模式。A consumer may have no order or multiple orders, and each order includes at least one item, that is, the consumer object contains the order object, and the order object contains the item object. Therefore, in the tree-shaped object pattern formed, the consumer object is the root node, the order object is the leaf node of the consumer object, and the commodity object is the leaf node of the order object. In the embodiment of the present application, the consumer, the order, and the commodity are no longer separate objects, and they form a tree-shaped object pattern having a root node according to the nested relationship as a parent node.
在关系数据库中,索引是按照唯一的数值对数据库表中一列或多列的值进行排序的一种存储结构,其可以是表中一列或若干列数值的集合以及指向表中标识这些数值的页表的逻辑指针清单。索引的作用相当于图书的目录,可以根据目录中的页码快速找到所需的内容。传统的基于键值对的数据库,键与值是一一对应的,这在一定程度上限制了对对象的数据进行多样化的查询,因此,我们通过对象模式为对象提供了多样化的键,增强数据的可操作性,为查询优化提供支撑。In a relational database, an index is a storage structure that sorts the values of one or more columns in a database table by a unique value, which can be a collection of values in one or more columns of the table and a page pointing to the values in the table. A list of logical pointers to the table. The role of the index is equivalent to the directory of the book, you can quickly find the content you need based on the page number in the directory. In the traditional database of key-value pairs, the key and the value are in one-to-one correspondence, which limits the diversification of the data of the object to a certain extent. Therefore, we provide a variety of keys for the object through the object mode. Enhance data operability and provide support for query optimization.
对象模式是相互嵌套的节点构成的树形数据结构,相互关联的子对象对应于树形数据结构的各个节点,该树形数据结构包括至少一个父节点,在根节点里描述了对象模式的表示方式(即模式名称)。每一个节点都可以包括标识名称(name)、类型(type)、域(fields)三种属性,其中标识名称(name)和类型(type)为必要属性,标识名称用于指示该节点对应对象所属种类,例如消费者、商品订单号等;类型(type)用于指示该节点的数据类型,例如整型、记录等。域(fields)只在一对多的父子节点中的父节点里出现,类似于数组的形式,父节点的域(fields)用于包含子节点(即子节点嵌套在父节点的域(fields)中)。The object mode is a tree data structure composed of nodes nested with each other, and the associated sub-objects correspond to respective nodes of the tree data structure, the tree data structure includes at least one parent node, and the object mode is described in the root node. Representation (that is, the schema name). Each node may include three attributes: a name, a type, and a field. The name and type are required attributes, and the identifier is used to indicate that the corresponding object belongs to the node. Kind, such as consumer, merchandise order number, etc.; type is used to indicate the data type of the node, such as integer, record, and the like. Fields appear only in the parent node of a one-to-many parent child node, similar to the form of an array. The fields of the parent node are used to contain child nodes (that is, the child nodes are nested in the parent node's domain (fields). )in).
树形数据结构的根节点中还包括键值(keys),键值中可以定义多个索引键,但有且仅有一个主键(primary key),该主键用于唯一地标识该对象,每个索引键可以由同一节点中的单个或多个域组成。主键指向对象的存储位置,非主键的索引键指向主键。The root node of the tree data structure also includes keys, and multiple index keys can be defined in the key value, but there is only one primary key, which is used to uniquely identify the object, each Index keys can consist of single or multiple domains in the same node. The primary key points to the storage location of the object, and the index key of the non-primary key points to the primary key.
图3中的键值示例只包括一个主键,还可以根据业务的实际需要,建立其他的索引键,其功能类似于关系型数据库中的索引,合理数量的索引键对于查询优化是有益的。The key value example in Figure 3 only includes one primary key. It can also create other index keys according to the actual needs of the business. Its function is similar to the index in the relational database. A reasonable number of index keys are beneficial for query optimization.
当定义了对象的对象模式后,元数据管理单元1103会根据对象模式以及用户输入 的相关信息自动生成关系型数据表。关系型数据表与对象模式是对应的,关系型数据表能够由对象模式自动推导得到。关系型数据表本质上是将对象模式中的每个对象节点分解为一个二维表,在子节点对应的二维表中包括父表标识、根表标识和外键,父表标识用于指向子节点的父节点的二维表,根表标识用于指向树形数据结构的根节点的二维表,外键指向对象模式的主键(primary key)。通过继承父表和根表的标识字段以及创建依赖关系(例如外键)来实现对象内节点的关系维护。关系型数据表示例如下:When the object mode of the object is defined, the metadata management unit 1103 automatically generates a relational data table based on the object mode and related information input by the user. The relational data table corresponds to the object pattern, and the relational data table can be automatically derived from the object pattern. The relational data table essentially decomposes each object node in the object schema into a two-dimensional table, including the parent table identifier, the root table identifier, and the foreign key in the two-dimensional table corresponding to the child node, and the parent table identifier is used to point A two-dimensional table of the child nodes of the child nodes, the root table identifies a two-dimensional table that points to the root node of the tree data structure, and the foreign key points to the primary key of the object schema. Relationship maintenance of nodes within an object is achieved by inheriting the identity fields of the parent and root tables and creating dependencies (such as foreign keys). Relational data representations such as the following:
Figure PCTCN2018083411-appb-000001
Figure PCTCN2018083411-appb-000001
每个节点消费者(customers)、订单(orders)、商品(items)都分解为一个二维表。根据键值(keys)中定义的,消费者(customers)中的ID(customers.id)是根表主键(primary key),也是其自身主键。订单(orders)是消费者(customers)的子节点,继承根表(root_field integer inherit)主键customers.id,继承父表(parent_field integer inherit)主键customers.id,外键依赖(FOREIGN KEY)customers.id。商品(items)是订单(orders)的子节点,继承根表主键customers.id,继承父表主键oders.id,同样外键依赖customers.id。其他内容是各个节点的属性。Each node customer, orders, and items are broken down into a two-dimensional table. According to the definitions in the keys, the ID (customers.id) in the customer is the primary key of the root table and its own primary key. Orders are child nodes of the customer, inherit the root table (root_field integer inherit) primary key customers.id, inherit the parent table (parent_field integer inherit) primary key customers.id, foreign key dependencies (FOREIGN KEY) customers.id . The items are the children of the orders, inherit the root table's primary key customers.id, inherit the parent table's primary key oders.id, and the foreign keys depend on the customers.id. The other content is the attribute of each node.
从中可以看出,关系型数据表使得对象内每个节点生成一个表,节点间的关系通过子节点(表)继承父节点(表)和根节点(表)的标识字段体现,并创建依赖关系外键保证关系强依赖;对象模式键值里定义了索引键的属性,且支持一个对象拥有多个索引键。另外可以在关系型数据表中附加信息对查询访问做优化,提升查询性能。It can be seen that the relational data table causes each node in the object to generate a table, and the relationship between the nodes is embodied by the child nodes (tables) inheriting the identification fields of the parent node (table) and the root node (table), and creating a dependency relationship. The foreign key guarantees strong dependency; the object mode key defines the attribute of the index key, and supports one object with multiple index keys. In addition, additional information can be added to the relational data table to optimize query access and improve query performance.
定义完成后,可以在元数据管理单元1103中存储所有对象的对象模式和关系型数据表。After the definition is completed, the object schema and the relational data table of all objects can be stored in the metadata management unit 1103.
S102、接收针对对象的写请求,写请求中包括对象的标识和属性。S102. Receive a write request for an object, where the write request includes an identifier and an attribute of the object.
具体的,通过对象接口单元1101来接收。由于写请求中的数据表示方式可能是JSON格式也可能是XML格式等等,因此对象接口单元1101会解析对象obj的标识和键值属性为系统能够处理的统一形式,并发送给对象访问处理单元1102处理。Specifically, it is received by the object interface unit 1101. Since the data representation in the write request may be JSON format or XML format, etc., the object interface unit 1101 parses the identifier and key value attribute of the object obj into a unified form that the system can process, and sends it to the object access processing unit. 1102 processing.
对象的标识用于指示该对象的类型。示例性的,参照图4中所示,(1)中的“消费者(customer)”为对象的标识,(1)中其他内容为对象的键值属性。The identity of the object is used to indicate the type of the object. Exemplarily, referring to FIG. 4, "customer" in (1) is the identifier of the object, and the other content in (1) is the key value attribute of the object.
S103、根据写请求中的对象的标识,以及对象的标识与对象模式之间的映射关系,得到对象的对象模式和关系型数据表。S103. Obtain an object mode and a relational data table of the object according to the identifier of the object in the write request, and the mapping relationship between the identifier of the object and the object mode.
示例性的,对象访问处理单元1102根据图4中所示的模式名称“消费者(customer)”,从元数据管理单元1103中可以查询得到图2中所示的名称(name)为“消费者”的对象模式以及对应的关系型数据表。Exemplarily, the object access processing unit 1102 can query the metadata management unit 1103 to obtain the name (name) shown in FIG. 2 as "consumer" according to the mode name "customer" shown in FIG. The object mode and the corresponding relational data table.
S104、根据该对象的对象模式将写请求中属性转换为具有完整存储结构的对象,并根据对象模式中定义的用于生成索引值的属性将写请求中的属性构建为索引值,其中,具有完整存储结构的对象指按照对象模式的所有属性分配的存储空间中所存储的对象,写请求中的属性存储在存储空间中。S104. Convert an attribute in the write request to an object having a complete storage structure according to an object mode of the object, and construct an attribute in the write request as an index value according to an attribute defined in the object pattern for generating an index value, where An object of a complete storage structure refers to an object stored in a storage space allocated according to all attributes of the object mode, and attributes in the write request are stored in the storage space.
具体的,对象访问处理单元1102根据对象的对象模式将属性数据封装为对象模式的完整存储结构的对象,是指开辟的存储空间的大小为整个对象模式的大小,对于接收的对象的写请求中包括的属性数据则按照对象模式填入该存储空间中,对于接收的对象的写请求中不包括的属性数据则赋空值(NULL)。示例性的,参照图4中所示,(1)中接收的对象的属性数据中不包括生日(birthday),则在(2)中完整结构的对象中令生日(birthday)为空值(NULL)。Specifically, the object access processing unit 1102 encapsulates the attribute data into an object of the complete storage structure of the object pattern according to the object mode of the object, and refers to the size of the opened storage space as the size of the entire object mode, and the write request for the received object. The included attribute data is filled in the storage space according to the object mode, and the attribute data not included in the write request of the received object is null (NULL). Exemplarily, referring to FIG. 4, if the attribute data of the object received in (1) does not include birthday, the birthday is null in the object of the complete structure in (2) (NULL ).
根据属性数据以及对象模式中的键值的定义构建索引值,是指图2中所示键值中的一个主键是消费者ID,因此,将图4中接收的对象的属性数据中的消费者ID(Customer.id)2计算哈希值作为索引值(第一键值)。这样进行查询时,根据第一键值即可以查询得到该对象。Constructing an index value according to the attribute data and the definition of the key value in the object schema means that one of the key values shown in FIG. 2 is a consumer ID, and therefore, the consumer in the attribute data of the object received in FIG. ID (Customer.id) 2 calculates a hash value as an index value (first key value). When the query is performed in this way, the object can be queried according to the first key value.
需要说明的是,虽然图中仅列出一个键值,本申请实施例并不限定键值的数目和索引关系,例如可以是第一键值是主键,第二键值是间接键,通过第二键值可以索引第一键值等等。It should be noted that, although only one key value is listed in the figure, the embodiment of the present application does not limit the number of key values and the index relationship, for example, the first key value is a primary key, and the second key value is an indirect key. The second key value can index the first key value and so on.
S105、根据对象的关系型数据表将具有完整存储结构的对象转换为对象的数据,并将对象的数据按照所述索引值进行存储。S105. Convert an object having a complete storage structure into data of the object according to the relational data table of the object, and store the data of the object according to the index value.
具体的,对象访问处理单元1102将上述数据存储至对象存储单元1104。Specifically, the object access processing unit 1102 stores the above data to the object storage unit 1104.
示例性的,参照图4中所示,(3)即是将(2)中具有完整存储结构的对象按照关系型数据表进行拆分后,得到的对象的数据,从中可以看出,各个节点单独存储, 节点间父子关系通过一对双向指针Ptr来维护。Exemplarily, referring to FIG. 4, (3) is the data of the object obtained by splitting the object having the complete storage structure in (2) according to the relational data table, from which it can be seen that each node Separate storage, parent-child relationship between nodes is maintained by a pair of bidirectional pointers Ptr.
S106、反馈写入状态标识。S106. The feedback write status identifier.
具体的,由对象存储单元1104通过对象访问处理单元1102向对象接口单元1101反馈写入状态标识,该标识用于指示是否写入成功。Specifically, the object storage unit 1104 feeds back the write status identifier to the object interface unit 1101 through the object access processing unit 1102, and the identifier is used to indicate whether the write is successful.
参照图5中所示,通过SQL接口单元1107执行SQL指令的方法包括:Referring to FIG. 5, the method of executing the SQL instruction by the SQL interface unit 1107 includes:
S201、接收一SQL指令,该SQL指令用于从一对象的数据中查询该对象的属性数据。S201. Receive an SQL instruction, where the SQL instruction is used to query attribute data of the object from data of an object.
具体的,本步骤可以通过SQL接口单元1107接收针对对象的标准SQL操作。例如,该SQL操作可以为SQL查询操作,用于查询对应的对象中的属性数据。例如查询items.product_id=1的对象的SQL查询语句可以写成“select*from customers where items.product_id=1;”,其从SQL的结果集中获取到的是customers为根节点的符合查询条件的所有属性;或者也可以写成“select*from customers.items where product_id=1;”,其从SQL的结果集中获取到的是items为根节点的符合查询条件的所有属性。Specifically, this step can receive standard SQL operations for the object through the SQL interface unit 1107. For example, the SQL operation can be an SQL query operation for querying attribute data in a corresponding object. For example, the SQL query statement of the object querying items.product_id=1 can be written as "select*from customers where items.product_id=1;", which obtains all the attributes of the root node that satisfy the query condition from the result set of the SQL. Or can be written as "select*from customers.items where product_id=1;", which gets all the attributes of the root node that match the query condition from the SQL result set.
S202、解析该SQL指令以得到待查询对象的标识、该对象的键值属性以及查询条件,对象的标识用于指示该对象的类型,对象的键值属性用于生成索引值,索引值与存储的该对象的数据相对应,查询条件用于从对象的数据中查询对应的属性数据。S202. Parse the SQL instruction to obtain an identifier of the object to be queried, a key value attribute of the object, and a query condition. The identifier of the object is used to indicate the type of the object, and the key value attribute of the object is used to generate an index value, the index value and the storage. The data of the object corresponds to the query condition for querying the corresponding attribute data from the data of the object.
对象的标识用于查询该对象的二维表信息,能够映射到唯一的对象模式。键值属性是指能够依据所映射到的对象模式中定义此类对象的属性中能够用于生成所述索引值的属性,通过哈希计算得到键值(索引值)的属性。例如,假设一个对象拥有名称为F0~F9的十个属性,在对象的对象模式里键值(Keys)中定义了Key1和Key2两个索引,其中Key1为主键,Key2为二级索引,Key2指向Key1的值。Key1由该对象的属性F0与F1的值计算哈希得到,Key2由该对象的属性F2与F3的值计算哈希得到。则F0、F1、F2、F3为该对象的键值属性,其他属性F4~F9为非键值属性。在读取对象的时候,可以依据对象模式里键值的定义,只要传入F0和F1的值就可以构造出Key1,或者只要传入F2和F3的值就可以构造出Key2,从而得到对象存储的位置。查询条件包括除键值属性之外的其他属性条件。The object's identity is used to query the object's two-dimensional table information and can be mapped to a unique object pattern. The key-value attribute refers to an attribute that can be used to generate the index value according to the attribute in which the object is defined in the mapped object pattern, and the key value (index value) is obtained by hash calculation. For example, suppose an object has ten attributes named F0~F9. In the object mode of the object, key indexes (Keys) define two indexes, Key1 and Key2, where Key1 is the primary key, Key2 is the secondary index, and Key2 points. The value of Key1. Key1 is obtained by hashing the values of the objects F0 and F1 of the object, and Key2 is obtained by hashing the values of the attributes F2 and F3 of the object. Then F0, F1, F2, and F3 are the key value attributes of the object, and other attributes F4 to F9 are non-key value attributes. When reading an object, you can construct Key1 by passing the values of F0 and F1 according to the definition of the key values in the object mode, or you can construct Key2 by passing in the values of F2 and F3, thus obtaining object storage. s position. The query condition includes other attribute conditions than the key value attribute.
假设用户传入“select*from customers.items where product_id=1 and price>30;”的SQL查询语句,SQL接口单元1107接收到该SQL查询操作后传递给关系型SQL查询访问处理单元1106。关系型SQL访问处理单元1106分析该SQL操作识别出关系算子select、from、where,并识别出除了关系算子以外的有效数据(节点信息customers.items、键值属性product_id=1以及查询条件price>30),将其发送给对象关系型转换单元1105。Assume that the user passes the SQL query statement of "select*from customers.items where product_id=1 and price>30;", and the SQL interface unit 1107 receives the SQL query operation and passes it to the relational SQL query access processing unit 1106. The relational SQL access processing unit 1106 analyzes the SQL operation to identify the relationship operators select, from, where, and identifies valid data other than the relationship operator (node information customers.items, key attribute product_id=1, and query condition price) >30), it is sent to the object-relational conversion unit 1105.
S203、根据所述对象的标识,以及对象的标识与对象模式之间的映射关系,得到该对象对应的对象模式和关系型数据表,。S203. Obtain an object mode and a relational data table corresponding to the object according to the identifier of the object and the mapping relationship between the identifier of the object and the object mode.
具体的,对象关系型转换单元1105根据对象的标识映射到模式名称customers,然后从元数据管理单元1103查找得到对应的对象模式和关系型数据表。Specifically, the object-relational conversion unit 1105 maps to the mode name customers according to the identifier of the object, and then searches for the corresponding object schema and the relational data table from the metadata management unit 1103.
S204、根据对象的键值属性以及对象模式中定义的用于生成索引值的属性,确定对象的数据对应的索引值。S204. Determine an index value corresponding to the data of the object according to the key value attribute of the object and the attribute used to generate the index value defined in the object mode.
示例性的,对象关系型转换单元1105通过有效数据中的customers.items查找对象 模式中的对应节点,将product_id作为该节点中的键值属性。Illustratively, the object-relational conversion unit 1105 looks up the corresponding node in the object schema by customers.items in the valid data, and uses product_id as the key-value attribute in the node.
例如,键值的定义可以为对product_id进行某种哈希运算后得到索引值。For example, the key value can be defined by some sort of hashing of the product_id to get the index value.
S205、根据对象的数据对应的索引值获得对象的数据,并根据查询条件和对象的关系型数据表,从对象的数据中查询得到属性数据。S205. Obtain data of the object according to an index value corresponding to the data of the object, and query the attribute data from the data of the object according to the query condition and the relational data table of the object.
对象关系型转换单元1105同时会根据SQL的操作,生成执行计划,如果键值属性包括的属性product_id是键值属性,并且能构造出索引值,则对象关系型转换单元1105可以直接通过该索引值从对象存储单元1104索引出相应的对象。The object-relational conversion unit 1105 simultaneously generates an execution plan according to the operation of the SQL. If the attribute product_id included in the key-value attribute is a key-value attribute, and the index value can be constructed, the object-relational conversion unit 1105 can directly pass the index value. The corresponding object is indexed from the object storage unit 1104.
需要说明的是,如果product_id是非键值属性,对象关系型转换单元1105会遍历全部对象查询得到对应的对象。It should be noted that if the product_id is a non-key value attribute, the object relational type conversion unit 1105 traverses all the object queries to obtain a corresponding object.
通过SQL访问对象时,根据关系型数据表对对象的数据进行SQL解析和优化,当关系算子需要访问到对象时,对象关系型转换单元1105根据关系算子将优化后对象的数据转换为关系型数据并通过关系型SQL访问处理单元1106和SQL接口单元1107返回至请求发起的位置,关系算子无需修改即可进行处理。例如当SQL操作为SQL查询操作时,要查询购买了某个product_id的客户、订单id和订单时间,传统的SQL查询操作为:When the object is accessed through SQL, the data of the object is parsed and optimized according to the relational data table. When the relational operator needs to access the object, the object-relational conversion unit 1105 converts the data of the optimized object into a relationship according to the relational operator. The type data is returned to the location where the request is initiated by the relational SQL access processing unit 1106 and the SQL interface unit 1107, and the relationship operator can be processed without modification. For example, when the SQL operation is a SQL query operation, to query the customer, order id, and order time for which a certain product_id is purchased, the traditional SQL query operation is:
Select customers.name,orders.id,orders.order_date from customers,orders,items where customers.id=orders.customer_id and orders.order_id=items.order_id and items.product_id in(x,y,z);其中,x,y,z指具体product_id取值。Select customers.name, orders.id, orders.order_date from customers, orders, items where customers.id=orders.customer_id and orders.order_id=items.order_id and items.product_id in(x,y,z);where,x , y, z refers to the specific product_id value.
该操作在对象内进行面向对象语言(Object-Oriented Language,OML)操作如图6所示。从中可以看出,依据查询条件,会在商品(items)表中通过Filter items_filter where items.product_id in(x,y,z)查询出items.product属于x,y,z的数据集;在订单(orders)表中通过Filter order_filter where orders_id=items.order_id查询出orders.id=items.order_id的数据集;在消费者(custormers)表中通过Filter customer_filter where customer.id=orders.customer_id查询出所有customer.id=orders.customer_id的数据集。然后会将这三组数据集按照SQL查询的顺序两两执行结合(join)操作,最后将符合条件的查询结果集返回给关系算子。This operation performs an Object-Oriented Language (OML) operation within the object as shown in FIG. 6. It can be seen that, according to the query conditions, the data items of items.product belonging to x, y, z are queried in the items table by Filter items_filter where items.product_id in(x, y, z); In the orders table, the data set of orders.id=items.order_id is queried by Filter order_filter where orders_id=items.order_id; all customers are queried in the consumer (custormers) table by Filter customer_filter where customer.id=orders.customer_id. The data set of id=orders.customer_id. Then the three sets of data sets are joined in the order of the SQL query, and finally the qualified query result set is returned to the relational operator.
参照图7中所示,采用本申请的SQL访问对象方法,只在初始OML操作时,通过Filter items_filter where items.product_id in(x,y,z)查询出items.product属于x,y,z的数据集。然后就可以依赖其关系型数据表内继承的父节点的主键查询出父节点信息。按照这个方法递进,就可以将整个对象信息查询出来,大大减少了结合(join)操作的次数。Referring to FIG. 7, the SQL access object method of the present application is used to query the items.product belonging to x, y, z through the Filter items_filter where items.product_id in(x, y, z) only during the initial OML operation. data set. Then you can rely on the parent key of the parent node inherited in the relational data table to query the parent node information. According to this method, the entire object information can be queried, which greatly reduces the number of join operations.
S206、以符合SQL标准的结果集形式返回SQL查询结果。S206. Return the SQL query result in the form of a result set conforming to the SQL standard.
由对象存储单元1104通过关系型SQL访问处理单元1106返回给SQL接口单元1107。The object storage unit 1104 returns to the SQL interface unit 1107 via the relational SQL access processing unit 1106.
本申请实施例通过上述执行SQL指令的方法,解析SQL指令中的对象的标识用于获取对应的对象模式和关系型数据表,解析SQL指令中的对象的键值属性用于生成对象的数据对应的索引值,并根据索引值得到对象的数据,解析SQL指令中查询条件用于从对象的数据中查询得到属性数据。上述SQL指令中的对象的标识、对象的键值属性以及查询条件均不是对象类数据,而是标准的SQL接口可传递和解析的变量、标 识等有效数据,通过对SQL指令解析得到的上述有效数据映射对象的数据及对象的属性数据,实现了支持标准SQL访问对象。In the embodiment of the present application, the method for executing the SQL instruction is used to parse the identifier of the object in the SQL instruction to obtain the corresponding object schema and the relational data table, and the key value attribute of the object in the SQL instruction is used to generate the data corresponding to the object. The index value, and the object data is obtained according to the index value, and the query condition in the parsing SQL instruction is used to query the attribute data from the object data. The identifier of the object in the above SQL instruction, the key value attribute of the object, and the query condition are not the object class data, but the valid data such as variables and identifiers that can be passed and parsed by the standard SQL interface, and the above validated by the SQL command parsing. The data of the data mapping object and the attribute data of the object implement the standard SQL access object.
参照图8中所示,通过对象接口单元1101读对象的方法包括:Referring to FIG. 8, the method of reading an object by the object interface unit 1101 includes:
S301、接收针对对象的读请求,读请求中包括对象的标识和键值属性。S301. Receive a read request for an object, where the read request includes an identifier of the object and a key value attribute.
该步骤与S202的区别在于,不需要去除SQL操作中的关系算子,读请求中显式地包括模式名称和键值属性。This step differs from S202 in that it is not necessary to remove the relational operator in the SQL operation, and the read request explicitly includes the mode name and the key value attribute.
与步骤S102类似的,由于读请求中的数据表示方式可能是JSON格式也可能是XML格式等等,因此对象接口单元1101会解析对象的模式名称和键值属性为系统能够处理的统一形式,并发送给对象访问处理单元1102处理。Similar to step S102, since the data representation in the read request may be a JSON format, an XML format, or the like, the object interface unit 1101 parses the object's schema name and key value attribute into a unified form that the system can handle, and The processing is sent to the object access processing unit 1102.
S302、根据读请求中的对象的标识,以及对象的标识与对象模式之间的映射关系,得到对应的对象模式。S302. Obtain a corresponding object mode according to the identifier of the object in the read request and the mapping relationship between the identifier of the object and the object mode.
该步骤与步骤S203区别在于不必查询得到关系型数据表。This step is different from step S203 in that it is not necessary to query to obtain a relational data table.
S303、根据对象的键值属性以及对象模式中定义的能够用于生成索引值的属性,确定对象的数据对应的索引值。S303. Determine an index value corresponding to the data of the object according to the key value attribute of the object and the attribute that can be used to generate the index value defined in the object mode.
该步骤与步骤S204类似,在此不再赘述。This step is similar to step S204, and details are not described herein again.
S304、根据索引值查询得到对象的数据。S304. Query the data of the object according to the index value.
该步骤与S205类似,区别在于,查询得到整个对象的数据,而不是对象的数据中的属性数据。This step is similar to S205, except that the query gets the data of the entire object, not the attribute data in the data of the object.
S305、返回查询得到的对象的数据。S305. Return data of the object obtained by the query.
对象存储单元1104通过对象访问处理单元1102将对象的数据返回给对象接口单元1101。The object storage unit 1104 returns the data of the object to the object interface unit 1101 through the object access processing unit 1102.
综上所述,本申请实施例提供的上述方法和装置,首先,解决了采用对象存储的系统无法提供标准关系SQL访问的问题;原因在于,本装置同时提供了对象接口和SQL接口,通过对象模式和关系型数据表能够让对象在装置里以关联关系存储,不仅让存储的数据具有键值的对象存储属性也具有关系型的关联属性,因此能够在对象存储的系统提供标准关系SQL访问。其次,通过自动转换,能够利用当前已经非常成熟的关系型SQL优化和执行相关技术;原因在于,关系型数据库有着非常多优秀的特性,不仅能保持数据的一致性,也由于以标准化为前提,数据更新的开销很小,且能进行结合(join)等复杂查询。在提供标准SQL接口的存储装置上,通过自动转换,能够充分利用这些技术。除此之外,对象模式定义本身就对SQL查询做了优化。再次,保留了系统的分布式特性,又提升系统的可编程性、可移植性,具有更广泛的使用前景;原因在于,本装置既能够用于单机环境中,也能部署在分布式的环境中。采用标准的SQL接口能够方便将本装置部署在已有的基于标准SQL的应用环境中,且多样化的接口增加了开发人员的编程选择。在大数据分布式的大趋势下,其具有广泛的使用前景。In summary, the foregoing method and apparatus provided by the embodiments of the present application first solve the problem that a system using object storage cannot provide standard relational SQL access; the reason is that the device simultaneously provides an object interface and a SQL interface, and the object is Pattern and relational data tables enable objects to be stored in associations in the device. Not only do the object storage attributes with stored values of keys have relational attributes, they can provide standard relational SQL access in the system where the objects are stored. Secondly, through automatic conversion, it is possible to optimize and execute related technologies using relational SQL that is already very mature; the reason is that relational databases have many excellent features, which not only maintain data consistency, but also rely on standardization. Data update has a small overhead and can perform complex queries such as joins. These technologies can be fully utilized by automatic conversion on storage devices that provide standard SQL interfaces. In addition to this, the object schema definition itself is optimized for SQL queries. Thirdly, the distributed characteristics of the system are preserved, and the programmability and portability of the system are improved, which has wider application prospects. The reason is that the device can be used in a stand-alone environment or in a distributed environment. in. The standard SQL interface makes it easy to deploy the device in an existing standard SQL-based application environment, and the variety of interfaces increases the developer's programming choices. Under the general trend of big data distribution, it has broad application prospects.
在采用集成的单元的情况下,图9示出了上述实施例中所涉及的执行SQL指令的装置的一种可能的结构示意图。执行SQL指令的装置11包括:处理模块1122和通信模块1123。处理模块1122用于对执行SQL指令的装置11的动作进行控制管理,例如,处理模块1122用于支持执行SQL指令的装置11执行图2中的过程S101-S106,图5中的过程S201-S206,图8中的过程S301-S305。通信模块1123用于支持执行SQL指 令的装置与其他实体的通信。执行SQL指令的装置11还可以包括存储模块1121,用于存储执行SQL指令的装置的程序代码和数据。In the case of employing an integrated unit, FIG. 9 shows a possible structural diagram of an apparatus for executing an SQL instruction involved in the above embodiment. The apparatus 11 that executes the SQL instruction includes a processing module 1122 and a communication module 1123. The processing module 1122 is configured to control and manage the action of the apparatus 11 that executes the SQL instruction. For example, the processing module 1122 is configured to support the apparatus 11 that executes the SQL instruction to execute the processes S101-S106 in FIG. 2, the process S201-S206 in FIG. , the process S301-S305 in FIG. Communication module 1123 is used to support communication of devices executing SQL instructions with other entities. The apparatus 11 executing the SQL instructions may further include a storage module 1121 for storing program codes and data of the apparatus that executes the SQL instructions.
当处理模块1122为处理器,通信模块1123为网口,存储模块1121为存储器时,本申请实施例所涉及的执行SQL指令的装置可以为如下所述的执行SQL指令的装置。When the processing module 1122 is a processor, the communication module 1123 is a network port, and the storage module 1121 is a memory, the apparatus for executing the SQL instruction according to the embodiment of the present application may be a device for executing the SQL instruction as described below.
参照图10所示,该执行SQL指令的装置11包括:处理器1132、网口1133、存储器1131、总线1134。其中,网口1133、处理器1132、存储器1131通过总线1134相互连接;总线1134可以是外设部件互连标准(Peripheral Component Interconnect,PCI)总线或扩展工业标准结构(Extended Industry Standard Architecture,EISA)总线等。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。Referring to FIG. 10, the apparatus 11 for executing an SQL command includes a processor 1132, a network port 1133, a memory 1131, and a bus 1134. The network port 1133, the processor 1132, and the memory 1131 are connected to each other through a bus 1134. The bus 1134 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. Wait. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in the figure, but it does not mean that there is only one bus or one type of bus.
应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that, in the various embodiments of the present application, the size of the sequence numbers of the foregoing processes does not mean the order of execution sequence, and the order of execution of each process should be determined by its function and internal logic, and should not be applied to the embodiment of the present application. The implementation process constitutes any limitation.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods to implement the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present application.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。A person skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the system, the device and the unit described above can refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、设备和方法,可以通过其它的方式实现。例如,以上所描述的设备实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,设备或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be electrical, mechanical or otherwise.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件程序实现时,可以全部或部分地以计算机程序产品的形式来实现。该计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或者数据中 心通过有线(例如同轴电缆、光纤、数字用户线(Digital Subscriber Line,DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可以用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带),光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using a software program, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present application are generated in whole or in part. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be from a website site, computer, server or data center Transmission to another website site, computer, server, or data center by wire (eg, coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (eg, infrared, wireless, microwave, etc.). The computer readable storage medium can be any available media that can be accessed by a computer or a data storage device that includes one or more servers, data centers, etc. that can be integrated with the media. The usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (such as a Solid State Disk (SSD)) or the like.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The foregoing is only a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto, and any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application. It should be covered by the scope of protection of this application. Therefore, the scope of protection of the present application should be determined by the scope of the claims.

Claims (12)

  1. 一种执行结构化查询语言SQL指令的方法,其特征在于,包括:A method for executing a structured query language SQL instruction, comprising:
    接收一SQL指令,所述SQL指令用于从一对象的数据中查询所述对象的属性数据;Receiving an SQL instruction, the SQL instruction is used to query attribute data of the object from data of an object;
    解析所述SQL指令以得到所述对象的标识、所述对象的键值属性以及查询条件,所述对象的标识用于指示所述对象的类型,所述对象的键值属性用于生成索引值,所述索引值与所述对象的数据相对应,所述查询条件用于从所述对象的数据中查询所述属性数据;Parsing the SQL instruction to obtain an identifier of the object, a key value attribute of the object, and a query condition, where the identifier of the object is used to indicate a type of the object, and the key value attribute of the object is used to generate an index value The index value corresponds to data of the object, and the query condition is used to query the attribute data from data of the object;
    根据所述对象的标识,以及对象的标识与对象模式之间的映射关系,得到所述对象对应的对象模式和关系型数据表,所述对象模式用于定义一类对象的树形数据结构,所述树形数据结构包括至少一个第一节点,所述第一节点用于定义此类对象的属性中能够用于生成所述索引值的属性,所述关系型数据表是二维表,所述二维表按照所述对象模式中指示的节点关系存储所述对象的属性数据;Obtaining an object schema and a relational data table corresponding to the object according to the identifier of the object, and a mapping relationship between the identifier of the object and the object schema, where the object schema is used to define a tree data structure of a type of object, The tree data structure includes at least one first node, the first node is used to define an attribute of an attribute of such an object that can be used to generate the index value, and the relational data table is a two-dimensional table. The two-dimensional table stores attribute data of the object according to a node relationship indicated in the object mode;
    根据所述对象的键值属性以及所述对象模式中定义的用于生成索引值的属性,确定所述对象的数据对应的索引值;Determining an index value corresponding to the data of the object according to the key value attribute of the object and the attribute for generating an index value defined in the object mode;
    根据所述对象的数据对应的索引值获得所述对象的数据,并根据所述查询条件和所述对象的关系型数据表,从所述对象的数据中查询得到所述属性数据。Obtaining data of the object according to an index value corresponding to the data of the object, and querying the attribute data from the data of the object according to the query condition and the relational data table of the object.
  2. 根据权利要求1所述的方法,其特征在于,在所述接收一SQL指令之前,所述方法还包括:The method of claim 1, wherein before the receiving an SQL instruction, the method further comprises:
    定义所述对象的对象模式以及关系型数据表;Defining an object schema of the object and a relational data table;
    接收针对所述对象的写请求,所述写请求中包括所述对象的标识和属性;Receiving a write request for the object, where the write request includes an identifier and an attribute of the object;
    根据所述写请求中的所述对象的标识,以及对象的标识与对象模式之间的映射关系,得到所述对象的对象模式和关系型数据表;Obtaining an object mode and a relational data table of the object according to the identifier of the object in the write request, and a mapping relationship between the identifier of the object and the object mode;
    根据所述对象的对象模式将所述写请求中属性转换为具有完整存储结构的对象,并根据所述对象模式中定义的用于生成索引值的属性将所述写请求中的属性构建为所述索引值,其中,所述具有完整存储结构的对象指按照对象模式的所有属性分配的存储空间所存储的对象,所述写请求中的属性存储在所述存储空间中;Converting an attribute in the write request into an object having a complete storage structure according to an object schema of the object, and constructing an attribute in the write request as an attribute according to an attribute defined in the object pattern for generating an index value An index value, wherein the object having a complete storage structure refers to an object stored in a storage space allocated according to all attributes of the object mode, and attributes in the write request are stored in the storage space;
    根据所述对象的关系型数据表将所述具有完整存储结构的对象转换为所述对象的数据,并将所述对象的数据按照所述索引值进行存储。Converting the object having the complete storage structure into data of the object according to the relational data table of the object, and storing the data of the object according to the index value.
  3. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method of claim 1 further comprising:
    接收针对对象的读请求,所述读请求中包括所述对象的标识和键值属性;Receiving a read request for an object, the read request including an identifier and a key value attribute of the object;
    根据所述读请求中的对象的标识,以及对象的标识与对象模式之间的映射关系,得到对应的对象模式;Obtaining a corresponding object mode according to the identifier of the object in the read request, and the mapping relationship between the identifier of the object and the object mode;
    根据所述对象的键值属性以及所述对象模式中定义的能够用于生成索引值的属性,确定所述对象的数据对应的索引值;Determining an index value corresponding to the data of the object according to the key value attribute of the object and an attribute that can be used to generate an index value defined in the object mode;
    根据所述索引值查询得到所述对象的数据。The data of the object is obtained according to the index value query.
  4. 根据权利要求1-3中任一项所述的方法,其特征在于,所述对象的树形数据结构中包括至少一个父节点,所述父节点包括标识和域,其中,所述父节点的标识用于指示所述父节点对应对象所属种类,所述父节点的域用于包含子节点。The method according to any one of claims 1 to 3, wherein at least one parent node is included in the tree data structure of the object, the parent node includes an identifier and a domain, wherein the parent node The identifier is used to indicate the category to which the parent node corresponds, and the domain of the parent node is used to include the child node.
  5. 根据权利要求4所述的方法,其特征在于,所述关系型数据表的每个节点包括父表标识、根表标识和外键,所述父表标识用于指向所述子节点的父节点的二维表,所述根表标识用于指向所述树形数据结构的根节点的二维表,所述外键指向所述对象模式的主键。The method according to claim 4, wherein each node of the relational data table includes a parent table identifier, a root table identifier, and a foreign key, and the parent table identifier is used to point to a parent node of the child node A two-dimensional table identifying a two-dimensional table for pointing to a root node of the tree data structure, the foreign key pointing to a primary key of the object schema.
  6. 一种执行结构化查询语言SQL指令的装置,其特征在于,包括:SQL接口单元、关系型SQL访问处理单元、对象关系型转换单元、元数据管理单元、对象存储单元,其中,An apparatus for executing a structured query language SQL instruction, comprising: a SQL interface unit, a relational SQL access processing unit, an object relational conversion unit, a metadata management unit, and an object storage unit, wherein
    所述SQL接口单元,用于接收一SQL指令,所述SQL指令用于从一对象的数据中查询所述对象的属性数据;The SQL interface unit is configured to receive an SQL instruction, where the SQL instruction is used to query attribute data of the object from data of an object;
    所述关系型SQL访问处理单元,用于解析所述SQL接口单元接收的所述SQL指令以得到所述对象的标识、所述对象的键值属性以及查询条件,所述对象的标识用于指示所述对象的类型,所述对象的键值属性用于生成索引值,所述索引值与所述对象的数据相对应,所述查询条件用于从所述对象的数据中查询所述属性数据;The relational SQL access processing unit is configured to parse the SQL instruction received by the SQL interface unit to obtain an identifier of the object, a key value attribute of the object, and a query condition, where the identifier of the object is used to indicate a type of the object, the key value attribute of the object is used to generate an index value, the index value corresponding to data of the object, the query condition is used to query the attribute data from data of the object ;
    所述对象关系型转换单元,用于根据所述关系型SQL访问处理单元得到的所述对象的标识,以及所述元数据管理单元所存储的对象的标识与对象模式之间的映射关系,得到所述对象对应的对象模式和关系型数据表,所述对象模式用于定义一类对象的树形数据结构,所述树形数据结构包括至少一个第一节点,所述第一节点用于定义此类对象的属性中能够用于生成所述索引值的属性,所述关系型数据表是二维表,所述二维表按照所述对象模式中指示的节点关系存储所述对象的属性数据;The object-relational conversion unit is configured to obtain, according to the identifier of the object obtained by the relational SQL access processing unit, and a mapping relationship between an identifier of an object stored by the metadata management unit and an object mode, An object schema and a relational data table corresponding to the object, the object schema is used to define a tree data structure of a class of objects, the tree data structure includes at least one first node, and the first node is used to define An attribute of such an object that can be used to generate an attribute of the index value, the relational data table being a two-dimensional table, the two-dimensional table storing attribute data of the object according to a node relationship indicated in the object pattern ;
    所述对象关系型转换单元,还用于根据所述对象的键值属性以及所述对象模式中定义的用于生成索引值的属性,确定所述对象的数据对应的索引值;The object-relational conversion unit is further configured to determine an index value corresponding to the data of the object according to the key value attribute of the object and the attribute for generating an index value defined in the object mode;
    所述对象关系型转换单元,还用于根据所述对象的数据对应的索引值获得所述对象的数据,并根据所述查询条件和所述对象的关系型数据表,从所述对象存储单元中所存储的所述对象的数据中查询得到所述属性数据。The object-relational conversion unit is further configured to obtain data of the object according to an index value corresponding to the data of the object, and obtain the data from the object storage unit according to the query condition and the relational data table of the object. The attribute data is obtained by querying the data of the object stored in the object.
  7. 根据权利要求6所述的装置,其特征在于,所述装置还包括对象接口单元、对象访问处理单元,The device according to claim 6, wherein the device further comprises an object interface unit, an object access processing unit,
    所述对象接口单元,用于在所述SQL接口单元接收一SQL指令之前,定义所述对象的对象模式以及关系型数据表;The object interface unit is configured to define an object mode and a relational data table of the object before the SQL interface unit receives an SQL instruction;
    所述对象接口单元,还用于接收针对所述对象的写请求,所述写请求中包括所述对象的标识和属性;The object interface unit is further configured to receive a write request for the object, where the write request includes an identifier and an attribute of the object;
    所述对象访问处理单元,用于根据所述写请求中的所述对象的标识,以及所述元数据管理单元所存储的对象的标识与对象模式之间的映射关系,得到所述对象的对象模式和关系型数据表;The object access processing unit is configured to obtain an object of the object according to an identifier of the object in the write request, and a mapping relationship between an identifier of an object stored by the metadata management unit and an object mode. Pattern and relational data tables;
    所述对象访问处理单元,还用于根据所述对象的对象模式将所述写请求中属性转换为具有完整存储结构的对象,并根据所述对象模式中定义的用于生成索引值的属性将所述写请求中的属性构建为所述索引值,其中,所述具有完整存储结构的对象指按照对象模式的所有属性分配的存储空间所存储的对象,所述写请求中的属性存储在所述存储空间中;The object access processing unit is further configured to convert an attribute in the write request into an object having a complete storage structure according to an object mode of the object, and according to an attribute defined in the object mode for generating an index value, An attribute in the write request is constructed as the index value, wherein the object having a complete storage structure refers to an object stored in a storage space allocated according to all attributes of the object pattern, and the attribute in the write request is stored in the In the storage space;
    所述对象访问处理单元,还用于根据所述对象的关系型数据表将所述具有完整存 储结构的对象转换为所述对象的数据,并将所述对象的数据按照所述索引值进行存储至所述对象存储单元。The object access processing unit is further configured to convert the object having the complete storage structure into data of the object according to the relational data table of the object, and store the data of the object according to the index value. To the object storage unit.
  8. 根据权利要求6所述的装置,其特征在于,所述装置还包括对象接口单元、对象访问处理单元,The device according to claim 6, wherein the device further comprises an object interface unit, an object access processing unit,
    所述对象接口单元,用于接收针对对象的读请求,所述读请求中包括所述对象的标识和键值属性;The object interface unit is configured to receive a read request for an object, where the read request includes an identifier and a key attribute of the object;
    所述对象访问处理单元,用于根据所述读请求中的对象的标识,以及所述元数据管理单元中存储的对象的标识与对象模式之间的映射关系,得到对应的对象模式;The object access processing unit is configured to obtain a corresponding object mode according to the identifier of the object in the read request and the mapping relationship between the identifier of the object stored in the metadata management unit and the object mode;
    所述对象访问处理单元,还用于根据所述对象的键值属性以及所述对象模式中定义的能够用于生成索引值的属性,确定所述对象的数据对应的索引值;The object access processing unit is further configured to determine an index value corresponding to the data of the object according to the key value attribute of the object and an attribute that can be used to generate an index value defined in the object mode;
    所述对象访问处理单元,还用于根据所述索引值从所述对象存储单元查询得到所述对象的数据。The object access processing unit is further configured to query, according to the index value, the data of the object from the object storage unit.
  9. 根据权利要求6-8中任一项所述的装置,其特征在于,所述对象的树形数据结构中包括至少一个父节点,所述父节点包括标识和域,其中,所述父节点的标识用于指示所述父节点对应对象所属种类,所述父节点的域用于包含子节点。The apparatus according to any one of claims 6-8, wherein the tree data structure of the object includes at least one parent node, the parent node includes an identifier and a domain, wherein the parent node The identifier is used to indicate the category to which the parent node corresponds, and the domain of the parent node is used to include the child node.
  10. 根据权利要求9所述的装置,其特征在于,所述关系型数据表的每个节点包括父表标识、根表标识和外键,所述父表标识用于指向所述子节点的父节点的二维表,所述根表标识用于指向所述树形数据结构的根节点的二维表,所述外键指向所述对象模式的主键。The apparatus according to claim 9, wherein each node of said relational data table includes a parent table identifier, a root table identifier, and a foreign key, said parent table identifier being used to point to a parent node of said child node A two-dimensional table identifying a two-dimensional table for pointing to a root node of the tree data structure, the foreign key pointing to a primary key of the object schema.
  11. 一种执行结构化查询语言SQL指令的装置,其特征在于,包括:处理器、存储器、总线和通信接口;所述存储器用于存储计算机执行指令,所述处理器与所述存储器通过所述总线连接,当所述装置运行时,所述处理器执行所述存储器存储的计算机执行指令,以使所述装置执行如权利要求1-5任一项所述的方法。An apparatus for executing a structured query language SQL instruction, comprising: a processor, a memory, a bus, and a communication interface; the memory is configured to store a computer to execute an instruction, and the processor and the memory pass through the bus Connected, when the device is in operation, the processor executes computer stored instructions stored in the memory to cause the device to perform the method of any of claims 1-5.
  12. 一种计算机存储介质,其特征在于,包括指令,当其在计算机上运行时,使得所述计算机执行如权利要求1-5任一项所述的方法。A computer storage medium, comprising instructions that, when executed on a computer, cause the computer to perform the method of any of claims 1-5.
PCT/CN2018/083411 2017-07-20 2018-04-17 Method and device for executing structured query language (sql) instruction WO2019015364A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710598140.7A CN110019287B (en) 2017-07-20 2017-07-20 Method and device for executing Structured Query Language (SQL) instruction
CN201710598140.7 2017-07-20

Publications (1)

Publication Number Publication Date
WO2019015364A1 true WO2019015364A1 (en) 2019-01-24

Family

ID=65015042

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/083411 WO2019015364A1 (en) 2017-07-20 2018-04-17 Method and device for executing structured query language (sql) instruction

Country Status (2)

Country Link
CN (1) CN110019287B (en)
WO (1) WO2019015364A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110647568A (en) * 2019-09-16 2020-01-03 金色熊猫有限公司 Method and device for converting graph database data into programming language data
CN113011117A (en) * 2021-02-18 2021-06-22 中科驭数(北京)科技有限公司 Hardware acceleration board card analog simulation method, system and device
CN116680299A (en) * 2023-06-05 2023-09-01 粤港澳大湾区(广东)国创中心 Database query method, system, storage medium and device
CN117194410A (en) * 2023-07-13 2023-12-08 广州白码科技有限公司 Method and system for generating business report by artificial intelligence language model

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110399387A (en) * 2019-07-26 2019-11-01 北京明略软件系统有限公司 Method and device based on table incidence relation dynamic generation query SQL
CN111259003B (en) * 2020-01-07 2023-07-21 广州虎牙科技有限公司 Database establishment method and device
US20220197902A1 (en) * 2020-12-21 2022-06-23 Teradata Us, Inc. Range partitioned in-memory joins

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1632746A (en) * 2003-12-24 2005-06-29 华为技术有限公司 DBMS security setting method and equipment
US8260764B1 (en) * 2004-03-05 2012-09-04 Open Text S.A. System and method to search and generate reports from semi-structured data
CN103412897A (en) * 2013-07-25 2013-11-27 中国科学院软件研究所 Parallel data processing method based on distributed structure
CN104850572A (en) * 2014-11-18 2015-08-19 中兴通讯股份有限公司 HBase non-primary key index building and inquiring method and system

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6285997B1 (en) * 1998-11-16 2001-09-04 International Business Machines Corporation Query optimization with deferred update and autonomous sources
CN105205103B (en) * 2015-08-25 2019-09-20 北京京东尚科信息技术有限公司 The method and apparatus for accessing database
CN106372176B (en) * 2016-08-30 2019-07-23 东华大学 A method of it supports to carry out nested document unified SQL query
CN106372177B (en) * 2016-08-30 2019-09-27 东华大学 Support the correlation inquiry of mixed data type and the enquiry expanding method of fuzzy grouping

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1632746A (en) * 2003-12-24 2005-06-29 华为技术有限公司 DBMS security setting method and equipment
US8260764B1 (en) * 2004-03-05 2012-09-04 Open Text S.A. System and method to search and generate reports from semi-structured data
CN103412897A (en) * 2013-07-25 2013-11-27 中国科学院软件研究所 Parallel data processing method based on distributed structure
CN104850572A (en) * 2014-11-18 2015-08-19 中兴通讯股份有限公司 HBase non-primary key index building and inquiring method and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
GUO, XUDONG: "Analysis and Design of Objects Persistence Model Based on Object Relation Map", ELECTRONIC TECHNOLOGY & INFORMATION SCIENCE, 15 October 2007 (2007-10-15), ISSN: 1674-0246 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110647568A (en) * 2019-09-16 2020-01-03 金色熊猫有限公司 Method and device for converting graph database data into programming language data
CN110647568B (en) * 2019-09-16 2023-12-12 金色熊猫有限公司 Method and device for converting graph database data into programming language data
CN113011117A (en) * 2021-02-18 2021-06-22 中科驭数(北京)科技有限公司 Hardware acceleration board card analog simulation method, system and device
CN116680299A (en) * 2023-06-05 2023-09-01 粤港澳大湾区(广东)国创中心 Database query method, system, storage medium and device
CN116680299B (en) * 2023-06-05 2024-04-09 粤港澳大湾区(广东)国创中心 Database query method, system, storage medium and device
CN117194410A (en) * 2023-07-13 2023-12-08 广州白码科技有限公司 Method and system for generating business report by artificial intelligence language model
CN117194410B (en) * 2023-07-13 2024-05-14 广州白码科技有限公司 Method and system for generating business report by artificial intelligence language model

Also Published As

Publication number Publication date
CN110019287A (en) 2019-07-16
CN110019287B (en) 2021-09-14

Similar Documents

Publication Publication Date Title
US10970270B2 (en) Unified data organization for multi-model distributed databases
WO2019015364A1 (en) Method and device for executing structured query language (sql) instruction
US11120006B2 (en) Ordering transaction requests in a distributed database according to an independently assigned sequence
US20220179876A1 (en) Metadata hub for metadata models of database objects
EP3028183B1 (en) A generic sql enhancement to query any semi-structured data and techniques to efficiently support such enhancements
US9734180B1 (en) Object metadata query with secondary indexes
US9053210B2 (en) Graph query processing using plurality of engines
US9864816B2 (en) Dynamically updating data guide for hierarchical data objects
KR102177190B1 (en) Managing data with flexible schema
CN109144994A (en) Index updating method, system and relevant apparatus
US20060265385A1 (en) Common interface to access catalog information from heterogeneous databases
KR20170019352A (en) Data query method and apparatus
US6401083B1 (en) Method and mechanism for associating properties with objects and instances
US8745021B2 (en) Transformation of complex data source result sets to normalized sets for manipulation and presentation
CN110019314B (en) Dynamic data packaging method based on data item analysis, client and server
US11726999B1 (en) Obtaining inferences to perform access requests at a non-relational database system
US11341142B2 (en) Framework and metadata artefacts for updating data artefacts
US10360232B2 (en) Semantic mapping of data from an entity-relationship model to a graph-based data format to facilitate simplified querying
EP4155965A1 (en) System and method for facilitating metadata identification and import
CN115905212A (en) Centralized metadata repository with dependency identifiers
US11188594B2 (en) Wildcard searches using numeric string hash
US10915541B2 (en) Generic API
US10997160B1 (en) Streaming committed transaction updates to a data store
US10528538B2 (en) Leveraging SQL with user defined aggregation to efficiently merge inverted indexes stored as tables
Farooq The data warehouse virtualization framework for operational business intelligence

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18834920

Country of ref document: EP

Kind code of ref document: A1