WO2020087796A1 - 一种基于键值对的数据查找方法、装置及计算机设备 - Google Patents
一种基于键值对的数据查找方法、装置及计算机设备 Download PDFInfo
- Publication number
- WO2020087796A1 WO2020087796A1 PCT/CN2019/073952 CN2019073952W WO2020087796A1 WO 2020087796 A1 WO2020087796 A1 WO 2020087796A1 CN 2019073952 W CN2019073952 W CN 2019073952W WO 2020087796 A1 WO2020087796 A1 WO 2020087796A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- product
- key
- searched
- category
- value
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
Definitions
- the present application relates to the technical field of data processing, and in particular to a data search method, device and equipment based on key-value pairs.
- the company will store the data information corresponding to each product in the database.
- the user uses the company ’s own APP to enter the product name from the search entrance on the APP, and then directly retrieves the data information corresponding to the product name from the database. For user reference.
- the product name and corresponding product data cannot be returned at the same time through an interface.
- the product name and corresponding product data are stored locally on the mobile terminal, and then returned to the corresponding APP interface, which will increase the storage process and thus increase the search time. , Which brings inconvenience to the search of product data.
- the present application provides a data search method, device and device based on key-value pairs.
- the main purpose is to solve the technical problem that the product name and corresponding product data cannot be returned at the same time through an interface when the product data is currently searched, and then it is stored locally, resulting in an extended search time.
- a data search method based on key-value pairs includes:
- each product name to be searched corresponds to at least one product feature to be searched, and each product feature to be searched corresponds to a product to be searched Find key value;
- a data search device based on key-value pairs comprising:
- An obtaining unit configured to obtain a product feature to be searched corresponding to a product name to be searched, and determine a key value to be searched according to the product feature to be searched, wherein each product name to be searched corresponds to at least one product feature to be searched, and each product to be searched Product features correspond to a key value to be found;
- a searching unit used to determine the category of the key value to be searched, and searching the corresponding category bucket to be searched from the database according to the category of the key value to be searched;
- the searching unit is further used to search for the key-value pair to be searched corresponding to the key-value to be searched from the category bucket to be searched using a hash algorithm, wherein at least one key-value pair is stored in each category bucket;
- the output unit is configured to search for target product data corresponding to the characteristics of the product to be searched and the corresponding target output interface according to the key-value pair to be searched, and output the target product data through the target output interface, wherein, Each key-value pair corresponds to an output interface.
- a computer non-volatile readable storage medium on which computer readable instructions are stored, and when the computer readable instructions are executed by a processor, the following steps are realized:
- each product name to be searched corresponds to at least one product feature to be searched, and each product feature to be searched corresponds to a product to be searched Find key value;
- a computer device which includes a memory, a processor, and computer-readable instructions stored on the memory and executable on the processor.
- the processor implements the program to implement the following steps:
- each product name to be searched corresponds to at least one product feature to be searched, and each product feature to be searched corresponds to a product to be searched Find key value;
- a data search method, device and device based on key-value pairs can store the product characteristics and product data of the product as a mode of key-value pairs, and divide these key-value pairs into various In the category bucket, when the user wants to find the product data of the corresponding product, he only needs to use the hash algorithm to find the corresponding key-value pair from the category bucket, and then pass the product data corresponding to the key-value pair with the key-value pair.
- the corresponding output interface is output and displayed to the user. It effectively avoids that when multiple product data are output, multiple product data share one output interface, which causes the output interface to be blocked, thereby speeding up the search of product data.
- FIG. 1 is a flowchart of an embodiment of a key-value pair-based data search method of the present application
- Figure 2 is a composition diagram of the key-value pairs of this application.
- Figure 3 is a diagram of the search procedure of the hash algorithm of the present application.
- FIG. 4 is a flowchart of another embodiment of a key-value pair-based data search method of this application.
- FIG. 5 is a structural block diagram of an embodiment of a key-value pair-based data search device of the present application.
- FIG. 6 is a schematic structural diagram of a computer device of the present application.
- Embodiments of the present application provide a key-value pair-based data search method, which can store product characteristics and product data of a product as a key-value pair mode, and divide these key-value pairs into buckets of various categories, so that when the user When you want to find the product data of the corresponding product, you only need to use the hash algorithm to find the corresponding key-value pair from the category bucket, and then display the product data corresponding to the key-value pair to the user, thereby speeding up the search of the product data.
- an embodiment of the present application provides a data search method based on key-value pairs.
- the steps include:
- Step 101 Obtain the product feature to be searched corresponding to the product name to be searched, and determine the key value to be searched according to the product feature to be searched, wherein each product name to be searched corresponds to at least one product feature to be searched, and at least one key value to be searched .
- the system will search for the corresponding feature to be found according to the product name to be found ( For example, product type, product color, production date, etc.). Among them, the system will associate the product features corresponding to each product name, and match each product feature to the corresponding key value, and store the list in the system.
- Step 102 Determine the category of the key value to be searched, and search the corresponding category bucket to be searched from the database according to the category of the key value to be searched.
- the code corresponding to each key value has a symbol that marks the key value category at the head or tail of the code, so that only the head or tail of the code of the key value to be found can be determined
- the category of the key value to be searched, and then the category bucket to be searched corresponding to the product data to be searched is found.
- Step 103 a hash algorithm is used to search for a key-value pair to be searched corresponding to the key-value to be searched from the category bucket to be searched, wherein at least one key-value pair is stored in each category bucket.
- each key value corresponds to a hash code (hashcode), that is, a key value pair, so that the hash algorithm can be used to obtain the corresponding hashcode (ie, the key value to be found) according to the key value to be searched (key key) Correct).
- Step 104 Find target product data corresponding to the feature of the product to be found and the corresponding target output interface according to the key-value pair to be searched, and output the target product data through the target output interface, where each key-value pair corresponds to an output interface.
- a hash algorithm is used to obtain the corresponding position of the target product data (value) in the category bucket to be searched according to the hashcode (key-value pair to be searched), and the corresponding target product data is extracted from the corresponding position.
- the target product data is: product type: travel shoes, product color: red, yellow and blue, production date: May 25, 2017, etc.
- the product characteristics and product data of the product can be stored as a mode of key-value pairs, and these key-value pairs can be divided into various categories of buckets.
- the user wants to find the product data of the corresponding product, only Use the hash algorithm to find the corresponding key-value pair from the category bucket, and then output the product data corresponding to the key-value pair through the output interface corresponding to the key-value pair, and display it to the user. It effectively avoids that when multiple product data are output, multiple product data share one output interface, which causes the output interface to be blocked, thereby speeding up the search of product data.
- step (1) at least one product feature corresponding to each product name and product data corresponding to the product feature are collected.
- step (2) the product features are converted into corresponding key values, the key values and corresponding product data are formed into key value pairs, and the corresponding output interfaces are matched for the key value pairs.
- the product features and corresponding product data of various products are collected for subsequent users to search, and the product features and product data are matched into a form of key-value pairs. And in order to facilitate the output of the product data, the corresponding output interface is matched for each key-value pair.
- the corresponding product characteristics are: washing weight, production date, product color, working power, etc.
- the corresponding product data are: 7.5kg, December 1, 2017, silver white, 500w / h.
- the key-value pairs of product features and product data are: 001-7.5kg, 002-December 1, 2017, 003-silver, 004-500w / h.
- match the corresponding output interface for the key-value pair match the corresponding output interface for the key-value pair.
- the output interface of 001-7.5kg is output port 1, 002—December 1, 2017 is output port 2, 003—silver and white is output port 3, 004 —500w / h is output port 4.
- step (3) the key-value pair is matched with the corresponding mapping relationship by means of hash mapping.
- Hashmap a mapping operation is provided for each key-value pair, that is, a key-value pair mapping relationship, and null values and null keys are allowed.
- Step (4) Classify the key-value pairs according to the mapping relationship, and place at least one key-value pair corresponding to each class and the output interface corresponding to the key-value pair in the corresponding class bucket.
- mapping relationship between these key-value pairs is divided into categories buckets corresponding to each category, and the mapping relationship between the key-value pairs is appropriately distributed between the category buckets using a hash function.
- Basic operations get and put provide stable performance.
- Step (5) store the category bucket in the database.
- the category buckets with multiple key-value pairs and corresponding output interfaces are stored in the database according to the different categories, so as to find the corresponding category buckets from the database according to the category.
- the product characteristics and corresponding product data of each product can be converted into corresponding key-value pairs, and the corresponding output interface is matched for each key-value pair, which can prevent multiple product data from being output at the same time and occupying the same An output interface, and the output interface is blocked. Then use the hash algorithm to classify these key-value pairs and store them in the category bucket of the corresponding category, so that you can find the corresponding key-value pairs from the category bucket according to the key value corresponding to the product characteristics of a product, and then adjust Taking product features of a product that the user needs makes the entire search process convenient and fast.
- step 103 If in step 103, the key-value pair to be searched corresponding to the key-value to be searched is not found from the category bucket to be searched, it proves that the database does not store product data corresponding to one or more product features of the product to be searched for.
- the data search method based on key-value pairs in this embodiment further includes:
- Step A Find all network product features corresponding to the name of the product to be searched through the network.
- Step B Delete all network product features that are the same as the product features to be found, and the remaining network product features are missing product features.
- Step C Find missing product data corresponding to missing product features from the network.
- the website addresses corresponding to the missing product features are obtained, and these websites are accessed to obtain corresponding missing product data according to the missing product features. And download the missing product data to the cache database.
- Step D Match the corresponding missing output interface for the missing product data, and output the missing product data through the missing output interface.
- this step after finding the missing product data corresponding to the name of the product to be found that is not in the database from the network, directly match the corresponding missing output interface for these missing product data (where different missing product data correspond to different missing outputs interface). Then it is combined with the target product data found in the above steps and output through their respective output interfaces.
- Step E Convert the missing product features into corresponding missing key values, form the missing key values and corresponding missing product data into missing key value pairs, and map the missing key value pairs to the corresponding missing output interfaces.
- Step F Determine the corresponding categories for the missing key-value pairs by means of hash mapping, and place the missing key-value pairs and the corresponding missing output interfaces in the corresponding category buckets, and update the corresponding category buckets.
- Step G store the updated category bucket in the database.
- the missing product data corresponding to the product name to be found from the network needs to be added to the corresponding In the category bucket, to ensure that the product data corresponding to the name of the product to be searched can be found later in the category bucket, it can be found in the category bucket of the database without having to obtain it from the network, which saves the search time of the product data.
- step (5) the method of this embodiment further includes:
- step (5 ') the key-value pair is used to lay out each category bucket by iterating the collection view to obtain a search graph corresponding to each category bucket.
- the corresponding step 103 specifically includes: retrieving the search graph in the category bucket to be searched, and obtaining the corresponding key-value pair to be searched from the search graph according to the key value to be searched.
- the iterative collection view in the hash algorithm is used to lay out the key-value pairs in each category bucket, and then the key-value pairs in each category bucket are searched by grid, stack, circle, etc.
- the graphics are stored, so that you can directly find the product data that the user needs according to the corresponding search graphics in the category bucket.
- the collection view can dynamically change the layout of the search graphics, or lay out the search graphics in any arrangement you can imagine.
- Step (1) specifically includes:
- Step (11) retrieve the URL of at least one website corresponding to each product name.
- step (12) the website is accessed through a web address, and the product features corresponding to each product name and product data corresponding to the product features in the website are obtained.
- step (11 ') after receiving the setting commands for each product name, the setting window corresponding to each product name is displayed for the user to input the product characteristics and product data corresponding to the product name in the corresponding setting window.
- Step (5) specifically includes:
- step (51) the set password is used to encrypt buckets of each category, wherein the set passwords of buckets of each category are the same or different numbers.
- the password for category I buckets is set to 263 *
- the password for category II buckets is set to 264 *, etc.
- the passwords for these category buckets are uniformly set to 2596.
- Step (52) matching a corresponding symbol code for each encrypted category bucket, where the symbol code corresponds to the category of each encrypted category bucket.
- the passwords corresponding to the buckets of each category can be better distinguished to avoid confusion in the passwords of buckets of each category.
- the corresponding step 103 specifically includes:
- the product characteristics and product data of the product can be stored as a mode of key-value pairs, and these key-value pairs can be divided into various categories of buckets.
- a data search method based on key-value pairs includes the following steps:
- Data update, data (that is, product features and product data) acquisition methods are mainly divided into two methods: network interface acquisition and manual input, which realizes real-time data update and data scalability, and two sources of data acquisition data source
- network interface acquisition is mainly done by the administrator to add data in the background management.
- the APP will request the background interface to complete the update of the local data when the data needs to be updated. Call to complete the update of the data. In order to ensure the security of the data, it is necessary to encrypt the data obtained.
- each product feature corresponds to the corresponding product data.
- the product data corresponding to the product feature can be simply understood as a key-value pair.
- the form is stored in the database, as shown in Figure 2, in the figure, key-value Paies, that is, key-value pairs, key represents the key (ie, product characteristics), and value represents the key value (ie, product data). Match the corresponding output interface for each value.
- Fast data search and matching is a main module for fast query based on key-value pairs.
- the key-value query mainly uses Hashmap, which is based on the realization of Map interface of hash table.
- HashMap is used as an out-of-order storage solution, and the data search speed is fast.
- the layout is iterated by using the iterative collection view to obtain the search graphs such as grid, stack, and circle.
- the layout of the graph, or the layout of the search graph composed of the arrangement mode set by the user.
- the time required to iterate the collection view for layout is proportional to the number of category buckets and the number of mapping relationships between the largest key-value pairs that the category bucket can store.
- the first step is to use the hash algorithm to obtain the hashcode according to the key in the search graph in the corresponding category bucket.
- Method: int hash hash (key.hashCode ()).
- the second step is to obtain the corresponding position of the value in the search graph according to the hashcode, and extract the corresponding value from the corresponding position.
- Method: int indexFor (hash, table.length).
- a key can be converted into a fixed position, which is also the reason for quick search.
- the user needs to obtain the corresponding product data, he can get the location of the value corresponding to the key, and quickly retrieve the value.
- the bottom layer of hashmap is realized with data
- the specific program code is:
- transientEntry [] table the table here is used to store data.
- Entry represents a variable.
- Step 401 the network obtains product data, and directly proceeds to step 403.
- Step 402 manually enter the product data, and proceed to step 403.
- Step 403 Encrypt the product data.
- Step 404 Store product data.
- Step 405 Search product data.
- step 406 it is judged whether the corresponding product data is found. If yes, step 407 is entered; otherwise, step 408 is entered.
- step 407 the product data is decrypted and output.
- Step 408 the network obtains the product name.
- Step 409 Find missing product data.
- Step 410 encrypt the missing product data, and then enter step 407.
- Step 411 Display product data.
- the user when the user wants to find the product data of the corresponding product, he only needs to use the hash algorithm to find the corresponding key-value pair from the category bucket, and then pass the product data corresponding to the key-value pair to the key-value pair.
- the output interface output, to achieve the purpose of quickly searching product data. In addition, it can effectively find and display the missing product data quickly.
- an embodiment of the present application provides a key-value pair-based data search device.
- the device includes an acquisition unit 51, a search unit 52, and an output unit 53.
- the obtaining unit 51 is configured to obtain the product characteristics to be searched corresponding to the product name to be searched, and determine the key value to be searched according to the product characteristics to be searched, wherein each product name to be searched corresponds to at least one product characteristic to be searched, and each product to be searched The feature corresponds to a key value to be found;
- the searching unit 52 is used to determine the category of the key value to be searched, and search the corresponding category bucket to be searched from the database according to the category of the key value to be searched;
- the searching unit 52 is also used to search for the key-value pair to be searched corresponding to the key-value to be searched from the category bucket to be searched using the hash algorithm, wherein at least one key-value pair is stored in each category bucket;
- the output unit 53 is configured to find target product data corresponding to the characteristics of the product to be searched according to the key-value pair to be searched, and the corresponding target output interface, and output the target product data through the target output interface, wherein each key-value pair corresponds to Output Interface.
- the device further includes:
- the collection unit is used to collect at least one product feature corresponding to each product name and product data corresponding to the product feature;
- the conversion unit is used to convert product features into corresponding key values, form key value pairs with corresponding product data, and match corresponding output interfaces for the key value pairs;
- the matching unit is used to match the key-value pair with the corresponding mapping relationship by means of hash mapping
- the dividing unit is used to classify the key-value pairs according to the mapping relationship, and place at least one key-value pair corresponding to each category and the output interface corresponding to the key-value pair in the corresponding category bucket;
- the storage unit is used to store the category bucket in the database.
- the collection unit is also used to find all the network product features corresponding to the product name to be searched through the network; delete all network product features that have the same characteristics as the product to be found, and the remaining network product features are missing products Features; find missing product data corresponding to missing product features from the network;
- the output unit 53 is also used to match the corresponding missing output interface for the missing product data, and output the missing product data through the missing output interface.
- the device further includes:
- the update unit is used to convert the missing product features into corresponding missing key values, form the missing key values and corresponding missing product data into missing key value pairs, and map the missing key value pairs to the corresponding missing output interfaces;
- the method of mapping is to determine the corresponding category for the missing key-value pair, and place the missing key-value pair and the corresponding missing output interface in the corresponding category bucket, and update the corresponding category bucket; update the updated category bucket Stored in the database.
- the device further includes:
- the layout unit is used to lay out each category bucket by iterating the collection view using key-value pairs to obtain the search graph corresponding to each category bucket;
- the searching unit 52 is also used to retrieve the search pattern in the category bucket to be searched, and obtain the corresponding key-value pair to be searched from the search pattern according to the key value to be searched.
- the collection unit specifically includes:
- the retrieval module is used to retrieve the URL of at least one website corresponding to each product name
- the access module is used to access the website through the URL and obtain the product features corresponding to each product name on the website and the product data corresponding to the product features;
- the setting module is used to display the setting window corresponding to each product name after receiving the setting command of each product name, so that the user can input the product characteristics and product data corresponding to the product name in the corresponding setting window;
- the receiving module is configured to receive at least one product feature and product data corresponding to each product name transmitted from the setting window.
- the storage unit is also used to encrypt the buckets of each category with a set password, where the set passwords of the buckets of each category are the same or different numbers; the corresponding symbol is matched for each encrypted bucket of the category Code, where the symbol code corresponds to the category of each encrypted category bucket;
- the searching unit 52 is also used to determine the category of the key value to be searched using a hash algorithm, obtain the symbol code corresponding to the category of the key value to be searched, and search the corresponding category bucket to be searched from the database according to the corresponding symbol code, and use Set a password to decrypt the bucket to be searched.
- an embodiment of the present application further provides a computer device, as shown in FIG. Both the 62 and the processor 61 are provided on the bus 63.
- the memory 62 stores computer-readable instructions.
- the processor 61 executes the computer-readable instructions, the data search method based on key-value pairs shown in FIG. 1 is implemented.
- the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile memory (can be a CD-ROM, U disk, mobile hard disk, etc.), including several instructions It is used to enable a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in each implementation scenario of the present application.
- a non-volatile memory can be a CD-ROM, U disk, mobile hard disk, etc.
- a computer device which may be a personal computer, a server, or a network device, etc.
- the device may also be connected to a user interface, a network interface, a camera, a radio frequency (Radio Frequency) circuit, a sensor, an audio circuit, a WI-FI module, and so on.
- the user interface may include a display (Display), an input unit such as a keyboard, and the like, and the optional user interface may also include a USB interface, a card reader interface, and the like.
- the network interface may optionally include a standard wired interface, a wireless interface (such as a Bluetooth interface, and a WI-FI interface).
- a computer device does not constitute a limitation on the physical device, and may include more or less components, or combine certain components, or arrange different components.
- embodiments of the present application also provide a non-volatile readable storage medium on which computer-readable instructions are stored, the program When executed by the processor, the above-mentioned data search method based on key-value pairs shown in FIG. 1 is realized.
- the non-volatile readable storage medium may also include an operating system and a network communication module.
- An operating system is a program that manages the hardware and software resources of a computer device, and supports the operation of information processing programs and other software and / or programs.
- the network communication module is used to realize communication between the components inside the non-volatile readable storage medium, and to communicate with other hardware and software in the computer device.
- the product features and product data of the product can be stored as a mode of key-value pairs, and these key-value pairs can be divided into buckets of various categories.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本申请公开了一种基于键值对的数据查找方法、装置及设备,其中方法包括:获取待查找产品名称对应的待查找产品特征,根据待查找产品特征确定待查找键值;确定待查找键值的类别,根据待查找键值的类别从数据库中搜寻对应的待查找类别桶;利用哈希算法从待查找类别桶中搜寻待查找键值相应的待查找键值对;根据待查找键值对查找与待查找产品特征对应的目标产品数据,以及对应的目标输出接口,将目标产品数据通过目标输出接口输出。通过上述方案,有效避免了产品数据输出时,出现多个产品数据共用一个输出接口,致使输出接口出现堵塞的情况,进而加快产品数据的查找速度。
Description
本申请要求于2018年10月31日提交中国专利局、申请号为201811288568、申请名称为“一种基于键值对的数据查找方法、装置及设备”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
本申请涉及数据处理技术领域,特别是涉及一种基于键值对的数据查找方法、装置及设备。
随着一些公司的发展壮大,公司的产品越来越多,公司的客户想要对这些产品的一些详细的数据信息进行了解时,往往需要通过产品名称直接进行查找。
一般公司会将每个产品对应的数据信息存储在数据库中,用户利用公司自己开发的APP,从APP上的搜索入口输入产品的名称,然后直接从数据库调取与该产品名称对应的数据信息,以供用户参考。
但是,产品名称及相应产品数据无法通过一个接口同时返回,通常将产品名称及相应产品数据存储在移动终端本地,然后再返至相应的APP界面,这样就会增加存储的过程,进而增加查找时间,给产品数据的查找带来不便。
发明内容
有鉴于此,本申请提供了一种基于键值对的数据查找方法、装置及设备。主要目的在于解决目前进行产品数据查找时,产品名称及相应产品数据无法通过一个接口同时返回,进而将其存储在本地,而导致查找时间延长的技术问题。
依据本申请的第一方面,提供了一种基于键值对的数据查找方法,所述方法的步骤包括:
获取待查找产品名称对应的待查找产品特征,根据所述待查找产品特征确定待查找键值,其中,每个待查找产品名称对应至少一个待查找产品特征,每个待查找产品特征对应一个待查找键值;
确定所述待查找键值的类别,根据所述待查找键值的类别从数据库中搜寻对应的待查找类别桶;
利用哈希算法从所述待查找类别桶中搜寻所述待查找键值相应的待查找键值对,其中,每个类别桶中存储有至少一个键值对;
根据所述待查找键值对查找与所述待查找产品特征对应的目标产品数据,以及对应的目标输出接口,将所述目标产品数据通过所述目标输出接口输出,其中,每个键值对对应一个输出接口。
依据本申请的第二方面,提供了一种基于键值对的数据查找装置,所述装置包括:
获取单元,用于获取待查找产品名称对应的待查找产品特征,根据所述待查找产品特征确定待查找键值,其中,每个待查找产品名称对应至少一个待查找产品特征,每个待查找产品特征对应一个待查找键值;
搜寻单元,用于确定所述待查找键值的类别,根据所述待查找键值的类别从数据库中搜寻对应的待查找类别桶;
所述搜寻单元,还用于利用哈希算法从所述待查找类别桶中搜寻所述待查找键值相应的待查找键值对,其中,每个类别桶中存储有至少一个键值对;
输出单元,用于根据所述待查找键值对查找与所述待查找产品特征对应的目标产品数据,以及对应的目标输出接口,将所述目标产品数据通过所述目标输出接口输出,其中,每个键值对对应一个输出接口。
依据本申请的第三方面,提供一种计算机非易失性可读存储介质,其上存储有计算机可读指令,该计算机可读指令被处理器执行时实现以下步骤:
获取待查找产品名称对应的待查找产品特征,根据所述待查找产品特征确定待查找键值,其中,每个待查找产品名称对应至少一个待查找产品特征,每个待查找产品特征对应一个待查找键值;
确定所述待查找键值的类别,根据所述待查找键值的类别从数据库中搜寻对应的待查找类别桶;
利用哈希算法从所述待查找类别桶中搜寻所述待查找键值相应的待查找键值对,其中,每个类别桶中存储有至少一个键值对;
根据所述待查找键值对查找与所述待查找产品特征对应的目标产品数据,以及对应的目标输出接口,将所述目标产品数据通过所述目标输出接口输出,其中,每个键值对对应一个输出接口。
依据本申请的第四方面,提供一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机可读指令,所述处理器执行所述程序时实现以下步骤:
获取待查找产品名称对应的待查找产品特征,根据所述待查找产品特征确定待查找键值,其中,每个待查找产品名称对应至少一个待查找产品特征,每个待查找产品特征对应一个待查找键值;
确定所述待查找键值的类别,根据所述待查找键值的类别从数据库中搜寻对应的待查找类别桶;
利用哈希算法从所述待查找类别桶中搜寻所述待查找键值相应的待查找键值对,其中,每个类别桶中存储有至少一个键值对;
根据所述待查找键值对查找与所述待查找产品特征对应的目标产品数据,以及对应的目标输出接口,将所述目标产品数据通过所述目标输出接口输出,其中,每个键值对对应一个输出接口。
借由上述技术方案,本申请提供的一种基于键值对的数据查找方法、装置及设备,能够将产品的产品特征和产品数据存储为键值对的模式,为这些键值对分到各个类别桶中,这样,当用户想要查找对应产品的产品数据时,只需利用哈希算法从类别桶中找到相应的键值对,进而将键值对对应的产品数据通过与该键值对相应的输出接口输出,并展示给用户。有效避免了产品数据输出时,出现多个产品数据共用一个输出接口,致使输出接口出现堵塞的情况,进而加快产品数据的查找速度。
上述说明仅是本申请技术方案的概述,为了能够更清楚了解本申请的技术手段,而可依照说明书的内容予以实施,并且为了让本申请的上述和其它目的、特征和优点能够更明显易懂,以下特举本申请的具体实施方式。
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本申请的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:
图1为本申请的基于键值对的数据查找方法的一个实施例的流程图;
图2为本申请的键值对的组成图;
图3为本申请的哈希算法查找程序图;
图4为本申请的基于键值对的数据查找方法的另一个实施例的流程图;
图5为本申请的基于键值对的数据查找装置的一个实施例的结构框图;
图6为本申请的计算机设备的结构示意图。
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。 相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。
本申请实施例提供了一种基于键值对的数据查找方法,能够将产品的产品特征和产品数据存储为键值对的模式,为这些键值对分到各个类别桶中,这样,当用户想要查找对应产品的产品数据时,只需利用哈希算法从类别桶中找到相应的键值对,进而将键值对对应的产品数据展示给用户,进而加快产品数据的查找速度。
如图1所示,本申请实施例提供了一种基于键值对的数据查找方法,步骤包括:
步骤101,获取待查找产品名称对应的待查找产品特征,根据待查找产品特征确定待查找键值,其中,每个待查找产品名称对应至少一个待查找产品特征,以及对应至少一个待查找键值。
在该步骤中,当用户想要查找某个产品的产品数据时,从输入窗口输入该产品的产品名称(即待查找产品名称),系统就会根据待查找产品名称查找相应的待查找特征(例如,产品种类、产品颜色、生产日期等)。其中,系统中会将每个产品名称对应的产品特征进行关联,并将每个产品特征匹配相应的键值,并列表存储在系统中。
步骤102,确定待查找键值的类别,根据待查找键值的类别从数据库中搜寻对应的待查找类别桶。
在该步骤中,每个键值相应的代码中,在代码的头部或者尾部都有标记该键值类别的符号,这样只需根据待查找键值的代码的头部或者尾部就能确定该待查找键值的类别,进而找到存放对应待查找产品数据的待查找类别桶。
步骤103,利用哈希算法从待查找类别桶中搜寻待查找键值相应的待查找键值对,其中,每个类别桶中存储有至少一个键值对。
在该步骤中,每个键值对应一个哈希码(hashcode),即键值对,这样就可以利用哈希算法根据待查找键值(key键)得到对应的hashcode(即,待查找键值对)。对应的程序代码为:int hash=hash(key.hashcode())。
步骤104,根据待查找键值对查找与待查找产品特征对应的目标产品数据,以及对应的目标输出接口,将目标产品数据通过目标输出接口输出,其中,每个键值对对应一个输出接口。
在该步骤中,利用哈希算法根据hashcode(待查找键值对)得到目标产品数据(value)在该待查找类别桶中对应的位置,从对应位置中提取相应的目标产品数据。程序代码为:int i=indexFor(hash,table.length)。其中,为了避免产品数据输出时,出现多个产品数据共用一个 输出接口,致使输出接口出现堵塞的情况,本实施例预先为每个键值对匹配相应的输出接口。并将匹配的输出接口与键值对一同存储在对应的类别桶中。
将目标产品数据从目标输出接口输出,如果用户需要的待查找产品名称,找到多个目标产品数据,就将这多个目标产品数据同时从对应的多个目标输出接口输出,并在显示装置上显示给用户。例如,显示内容有,产品种类:旅游鞋、产品颜色:红黄蓝相间、生产日期:2017年5月25日等。
通过上述技术方案,能够将产品的产品特征和产品数据存储为键值对的模式,为这些键值对分到各个类别桶中,这样,当用户想要查找对应产品的产品数据时,只需利用哈希算法从类别桶中找到相应的键值对,进而将键值对对应的产品数据通过与该键值对相应的输出接口输出,并展示给用户。有效避免了产品数据输出时,出现多个产品数据共用一个输出接口,致使输出接口出现堵塞的情况,进而加快产品数据的查找速度。
本实施例的基于键值对的数据查找方法,还包括:
步骤(1),收集每个产品名称相应的至少一个产品特征,以及产品特征对应的产品数据。
步骤(2),将产品特征转换成相应的键值,将键值与对应的产品数据组成键值对,并为键值对匹配相应的输出接口。
在该步骤中,将各种产品的产品特征以及对应的产品数据收集起来,以供后续用户进行查找,将产品特征与产品数据匹配成键值对的形式。并且为了便于该产品数据的输出,为每个键值对匹配相应的输出接口。
例如,针对产品波轮洗衣机,对应的产品特征有:洗涤重量、生产日期、产品颜色、工作功率等,对应的产品数据为:7.5kg、2017年12月1日、银白色、500w/h。然后,为波轮洗衣机的产品特征匹配相应的键值,洗涤重量:001,生产日期:002,产品颜色:003,工作功率:004。则产品特征与产品数据组成的键值对为:001—7.5kg,002—2017年12月1日,003—银白色,004—500w/h。最后,为键值对匹配相应的输出接口,001—7.5kg的输出接口为1号输出口,002—2017年12月1日为2号输出口,003—银白色为3号输出口,004—500w/h为4号输出口。
步骤(3),利用哈希映射的方式将键值对匹配相应的映射关系。
在该步骤中,通过哈希映射(Hashmap)的方式,为每个键值对提供映射操作,即键值对映射关系,并允许使用null值和null键。
步骤(4),根据映射关系对键值对进行类别划分,并将各个类别对应的至少一个键值对,以及与键值对相对应的输出接口放置在对应的类别桶中。
在该步骤中,为这些键值对的映射关系进行类别划分,分到各个类别对应的类别桶中,利用哈希函数将键值对的映射关系适当地分布在各类别桶之间,可为基本操作(get和put)提供稳定的性能。
步骤(5),将类别桶存储在数据库中。
在该步骤中,将存储有多个键值对及对应输出接口的类别桶,按照类别的不同在数据库中进行存储,以便根据类别从数据库中查找相应的类别桶。
通过上述技术方案,能够将每个产品的产品特征和对应的产品数据转换成相应的键值对,为每个键值对匹配相应的输出接口,能够防止多个产品数据同时输出时,占用同一个输出接口,而导致输出接口堵塞的情况出现。再利用哈希算法将这些键值对进行类别划分后存储在对应类别的类别桶中,这样就可以根据某产品的产品特征对应的键值,从类别桶中查找相应的键值对,进而调取用户需要的某产品的产品特征,使得整个查找过程方便快速。
若步骤103中,从待查找类别桶中未搜寻到待查找键值相应的待查找键值对,证明数据库中并没有存储该待查找产品的一个或多个产品特征对应的产品数据。
则需要对数据库中存储的类别桶进行更新,因此,本实施例的基于键值对的数据查找方法,还包括:
步骤A,通过网络查找与待查找产品名称相对应的所有网络产品特征。
在该步骤中,首先确定有该待查找产品名称的所有网站,并提取网站地址,对网站进行访问,将各个网站中的与该待查找产品名称相关的所有产品特征都集中在一起,然后将相同的产品特征只保留一条其余的删除,对剩余的产品特征进行汇总作为网络产品特征。
步骤B,将所有网络产品特征中,与待查找产品特征相同的网络产品特征删除,剩余的网络产品特征为缺失产品特征。
在该步骤中,汇总到一起的所有网络产品特征中有一些与待查找产品特征相同,有一些与待查找产品特征不同,因此为了避免这些与待查找产品特征相同的网络产品特征的干扰,需要将其删除。剩余的网络产品特征才是需要进行补充的缺失产品特征。
步骤C,从网络中查找缺失产品特征对应的缺失产品数据。
在该步骤中,获取缺失产品特征对应的网站地址,并对这些网站进行访问,根据缺失产品特征获取相应的缺失产品数据。并将缺失产品数据下载下来保存到缓存数据库中。
步骤D,为缺失产品数据匹配相应的缺失输出接口,将缺失产品数据通过缺失输出接口输出。
在该步骤中,从网络中找到了数据库中没有的待查找产品名称对应的缺失产品数据后,直接为这些缺失产品数据匹配相应的缺失输出接口(其中,不同的缺失产品数据对应不同的 缺失输出接口)。然后与上述步骤中查找到的目标产品数据组合在一起,并通过各自的输出接口输出。
通过上述技术方案,在数据库的类别桶中对用户需要的产品的产品数据进行查找过程中,若数据库的类别桶中无法找到对应的产品数据,或者只找到一部分对应的产品数据,则需要根据该产品名称在网络中进行查找,并将对应缺失产品数据与已经找到的目标产品数据,一起通过对应的输出接口输出,展示给用户。这样能够保证为用户展示的产品数据的完整性。
步骤E,将缺失产品特征转换成相应的缺失键值,将缺失键值与对应的缺失产品数据组成缺失键值对,将缺失键值对与相应的缺失输出接口进行映射匹配。
步骤F,利用哈希映射的方式为缺失键值对确定相应的类别,并将缺失键值对,以及相对应的缺失输出接口放置在对应的类别桶中,将对应的类别桶进行更新。
步骤G,将更新后的类别桶存储在数据库中。
在上述技术方案中,当发现对应的待查找产品名称对应的产品数据无法在数据库存储的类别桶中全部找到后,需要将从网络找到的该待查找产品名称对应的缺失产品数据补充到相应的类别桶中,进而保证后期再对该待查找产品名称对应的产品数据进行查找时,能够在该数据库的类别桶中全部找到,无需再从网络中获取,节省了产品数据的查找时间。
在步骤(5)之前,本实施例的方法还包括:
步骤(5’),利用键值对通过迭代collection视图的方式对每个类别桶进行布图,得到与每个类别桶相对应的查找图形。
则对应步骤103具体包括:调取待查找类别桶中的查找图形,根据待查找键值从查找图形中获取相应的待查找键值对。
在上述技术方案中,利用哈希算法中迭代collection视图的方式,将各个类别桶中的键值对进行布图,则将各个类别桶中的键值对以网格、栈、圆形等查找图形进行存储,这样就可以直接根据类别桶中对应的查找图形查找用户需要的产品数据,其中collection视图可以动态改变查找图形的布局,或以任何你可以想象的排列对查找图形进行布局。
通过上述技术方案,将各个类别桶中的键值对以网格、栈、圆形等查找图形进行存储,可以加快产品数据的查找时间。
步骤(1)具体包括:
步骤(11),调取每个产品名称对应的至少一个网站的网址。
步骤(12),通过网址对网站进行访问,并获取网站中与各个产品名称对应的产品特征,以及与产品特征对应的产品数据。
和/或,
步骤(11’),接收到各个产品名称的设置命令后,将各个产品名称对应的设置窗口进行显示,以供用户在对应的设置窗口输入与产品名称相对应的产品特征和产品数据。
步骤(12’),接收设置窗口传来的与每个产品名称对应的至少一个产品特征和产品数据。
通过上述技术方案,可以通过两种方式来获取每个产品的多个产品特征和相应的产品数据,分别是通过网络搜寻自动获取,如果网络自动获取的不够完善,用户可以通过设置窗口手动输入相应的产品数据。进而保证搜集的各个产品的产品数据的完整性。
另外,还可以定期(例如,一星期)对数据库中各个类别桶存储数据,进行更新,更新的方式可以是上述任一一种或两种。
步骤(5)具体包括:
步骤(51),利用设定密码为各个类别桶进行加密,其中,各个类别桶的设定密码为相同或不同数码。
例如,对于I类别桶的密码设置成263*,II类别桶的密码设置成264*等,或者将这些类别桶的密码统一设置成2596。
这样可以保证各个类别桶内存储数据的安全性,并且各个类别桶的密码可以定期调整,以避免密码泄密之后,有人盗取类别桶内数据。
步骤(52),为每个加密后的类别桶匹配相应的符号代码,其中,符号代码与各个加密后的类别桶的类别相对应。
在该步骤中,能够更好的区别各个类别桶对应的密码,避免各个类别桶的密码出现混淆的情况。
则对应的步骤103具体包括:
利用哈希算法确定待查找键值的类别,获取待查找键值的类别对应的符号代码,根据对应的符号代码从数据库中搜寻对应的待查找类别桶,并利用设定密码对待查找类别桶进行解密。
通过以上加密和解密的过程,能够有效保证各个类别桶内存储的数据的安全性,避免数据被盗取。
通过本实施例的技术方案,,能够将产品的产品特征和产品数据存储为键值对的模式,为这些键值对分到各个类别桶中,这样,当用户想要查找对应产品的产品数据时,只需利用哈希算法从类别桶中找到相应的键值对,进而将键值对对应的产品数据通过与该键值对相应的输出接口输出,并展示给用户。有效避免了产品数据输出时,出现多个产品数据共用一个输出接口,致使输出接口出现堵塞的情况,进而加快产品数据的查找速度。
在本申请的另一个实施例的基于键值对的数据查找方法包括如下步骤:
一、数据管理
1、数据更新,数据(即,产品的产品特征和产品数据)获取方式主要分为网络接口获取和手动输入两种方式,实现了数据实时更新和数据可扩展性,两种获取数据方式数据来源不同,网络接口获取主要通过管理员在后台管理中添加数据,APP在获取到有数据需要更新时会请求后台接口,完成对本地数据的更新;手动输入主要通过开发人员对数据管理系统的添加接口调用,完成对数据的更新。为了保证数据的安全性,需要针对获取到的数据进行数据加密。
2、对数据进行存储
数据更新完成后,每个产品特征与相应的产品数据进行对应,数据存储方面可以简单的把产品特征对应的产品数据理解为一个个键值对,根据不同的数据类型将数据以键值对的形式存储在数据库中,如图2所示,图中,key-value paies,即键值对,key表示键(即,产品特征),value表示键值(即,产品数据)。为每个value匹配相应的输出接口。
二、数据查找布局
数据快速查找匹配是基于键值对快速查询的一个主要模块,键值对查询中主要应用了Hashmap,基于哈希表的Map接口的实现。针对业务需求来说,HashMap作为无序存储方案中,数据查找速度快。
具体查找过程如下:
(1)通过Hashmap为每个键值对匹配相应的映射关系,并允许使用null值和null键。这种方式不保证各个键值对的映射关系的顺序,更不保证该顺序恒久不变。
然后,利用哈希函数为这些键值对的映射关系进行类别划分,分到各个类别对应的类别桶中,可为基本操作(get和put)提供稳定的性能。
(2)根据上述得到的各个类别桶以及类别桶内的键值对的映射关系,利用迭代collection视图的方式进行布图,得到网格、栈、圆形等查找图形,collection视图可以动态改变查找图形的布局,或以用户设定的排列方式组成的查找图形进行布局。
其中,迭代collection视图进行布图所需的时间与类别桶的数量及类别桶能够存储的最大键值对的映射关系数量成比例。
(3)利用哈希算法查找相应的value产品数据,具体过程如图3所示。
第一步,在对应的类别桶中的查找图形中利用哈希算法根据key键得到hashcode。方法:int hash=hash(key.hashCode())。
第二步,根据hashcode得到value在查找图形中对应的位置,从对应位置中提取相应的value。方法:int i=indexFor(hash,table.length)。
若在图形中没有找到key键对应的hashcode,证明对应的value产品数据信息缺失,需要通过下述方式进行快速查找相应的value产品数据:
首先,需要根据key键通过网络获取对应产品的名称。
然后,从网络中获取该产品名称对应的所有value产品数据,并将获取到的value产品数据与数据库中该产品名称对应的value产品数据进行比对,查找到数据库中没有的一个或多个value,即缺失产品数据。
这样就可以将一个key转换成一个固定的位置,这也是能够实现快速查找的原因。当用户需要获取对应产品数据的时候,就可以得到该key键对应的value所在的位置,快速取出value。
其中,hashmap底层是用数据实现的,具体程序代码为:
transient Entry[]table;这里的table就是用来存储数据的。
static class Entry<K,V>implements Map.Entry<K,V>{
final K key;
V value;
Entry<K,V>next;
final int hash;}
其中,Entry表示变量。
三、数据输出
获取查找到的value的对应输出接口,通过对应输出接口返回给调用者,并进行展示。
总结上述对应的流程图如图4所示,步骤如下:
步骤401,网络获取产品数据,直接进入步骤403。
步骤402,手动输入产品数据,进入步骤403。
步骤403,对产品数据进行加密。
步骤404,对产品数据进行存储。
步骤405,对产品数据进行查找。
步骤406,判断是否查找到对应的产品数据,是则进入步骤407,否则进入步骤408。
步骤407,将产品数据解密输出。
步骤408,网络获取产品名称。
步骤409,查找缺失的产品数据。
步骤410,对缺失的产品数据进行加密,然后进入步骤407。
步骤411,对产品数据进行展示。
综上所述,当用户想要查找对应产品的产品数据时,只需利用哈希算法从类别桶中找到相应的键值对,进而将键值对对应的产品数据通过与该键值对相应的输出接口输出,实现快速查找产品数据的目的。另外,还能有效对缺失的产品数据进行快速查找并展示。
进一步的,作为图1方法的具体实现,本申请实施例提供了一种基于键值对的数据查找装置,如图5所示,装置包括:获取单元51、搜寻单元52和输出单元53。
获取单元51,用于获取待查找产品名称对应的待查找产品特征,根据待查找产品特征确定待查找键值,其中,每个待查找产品名称对应至少一个待查找产品特征,每个待查找产品特征对应一个待查找键值;
搜寻单元52,用于确定待查找键值的类别,根据待查找键值的类别从数据库中搜寻对应的待查找类别桶;
搜寻单元52,还用于利用哈希算法从待查找类别桶中搜寻待查找键值相应的待查找键值对,其中,每个类别桶中存储有至少一个键值对;
输出单元53,用于根据待查找键值对查找与待查找产品特征对应的目标产品数据,以及对应的目标输出接口,将目标产品数据通过目标输出接口输出,其中,每个键值对对应一个输出接口。
在具体实施例中,装置还包括:
收集单元,用于收集每个产品名称相应的至少一个产品特征,以及产品特征对应的产品数据;
转换单元,用于将产品特征转换成相应的键值,将键值与对应的产品数据组成键值对,并为键值对匹配相应的输出接口;
匹配单元,用于利用哈希映射的方式将键值对匹配相应的映射关系;
划分单元,用于根据映射关系对键值对进行类别划分,并将各个类别对应的至少一个键值对,以及与键值对相对应的输出接口放置在对应的类别桶中;
存储单元,用于将类别桶存储在数据库中。
在具体实施例中,若从待查找类别桶中未搜寻到待查找键值相应的待查找键值对。
则收集单元,还用于通过网络查找与待查找产品名称相对应的所有网络产品特征;将所有网络产品特征中,与待查找产品特征相同的网络产品特征删除,剩余的网络产品特征为缺失产品特征;从网络中查找缺失产品特征对应的缺失产品数据;
输出单元53,还用于为缺失产品数据匹配相应的缺失输出接口,将缺失产品数据通过缺失输出接口输出。
在具体实施例中,装置还包括:
更新单元,用于将缺失产品特征转换成相应的缺失键值,将缺失键值与对应的缺失产品数据组成缺失键值对,将缺失键值对与相应的缺失输出接口进行映射匹配;利用哈希映射的方式为缺失键值对确定相应的类别,并将缺失键值对,以及相对应的缺失输出接口放置在对应的类别桶中,将对应的类别桶进行更新;将更新后的类别桶存储在数据库中。
在具体实施例中,装置还包括:
布图单元,用于利用键值对通过迭代collection视图的方式对每个类别桶进行布图,得到与每个类别桶相对应的查找图形;
搜寻单元52,还用于调取待查找类别桶中的查找图形,根据待查找键值从查找图形中获取相应的待查找键值对。
在具体实施例中,收集单元具体包括:
调取模块,用于调取每个产品名称对应的至少一个网站的网址;
访问模块,用于通过网址对网站进行访问,并获取网站中与各个产品名称对应的产品特征,以及与产品特征对应的产品数据;
和/或,
设置模块,用于接收到各个产品名称的设置命令后,将各个产品名称对应的设置窗口进行显示,以供用户在对应的设置窗口输入与产品名称相对应的产品特征和产品数据;
接收模块,用于接收设置窗口传来的与每个产品名称对应的至少一个产品特征和产品数据。
在具体实施例中,存储单元,还用于利用设定密码为各个类别桶进行加密,其中,各个类别桶的设定密码为相同或不同数码;为每个加密后的类别桶匹配相应的符号代码,其中,符号代码与各个加密后的类别桶的类别相对应;
则搜寻单元52,还用于利用哈希算法确定待查找键值的类别,获取待查找键值的类别对应的符号代码,根据对应的符号代码从数据库中搜寻对应的待查找类别桶,并利用设定密码对待查找类别桶进行解密。
基于上述图1所示方法和图5所示装置的实施例,为了实现上述目的,本申请实施例还提供了一种计算机设备,如图6所示,包括存储器62和处理器61,其中存储器62和处理器61均设置在总线63上存储器62存储有计算机可读指令,处理器61执行计算机可读指令时实现图1所示的基于键值对的数据查找方法。
基于这样的理解,本申请的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储器(可以是CD-ROM,U盘,移动硬盘等)中,包括若干指令用以 使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施场景所述的方法。
可选地,该设备还可以连接用户接口、网络接口、摄像头、射频(Radio Frequency,RF)电路,传感器、音频电路、WI-FI模块等等。用户接口可以包括显示屏(Display)、输入单元比如键盘(Keyboard)等,可选用户接口还可以包括USB接口、读卡器接口等。网络接口可选的可以包括标准的有线接口、无线接口(如蓝牙接口、WI-FI接口)等。
本领域技术人员可以理解,本实施例提供的一种计算机设备的结构并不构成对该实体设备的限定,可以包括更多或更少的部件,或者组合某些部件,或者不同的部件布置。
基于上述如图1所示方法和图5所示装置的实施例,相应的,本申请实施例还提供了一种非易失性可读存储介质,其上存储有计算机可读指令,该程序被处理器执行时实现上述如图1所示的基于键值对的数据查找方法。
非易失性可读存储介质中还可以包括操作系统、网络通信模块。操作系统是管理计算机设备硬件和软件资源的程序,支持信息处理程序以及其它软件和/或程序的运行。网络通信模块用于实现非易失性可读存储介质内部各组件之间的通信,以及与计算机设备中其它硬件和软件之间通信。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到本申请可以借助软件加必要的通用硬件平台的方式来实现,也可以通过硬件实现。
通过应用本申请的技术方案,能够将产品的产品特征和产品数据存储为键值对的模式,为这些键值对分到各个类别桶中,这样,当用户想要查找对应产品的产品数据时,只需利用哈希算法从类别桶中找到相应的键值对,进而将键值对对应的产品数据通过与该键值对相应的输出接口输出,并展示给用户。有效避免了产品数据输出时,出现多个产品数据共用一个输出接口,致使输出接口出现堵塞的情况,进而加快产品数据的查找速度。
本领域技术人员可以理解附图只是一个优选实施场景的示意图,附图中的模块或流程并不一定是实施本申请所必须的。本领域技术人员可以理解实施场景中的装置中的模块可以按照实施场景描述进行分布于实施场景的装置中,也可以进行相应变化位于不同于本实施场景的一个或多个装置中。上述实施场景的模块可以合并为一个模块,也可以进一步拆分成多个子模块。
上述本申请序号仅仅为了描述,不代表实施场景的优劣。以上公开的仅为本申请的几个具体实施场景,但是,本申请并非局限于此,任何本领域的技术人员能思之的变化都应落入本申请的保护范围。
Claims (20)
- 一种基于键值对的数据查找方法,其特征在于,所述方法的步骤包括:获取待查找产品名称对应的待查找产品特征,根据所述待查找产品特征确定待查找键值,其中,每个待查找产品名称对应至少一个待查找产品特征,每个待查找产品特征对应一个待查找键值;确定所述待查找键值的类别,根据所述待查找键值的类别从数据库中搜寻对应的待查找类别桶;利用哈希算法从所述待查找类别桶中搜寻所述待查找键值相应的待查找键值对,其中,每个类别桶中存储有至少一个键值对;根据所述待查找键值对查找与所述待查找产品特征对应的目标产品数据,以及对应的目标输出接口,将所述目标产品数据通过所述目标输出接口输出,其中,每个键值对对应一个输出接口。
- 根据权利要1所述的数据查找方法,其特征在于,在所述获取待查找产品名称对应的待查找产品特征之前,所述方法还包括:收集每个产品名称相应的至少一个产品特征,以及所述产品特征对应的产品数据;将所述产品特征转换成相应的键值,将键值与对应的产品数据组成键值对,并为所述键值对匹配相应的输出接口;利用哈希映射的方式将所述键值对匹配相应的映射关系;根据所述映射关系对所述键值对进行类别划分,并将各个类别对应的至少一个键值对,以及与键值对相对应的输出接口放置在对应的类别桶中;将所述类别桶存储在数据库中。
- 根据权利要2所述的数据查找方法,其特征在于,若从所述待查找类别桶中未搜寻到所述待查找键值相应的待查找键值对,则所述方法还包括:通过网络查找与所述待查找产品名称相对应的所有网络产品特征;将所有网络产品特征中,与所述待查找产品特征相同的网络产品特征删除,剩余的网络产品特征为缺失产品特征;从网络中查找所述缺失产品特征对应的缺失产品数据;为所述缺失产品数据匹配相应的缺失输出接口,将所述缺失产品数据通过所述缺失输出接口输出。
- 根据权利要3所述的数据查找方法,其特征在于,在为所述缺失产品数据匹配相应 的缺失输出接口,将所述缺失产品数据通过所述缺失输出接口输出之后,还包括:将所述缺失产品特征转换成相应的缺失键值,将缺失键值与对应的缺失产品数据组成缺失键值对,将所述缺失键值对与相应的缺失输出接口进行映射匹配;利用哈希映射的方式为所述缺失键值对确定相应的类别,并将所述缺失键值对,以及相对应的缺失输出接口放置在对应的类别桶中,将对应的类别桶进行更新;将更新后的类别桶存储在数据库中。
- 根据权利要2所述的数据查找方法,其特征在于,在将所述类别桶存储在数据库中之前,所述方法还包括:利用键值对通过迭代collection视图的方式对每个类别桶进行布图,得到与每个类别桶相对应的查找图形;利用哈希算法从所述待查找类别桶中搜寻所述待查找键值相应的待查找键值对,具体包括:调取所述待查找类别桶中的查找图形,根据所述待查找键值从查找图形中获取相应的待查找键值对。
- 根据权利要2所述的数据查找方法,其特征在于,所述收集每个产品名称相应的至少一个产品特征,以及所述产品特征对应的产品数据,具体包括:调取每个产品名称对应的至少一个网站的网址;通过网址对网站进行访问,并获取网站中与各个产品名称对应的产品特征,以及与所述产品特征对应的产品数据;和/或,接收到各个产品名称的设置命令后,将各个产品名称对应的设置窗口进行显示,以供用户在对应的设置窗口输入与产品名称相对应的产品特征和产品数据;接收设置窗口传来的与每个产品名称对应的至少一个产品特征和产品数据。
- 根据权利要2-6任一项所述的数据查找方法,其特征在于,将所述类别桶存储在数据库中,具体包括:利用设定密码为各个类别桶进行加密,其中,各个类别桶的设定密码为相同或不同数码;为每个加密后的类别桶匹配相应的符号代码,其中,所述符号代码与各个加密后的类别桶的类别相对应;所述利用哈希算法确定所述待查找键值的类别,根据所述待查找键值的类别从数据库中搜寻对应的待查找类别桶,具体包括:利用哈希算法确定所述待查找键值的类别,获取所述待查找键值的类别对应的符号代码,根据对应的符号代码从数据库中搜寻对应的待查找类别桶,并利用设定密码对待查找类别桶进行解密。
- 一种基于键值对的数据查找装置,其特征在于,所述装置包括:获取单元,用于获取待查找产品名称对应的待查找产品特征,根据所述待查找产品特征确定待查找键值,其中,每个待查找产品名称对应至少一个待查找产品特征,每个待查找产品特征对应一个待查找键值;搜寻单元,用于确定所述待查找键值的类别,根据所述待查找键值的类别从数据库中搜寻对应的待查找类别桶;所述搜寻单元,还用于利用哈希算法从所述待查找类别桶中搜寻所述待查找键值相应的待查找键值对,其中,每个类别桶中存储有至少一个键值对;输出单元,用于根据所述待查找键值对查找与所述待查找产品特征对应的目标产品数据,以及对应的目标输出接口,将所述目标产品数据通过所述目标输出接口输出,其中,每个键值对对应一个输出接口。
- 根据权利要求8所述的装置,其特征在于,装置还包括:收集单元,用于收集每个产品名称相应的至少一个产品特征,以及产品特征对应的产品数据;转换单元,用于将产品特征转换成相应的键值,将键值与对应的产品数据组成键值对,并为键值对匹配相应的输出接口;匹配单元,用于利用哈希映射的方式将键值对匹配相应的映射关系;划分单元,用于根据映射关系对键值对进行类别划分,并将各个类别对应的至少一个键值对,以及与键值对相对应的输出接口放置在对应的类别桶中;存储单元,用于将类别桶存储在数据库中。
- 根据权利要求9所述的装置,其特征在于,若从待查找类别桶中未搜寻到待查找键值相应的待查找键值对;所述收集单元,还用于通过网络查找与待查找产品名称相对应的所有网络产品特征;将所有网络产品特征中,与待查找产品特征相同的网络产品特征删除,剩余的网络产品特征为缺失产品特征;从网络中查找缺失产品特征对应的缺失产品数据;所述输出单元,还用于为缺失产品数据匹配相应的缺失输出接口,将缺失产品数据通过缺失输出接口输出。
- 根据权利要求9所述的装置,其特征在于,所述装置还包括:更新单元,用于将缺失产品特征转换成相应的缺失键值,将缺失键值与对应的缺失产品数据组成缺失键值对,将缺失键值对与相应的缺失输出接口进行映射匹配;利用哈希映射的方式为缺失键值对确定相应的类别,并将缺失键值对,以及相对应的缺失输出接口放置在对应的类别桶中,将对应的类别桶进行更新;将更新后的类别桶存储在数据库中。
- 根据权利要求9所述的装置,其特征在于,所述装置还包括:布图单元,用于利用键值对通过迭代collection视图的方式对每个类别桶进行布图,得到与每个类别桶相对应的查找图形;所述搜寻单元,还用于调取待查找类别桶中的查找图形,根据待查找键值从查找图形中获取相应的待查找键值对。
- 根据权利要求9所述的装置,其特征在于,所述收集单元具体包括:调取模块,用于调取每个产品名称对应的至少一个网站的网址;访问模块,用于通过网址对网站进行访问,并获取网站中与各个产品名称对应的产品特征,以及与产品特征对应的产品数据;和/或,设置模块,用于接收到各个产品名称的设置命令后,将各个产品名称对应的设置窗口进行显示,以供用户在对应的设置窗口输入与产品名称相对应的产品特征和产品数据;接收模块,用于接收设置窗口传来的与每个产品名称对应的至少一个产品特征和产品数据。
- 根据权利要求9-13中任一项所述的装置,其特征在于,所述存储单元,还用于利用设定密码为各个类别桶进行加密,其中,各个类别桶的设定密码为相同或不同数码;为每个加密后的类别桶匹配相应的符号代码,其中,符号代码与各个加密后的类别桶的类别相对应;所述搜寻单元,还用于利用哈希算法确定待查找键值的类别,获取待查找键值的类别对应的符号代码,根据对应的符号代码从数据库中搜寻对应的待查找类别桶,并利用设定密码对待查找类别桶进行解密。
- 一种计算机非易失性可读存储介质,其上存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现基于键值对的数据查找方法,包括:获取待查找产品名称对应的待查找产品特征,根据所述待查找产品特征确定待查找键值,其中,每个待查找产品名称对应至少一个待查找产品特征,每个待查找产品特征对应一个待查找键值;确定所述待查找键值的类别,根据所述待查找键值的类别从数据库中搜寻对应的待查 找类别桶;利用哈希算法从所述待查找类别桶中搜寻所述待查找键值相应的待查找键值对,其中,每个类别桶中存储有至少一个键值对;根据所述待查找键值对查找与所述待查找产品特征对应的目标产品数据,以及对应的目标输出接口,将所述目标产品数据通过所述目标输出接口输出,其中,每个键值对对应一个输出接口。
- 根据权利要求15所述的计算机非易失性可读存储介质,其特征在于,所述计算机可读指令被处理器执行时实现在所述获取待查找产品名称对应的待查找产品特征之前,所述方法还包括:收集每个产品名称相应的至少一个产品特征,以及所述产品特征对应的产品数据;将所述产品特征转换成相应的键值,将键值与对应的产品数据组成键值对,并为所述键值对匹配相应的输出接口;利用哈希映射的方式将所述键值对匹配相应的映射关系;根据所述映射关系对所述键值对进行类别划分,并将各个类别对应的至少一个键值对,以及与键值对相对应的输出接口放置在对应的类别桶中;将所述类别桶存储在数据库中。
- 根据权利要求16所述的计算机非易失性可读存储介质,其特征在于,所述计算机可读指令被处理器执行时实现若从所述待查找类别桶中未搜寻到所述待查找键值相应的待查找键值对,则所述方法还包括:通过网络查找与所述待查找产品名称相对应的所有网络产品特征;将所有网络产品特征中,与所述待查找产品特征相同的网络产品特征删除,剩余的网络产品特征为缺失产品特征;从网络中查找所述缺失产品特征对应的缺失产品数据;为所述缺失产品数据匹配相应的缺失输出接口,将所述缺失产品数据通过所述缺失输出接口输出。
- 一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现基于键值对的数据查找方法,包括:获取待查找产品名称对应的待查找产品特征,根据所述待查找产品特征确定待查找键值,其中,每个待查找产品名称对应至少一个待查找产品特征,每个待查找产品特征对应 一个待查找键值;确定所述待查找键值的类别,根据所述待查找键值的类别从数据库中搜寻对应的待查找类别桶;利用哈希算法从所述待查找类别桶中搜寻所述待查找键值相应的待查找键值对,其中,每个类别桶中存储有至少一个键值对;根据所述待查找键值对查找与所述待查找产品特征对应的目标产品数据,以及对应的目标输出接口,将所述目标产品数据通过所述目标输出接口输出,其中,每个键值对对应一个输出接口。
- 根据权利要求18所述的计算机设备,其特征在于,所述处理器执行所述计算机可读指令时实现在所述获取待查找产品名称对应的待查找产品特征之前,所述方法还包括:收集每个产品名称相应的至少一个产品特征,以及所述产品特征对应的产品数据;将所述产品特征转换成相应的键值,将键值与对应的产品数据组成键值对,并为所述键值对匹配相应的输出接口;利用哈希映射的方式将所述键值对匹配相应的映射关系;根据所述映射关系对所述键值对进行类别划分,并将各个类别对应的至少一个键值对,以及与键值对相对应的输出接口放置在对应的类别桶中;将所述类别桶存储在数据库中。
- 根据权利要求19所述的计算机设备,其特征在于,所述处理器执行所述计算机可读指令时实现若从所述待查找类别桶中未搜寻到所述待查找键值相应的待查找键值对,则所述方法还包括:通过网络查找与所述待查找产品名称相对应的所有网络产品特征;将所有网络产品特征中,与所述待查找产品特征相同的网络产品特征删除,剩余的网络产品特征为缺失产品特征;从网络中查找所述缺失产品特征对应的缺失产品数据;为所述缺失产品数据匹配相应的缺失输出接口,将所述缺失产品数据通过所述缺失输出接口输出。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811288856.8 | 2018-10-31 | ||
CN201811288856.8A CN109558423A (zh) | 2018-10-31 | 2018-10-31 | 一种基于键值对的数据查找方法、装置及设备 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2020087796A1 true WO2020087796A1 (zh) | 2020-05-07 |
Family
ID=65865749
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2019/073952 WO2020087796A1 (zh) | 2018-10-31 | 2019-01-30 | 一种基于键值对的数据查找方法、装置及计算机设备 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN109558423A (zh) |
WO (1) | WO2020087796A1 (zh) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111582991B (zh) * | 2020-05-13 | 2023-09-01 | 中国银行股份有限公司 | 产品信息推荐方法及装置 |
CN112685612B (zh) * | 2020-12-31 | 2022-08-30 | 武汉思普崚技术有限公司 | 一种特征码查找和匹配方法、设备及存储介质 |
CN112905982B (zh) * | 2021-01-19 | 2022-11-25 | 集物(北京)科技有限公司 | 一种基于互联网的电商平台入侵检测方法及监控系统 |
CN114356481A (zh) * | 2021-12-29 | 2022-04-15 | 中国建设银行股份有限公司 | 数据处理方法、装置、电子设备及存储介质 |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101051939A (zh) * | 2006-06-15 | 2007-10-10 | 华为技术有限公司 | 一种实现网络流量负载分担的方法及装置 |
US8504521B2 (en) * | 2005-07-28 | 2013-08-06 | Gopivotal, Inc. | Distributed data management system |
US20160147750A1 (en) * | 2014-11-25 | 2016-05-26 | Rolando Blanco | Versioned Insert Only Hash Table for In-Memory Columnar Stores |
CN106294402A (zh) * | 2015-05-21 | 2017-01-04 | 阿里巴巴集团控股有限公司 | 一种异构数据源的数据搜索方法及其装置 |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102402394B (zh) * | 2010-09-13 | 2014-10-22 | 腾讯科技(深圳)有限公司 | 一种基于哈希算法的数据存储方法及装置 |
CN102811158A (zh) * | 2011-06-02 | 2012-12-05 | 中兴通讯股份有限公司 | 一种数据定位、重组方法及相应装置 |
CN106302172A (zh) * | 2015-05-18 | 2017-01-04 | 深圳市中兴微电子技术有限公司 | 同时支持哈希查找和路由查找的存储、查找方法和装置 |
CN108153757B (zh) * | 2016-12-02 | 2020-04-03 | 深圳市中兴微电子技术有限公司 | 一种哈希表管理的方法和装置 |
CN108681577A (zh) * | 2018-05-08 | 2018-10-19 | 亳州中药材商品交易中心有限公司 | 一种新型的库结构数据索引方法 |
-
2018
- 2018-10-31 CN CN201811288856.8A patent/CN109558423A/zh active Pending
-
2019
- 2019-01-30 WO PCT/CN2019/073952 patent/WO2020087796A1/zh active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8504521B2 (en) * | 2005-07-28 | 2013-08-06 | Gopivotal, Inc. | Distributed data management system |
CN101051939A (zh) * | 2006-06-15 | 2007-10-10 | 华为技术有限公司 | 一种实现网络流量负载分担的方法及装置 |
US20160147750A1 (en) * | 2014-11-25 | 2016-05-26 | Rolando Blanco | Versioned Insert Only Hash Table for In-Memory Columnar Stores |
CN106294402A (zh) * | 2015-05-21 | 2017-01-04 | 阿里巴巴集团控股有限公司 | 一种异构数据源的数据搜索方法及其装置 |
Also Published As
Publication number | Publication date |
---|---|
CN109558423A (zh) | 2019-04-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2020087796A1 (zh) | 一种基于键值对的数据查找方法、装置及计算机设备 | |
US10878218B2 (en) | Device fingerprinting, tracking, and management | |
US9349023B2 (en) | Database encryption system, method, and program | |
EP2778952B1 (en) | Database device, method and program | |
US9672053B2 (en) | Service request processing | |
CN107798038B (zh) | 数据响应方法及数据响应设备 | |
US10235685B2 (en) | Method and system for two-dimensional charting using live queries | |
US8838679B2 (en) | Providing state service for online application users | |
WO2019019769A1 (zh) | 业务功能实现的方法、装置、计算机设备及存储介质 | |
EP3491808B1 (en) | Interchangeable retrieval of content | |
CN111241559A (zh) | 训练模型保护方法、装置、系统、设备和计算机存储介质 | |
US10581808B2 (en) | Keyed hash contact table | |
CN113568994A (zh) | 一种基于栅格瓦片地图的真实数据获取方法 | |
CN111680477A (zh) | 导出电子表格文件的方法、装置、计算机设备及存储介质 | |
CN112860953A (zh) | 图数据库的数据导入方法、装置、设备及存储介质 | |
JP2009003549A (ja) | データ管理装置およびデータ管理方法、データ管理プログラム、データ管理プログラム記憶媒体 | |
WO2023060046A1 (en) | Errors monitoring in public and private blockchain by a data intake system | |
CN113238999B (zh) | 数据共享方法、装置、电子设备及计算机可读存储介质 | |
JP2007219634A (ja) | 分散型データベースシステム及びデータベースの分散管理方法 | |
JP5983333B2 (ja) | 検索処理方法、データ生成方法及び情報処理装置 | |
CN107979595A (zh) | 私有数据保护方法及网关系统 | |
WO2014135493A1 (en) | Semantic search over encrypted data | |
US20220309178A1 (en) | Private searchable database | |
US11062046B1 (en) | Self-referencing data encryption | |
CN112580087B (zh) | 加密数据搜索方法及装置、存储介质、电子设备 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19877775 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 22/06/2021) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 19877775 Country of ref document: EP Kind code of ref document: A1 |