





技术领域technical field
本申请的实施例涉及计算机技术领域,进一步涉及知识图谱领域,具体涉及用于存储数据的方法、装置、设备以及存储介质。The embodiments of the present application relate to the field of computer technology, further to the field of knowledge graphs, and specifically to methods, devices, devices and storage media for storing data.
背景技术Background technique
图数据库是一个使用图结构进行语义查询的数据库,通常使用节点和节点对应的关系信息表示和存储数据。A graph database is a database that uses a graph structure for semantic query, and usually uses nodes and their corresponding relationship information to represent and store data.
当数据量达到一定量级时,数据存储性能与数据查询性能都会受到影响,当数据量增长超过单个图数据库的存储容量时,可以对图数据库进行扩容以确保数据的完整性。When the amount of data reaches a certain level, both data storage performance and data query performance will be affected. When the amount of data grows beyond the storage capacity of a single graph database, the graph database can be expanded to ensure data integrity.
发明内容Contents of the invention
本申请的实施例提出了用于存储数据的方法、装置、设备以及存储介质。Embodiments of the present application propose methods, devices, devices and storage media for storing data.
第一方面,本申请的实施例提供了一种用于存储数据的方法,该方法包括:获取存储目标实体的目标分片的标识信息;按照自增序列的方式,确定目标实体的顺序标识信息;根据目标实体的实体类型以及类型与类型标识信息的第一预设对应关系,确定目标实体的类型标识信息;根据目标分片的标识信息、顺序标识信息以及类型标识信息,生成目标实体的内部标识信息;将内部标识信息存储至目标分片中。In the first aspect, the embodiment of the present application provides a method for storing data, the method includes: obtaining the identification information of the target fragment storing the target entity; determining the sequence identification information of the target entity in the manner of an auto-increment sequence ; Determine the type identification information of the target entity according to the entity type of the target entity and the first preset correspondence between the type and the type identification information; generate the internal Identification information; store the internal identification information in the target shard.
第二方面,本申请的实施例提供了一种用于存储数据的装置,该装置包括:第一获取单元,被配置成获取存储目标实体的目标分片的标识信息;第一确定单元,被配置成按照自增序列的方式,确定目标实体的顺序标识信息;第二确定单元,被配置成根据目标实体的实体类型以及类型与类型标识信息的第一预设对应关系,确定目标实体的类型标识信息;生成单元,被配置成根据目标分片的标识信息、顺序标识信息以及类型标识信息,生成目标实体的内部标识信息;第一存储单元,被配置成将内部标识信息存储至目标分片中。In a second aspect, an embodiment of the present application provides a device for storing data, including: a first obtaining unit configured to obtain identification information of a target segment of a storage target entity; a first determining unit configured to It is configured to determine the sequence identification information of the target entity in the manner of an auto-increment sequence; the second determination unit is configured to determine the type of the target entity according to the entity type of the target entity and the first preset correspondence between the type and the type identification information Identification information; a generating unit configured to generate internal identification information of the target entity according to the identification information, sequence identification information, and type identification information of the target fragment; a first storage unit configured to store the internal identification information in the target fragment middle.
第三方面,本申请的实施例提供了一种电子设备,该电子设备包括:至少一个处理器;以及与至少一个处理器通信连接的存储器;其中,存储器存储有可被至少一个处理器执行的指令,指令被至少一个处理器执行,以使至少一个处理器能够执行如第一方面中任一实现方式描述的方法。In a third aspect, an embodiment of the present application provides an electronic device, which includes: at least one processor; and a memory connected to the at least one processor in communication; wherein, the memory stores information executable by the at least one processor. An instruction, the instruction is executed by at least one processor, so that the at least one processor can execute the method described in any implementation manner of the first aspect.
第四方面,本申请的实施例提供了一种存储有计算机指令的非瞬时计算机可读存储介质,计算机指令用于使计算机执行如第一方面中任一实现方式描述的方法。In a fourth aspect, the embodiments of the present application provide a non-transitory computer-readable storage medium storing computer instructions, the computer instructions are used to cause a computer to execute the method described in any implementation manner in the first aspect.
根据本申请的技术解决了如何为每个实体生成唯一的内部标识信息的问题/根据内部标识信息所包含的丰富信息,快速定位出实体所在的分片,提高图数据库的查询效率。According to the technology of this application, the problem of how to generate unique internal identification information for each entity is solved/according to the rich information contained in the internal identification information, quickly locate the shard where the entity is located, and improve the query efficiency of the graph database.
应当理解,本部分所描述的内容并非旨在标识本申请的实施例的关键或重要特征,也不用于限制本申请的范围。本申请的其它特征将通过以下的说明书而变得容易理解。It should be understood that what is described in this section is not intended to identify key or important features of the embodiments of the application, nor is it intended to limit the scope of the application. Other features of the present application will be easily understood from the following description.
附图说明Description of drawings
通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本申请的其它特征、目的和优点将会变得更明显:Other characteristics, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
图1是本申请的一个实施例可以应用于其中的示例性系统架构图;FIG. 1 is an exemplary system architecture diagram to which an embodiment of the present application can be applied;
图2是根据本申请的用于存储数据的方法的一个实施例的流程图;Fig. 2 is a flow chart of one embodiment of the method for storing data according to the present application;
图3是根据本申请的用于存储数据的方法的一个应用场景的示意图;FIG. 3 is a schematic diagram of an application scenario of a method for storing data according to the present application;
图4是根据本申请的用于存储数据的方法的又一个实施例的流程图;Fig. 4 is a flow chart of another embodiment of the method for storing data according to the present application;
图5是根据本申请的用于存储数据的装置的一个实施例的结构示意图;FIG. 5 is a schematic structural diagram of an embodiment of a device for storing data according to the present application;
图6是适于用来实现本申请的实施例的电子设备的结构示意图。Fig. 6 is a schematic structural diagram of an electronic device suitable for implementing the embodiments of the present application.
具体实施方式Detailed ways
以下结合附图对本申请的示范性实施例做出说明,其中包括本申请实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本申请的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。Exemplary embodiments of the present application are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present application to facilitate understanding, and they should be regarded as exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
图1示出了可以应用本申请的用于存储数据的方法或用于存储数据的装置的示例性架构100。FIG. 1 shows an
如图1所示,系统架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in FIG. 1 , a
终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。终端设备101、102、103上可以安装有各种通讯客户端应用,例如信息查询类软件、数据库类软件、自然语言处理类软件、搜索类应用、即时通信工具、社交平台应用、浏览器类应用等。The
终端设备101、102、103可以是硬件,也可以是软件。当终端设备101、102、103为硬件时,可以是具有显示屏的各种电子设备,包括但不限于智能手机、平板电脑、笔记本电脑、和台式计算机等等。当终端设备101、102、103为软件时,可以安装在上述所列举的电子设备中。其可以实现成多个软件或软件模块(例如用来提供分布式服务),也可以实现成单个软件或软件模块。在此不做具体限定。The
服务器105可以是为终端设备101、102、103安装的信息查询类应用提供支持的服务器。服务器105可以自动处理终端设备101、102、103输入的待查询实体的待查询内部标识信息,确定待查询实体。The
需要说明的是,本申请的实施例所提供的用于存储数据的方法可以通过终端设备101、102、103执行,也可以通过服务器105执行。相应地,用于存储数据的装置可以设置于终端设备101、102、103中,也可以设置于服务器105中。本申请对此不做限定。It should be noted that the method for storing data provided by the embodiments of the present application may be executed by the
应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the numbers of terminal devices, networks and servers in Fig. 1 are only illustrative. According to the implementation needs, there can be any number of terminal devices, networks and servers.
继续参考图2,示出了根据本申请的用于存储数据的方法的一个实施例的流程200。本实施例的图数据库可以包括多个数据库分片(以下简称分片)。该用于存储数据的方法包括以下步骤:Continuing to refer to FIG. 2 , a
步骤201,获取存储目标实体的目标分片的标识信息。
在本实施例中,上述用于存储数据的方法的执行主体(例如图1所示的终端设备101、102、103或服务器105)可以随机为目标实体分配目标分片,确定存储目标实体的目标分片的标识信息。例如图数据库中有五个分片,则可以将数字标识0、1、2、3、4分别作为五个分片的标识信息。在这里,目标实体可以是外来的、需要存储至图数据库的实体。上述执行主体可以从信息查询类应用获取目标实体。In this embodiment, the execution subject of the above-mentioned method for storing data (for example, the
在本实施的一些可选的实现方式中,上述步骤201具体可以通过以下步骤来实现:根据预先设置的对应关系,确定存储目标实体的目标分片,其中,对应关系包括实体的属性信息与分片之间的对应关系;确定目标分片的标识信息。In some optional implementations of this implementation, the
在该可选实现方式中,上述执行主体可以根据实体的属性信息与分片之间的对应关系,确定存储目标实体的目标分片以及目标分片的标识。例如,上述执行主体可以预先设定实体属性信息所包括的年龄属性与分片之间的对应关系。具体地,年龄段为0-10的实体可以对应分片0,年龄段为11-20的实体可以对应分片1。上述执行主体可以根据目标实体的属性信息中的年龄值确定存储目标实体的目标分片。或者,上述执行主体可以预先设定实体属性信息所包括的公司市值与分片之间的对应关系。具体地,公司市值范围为0-500万的实体可以对应分片0,公司市值范围为501-1000万的实体可以对应分片1。上述执行主体可以根据目标实体的属性信息中的公司市值确定存储目标实体的目标分片。在查询目标实体时,该实现方式可以根据预先设定的对应关系以及目标分片的标识确定出目标实体的实体属性,并且将同一属性范围的实体存储于同一分片,提高查询效率。In this optional implementation manner, the execution subject may determine the target shard for storing the target entity and the identifier of the target shard according to the correspondence between the attribute information of the entity and the shard. For example, the above execution subject may preset the correspondence between the age attribute included in the entity attribute information and the fragment. Specifically, entities whose age range is 0-10 may correspond to shard 0, and entities whose age range is 11-20 may correspond to shard 1. The above execution subject may determine the target shard for storing the target entity according to the age value in the attribute information of the target entity. Alternatively, the execution subject may preset the correspondence between the company's market capitalization included in the entity attribute information and the shards. Specifically, entities whose company market value ranges from 0 to 5 million can correspond to shard 0, and entities whose company market value ranges from 5.01 to 10 million can correspond to shard 1. The above execution subject may determine the target shard for storing the target entity according to the company market value in the attribute information of the target entity. When querying the target entity, this implementation can determine the entity attributes of the target entity according to the preset corresponding relationship and the identification of the target shard, and store entities of the same attribute range in the same shard to improve query efficiency.
在本实施的一些可选的实现方式中,上述步骤201具体可以通过以下步骤来实现:获取目标实体的原始标识信息;基于原始标识信息与图数据库中包括的分片的数量,确定存储目标实体的目标分片;确定目标分片的标识信息。In some optional implementations of this implementation, the
在该可选实现方式中,上述执行主体可以先获取目标实体的原始标识信息。然后根据原始标识信息与图数据库中包括的分片的数量,确定存储目标实体的目标分片以及目标分片的标识。例如,目标实体的原始标识信息可以为用户标识,具体地,用户标识可以为1002,则将用户标识1002除以分片的数量,得到整数商和余数。将标识信息为余数的分片作为存储目标实体的目标分片。通过该实现方式,可以将实体均匀的分配至各个分片进行存储,实现负载均衡。In this optional implementation manner, the execution subject may first obtain the original identification information of the target entity. Then, according to the original identification information and the number of shards included in the graph database, the target shard for storing the target entity and the identifier of the target shard are determined. For example, the original identification information of the target entity may be a user ID, specifically, the user ID may be 1002, then divide the user ID 1002 by the number of shards to obtain an integer quotient and a remainder. The shard whose identification information is the remainder is used as the target shard for storing the target entity. Through this implementation method, entities can be evenly distributed to each shard for storage to achieve load balancing.
步骤202,按照自增序列的方式,确定目标实体的顺序标识信息。Step 202: Determine the sequence identification information of the target entity in the manner of an auto-increment sequence.
在本实施例中,上述执行主体可以按照自增序列的方式,确定目标实体的顺序标识信息。顺序标识信息可以用于区别各个实体的定长的唯一标识。具体地,上述执行主体可以从将0或1作为初始顺序标识信息,然后按照自增序列的方式依次为每一个实体分配顺序标识信息。自增序列可以是一组单调递增的整数,例如1,2,3,…,或者0,2,4,…。In this embodiment, the execution subject may determine the sequence identification information of the target entity in a self-incrementing sequence manner. The sequence identification information can be used to distinguish the fixed-length unique identification of each entity. Specifically, the above-mentioned execution subject may start with 0 or 1 as the initial sequence identification information, and then sequentially assign sequence identification information to each entity in the manner of an auto-increment sequence. The auto-increment sequence can be a set of monotonically increasing integers, such as 1,2,3,…, or 0,2,4,….
步骤203,根据目标实体的实体类型以及类型与类型标识信息的第一预设对应关系,确定目标实体的类型标识信息。Step 203: Determine the type identification information of the target entity according to the entity type of the target entity and a first preset correspondence between the type and the type identification information.
在本实施例中,上述执行主体先确定目标实体的实体类型,然后根据预先设定的类型与类型标识信息的第一预设对应关系,确定目标实体的类型标识信息。例如,实体类型为人的实体可以对应类型标识信息1,实体类型为公司的实体可以对应类型标识信息2。上述执行主体可以根据目标实体的实体类型,确定目标实体的类型标识信息。In this embodiment, the execution subject first determines the entity type of the target entity, and then determines the type identification information of the target entity according to the first preset correspondence between the preset type and the type identification information. For example, an entity whose entity type is a person may correspond to type identification information 1, and an entity whose entity type is a company may correspond to type identification information 2. The above execution subject may determine the type identification information of the target entity according to the entity type of the target entity.
步骤204,根据目标分片的标识信息、顺序标识信息以及类型标识信息,生成目标实体的内部标识信息。Step 204: Generate internal identification information of the target entity according to the identification information, sequence identification information, and type identification information of the target fragment.
在本实施例中,上述执行主体可以根据目标分片的标识信息、顺序标识信息以及类型标识信息,生成目标实体的内部标识信息。具体地,目标实体的内部标识信息的组成从前往后可以依次为:2个字节表示目标分片的标识信息,1个字节表示类型标识信息,5个字节表示顺序标识信息。In this embodiment, the execution subject may generate the internal identification information of the target entity according to the identification information, sequence identification information, and type identification information of the target fragment. Specifically, the composition of the internal identification information of the target entity may be sequentially as follows: 2 bytes represent the identification information of the target fragment, 1 byte represents the type identification information, and 5 bytes represent the sequence identification information.
步骤205,将内部标识信息存储至目标分片中。
在本实施例中,上述执行主体可以将步骤204生成的内部标识信息存储至目标分片中,可以在图数据库中维持统一的、整型的标识信息,便于后续查询。In this embodiment, the execution subject can store the internal identification information generated in
在本实施的一些可选的实现方式中,上述方法还可以进一步包括图2中未示出的以下步骤:根据目标实体的实体类型以及类型与编码方式的第二预设对应关系,确定目标编码方式;利用目标编码方式对目标实体的属性信息进行编码;将编码后的属性信息存储至目标分片中。In some optional implementations of this embodiment, the above method may further include the following steps not shown in FIG. 2: determine the target encoding according to the entity type of the target entity and the second preset correspondence between the type and the encoding method method; use the target encoding method to encode the attribute information of the target entity; store the encoded attribute information in the target segment.
在该可选实现方式中,上述执行主体可以先确定目标实体的实体类型。然后根据实体类型以及类型与编码方式的第二预设对应关系,确定目标编码方式,然后利用目标编码方式对目标实体的属性信息进行编码,将编码后的属性信息存储至目标分片中。在这里,编码方式可以将自然语言状态下的属性信息,转化为机器语言状态下的属性信息进行存储。具体地,不同的实体类型的属性信息所包括的各个属性类别是不同的。例如实体类型为人的属性信息可以包括性别、年龄等属性类别的属性值,实体类型为公司的属性信息可以包括公司市值等属性类别的属性值。实体类型不同,实体的属性信息所包括的属性类别不同,属性信息对应的编码模式也不同。上述执行主体将目标实体与编码后的属性信息对应存储在目标分片中。通过该实现方式,可以根据目标实体的实体类型,确定目标编码方式对目标实体的属性信息进行编码,将编码后的属性信息存储。In this optional implementation manner, the execution subject may first determine the entity type of the target entity. Then, according to the entity type and the second preset corresponding relationship between the type and the coding method, the target coding method is determined, and then the attribute information of the target entity is encoded by using the target coding method, and the encoded attribute information is stored in the target slice. Here, the encoding method can convert the attribute information in the natural language state into the attribute information in the machine language state for storage. Specifically, attribute information of different entity types includes different attribute categories. For example, attribute information whose entity type is person may include attribute values of attribute categories such as gender and age, and attribute information whose entity type is company may include attribute values of attribute categories such as company market value. The entity types are different, the attribute information of the entity includes different attribute categories, and the encoding modes corresponding to the attribute information are also different. The above execution subject stores the target entity and the encoded attribute information in the target slice correspondingly. Through this implementation, according to the entity type of the target entity, the target encoding method can be determined to encode the attribute information of the target entity, and the encoded attribute information can be stored.
继续参考图3,图3是根据本申请的用于存储数据的方法的一个应用场景的示意图。在图3的应用场景中,执行主体可以为图数据库服务器301,用户在终端302安装的信息查询类软件中进行操作,图数据库服务器302可以存储用户在操作过程中所产生的目标实体。图数据库服务器301可以首先确定存储目标实体的目标分片的标识信息303,而后按照自增序列的方式,确定目标实体的顺序标识信息304,再根据目标实体的实体类型以及类型与类型标识信息的第一预设对应关系,确定目标实体的类型标识信息305,最后可以根据目标分片的标识信息303、顺序标识信息304以及类型标识信息305,生成目标实体的内部标识信息306。将内部标识信息306存储至目标分片中。Continue to refer to FIG. 3 , which is a schematic diagram of an application scenario of the method for storing data according to the present application. In the application scenario of FIG. 3 , the execution subject may be the
本公开的上述实施例提供的方法,通过获取存储目标实体的目标分片的标识信息,然后按照自增序列的方式,确定目标实体的顺序标识信息,根据目标实体的实体类型以及类型与类型标识信息的第一预设对应关系,确定目标实体的类型标识信息,最后根据目标分片的标识信息、顺序标识信息以及类型标识信息,生成目标实体的内部标识信息,该方法可以为每个实体生成唯一的内部标识信息,并且可以根据内部标识信息所包含的丰富信息,快速定位出实体所在的分片,提高图数据库的查询效率。In the method provided by the above-mentioned embodiments of the present disclosure, by obtaining the identification information of the target fragment that stores the target entity, and then determining the sequence identification information of the target entity in an auto-increment sequence, according to the entity type and type and type identification of the target entity The first preset correspondence relationship of information determines the type identification information of the target entity, and finally generates the internal identification information of the target entity according to the identification information, sequence identification information and type identification information of the target fragment. This method can generate for each entity Unique internal identification information, and according to the rich information contained in the internal identification information, the shard where the entity is located can be quickly located to improve the query efficiency of the graph database.
继续参考图4,示出了根据本申请的用于存储数据的方法的又一个实施例的流程400。该用于存储数据的方法包括以下步骤:Continuing to refer to FIG. 4 , a
步骤401,获取存储目标实体的目标分片的标识信息。
步骤402,按照自增序列的方式,确定目标实体的顺序标识信息。Step 402: Determine the sequence identification information of the target entity in the manner of an auto-increment sequence.
步骤403,根据目标实体的实体类型以及类型与类型标识信息的第一预设对应关系,确定目标实体的类型标识信息。Step 403: Determine the type identification information of the target entity according to the entity type of the target entity and a first preset correspondence between the type and the type identification information.
步骤404,根据目标分片的标识信息、顺序标识信息以及类型标识信息,生成目标实体的内部标识信息。Step 404: Generate internal identification information of the target entity according to the identification information, sequence identification information, and type identification information of the target fragment.
步骤405,将内部标识信息存储至目标分片中。
上述步骤401~405分别与前述实施例中的步骤201~205一致,上文针对步骤201~205的描述也适用于步骤401~405,此处不再赘述。The above steps 401-405 are respectively consistent with the steps 201-205 in the foregoing embodiments, and the above descriptions for steps 201-205 are also applicable to steps 401-405, and will not be repeated here.
步骤406,将与目标实体相关联的第一实体的内部标识信息存储至目标分片中。
在本实施例中,上述执行主体可以将与实体相关联的第一实体的内部标识信息存储至目标分片中。在这里,第一实体可以是图数据库中与目标实体邻接的节点所表示的实体。在实际的应用场景中,可以从目标分片中查找与目标实体相关联的第一实体,并且从第一实体的内部标识信息所包括的分片的标识信息所指示的分片,确定出第一实体,提高检索效率。In this embodiment, the execution subject may store the internal identification information of the first entity associated with the entity in the target segment. Here, the first entity may be an entity represented by a node adjacent to the target entity in the graph database. In an actual application scenario, the first entity associated with the target entity can be searched from the target shard, and the first entity can be determined from the shard indicated by the shard identification information included in the internal identification information of the first entity. One entity, improving retrieval efficiency.
步骤407,获取待查询实体的待查询内部标识信息。
在本实施例中,上述执行主体可以从图数据库中获取待查询实体的待查询内部标识信息。In this embodiment, the execution subject may obtain the internal identification information of the entity to be queried from the graph database.
步骤408,根据待查询内部标识信息,确定对应的待查询分片的标识信息。Step 408: Determine the identification information of the corresponding segment to be queried according to the internal identification information to be queried.
在本实施例中,上述执行主体可以根据待查询内部标识信息以及预先设置的内部标识信息的组成结构,从中确定出待查询分片的标识信息。In this embodiment, the execution subject may determine the identification information of the segment to be queried according to the composition structure of the internal identification information to be queried and the preset internal identification information.
步骤409,从待查询分片的标识信息所指示的分片中确定待查询实体。
在本实施例中,上述执行主体可以根据待查询分片的标识信息,确定出与之对应的分片,并根据目标实体的待查询内部标识信息确定待查询实体。In this embodiment, the execution subject may determine the corresponding segment according to the identification information of the segment to be queried, and determine the entity to be queried according to the internal identification information of the target entity to be queried.
在本实施的一些可选的实现方式中,上述方法还可以进一步包括图4中未示出的以下步骤:根据待查询实体的实体类型以及类型与解码方式的第三预设对应关系,确定目标解码方式;根据目标解码方式对待查询实体的、编码后的属性信息进行解码;将解码后的属性信息输出。In some optional implementations of this embodiment, the above method may further include the following steps not shown in FIG. 4: according to the entity type of the entity to be queried and the third preset correspondence between the type and the decoding method, determine the target Decoding method: decode the encoded attribute information of the entity to be queried according to the target decoding method; output the decoded attribute information.
在该可选实现方式中,上述执行主体可以根据待查询实体的实体类型或者待查询实体的内部标识信息所包括的类型标识信息、以及类型与解码方式的第三预设对应关系,确定出与目标实体的实体类型对应的解码方式。在这里,解码方式可以将机器语言状态下的属性信息,转化为自然语言状态下的属性信息。实体类型不同,实体的属性信息所包括的属性类别不同,属性信息对应的解码模式也不同。上述执行主体可以将待查询实体以及解码后的属性信息输出。In this optional implementation, the execution subject may determine the corresponding The decoding method corresponding to the entity type of the target entity. Here, the decoding method can convert the attribute information in the machine language state into the attribute information in the natural language state. The entity types are different, the attribute information of the entity includes different attribute categories, and the decoding modes corresponding to the attribute information are also different. The above execution subject can output the entity to be queried and the decoded attribute information.
本实施例中的用于存储数据的装置的流程图400,增加了将与目标实体相关联的第一实体的内部标识信息存储至目标分片中的操作、确定待查询实体的操作以及解码获取待查询实体的属性信息的操作。由此,本实施例描述的技术方案可以根据在目标分片中确定出的与目标实体有关联关系的实体的内部标识信息,快速确定出与目标实体有关联关系的实体所在的分片。并且可以根据待查询实体的待查询内部标识信息,确定出待查询实体所在的分片以及解码模式,将待查询实体和待查询实体的属性信息输出,提高属性信息的解析效率以及提高检索效率。The
进一步参考图5,作为对上述各图所示方法的实现,本申请提供了用于存储数据的装置的一个实施例,该装置实施例与图2所示的方法实施例相对应,该装置具体可以应用于各种电子设备中。Further referring to FIG. 5 , as an implementation of the methods shown in the above figures, the present application provides an embodiment of a device for storing data, which corresponds to the method embodiment shown in FIG. 2 , and the device specifically It can be applied to various electronic devices.
如图5所示,本实施例提供的用于存储数据的装置500包括第一获取单元501、第一确定单元502、第二确定单元503、生成单元504以及第一存储单元505。其中,第一获取单元501,被配置成获取存储目标实体的目标分片的标识信息;第一确定单元502,被配置成按照自增序列的方式,确定目标实体的顺序标识信息;第二确定单元503,被配置成根据目标实体的实体类型以及类型与类型标识信息的第一预设对应关系,确定目标实体的类型标识信息;生成单元504,被配置成根据目标分片的标识信息、顺序标识信息以及类型标识信息,生成目标实体的内部标识信息;第一存储单元505,被配置成将内部标识信息存储至目标分片中。As shown in FIG. 5 , an
在本实施例中,用于存储数据的装置500中:第一获取单元501、第一确定单元502、第二确定单元503、生成单元504以及第一存储单元505的具体处理及其所带来的技术效果可分别参考图2对应实施例中的步骤201、步骤202、步骤203、步骤204和步骤205的相关说明,在此不再赘述。In this embodiment, in the
在本实施例的一些可选的实现方式中,第一获取单元501进一步被配置成通过以下模块获取存储目标实体的目标分片的标识信息:第一确定模块,被配置成根据预先设置的对应关系,确定存储目标实体的目标分片,其中,对应关系包括实体的属性信息与分片之间的对应关系;第二确定模块,被配置成确定目标分片的标识信息。In some optional implementations of this embodiment, the first obtaining
在本实施例的一些可选的实现方式中,第一获取单元501进一步被配置成通过以下模块获取存储目标实体的目标分片的标识信息:获取模块,被配置成获取目标实体的原始标识信息;第三确定模块,被配置成基于原始标识信息与图数据库中包括的分片的数量,确定存储目标实体的目标分片;第四确定模块,被配置成确定目标分片的标识信息。In some optional implementations of this embodiment, the first obtaining
在本实施例的一些可选的实现方式中,上述装置还包括:第三确定单元(图中未示出),被配置成根据目标实体的实体类型以及类型与编码方式的第二预设对应关系,确定目标编码方式;编码单元(图中未示出),被配置成利用目标编码方式对目标实体的属性信息进行编码;第二存储单元(图中未示出),被配置成将编码后的属性信息存储至目标分片中。In some optional implementations of this embodiment, the above device further includes: a third determining unit (not shown in the figure), configured to correspond to the second preset encoding method according to the entity type of the target entity and the type relationship, to determine the target encoding method; the encoding unit (not shown in the figure), configured to use the target encoding method to encode the attribute information of the target entity; the second storage unit (not shown in the figure), configured to encode The final attribute information is stored in the target shard.
在本实施例的一些可选的实现方式中,上述述装置还包括:第三存储单元(图中未示出),被配置成将与目标实体相关联的第一实体的内部标识信息存储至目标分片中。In some optional implementations of this embodiment, the above-mentioned device further includes: a third storage unit (not shown in the figure), configured to store the internal identification information of the first entity associated with the target entity in in the target shard.
在本实施例的一些可选的实现方式中,上述装置还包括:第二获取单元(图中未示出),被配置成获取待查询实体的待查询内部标识信息;第四确定单元,被配置成根据待查询内部标识信息,确定对应的待查询分片的标识信息;第五确定单元(图中未示出),被配置成从待查询分片的标识信息所指示的分片中确定待查询实体。In some optional implementation manners of this embodiment, the above-mentioned apparatus further includes: a second acquiring unit (not shown in the figure), configured to acquire internal identification information of the entity to be queried; a fourth determining unit, configured by It is configured to determine the identification information of the corresponding segment to be queried according to the internal identification information to be queried; the fifth determination unit (not shown in the figure) is configured to determine from the segment indicated by the identification information of the segment to be queried The entity to be queried.
在本实施例的一些可选的实现方式中,上述装置还包括:第六确定单元(图中未示出),被配置成根据待查询实体的实体类型以及类型与解码方式的第三预设对应关系,确定目标解码方式;解码单元(图中未示出),被配置成根据目标解码方式对待查询实体的、编码后的属性信息进行解码;输出单元,被配置成将解码后的属性信息输出。In some optional implementations of this embodiment, the above-mentioned device further includes: a sixth determination unit (not shown in the figure), configured to: The corresponding relationship determines the target decoding mode; the decoding unit (not shown in the figure) is configured to decode the encoded attribute information of the entity to be queried according to the target decoding mode; the output unit is configured to decode the decoded attribute information output.
本申请的上述实施例提供的装置,通过第一获取单元501获取存储目标实体的目标分片的标识信息,然后根据第一确定单元502按照自增序列的方式,确定目标实体的顺序标识信息,第二确定单元503根据目标实体的实体类型以及类型与类型标识信息的第一预设对应关系,确定目标实体的类型标识信息,生成单元504根据目标分片的标识信息、顺序标识信息以及类型标识信息,生成目标实体的内部标识信息,第一存储单元505将内部标识信息存储至目标分片中,该装置可以为每个实体生成唯一的内部标识信息,并且可以根据内部标识信息所包含的丰富信息,快速定位出实体所在的分片,提高图数据库的查询效率。The device provided by the above-mentioned embodiments of the present application acquires the identification information of the target fragment storing the target entity through the
根据本申请的实施例,本申请还提供了一种电子设备和一种可读存储介质。According to the embodiments of the present application, the present application also provides an electronic device and a readable storage medium.
如图6所示,是根据本申请实施例的用于存储数据的方法的电子设备的框图。电子设备旨在表示各种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示各种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本申请的实现。As shown in FIG. 6 , it is a block diagram of an electronic device used for a method for storing data according to an embodiment of the present application. Electronic device is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are by way of example only, and are not intended to limit implementations of the applications described and/or claimed herein.
如图6所示,该电子设备包括:一个或多个处理器601、存储器602,以及用于连接各部件的接口,包括高速接口和低速接口。各个部件利用不同的总线互相连接,并且可以被安装在公共主板上或者根据需要以其它方式安装。处理器可以对在电子设备内执行的指令进行处理,包括存储在存储器中或者存储器上以在外部输入/输出装置(诸如,耦合至接口的显示设备)上显示GUI的图形信息的指令。在其它实施方式中,若需要,可以将多个处理器和/或多条总线与多个存储器和多个存储器一起使用。同样,可以连接多个电子设备,各个设备提供部分必要的操作(例如,作为服务器阵列、一组刀片式服务器、或者多处理器系统)。图6中以一个处理器601为例。As shown in FIG. 6, the electronic device includes: one or
存储器602即为本申请所提供的非瞬时计算机可读存储介质。其中,所述存储器存储有可由至少一个处理器执行的指令,以使所述至少一个处理器执行本申请所提供的用于存储数据的方法。本申请的非瞬时计算机可读存储介质存储计算机指令,该计算机指令用于使计算机执行本申请所提供的用于存储数据的方法。The
存储器602作为一种非瞬时计算机可读存储介质,可用于存储非瞬时软件程序、非瞬时计算机可执行程序以及模块,如本申请实施例中的用于存储数据的方法对应的程序指令/模块(例如,附图5所示的第一获取单元501、第一确定单元502、第二确定单元503、生成单元504以及第一存储单元505)。处理器601通过运行存储在存储器602中的非瞬时软件程序、指令以及模块,从而执行服务器的各种功能应用以及数据处理,即实现上述方法实施例中的用于存储数据的方法。The
存储器602可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储根据用于存储数据的电子设备的使用所创建的数据等。此外,存储器602可以包括高速随机存取存储器,还可以包括非瞬时存储器,例如至少一个磁盘存储器件、闪存器件、或其他非瞬时固态存储器件。在一些实施例中,存储器602可选包括相对于处理器601远程设置的存储器,这些远程存储器可以通过网络连接至用于存储数据的电子设备。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The
用于存储数据的方法的电子设备还可以包括:输入装置603和输出装置604。处理器601、存储器602、输入装置603和输出装置604可以通过总线或者其他方式连接,图6中以通过总线连接为例。The electronic device used in the method for storing data may further include: an
输入装置603可接收输入的数字或字符信息,以及产生与用于存储数据的电子设备的用户设置以及功能控制有关的键信号输入,例如触摸屏、小键盘、鼠标、轨迹板、触摸板、指示杆、一个或者多个鼠标按钮、轨迹球、操纵杆等输入装置。输出装置604可以包括显示设备、辅助照明装置(例如,LED)和触觉反馈装置(例如,振动电机)等。该显示设备可以包括但不限于,液晶显示器(LCD)、发光二极管(LED)显示器和等离子体显示器。在一些实施方式中,显示设备可以是触摸屏。The
此处描述的系统和技术的各种实施方式可以在数字电子电路系统、集成电路系统、专用ASIC(专用集成电路)、计算机硬件、固件、软件、和/或它们的组合中实现。这些各种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。Various implementations of the systems and techniques described herein can be implemented in digital electronic circuitry, integrated circuit systems, application specific ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include being implemented in one or more computer programs executable and/or interpreted on a programmable system including at least one programmable processor, the programmable processor Can be special-purpose or general-purpose programmable processor, can receive data and instruction from storage system, at least one input device, and at least one output device, and transmit data and instruction to this storage system, this at least one input device, and this at least one output device an output device.
这些计算程序(也称作程序、软件、软件应用、或者代码)包括可编程处理器的机器指令,并且可以利用高级过程和/或面向对象的编程语言、和/或汇编/机器语言来实施这些计算程序。如本文使用的,术语“机器可读介质”和“计算机可读介质”指的是用于将机器指令和/或数据提供给可编程处理器的任何计算机程序产品、设备、和/或装置(例如,磁盘、光盘、存储器、可编程逻辑装置(PLD)),包括,接收作为机器可读信号的机器指令的机器可读介质。术语“机器可读信号”指的是用于将机器指令和/或数据提供给可编程处理器的任何信号。These computing programs (also referred to as programs, software, software applications, or codes) include machine instructions for a programmable processor and may be implemented using high-level procedural and/or object-oriented programming languages, and/or assembly/machine language calculation program. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or means for providing machine instructions and/or data to a programmable processor ( For example, magnetic disks, optical disks, memories, programmable logic devices (PLDs), including machine-readable media that receive machine instructions as machine-readable signals. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
为了提供与用户的交互,可以在计算机上实施此处描述的系统和技术,该计算机具有:用于向用户显示信息的显示装置(例如,CRT(阴极射线管)或者LCD(液晶显示器)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给计算机。其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。To provide for interaction with the user, the systems and techniques described herein can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user. ); and a keyboard and pointing device (eg, a mouse or a trackball) through which a user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and can be in any form (including Acoustic input, speech input or, tactile input) to receive input from the user.
可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。通信网络的示例包括:局域网(LAN)、广域网(WAN)和互联网。The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., as a a user computer having a graphical user interface or web browser through which a user can interact with embodiments of the systems and techniques described herein), or including such backend components, middleware components, Or any combination of front-end components in a computing system. The components of the system can be interconnected by any form or medium of digital data communication, eg, a communication network. Examples of communication networks include: Local Area Network (LAN), Wide Area Network (WAN) and the Internet.
计算机系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。A computer system may include clients and servers. Clients and servers are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by computer programs running on the respective computers and having a client-server relationship to each other.
根据本申请实施例的技术方案,可以为每个实体生成唯一的内部标识信息,并且可以根据内部标识信息所包含的丰富信息,快速定位出实体所在的分片,提高图数据库的查询效率。According to the technical solution of the embodiment of the application, unique internal identification information can be generated for each entity, and the shard where the entity is located can be quickly located according to the rich information contained in the internal identification information, so as to improve the query efficiency of the graph database.
应该理解,可以使用上面所示的各种形式的流程,重新排序、增加或删除步骤。例如,本发申请中记载的各步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本申请公开的技术方案所期望的结果,本文在此不进行限制。It should be understood that steps may be reordered, added or deleted using the various forms of flow shown above. For example, the steps described in the present application may be executed in parallel, sequentially, or in a different order, as long as the desired result of the technical solution disclosed in the present application can be achieved, there is no limitation herein.
上述具体实施方式,并不构成对本申请保护范围的限制。本领域技术人员应该明白的是,根据设计要求和其他因素,可以进行各种修改、组合、子组合和替代。任何在本申请的精神和原则之内所作的修改、等同替换和改进等,均应包含在本申请保护范围之内。The above specific implementation methods are not intended to limit the protection scope of the present application. It should be apparent to those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made depending on design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of this application shall be included within the protection scope of this application.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010325586.4ACN111523001B (en) | 2020-04-23 | 2020-04-23 | Method, device, equipment and storage medium for storing data |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010325586.4ACN111523001B (en) | 2020-04-23 | 2020-04-23 | Method, device, equipment and storage medium for storing data |
| Publication Number | Publication Date |
|---|---|
| CN111523001A CN111523001A (en) | 2020-08-11 |
| CN111523001Btrue CN111523001B (en) | 2023-03-14 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202010325586.4AActiveCN111523001B (en) | 2020-04-23 | 2020-04-23 | Method, device, equipment and storage medium for storing data |
| Country | Link |
|---|---|
| CN (1) | CN111523001B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112559631B (en)* | 2020-12-15 | 2023-09-26 | 北京百度网讯科技有限公司 | Data processing method, device and electronic equipment for distributed graph database |
| CN113312193B (en)* | 2021-06-10 | 2025-08-19 | 北京沃东天骏信息技术有限公司 | Method and device for transmitting information |
| CN113343042B (en)* | 2021-06-29 | 2024-08-23 | 维沃移动通信有限公司 | Data fragment storage method and device, electronic equipment and storage medium |
| CN113434508B (en)* | 2021-06-30 | 2023-09-22 | 北京百度网讯科技有限公司 | Method and apparatus for storing information |
| CN113408945B (en)* | 2021-07-15 | 2023-03-24 | 广西中烟工业有限责任公司 | Method and device for detecting purity of flue-cured tobacco, electronic equipment and storage medium |
| CN114005544A (en)* | 2021-11-12 | 2022-02-01 | 广东省实验动物监测所 | Data management method and system for human disease animal model resources |
| CN114238929B (en)* | 2021-12-20 | 2022-09-13 | 深圳市德仪电子科技有限公司 | MCU chip with built-in operational amplifier and application thereof in frequency conversion system |
| CN116383454B (en)* | 2023-04-10 | 2024-01-30 | 星环信息科技(上海)股份有限公司 | Data query method of graph database, electronic equipment and storage medium |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1321277A (en)* | 1999-08-31 | 2001-11-07 | 清水勋 | Database system |
| EP3035595A1 (en)* | 2014-12-17 | 2016-06-22 | Alcatel Lucent | Routable distributed database for managing a plurality of entities of a telecommunication network |
| WO2019067024A1 (en)* | 2017-09-29 | 2019-04-04 | Oracle International Corporation | Handling semi-structured and unstructured data in a sharded database environment |
| CN110737663A (en)* | 2019-10-15 | 2020-01-31 | 腾讯科技(深圳)有限公司 | data storage method, device, equipment and storage medium |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US11354348B2 (en)* | 2017-06-29 | 2022-06-07 | Microsoft Technology Licensing, Llc | Optimized record placement in graph database |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1321277A (en)* | 1999-08-31 | 2001-11-07 | 清水勋 | Database system |
| EP3035595A1 (en)* | 2014-12-17 | 2016-06-22 | Alcatel Lucent | Routable distributed database for managing a plurality of entities of a telecommunication network |
| WO2019067024A1 (en)* | 2017-09-29 | 2019-04-04 | Oracle International Corporation | Handling semi-structured and unstructured data in a sharded database environment |
| CN110737663A (en)* | 2019-10-15 | 2020-01-31 | 腾讯科技(深圳)有限公司 | data storage method, device, equipment and storage medium |
| Title |
|---|
| 大规模图数据查询处理关键技术研究;成雨蓉;《中国博士学位论文全文数据库(电子期刊)》;全文* |
| Publication number | Publication date |
|---|---|
| CN111523001A (en) | 2020-08-11 |
| Publication | Publication Date | Title |
|---|---|---|
| CN111523001B (en) | Method, device, equipment and storage medium for storing data | |
| CN111522967B (en) | Knowledge graph construction method, device, equipment and storage medium | |
| CN112269789B (en) | Method and device for storing data, and method and device for reading data | |
| CN112069201A (en) | Target data acquisition method and device | |
| CN111259107B (en) | Determinant text storage method and device and electronic equipment | |
| CN112579897B (en) | Information searching method and device | |
| CN113220710B (en) | Data query method, device, electronic device and storage medium | |
| EP3816817B1 (en) | Method and apparatus for importing data into graph database, electronic device and medium | |
| CN111966633A (en) | Method, device, electronic equipment and medium for inquiring child nodes under directory | |
| CN112015468A (en) | Interface document processing method and device, electronic equipment and storage medium | |
| CN111523007A (en) | User interest information determination method, device, equipment and storage medium | |
| CN112528067A (en) | Graph database storage method, graph database reading method, graph database storage device, graph database reading device and graph database reading equipment | |
| CN112115313A (en) | Regular expression generation, data extraction method, apparatus, equipment and medium | |
| CN111767321A (en) | Method, device, electronic device and storage medium for determining node relationship network | |
| CN111523000B (en) | Method, apparatus, device and storage medium for importing data | |
| CN111737404A (en) | Data processing method, apparatus, device and computer storage medium | |
| CN112069137A (en) | Method and device for generating information, electronic equipment and computer readable storage medium | |
| CN111782633B (en) | Data processing method and device and electronic equipment | |
| CN111290714B (en) | Data reading method and device | |
| CN111177479B (en) | Method and device for acquiring feature vector of node in relational network graph | |
| CN111966576A (en) | Abnormal code positioning method and device, electronic equipment and storage medium | |
| CN111459887A (en) | Resource screening method and device, electronic equipment and storage medium | |
| CN116303298A (en) | Method, device, equipment and storage medium for managing cache data | |
| CN111506737B (en) | Graph data processing method, retrieval method, device and electronic equipment | |
| CN112507100A (en) | Method and device for updating question-answering system |
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |