CN111339193A - Category coding method and device - Google Patents

Category coding method and device Download PDF

Info

Publication number
CN111339193A
CN111339193A CN202010109043.9A CN202010109043A CN111339193A CN 111339193 A CN111339193 A CN 111339193A CN 202010109043 A CN202010109043 A CN 202010109043A CN 111339193 A CN111339193 A CN 111339193A
Authority
CN
China
Prior art keywords
category
class
target
code
parent
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010109043.9A
Other languages
Chinese (zh)
Other versions
CN111339193B (en
Inventor
朱江涛
周洪飞
杨鑫
崔文盛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Cloud Computing Beijing Co Ltd
Original Assignee
Tencent Cloud Computing Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Cloud Computing Beijing Co Ltd filed Critical Tencent Cloud Computing Beijing Co Ltd
Priority to CN202010109043.9A priority Critical patent/CN111339193B/en
Publication of CN111339193A publication Critical patent/CN111339193A/en
Application granted granted Critical
Publication of CN111339193B publication Critical patent/CN111339193B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/08Payment architectures
    • G06Q20/085Payment architectures involving remote charge determination or related payment systems

Abstract

The invention provides a class coding method and a class coding device; the method comprises the following steps: acquiring a category hierarchical relation corresponding to a target category; determining a parent category to which the target category belongs and at least two subcategories included in the parent category according to the category hierarchical relationship; acquiring the category coding of the parent category and the category coding states of the at least two subcategories; assigning a hierarchical code to the target category according to the category coding states of the at least two subcategories; generating a class code of the target class according to the class code of the parent class and the hierarchical code of the target class; storing a category encoding of the target category, the category encoding for use in searching for category information associated with the target category. By the method and the device, the searching efficiency of searching the category information associated with the target category can be improved.

Description

Category coding method and device
Technical Field
The invention relates to a cloud storage technology, in particular to a class encoding method and device.
Background
Cloud technology refers to a hosting technology for unifying serial resources such as hardware, software, network and the like in a wide area network or a local area network to realize calculation, storage, processing and sharing of data. Cloud storage (cloudstorage) is a new concept extended and developed on the cloud computing concept, and a large number of various storage devices of different types in a network are integrated to cooperatively work through application software or application interfaces through functions of cluster application, grid technology, distributed storage file systems and the like, so that a storage system with data storage and service access functions is provided for the outside.
When data is stored, the data is generally classified, for example, an article belongs to a certain classification, and a multi-level structure exists in the classification itself, that is, each classification may have a plurality of sub-classifications, and there may be a plurality of sub-classifications under the sub-classifications. In the related art, a classification tree structure is usually used to describe a multi-level classification structure, that is, an Identity (ID) is randomly generated for each class, and each class is described by using (ID, parent class ID).
Disclosure of Invention
The embodiment of the invention provides a category coding method and a category coding device, which can improve the searching efficiency of searching category information associated with a target category.
The technical scheme of the embodiment of the invention is realized as follows:
the embodiment of the invention provides a category coding method, which comprises the following steps:
acquiring a category hierarchical relation corresponding to a target category;
determining a parent category to which the target category belongs and at least two subcategories included in the parent category according to the category hierarchical relationship;
acquiring the category coding of the parent category and the category coding states of the at least two subcategories;
assigning a hierarchical code to the target category according to the category coding states of the at least two subcategories;
generating a class code of the target class according to the class code of the parent class and the hierarchical code of the target class;
storing a category encoding of the target category, the category encoding for use in searching for category information associated with the target category.
In the foregoing solution, the matching the category code of each article with the category code of the target category to obtain the article belonging to the target category includes:
in response to a first search request for the target category, acquiring a category code of the target category;
respectively matching the class code of each article with the class code of the target class to obtain the article belonging to the target class;
and presenting the item information corresponding to the item belonging to the target category.
In the above scheme, the method further comprises: when the class code is a numerical type, determining a coding interval of the target class according to the class code of the target class;
and respectively comparing the category code of each article with the code interval, and determining the article with the category code in the code interval as the article belonging to the target category.
In the above scheme, the method further comprises: in response to a second search request for the target category, acquiring a category code of the target category;
determining a class code of a parent class of the target class from the class codes;
determining a parent class to which the target class belongs according to the class code of the parent class of the target class;
category information belonging to at least two sub-categories of the parent category is obtained and presented.
In the above scheme, the allocating hierarchical codes to the target category according to the category coding states of at least two sub-categories included in the parent category includes:
according to the category coding states of at least two sub-categories included in the parent category, when the category coding state of at least one sub-category is determined to be a coded state, acquiring the category coding of at least one sub-category of the coded state;
extracting a hierarchical encoding of at least one sub-category of the encoded state from a category encoding of the sub-category;
generating a hierarchical code for the target category according to the hierarchical codes for the sub-categories.
In the above solution, the generating a class code of the target class according to the class code of the parent class and the hierarchical code of the target class includes:
and splicing the category code of the parent category with the hierarchy code of the target category to obtain the category code of the target category.
In the above solution, the generating a class code of the target class according to the class code of the parent class and the hierarchical code of the target class includes:
acquiring a level corresponding to the target category and a coding length of a category code;
selecting characters with a target quantity from the first character in the category code of the parent category according to the level corresponding to the target category, wherein the target quantity corresponds to the level corresponding to the target category;
splicing the characters with the target number with the hierarchical codes of the target categories to obtain spliced codes;
and adjusting the splicing codes according to the coding length of the splicing codes and the coding length of the category codes to obtain the category codes of the target category.
In the above scheme, the method further comprises:
obtaining the searching frequency of at least two sub-categories included in the parent category;
and according to the searching frequency, adjusting the encoding order of the hierarchical encoding of at least two sub-categories included in the parent category.
In the above scheme, the method further comprises:
storing the class code of the target class to a blockchain network.
An embodiment of the present invention provides a class encoding device, including:
the first acquisition module is used for acquiring a category hierarchical relationship corresponding to a target category;
the determining module is used for determining a parent category to which the target category belongs and at least two sub-categories included in the parent category according to the category hierarchical relationship;
a second obtaining module, configured to obtain a category code of the parent category and category code states of the at least two sub-categories;
a first encoding module for assigning a hierarchical encoding to the target category according to the category encoding status of the at least two sub-categories;
the second encoding module is used for generating the class code of the target class according to the class code of the parent class and the hierarchical code of the target class;
a storage module to store a category code for the target category, the category code for use in searching for category information associated with the target category.
In the above scheme, the apparatus further comprises:
the first search module is used for responding to a first search request aiming at the target category and acquiring the category code of the target category;
respectively matching the class code of each article with the class code of the target class to obtain the article belonging to the target class;
and presenting the item information corresponding to the item belonging to the target category.
In the above scheme, the first search module is configured to determine, when the category code is a numeric type, a coding interval of the target category according to the category code of the target category;
and respectively comparing the category code of each article with the code interval, and determining the article with the category code in the code interval as the article belonging to the target category.
In the above scheme, the apparatus further comprises:
the second search module is used for responding to a second search request aiming at the target category and acquiring the category code of the target category;
determining a class code of a parent class of the target class from the class codes;
determining a parent class to which the target class belongs according to the class code of the parent class of the target class;
category information belonging to at least two sub-categories of the parent category is obtained and presented.
In the above scheme, the first encoding module is further configured to, when determining that the category encoding status of at least one sub-category is the encoded status according to the category encoding statuses of at least two sub-categories included in the parent category, acquire the category encoding of at least one sub-category of the encoded status;
extracting a hierarchical encoding of at least one sub-category of the encoded state from a category encoding of the sub-category;
generating a hierarchical code for the target category according to the hierarchical codes for the sub-categories.
In the above scheme, the second encoding module is further configured to splice the category code of the parent category with the hierarchical code of the target category to obtain the category code of the target category.
In the above scheme, the second encoding module is further configured to obtain a level corresponding to the target category and an encoding length of the category code;
selecting characters with a target quantity from the first character in the category code of the parent category according to the level corresponding to the target category, wherein the target quantity corresponds to the level corresponding to the target category;
splicing the characters with the target number with the hierarchical codes of the target categories to obtain spliced codes;
and adjusting the splicing codes according to the coding length of the splicing codes and the coding length of the category codes to obtain the category codes of the target category.
In the above scheme, the apparatus further comprises:
the adjusting module is further used for acquiring the searching frequency of at least two sub-categories included in the parent category;
and according to the searching frequency, adjusting the encoding order of the hierarchical encoding of at least two sub-categories included in the parent category.
In the foregoing solution, the storage module is further configured to store the class code of the target class to a blockchain network.
An embodiment of the present invention provides an electronic device, including:
a memory for storing executable instructions;
and the processor is used for realizing the class coding method provided by the embodiment of the invention when executing the executable instructions stored in the memory.
Embodiments of the present invention provide a computer-readable storage medium, which stores executable instructions for causing a processor to implement a class encoding method provided in embodiments of the present invention when executed.
The embodiment of the invention has the following beneficial effects:
by generating the class code of the target class according to the class code of the parent class and the hierarchy code of the target class, since the class code of each class contains the class hierarchy relationship of the class, when searching the class information associated with the target class, the search can be directly carried out based on the class code without traversing the class of each hierarchy layer by layer, so that the search efficiency of searching the class information associated with the target class can be improved.
Drawings
FIG. 1 is an alternative architectural diagram of a generic encoding system 100 provided by embodiments of the present invention;
fig. 2 is a schematic structural diagram of an electronic device provided in an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a category encoding method according to an embodiment of the present invention;
FIG. 4 is a diagram of a multi-level classification architecture provided by an embodiment of the present invention;
fig. 5 is a schematic application architecture diagram of a blockchain network according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a block chain in a block chain network 900 according to an embodiment of the present invention;
fig. 7 is a functional architecture diagram of a blockchain network 900 according to an embodiment of the present invention;
FIG. 8 is a flowchart illustrating a category encoding method according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of class encoding provided by an embodiment of the present invention;
FIG. 10 is a flowchart illustrating a category encoding method according to an embodiment of the present invention;
FIG. 11 is a diagram illustrating class encoding provided by an embodiment of the present invention;
FIG. 12 is a flowchart illustrating a category encoding method according to an embodiment of the present invention;
fig. 13 is a schematic structural diagram of a category encoding device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail with reference to the accompanying drawings, the described embodiments should not be construed as limiting the present invention, and all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.
In the description that follows, references to the terms "first", "second", and the like, are intended only to distinguish between similar objects and not to indicate a particular ordering for the objects, it being understood that "first", "second", and the like may be interchanged under certain circumstances or sequences of events to enable embodiments of the invention described herein to be practiced in other than the order illustrated or described herein.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to be limiting of the invention.
Before further detailed description of the embodiments of the present invention, terms and expressions mentioned in the embodiments of the present invention are explained, and the terms and expressions mentioned in the embodiments of the present invention are applied to the following explanations.
1) The category hierarchical relationship comprises an upper-lower level relationship, a peer level relationship and the like: for example, to which parent category the target category belongs, which sub-categories the target category includes, which categories the target category belongs to the same parent category as the target category, etc.
2) In response to the condition or state on which the performed operation depends, one or more of the performed operations may be in real-time or may have a set delay when the dependent condition or state is satisfied; there is no restriction on the order of execution of the operations performed unless otherwise specified.
3) The classification tree is a logical tree structure consisting of classifications and subcategories thereof.
4) Transactions (transactions), equivalent to the computer term "Transaction," include operations that need to be committed to a blockchain network for execution and do not refer solely to transactions in the context of commerce, which embodiments of the present invention follow in view of the convention colloquially used in blockchain technology.
For example, a deployment (deployment) transaction is used to install a specified smart contract to a node in a blockchain network and is ready to be invoked; the Invoke (Invoke) transaction is used to append records of the transaction in the blockchain by invoking the smart contract and to perform operations on the state database of the blockchain, including update operations (including adding, deleting, and modifying key-value pairs in the state database) and query operations (i.e., querying key-value pairs in the state database).
5) A Block chain (Blockchain) is a storage structure for encrypted, chained transactions formed from blocks (blocks).
6) A Blockchain Network (Blockchain Network) incorporates new blocks into a set of nodes of a Blockchain in a consensus manner.
7) Ledger (legger) is a general term for blockchains (also called Ledger data) and state databases synchronized with blockchains. Wherein, the blockchain records the transaction in the form of a file in a file system; the state database records the transactions in the blockchain in the form of different types of Key (Key) Value pairs for supporting fast query of the transactions in the blockchain.
8) Intelligent Contracts (Smart Contracts), also known as chain codes (chaincodes) or application codes, are programs deployed in nodes of a blockchain network, and the nodes execute the intelligent Contracts called in received transactions to perform operations of updating or querying key-value data of a state database.
9) Consensus (Consensus), a process in a blockchain network, is used to agree on transactions in a block among a plurality of nodes involved, the agreed block is to be appended to the end of the blockchain, and the mechanisms for achieving Consensus include Proof of workload (PoW, Proof of Work), Proof of rights and interests (PoS, Proof of equity (DPoS), Proof of granted of shares (DPoS), Proof of Elapsed Time (PoET, Proof of Elapsed Time), and so on.
10) In response to the condition or state on which the performed operation depends, one or more of the performed operations may be in real-time or may have a set delay when the dependent condition or state is satisfied; there is no restriction on the order of execution of the operations performed unless otherwise specified.
In the related art, a description method of a multi-level classification structure based on a classification tree is provided, that is, an ID (identity) document is randomly generated for each class, each class is described by an (ID, parent class ID), and it should be noted that a description corresponding to an article at least includes the parent class ID to which the article belongs. When an article belonging to a certain category needs to be searched, layer-by-layer traversal needs to be performed, namely all sub-categories of the category are obtained first, and then the articles belonging to the sub-categories are obtained. The search efficiency is low due to the need of multiple rounds of traversal of the classification tree.
In the related art, a description method of a multi-level classification structure based on a classification tree is further provided, which stores a complete classification chain corresponding to each article, and if the classification tree is 4 layers, each article corresponds to four classification fields, and classification IDs of a first layer to a fourth layer of the category to which the article belongs are respectively stored. Although the problem of requiring multiple rounds of traversal of the classification tree is solved, the storage cost is increased, and the storage is not flexible.
Based on this, the encoding method and apparatus of the present invention are proposed to solve at least the above problems in the related art, and each of the following descriptions is provided.
Referring to fig. 1, fig. 1 is an alternative architecture diagram of a coding system 100 of the type provided by the embodiment of the present invention, in order to support an exemplary application, terminals (terminal 400-1 and terminal 400-2 are exemplarily shown) are connected to a server 200 through a network 300, and the network 300 may be a wide area network or a local area network, or a combination of both.
The server 200 is used for acquiring a category hierarchical relationship corresponding to a target category; determining a parent category to which the target category belongs and at least two subcategories included in the parent category according to the category hierarchical relationship; acquiring the category coding state of a parent category and the category coding states of at least two subcategories; assigning a hierarchical code to the target category according to the category coding states of the at least two subcategories; generating a class code of the target class according to the class code of the parent class and the hierarchical code of the target class; storing a class code for the target class;
a terminal (e.g., terminal 400-1) for transmitting a search request for a target category to the server 200;
and the server 200 is used for responding to the search request, searching the category information associated with the target category according to the category code of the target category.
In practical application, the server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, a middleware service, a domain name service, a security service, a CDN, a big data and artificial intelligence platform, and the like. The terminal may be, but is not limited to, a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and the like. The terminal and the server may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein.
Next, an electronic device implementing the encoding method of the class of the embodiment of the present invention will be described. In some embodiments, the electronic device may be a terminal and may also be a server. Referring to fig. 2, fig. 2 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, where the electronic device shown in fig. 2 includes: a processor 410, a memory 450, a network interface 420, and a user interface 430. The various components in electronic device 400 are coupled together by a bus system 440. It is understood that the bus system 440 is used to enable communications among the components. The bus system 440 includes a power bus, a control bus, and a status signal bus in addition to a data bus. For clarity of illustration, however, the various buses are labeled as bus system 440 in fig. 2.
The Processor 410 may be an integrated circuit chip having Signal processing capabilities, such as a general purpose Processor, a Digital Signal Processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like, wherein the general purpose Processor may be a microprocessor or any conventional Processor, or the like.
The user interface 430 includes one or more output devices 431, including one or more speakers and/or one or more visual displays, that enable the presentation of media content. The user interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, and the like. Memory 450 optionally includes one or more storage devices physically located remote from processor 410.
The memory 450 includes either volatile memory or nonvolatile memory, and may include both volatile and nonvolatile memory. The nonvolatile Memory may be a Read Only Memory (ROM), and the volatile Memory may be a Random Access Memory (RAM). The memory 450 described in embodiments of the invention is intended to comprise any suitable type of memory.
In some embodiments, memory 450 is capable of storing data, examples of which include programs, modules, and data structures, or a subset or superset thereof, to support various operations, as exemplified below.
An operating system 451, including system programs for handling various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and handling hardware-based tasks;
a network communication module 452 for communicating to other computing devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 including: bluetooth, wireless compatibility authentication (WiFi), and Universal Serial Bus (USB), etc.;
a presentation module 453 for enabling presentation of information (e.g., user interfaces for operating peripherals and displaying content and information) via one or more output devices 431 (e.g., display screens, speakers, etc.) associated with user interface 430;
an input processing module 454 for detecting one or more user inputs or interactions from one of the one or more input devices 432 and translating the detected inputs or interactions.
In some embodiments, the encoding apparatus of the class provided by the embodiments of the present invention may be implemented in software, and fig. 2 shows the encoding apparatus 455 of the class stored in the memory 450, which may be software in the form of programs and plug-ins, and the like, and includes the following software modules: a first obtaining module 4551, a determining module 4552, a second obtaining module 4553, a first coding module 4554, a second coding module 4555 and a storage module 4556, which are logical, and thus may be arbitrarily combined or further divided according to the functions implemented, and the functions of the respective modules will be described below.
In other embodiments, the class of coding Device provided in the embodiments of the present invention may be implemented in hardware, and for example, the class of coding Device provided in the embodiments of the present invention may be a processor in the form of a hardware decoding processor, which is programmed to execute the class of coding method provided in the embodiments of the present invention, for example, the processor in the form of the hardware decoding processor may be one or more Application Specific Integrated Circuits (ASICs), DSPs, Programmable Logic Devices (PLDs), Complex Programmable Logic Devices (CPLDs), Field Programmable Gate Arrays (FPGAs), or other electronic components.
The category encoding method provided by the embodiment of the present invention will be described in connection with exemplary applications and implementations of the electronic device provided by the embodiment of the present invention, and the category encoding method is implemented by a terminal.
Referring to fig. 3, fig. 3 is a flowchart illustrating a class encoding method according to an embodiment of the present invention, which will be described with reference to the steps shown in fig. 3.
Step 301: the terminal acquires a category hierarchical relation corresponding to the target category.
It should be noted that the multi-level classification structure is preset, and the terminal may determine the category hierarchical relationship corresponding to the target category directly according to the multi-level classification structure. Here, the category hierarchical relationship includes a superior-inferior relationship, an sibling relationship, and the like: for example, to which parent category the target category belongs, which sub-categories the target category includes, which categories the target category belongs to the same parent category as the target category, etc.
For example, fig. 4 is a schematic diagram of a multi-level classification structure provided in an embodiment of the present invention, and referring to fig. 4, the multi-level classification structure includes four levels of classes, when the target class is an automobile, the hierarchical relationship of the automobile can be obtained, that is, the parent class of the automobile is manufacturing, the child class of the automobile is car and SUV, and the class belonging to manufacturing with the automobile is steel.
Step 302: and determining a parent category to which the target category belongs and at least two subcategories included in the parent category according to the category hierarchical relationship.
Step 303: the category encoding of the parent category and the category encoding status of at least two sub-categories are obtained.
Here, the category coding state is used to describe whether a certain category is already coded, i.e., whether there is a category code corresponding to the category, including a coded state and an uncoded state.
In actual implementation, when the parent class is in an encoded state, the terminal directly acquires the class code of the parent class; and when the parent class is in an uncoded state, the terminal firstly codes the parent class to acquire the class code of the parent class. The parent type is encoded in the same manner as the target type.
Step 304: a hierarchical code is assigned to the target category based on the category coding states of the at least two subcategories.
Here, the hierarchical codes of the plurality of sub-categories included in the same parent category should be different from each other, and it is necessary to assign the hierarchical codes to the target category according to the category coding states of all the sub-categories included in the parent category, so that the hierarchical codes of the target category may be different from the hierarchical codes of the sub-categories of the coded states.
It should be noted that the hierarchical coding of the target category may be any character, wherein the character refers to a font unit or symbol, including letters, numbers, operation symbols, punctuation marks and other symbols, and some functional symbols.
In some embodiments, the terminal may assign a hierarchical code to the target class by: according to the category coding states of at least two sub-categories included in the parent category, when the category coding state of at least one sub-category is determined to be a coded state, the category coding of at least one sub-category of the coded state is acquired; extracting a hierarchical code of at least one sub-category of the encoded state from a category code of the sub-category; generating a hierarchical code for the target category according to the hierarchical codes for the sub-categories.
In an actual implementation, when a sub-category of the encoded state exists in a plurality of sub-categories included in the parent category, the hierarchical coding of the target category is generated according to the hierarchical coding of the sub-category of the encoded state, wherein the hierarchical coding of the target category is different from the hierarchical coding of the sub-category of the encoded state.
In practical applications, the terminal may sequentially generate the hierarchical codes of the target categories according to the hierarchical codes of the sub-categories of the encoded states, for example, if there are two sub-categories of the encoded states, whose hierarchical codes are 01 and 02, respectively, then sequentially generate the hierarchical codes 03 of the target categories; if there are two sub-categories of encoded state, whose level codes are A, B, then the level codes C of the target category are generated sequentially.
In practical application, the terminal can also randomly generate a hierarchical code of the target category, then compare the hierarchical code of the target category with the hierarchical code of the sub-category in the coded state, and regenerate the hierarchical code of the target category when the hierarchical code of the target category is the same as the hierarchical code of the sub-category in the coded state; and if the difference is not the same, executing the next operation.
For example, there are two encoded state sub-categories, whose hierarchical codes are A, B respectively, and the hierarchical code of the randomly generated target category is a, and since there is already one sub-category whose hierarchical code is a, the hierarchical code of the target category needs to be regenerated, and if the generated hierarchical code of the target category is D, the hierarchical code of the target category does not need to be regenerated.
In some embodiments, the terminal may obtain, by the terminal, the number of subcategories of the encoded status according to the category encoding statuses of the at least two subcategories, so as to assign the hierarchical encoding to the target category based on the number of subcategories of the encoded status, that is, to assign the hierarchical encoding according to the encoding order of each subcategory, if the number of subcategories of the encoded status is 1, then the target category is the second encoded subcategory, and is assigned with the base layer encoding matching the second bit in the encoding order.
In some embodiments, when the category encoding states of at least two sub-categories included in the parent category are both unencoded states, the target category may be assigned a hierarchical encoding in the encoding order, or may be directly randomly generated with the hierarchical encoding, without consideration of the other sub-categories.
Step 305: and generating the class code of the target class according to the class code of the parent class and the hierarchical code of the target class.
It should be noted that, since the class code of the target class is generated according to the class code of the parent class and the hierarchical code of the target class, the parent class can be determined directly according to the class code of the target class. Meanwhile, the generation mode of the parent class is the same as that of the target class, so that the parent class of the parent class can be determined according to the class code of the parent class. That is, the class code of the target class actually contains the complete class hierarchy of the target class. In this way, the efficiency of searching for category information associated with a target category can be improved.
In some embodiments, the terminal may assume a root class as a parent class of the primary class and preset a class code for the root class. And when the target class is a primary class, determining the class code according to the class code of the root class and the self hierarchical code. In other embodiments, the class code may not be preset for the root class, i.e., the class code of the root class is null, and then the class code of the primary class is actually determined only according to its own hierarchical code. Here, by assuming one root class, the generation process of class codes of the first class can be simplified, and the generation efficiency of class codes can be improved.
In some embodiments, the terminal may obtain the class code of the target class by: and splicing the category code of the parent category and the hierarchy code of the target category to obtain the category code of the target category.
Here, the class code of the target class is obtained by directly splicing the class code of the parent class and the hierarchical code of the target class, and the length of the class code of each hierarchical level is different, that is, the lower the hierarchical level of the class is, the longer the length of the class code is.
For example, the class code of the parent class of the target class is a, the hierarchy code of the target class is B, then the class code of the target class is AB; assuming that the hierarchy coding of a certain sub-category of the target category is C, the category coding of this sub-category is ABC.
In some embodiments, the terminal may obtain the class code of the target class by: acquiring a level corresponding to a target category and a coding length of a category code; selecting characters with a target number from the first character in the category code of the father category according to the level corresponding to the target category, wherein the target number corresponds to the level corresponding to the target category; splicing the characters with the target number with the hierarchical codes of the target categories to obtain spliced codes; and adjusting the splicing codes according to the coding length of the splicing codes and the coding length of the category codes to obtain the category codes of the target categories.
It should be noted that the encoding length of the category code is determined according to the total category hierarchy and the number of characters of the hierarchy code corresponding to each hierarchy, so as to ensure that the encoding length of the category code of each hierarchy is the same and ensure the integrity of information contained in the category code. The number of characters of the hierarchical code corresponding to each hierarchical level may be the same or different, for example, the number of characters of the hierarchical code corresponding to each hierarchical level may be 2; the number of characters of the hierarchical code corresponding to the first hierarchical level may be 2, and the number of characters of the hierarchical code corresponding to the second hierarchical level may be 4.
For example, the number of characters of the hierarchical code of each hierarchy is 2, the hierarchy corresponding to the target class is three, the hierarchy of the parent class is two, if the class code of the parent class is 02010000, the first four characters, namely 0201, are selected, and if the hierarchical code of the target class is 03, 020103 is obtained by splicing 0201 and 03. Because the coding length of the class code corresponds to the maximum level, if the maximum level is 3, the class code length is 6, at this time, the coding length of the splicing code is also 6, and the splicing code is directly used as the class code of the target class without adjusting the splicing code; if the maximum level is 4, the encoding length of the class encoding is 8, and at this time, the encoding length of the splicing encoding is 6, and the splicing encoding needs to be adjusted to obtain the class encoding with the encoding length of 8, and the splicing encoding may be adjusted in such a manner that meaningless characters are added after the splicing encoding, for example, a plurality of 0 s may be added, the encoding length is 8, that is, 20 s are added after 020103, and the class encoding of the target class is 02010300.
In practical implementation, the terminal may assume a root class as a parent class of the first class, and preset a class code for the root class, but the class code of the root class does not include meaningful information, so that when the level corresponding to the target class is one level, the target number may be 0. For example, the class code of the root class is 00000000, the first 0 characters of the class code of the root class may be selected, and assuming that the level code of the target class is 01, the class code of the target class is 01000000.
Step 306: the class code of the object class is stored.
Here, the category code is used for searching category information associated with the target category.
In some embodiments, the terminal may search for category information associated with the target category by: the terminal responds to a first search request aiming at a target category and acquires a category code of the target category; respectively matching the class code of each article with the class code of the target class to obtain the article belonging to the target class; and presenting item information corresponding to the items belonging to the target category.
In actual implementation, a user can input a keyword corresponding to a target category through a terminal to trigger a first search request aiming at the target category; or, the user may also input a picture corresponding to the target category through the terminal to trigger a search request for the target category. The terminal determines the target category to be searched according to the keyword or the picture carried in the first search request, and further searches the category code of the target category so as to match the category code of each article in the database with the category code of the target category.
In some embodiments, the terminal may obtain the article belonging to the target category by means of character matching, that is, determine whether the category code of the article includes some or all characters of the category code of the target category.
When the class code of the target class is obtained by splicing the class code of the parent class with the hierarchical code of the target class, it is determined whether the class code of the article starts with the class code of the target class, for example, the code of the target class is AB, and then it is determined whether the class code of the article starts with AB, for example, the class code of the article starts with ABC, and starts with AB, then the article is an article belonging to the target class.
When the class code of the object class is to splice a target number of characters in the class code of the parent class with the hierarchical code of the object class to obtain a splicing code, and then the splicing code is adjusted according to the code length of the class code, whether the class code of the article starts with the splicing code is judged, for example, the class code of the object class is 02010000, the splicing code is 0201, whether the class code of the article starts with 0201 is judged, and if yes, the article is the article belonging to the object class.
In some embodiments, the terminal may obtain the items belonging to the target category by means of a numerical comparison: when the category code is a numerical type, determining a coding interval of the target category according to the category code of the target category; and respectively comparing the category code of each article with the coding interval, and determining the article with the category code in the coding interval as the article belonging to the target category.
In practical implementation, when the category is coded into a numerical type, the object belonging to the target category can be obtained based on the comparison of numerical values, so that the search efficiency is higher relative to the matching of character strings based on the comparison of numerical values.
Illustratively, when the lengths of the class codes are equal, the code interval of the target class is directly determined, for example, the class code of the target class is 02010000, wherein 02010000 is a hexadecimal value, then the code interval of the target class is determined to be (0x02010000, 0x0201FFFF), the class code of each article is compared with the code interval (0x02010000, 0x0201FFFF), and the article with the class code in (0x02010000, 0x0201FFFF) is the article belonging to the target class.
Illustratively, when the code length of each category code is related to the hierarchy, the code section of the category code is determined according to the code length of the category code of the item, for example, the category code of the target category is 0201, and the code length of the category code of the item is 8 bits, then the code section of the target category is (0x02010000, 0x0201FFFF), the category code of each item is compared with the code section (0x02010000, 0x0201FFFF), and the items with category codes in (0x02010000, 0x0201FFFF) are the items belonging to the target category.
In some embodiments, the terminal may search for category information associated with the target category by: responding to a second search request aiming at the target category, and acquiring a category code of the target category; determining a class code of a parent class of the target class from class codes; determining a parent class to which the target class belongs according to the class code of the parent class of the target class; category information belonging to at least two sub-categories of the parent category is obtained and presented.
Here, since the class code of the target class is generated from the class code of its parent class and its own hierarchical code, the class code of the parent class of the target class can be acquired from the class code of the target class.
In actual implementation, the encoding of the parent category may be further obtained according to the acquired category encoding of the parent category of the target category, and the category information of the sub-category belonging to the parent category of the parent category may be acquired and presented.
In practical implementation, when the class code of the target class is obtained by splicing the class code of the parent class and the hierarchical code of the target class, the terminal intercepts the class code of the parent class from the class code of the target class. For example, the class code of the target class is ABC, the class code of its parent class is AB, and the class code of its parent class is a.
In practical implementation, when the class code of the target class is obtained by splicing the target number of characters in the class code of the parent class with the hierarchical code of the target class, and adjusting the splicing code according to the code length of the class code, the terminal extracts the target number of characters from the first character of the hierarchical code of the target class, and then determines the class code of the parent class according to the code length of the class code. For example, the class code of the target class is 02010100, the class code of its parent class is 02010000, and the class code of its parent class is 02000000.
In some embodiments, the terminal may further obtain search frequencies of at least two sub-categories included in the parent category; and according to the searching frequency, adjusting the encoding sequence of the hierarchical encoding of at least two sub-categories included in the parent category.
In practical implementation, the terminal can adjust the coding sequence of the hierarchical codes of the same parent class according to the searching frequency of each class, so that the searching efficiency is improved. For example, referring to fig. 4, the passenger car includes a compact car, a small car, a medium car, and a large car, the compact car has a category code of 02010101, the small car has a category code of 02010102, the medium car has a category code of 02010103, and the large car has a category code of 02010104, and when the medium car has a higher search frequency than the small car, the encoding order of the hierarchical codes of the medium car and the small car, that is, the category code of the medium car is 02010102, and the category code of the small car is 02010103 can be adjusted.
In some embodiments, after the terminal generates the class code of the target class, the class code of the target class may be further stored in the blockchain network in conjunction with a blockchain technique, so that when searching for class information associated with the target class, the class code of the target class can be directly acquired from the blockchain network.
Generating a transaction for storing the class code of the target class after generating the class code of the target class, and submitting the generated transaction to a node of the blockchain network so that the node identifies the transaction and then stores the class code corresponding to the target class in the blockchain network; before storing the block chain network, the terminal can also obtain the abstract information of the class code of the target class corresponding to the class code of the target class; and storing the obtained abstract information of the class code of the target class in the block chain network.
Referring to fig. 5, fig. 5 is a schematic diagram of an application architecture of a blockchain network according to an embodiment of the present invention, which includes a service agent 500, an authentication center 800, and a blockchain network 900 (exemplarily illustrating a consensus node 910-1 to a consensus node 910-3), which are described below.
The type of blockchain network 900 is flexible and may be, for example, any of a public chain, a private chain, or a federation chain. Taking a public chain as an example, electronic devices such as user terminals and terminals of any service entity can access the blockchain network 900 without authorization; taking a federation chain as an example, after being authorized, an electronic device (e.g., a terminal/terminal) under the jurisdiction of a service entity may access the blockchain network 900, and at this time, the service entity becomes a special node, i.e., a client node, in the blockchain network 900.
In some embodiments, the client node may act as a mere watcher of the blockchain network 900, i.e., provides functionality to support the business entity to initiate transactions (e.g., for uplink storage of data or querying of data on the chain), and the end node may be implemented by default or selectively (e.g., depending on the specific business requirements of the business entity) for the functions of the consensus node 910 of the blockchain network 900, such as a ranking function, a consensus service, and an accounting function, etc. Therefore, the data and the service processing logic of the service subject can be migrated to the blockchain network 900 to the maximum extent, and the credibility and traceability of the data and service processing process are realized through the blockchain network 900.
Consensus nodes in blockchain network 900 receive transactions submitted by client nodes from business entity 500, perform transactions to update ledgers or query ledgers, and various intermediate or final results of performing transactions may be returned to business entity's client nodes for display.
An exemplary application of the blockchain network is described below by taking an example in which a service agent accesses the blockchain network to realize playing of a media file.
Referring to fig. 5, the service entity 500 involved in the category encoding registers with the certificate authority 800 to obtain a digital certificate, where the digital certificate includes the public key of the service entity and a digital signature signed by the certificate authority 800 on the public key and identity information of the service entity, and is used to be attached to the transaction together with the digital signature of the service entity for the transaction, and is sent to the blockchain network, so that the blockchain network can take the digital certificate and signature from the transaction, verify the authenticity of the message (i.e. whether the message is not tampered) and the identity information of the service entity sending the message, and verify the blockchain network according to the identity, for example, whether the service entity has the right to initiate the transaction. Clients operating on electronic devices (e.g., terminals or terminals) hosted by the business entity may request access from the blockchain network 900 to become client nodes.
The client node of the service body 500 is used for encoding the category, for example, obtaining a category hierarchical relationship corresponding to the target category;
determining a parent category to which the target category belongs and at least two subcategories included in the parent category according to the category hierarchical relationship; acquiring the category coding state of a parent category and the category coding states of at least two subcategories; assigning a hierarchical code to the target category according to the category coding states of the at least two subcategories; generating a class code of the target class according to the class code of the parent class and the hierarchical code of the target class; storing the class code of the target class into the blockchain network.
In the operation of sending the key to the blockchain network 900, a service logic may be set in the client node 510 in advance, and when the target class hierarchical code is generated, the client node 510 automatically sends the target class hierarchical code to the blockchain network 900, or a service person of the service agent 500 logs in the client node 510, manually packages the target class hierarchical code, and sends the target class hierarchical code to the blockchain network 900. Upon transmission, the client node 510 generates a transaction for the corresponding storage operation based on the corresponding key, in which transaction the smart contract that needs to be invoked to effect the storage operation and the parameters passed to the smart contract are specified, the transaction also carries the client node's 510 digital certificate, a signed digital signature (e.g., a digest of the transaction encrypted using a private key in the client node's 510 digital certificate), and broadcasts the transaction to the consensus node 910 in the blockchain network 900.
When a transaction is received in the consensus node 910 in the blockchain network 900, the digital certificate and the digital signature carried in the transaction are verified, and after the verification is successful, whether the service agent 500 has the transaction right or not is determined according to the identity of the service agent 500 carried in the transaction, and the transaction fails due to any verification judgment of the digital signature and the right verification. After verification is successful, node 910 signs its own digital signature (e.g., by encrypting the digest of the transaction using the private key of node 910-1) and continues to broadcast in blockchain network 900.
After the consensus node 910 in the blockchain network 900 receives the transaction successfully verified, the transaction is filled into a new block and broadcast. When a new block is broadcasted by the consensus node 910 in the block chain network 900, performing a consensus process on the new block, if the consensus is successful, adding the new block to the tail of the block chain stored in the new block, updating the state database according to the transaction result, and executing the transaction in the new block: for transactions submitting updated pick-up records, the pick-up records are added to the state database.
As an example of a block chain, referring to fig. 6, fig. 6 is a schematic structural diagram of a block chain in a block chain network 900 according to an embodiment of the present invention, where a header of each block may include hash values of all transactions in the block and also include hash values of all transactions in a previous block, a record of a newly generated transaction is filled in the block and is added to a tail of the block chain after being identified by nodes in the block chain network, so as to form a chain growth, and a chain structure based on hash values between blocks ensures tamper resistance and forgery prevention of transactions in the block.
An exemplary functional architecture of a block chain network provided in the embodiment of the present invention is described below, referring to fig. 7, fig. 7 is a schematic functional architecture diagram of a block chain network 900 provided in the embodiment of the present invention, which includes an application layer 901, a consensus layer 902, a network layer 903, a data layer 904, and a resource layer 905, and the following description is separately given below.
Resource layer 905 encapsulates the computing, storage, and communication resources that implement the nodes in blockchain network 900.
The data layer 904 encapsulates various data structures that implement the ledger, including blockchains implemented in files in a file system, state databases of the key-value type, and proof of presence (e.g., hash trees of transactions in blocks).
The network layer 903 encapsulates the functions of a Point-to-Point (P2P) network protocol, a data propagation mechanism and a data verification mechanism, an access authentication mechanism, and service agent identity management.
The P2P network protocol implements communication between nodes in the blockchain network 900, the data propagation mechanism ensures propagation of transactions in the blockchain network 900, and the data verification mechanism is used for implementing reliability of data transmission between nodes based on cryptography methods (such as digital certificates, digital signatures, public/private key pairs); the access authentication mechanism is used for authenticating the identity of the service subject added to the block chain network 900 according to an actual service scene, and endowing the service subject with the authority of accessing the block chain network 900 when the authentication is passed; the business entity identity management is used to store the identity of the business entity that is allowed to access blockchain network 900, as well as the permissions (e.g., the types of transactions that can be initiated).
Consensus layer 902 encapsulates the functions of a mechanism for nodes in blockchain network 900 to agree on a block (i.e., a consensus mechanism), transaction management, and ledger management. The consensus mechanism comprises consensus algorithms such as POS, POW and DPOS, and the pluggable consensus algorithm is supported.
The transaction management is used for verifying the digital signature carried in the transaction received by the node, verifying the identity information of the business body and judging and confirming whether the business body has the authority to carry out the transaction (reading the related information from the identity management of the business body) according to the identity information; for the service agents authorized to access the blockchain network 900, the service agents all have digital certificates issued by the certificate authority, and the service agents sign the submitted transactions by using private keys in the digital certificates of the service agents, so that the legal identities of the service agents are declared.
The ledger administration is used to maintain blockchains and state databases. For the block with the consensus, adding the block to the tail of the block chain; and executing the transaction in the acquired consensus block, updating the key value pairs in the state database when the transaction comprises an updating operation, inquiring the key value pairs in the state database when the transaction comprises an inquiring operation, and returning an inquiring result to the terminal node of the service main body. Supporting query operations for multiple dimensions of a state database, comprising: querying the chunk based on the chunk sequence number (e.g., hash value of the transaction); inquiring the block according to the block hash value; inquiring a block according to the transaction serial number; inquiring the transaction according to the transaction serial number; inquiring account data of a business main body according to an account (serial number) of the business main body; and inquiring the block chain in the channel according to the channel name.
The application layer 901 encapsulates various services that can be implemented by the blockchain network, including tracing, crediting, and verifying transactions.
According to the embodiment of the invention, the class code of the target class is generated according to the class code of the parent class and the hierarchy code of the target class, and because the class code of each class contains the class hierarchy relation of the class, when the class information associated with the target class is searched, the search can be directly carried out based on the class code without traversing the class of each hierarchy layer by layer, so that the search efficiency of searching the class information associated with the target class can be improved.
Fig. 8 is a schematic flowchart of a category encoding method according to an embodiment of the present invention, and referring to fig. 8, the category encoding method according to the embodiment of the present invention includes:
step 601: the server obtains a category hierarchy relation corresponding to the target category.
It should be noted that the multi-level classification structure is preset, and the terminal may determine the category hierarchical relationship corresponding to the target category directly according to the multi-level classification structure.
Step 602: and the server determines a parent category to which the target category belongs and at least two subcategories included in the parent category according to the category hierarchical relationship.
Step 603: the server obtains the category code of the parent category and the category code status of at least two sub-categories.
Here, the category coding state is used to describe whether a certain category is already coded, i.e., whether there is a category code corresponding to the category, including a coded state and an uncoded state.
Step 604: the server determines the number of sub-categories of encoded states from the category encoding states of the at least two sub-categories.
Step 605: the server assigns a hierarchical code to the target category based on the number of sub-categories of the encoded status.
If the number of sub-categories of encoded state is 1, then the target category is the second encoded sub-category, which is assigned the base layer encoding that matches the second bit in encoding order.
Step 606: the server acquires the level corresponding to the target category and the encoding length of the category code.
Step 607: and the server selects characters with target quantity from the first character in the category code of the father category according to the corresponding hierarchy of the target category.
For example, the number of characters coded by the hierarchy of each hierarchy is 2, the hierarchy corresponding to the target category is three, the hierarchy of the parent category is two, and if the category code of the parent category is 02010000, the first four characters, namely 0201, are selected.
Step 608: and the server splices the characters with the target number and the hierarchical codes of the target categories to obtain spliced codes.
For example, the target number of characters is 0201, the hierarchy of the target class is encoded as 03, and 020103 is obtained by splicing 0201 and 03.
Step 609: and the server adjusts the splicing codes according to the coding length of the splicing codes and the coding length of the category codes to obtain the category codes of the target categories.
For example, if the code length of the class code is 8 and the code length of the splicing code is 6, 20 s are added after the splicing code.
Fig. 9 is a schematic diagram of category codes according to an embodiment of the present invention, and referring to fig. 9, for the category code of each category, the first (L-1) × 2 characters are the same as the first (L-1) × 2 characters of its parent category, and the (L-1) × 2 and L × 2 characters are hierarchical codes of the category. Note that 2 indicates a hierarchical code having a length of 2 characters, and L indicates a hierarchy of the category.
Step 610: the server stores the class code of the target class.
Step 611: the client sends a search request for the target category.
Step 612: the server responds to the search request aiming at the target category, and obtains the category code of the target category.
Step 613: and the server determines the coding interval of the target category according to the category coding of the target category.
For example, the class code of the target class is 02010000, wherein 02010000 is a hexadecimal number, and then the code interval of the target class is determined to be (0x02010000, 0x0201 FFFF).
Step 614: the server compares the category code of each article with the code interval, and determines the article with the category code in the code interval as the article belonging to the target category.
Step 615: and the server returns the item information corresponding to the item belonging to the target category to the client.
Step 616: and the terminal presents the item information corresponding to the item belonging to the target category.
Fig. 10 is a schematic flowchart of a category encoding method according to an embodiment of the present invention, and referring to fig. 10, the category encoding method according to the embodiment of the present invention includes:
step 701: the server obtains a category hierarchy relation corresponding to the target category.
It should be noted that the multi-level classification structure is preset, and the terminal may determine the category hierarchical relationship corresponding to the target category directly according to the multi-level classification structure.
Step 702: and the server determines a parent category to which the target category belongs and at least two subcategories included in the parent category according to the category hierarchical relationship.
Step 703: the server obtains the category code of the parent category and the category code status of at least two sub-categories.
Here, the category coding state is used to describe whether a certain category is already coded, i.e., whether there is a category code corresponding to the category, including a coded state and an uncoded state.
Step 704: and the server acquires the class code of at least one sub-category of the coded state when determining that the class code state of at least one sub-category is the coded state according to the class code states of at least two sub-categories.
Step 705: the server extracts the hierarchical coding of the sub-category from the category coding of at least one sub-category of the encoded state.
Step 706: and the server sequentially generates the hierarchical codes of the target categories according to the hierarchical codes of the sub-categories.
For example, if there are two sub-categories of encoded state whose hierarchical encodings are 01, 02, then the hierarchical encodings 03 of the target category are generated sequentially; if there are two sub-categories of encoded state, whose level codes are A, B, then the level codes C of the target category are generated sequentially.
Step 707: and the server splices the category code of the parent category and the hierarchical code of the target category to obtain the category code of the target category.
For example, the class code of the parent class of the target class is a, the hierarchy code of the target class is B, then the class code of the target class is AB; assuming that the hierarchy coding of a certain sub-category of the target category is C, the category coding of this sub-category is ABC.
Fig. 11 is a schematic diagram of class codes provided in an embodiment of the present invention, and referring to fig. 11, for each class code, the class code of its parent class is spliced with its own hierarchical code.
Step 708: the server stores the class code of the target class.
Step 709: the client sends a search request for the target category.
Step 710: the server responds to the search request aiming at the target category, and obtains the category code of the target category.
Step 711: the server extracts the class code of the parent class of the target class from the class code of the target class.
For example, the class code of the target class is AB, then the class code of the parent class of the target class is a.
Step 712: and the server determines the parent class to which the target class belongs according to the class code of the parent class of the target class.
Step 713: the server obtains and returns category information belonging to at least two sub-categories of the parent category.
Step 714: the terminal presents category information attributed to at least two sub-categories of the parent category.
In the following, an exemplary application of the embodiments of the present invention in a practical application scenario will be described. The core of the embodiment of the invention is a class coding method based on numerical value bit segmentation, wherein the numerical value refers to a class coded value, and the bit segmentation refers to the segmentation of the class coded value according to two-level bit making. After the class coding method is divided into multiple segments, each segment represents a hierarchy of classes from high to low. For a class with a maximum level of N, we use a partition every 8 bits (i.e. 1 byte), and the class is encoded by a value of N bytes, each byte representing a level.
Fig. 12 is a schematic flowchart of a category encoding method according to an embodiment of the present invention, and referring to fig. 12, the category encoding method according to the embodiment of the present invention includes:
step 801: and acquiring the byte number of the class code of the target class.
Here, the number of bytes of the class code is the same as the maximum level number of the multi-level classification structure, for example, referring to fig. 4, the maximum level is 4, and then the number of bytes of the class code is 4, it should be noted that 1 byte includes 8-bit binary number.
In practical implementation, before step 801 is executed, a root class needs to be constructed and preset with a class code, for example, the class code of the root class as shown in fig. 4 may be preset to 0x00000000 (hexadecimal).
The root category can be understood as a category of the 0 th layer, only 1 category exists in the whole classification tree, and the first-level category in the service exists as a sub-category form of the root category. If there is only one root class in the classification tree and there are no other classes, it is indicated that this is an empty classification tree and no class data has been added.
Step 802: judging whether the target type is a root type, if so, executing a step 803; otherwise, step 804 is performed.
Step 803: and determining the class code of the target class as the class code of the preset root class.
For example, the class code of the root class shown in fig. 4 is preset to 0x000000, and the class code of the target class is 0x 000000.
Step 804: the hierarchy of the target class is determined to be L (L > 0).
Step 805: the high (L-1) bytes of the class code of the target class is determined based on the high (L-1) bytes of the class code of the parent class of the target class.
Here, the high L-1 byte of the class code of the target class is the same as the high L-1 byte of the class code of its parent class. It should be noted that, when the target class is a first-class, the highest 0 bytes are the same as the parent class, and can be ignored.
Step 806: the lth byte of the category code is sequentially assigned to the target category according to the category code status of the plurality of subcategories included in the parent category (hierarchical code).
Here, the lth byte of the category code of the target category is related to the category coding states of the plurality of subcategories included in the parent category, and if all of the plurality of subcategories included in the parent category are in an uncoded state, the lth byte of the category code of the target category is 01; if there are multiple sub-categories included in the parent category, it can be determined that the target category is encoded according to the number of sub-categories of the encoded state, and only the lth byte value is assigned to the target category.
For example, referring to fig. 9, the lth byte of the class code for design, manufacture and monitor is 01, 02 and 03 respectively, i.e. the lth byte is sequentially allocated from 01. It will be appreciated that when the target category is manufactured, it is the second encoded sub-category, and therefore its lth byte is 02.
For another example, the large car as the child category of the car is located at the fourth level, the high 3 bytes of the large car are the same as the parent category, namely 0x020101, the 4 th byte is assigned by increment, and since the 4 th byte is assigned to 03, the category is assigned 04, so that the category of the large car category is finally encoded to 0x 02010104.
Step 807: the last few bytes of the lth byte of the class code of the target class are set to 0.
Here, when L is not the maximum level, setting several bytes after the L-th byte of the class code of the target class as 0; when L is the maximum level, there are no bytes left after the lth byte that encodes the class of the target class.
For example, referring to fig. 9, the class codes of the first class are 0x01000000, 0x02000000, and 0x03000000, respectively, where 01, 02, and 03 are sequentially allocated, and the last 3 bytes are set to 0. The class codes of the four-level classes are 0x02010101, 0x02010102, 0x02010103 and 0x02010104 respectively, and no bytes remain after the L-th byte.
The application of the embodiment of the invention has the following beneficial effects:
1) the complete hierarchical relationship of the category can be directly traced through category coding. Referring to fig. 9, the category code added to an item is 0x02010101, and it is directly known that it is a compact car category (0x02010101) under the car category (0x02010100) under the car category (0x 02010110000) under the manufacturing category (0x02000000) by the category code.
2) And classification search containing subcategories is supported, and the search efficiency is extremely high based on comparison of numerical values. As shown in fig. 1, if all cars in the article library are to be searched, the classification tree does not need to be searched to obtain all the sub-classifications thereof and the sub-classifications of the sub-classifications, but the article library can be directly traversed to search all the articles with the classification codes between (0x02010000, 0x0201 FFFF). Since the class code is a pure numerical type, it is faster and more efficient in database operations.
In some embodiments, a multi-level character string structure may be used to represent the category code, that is, the form of ABC, where AB is the category code of the parent category of the category, and when a search involving a sub-category is required, for example, to search for all items under the category AB and all sub-categories thereof, the item library may be directly traversed, and all items whose category codes begin with AB may be searched for, so that a process of acquiring sub-categories through multiple rounds of traversal of the classification tree may be avoided, and the search efficiency is improved.
Continuing with the exemplary structure of the coding apparatus 455 of the type provided by the embodiment of the present invention implemented as a software module, fig. 13 is a schematic structural diagram of a coding apparatus of the type provided by the embodiment of the present invention, and referring to fig. 13, in some embodiments, the coding apparatus of the type provided by the embodiment of the present invention includes:
a first obtaining module 4551, configured to obtain a category hierarchical relationship corresponding to a target category;
a determining module 4552, configured to determine, according to the category hierarchical relationship, a parent category to which the target category belongs and at least two subcategories included in the parent category;
a second obtaining module 4553, configured to obtain the category coding of the parent category and the category coding statuses of the at least two subcategories;
a first encoding module 4554 configured to assign a hierarchical encoding to the target category according to the category encoding statuses of the at least two sub-categories;
a second encoding module 4555, configured to generate a class code of the target class according to the class code of the parent class and the hierarchical code of the target class;
a storage module 4556, configured to store a category code of the target category, where the category code is used for searching for category information associated with the target category.
In some embodiments, the apparatus further comprises:
the first search module is used for responding to a first search request aiming at the target category and acquiring the category code of the target category;
respectively matching the class code of each article with the class code of the target class to obtain the article belonging to the target class;
and presenting the item information corresponding to the item belonging to the target category.
In some embodiments, the first search module is configured to determine, when the category code is a numeric type, a coding interval of the target category according to the category code of the target category;
and respectively comparing the category code of each article with the code interval, and determining the article with the category code in the code interval as the article belonging to the target category.
In some embodiments, the apparatus further comprises:
the second search module is used for responding to a second search request aiming at the target category and acquiring the category code of the target category;
determining a class code of a parent class of the target class from the class codes;
determining a parent class to which the target class belongs according to the class code of the parent class of the target class;
category information belonging to at least two sub-categories of the parent category is obtained and presented.
In some embodiments, the first encoding module 4554 is further configured to, when determining that the category encoding status of at least one sub-category is the encoded status according to the category encoding statuses of at least two sub-categories included in the parent category, obtain a category encoding of at least one sub-category of the encoded status;
extracting a hierarchical encoding of at least one sub-category of the encoded state from a category encoding of the sub-category;
generating a hierarchical code for the target category according to the hierarchical codes for the sub-categories.
In some embodiments, the second encoding module 4555 is further configured to splice the class code of the parent class with the hierarchical code of the target class to obtain the class code of the target class.
In some embodiments, the second encoding module 4555 is further configured to obtain a level corresponding to the target category and an encoding length of a category code;
selecting characters with a target quantity from the first character in the category code of the parent category according to the level corresponding to the target category, wherein the target quantity corresponds to the level corresponding to the target category;
splicing the characters with the target number with the hierarchical codes of the target categories to obtain spliced codes;
and adjusting the splicing codes according to the coding length of the splicing codes and the coding length of the category codes to obtain the category codes of the target category.
In some embodiments, the apparatus further comprises:
the adjusting module is further used for acquiring the searching frequency of at least two sub-categories included in the parent category;
and according to the searching frequency, adjusting the encoding order of the hierarchical encoding of at least two sub-categories included in the parent category.
In some embodiments, the storage module 4556 is further configured to store the class code of the target class in a blockchain network.
Embodiments of the present invention provide a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform a method provided by embodiments of the present invention, for example, the method shown in fig. 3.
In some embodiments, the computer-readable storage medium may be memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.
In some embodiments, executable instructions may be written in any form of programming language (including compiled or interpreted languages), in the form of programs, software modules, scripts or code, and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
By way of example, executable instructions may correspond, but do not necessarily have to correspond, to files in a file system, and may be stored in a portion of a file that holds other programs or data, such as in one or more scripts in a hypertext markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code).
By way of example, executable instructions may be deployed to be executed on one computing device or on multiple computing devices at one site or distributed across multiple sites and interconnected by a communication network.
The above description is only an example of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, and improvement made within the spirit and scope of the present invention are included in the protection scope of the present invention.

Claims (10)

1. A method of coding of a class, the method comprising:
acquiring a category hierarchical relation corresponding to a target category;
determining a parent category to which the target category belongs and at least two subcategories included in the parent category according to the category hierarchical relationship;
acquiring the category coding of the parent category and the category coding states of the at least two subcategories;
assigning a hierarchical code to the target category according to the category coding states of the at least two subcategories;
generating a class code of the target class according to the class code of the parent class and the hierarchical code of the target class;
storing a category encoding of the target category, the category encoding for use in searching for category information associated with the target category.
2. The method of claim 1, wherein the method further comprises:
in response to a first search request for the target category, acquiring a category code of the target category;
respectively matching the class code of each article with the class code of the target class to obtain the article belonging to the target class;
and presenting the item information corresponding to the item belonging to the target category.
3. The method of claim 2, wherein said separately matching the class code of each item to the class code of the target class, resulting in the item belonging to the target class, comprises:
when the class code is a numerical type, determining a coding interval of the target class according to the class code of the target class;
and respectively comparing the category code of each article with the code interval, and determining the article with the category code in the code interval as the article belonging to the target category.
4. The method of claim 1, wherein the method further comprises:
in response to a second search request for the target category, acquiring a category code of the target category;
determining a class code of a parent class of the target class from the class codes;
determining a parent class to which the target class belongs according to the class code of the parent class of the target class;
category information belonging to at least two sub-categories of the parent category is obtained and presented.
5. The method of claim 1, wherein said assigning a hierarchical code to the target category based on the category coding states of at least two sub-categories included in the parent category comprises:
according to the category coding states of at least two sub-categories included in the parent category, when the category coding state of at least one sub-category is determined to be a coded state, acquiring the category coding of at least one sub-category of the coded state;
extracting a hierarchical encoding of at least one sub-category of the encoded state from a category encoding of the sub-category;
generating a hierarchical code for the target category according to the hierarchical codes for the sub-categories.
6. The method of claim 1, wherein generating the class code for the target class based on the class code for the parent class and the hierarchical code for the target class comprises:
and splicing the category code of the parent category with the hierarchy code of the target category to obtain the category code of the target category.
7. The method of claim 1, wherein generating the class code for the target class based on the class code for the parent class and the hierarchical code for the target class comprises:
acquiring a level corresponding to the target category and a coding length of a category code;
selecting characters with a target quantity from the first character in the category code of the parent category according to the level corresponding to the target category, wherein the target quantity corresponds to the level corresponding to the target category;
splicing the characters with the target number with the hierarchical codes of the target categories to obtain spliced codes;
and adjusting the splicing codes according to the coding length of the splicing codes and the coding length of the category codes to obtain the category codes of the target category.
8. The method of claim 1, wherein the method further comprises:
obtaining the searching frequency of at least two sub-categories included in the parent category;
and according to the searching frequency, adjusting the encoding order of the hierarchical encoding of at least two sub-categories included in the parent category.
9. The method of claim 1, wherein the method further comprises:
storing the class code of the target class to a blockchain network.
10. An encoding apparatus of the class, characterized in that the apparatus comprises:
the first acquisition module is used for acquiring a category hierarchical relationship corresponding to a target category;
the determining module is used for determining a parent category to which the target category belongs and at least two sub-categories included in the parent category according to the category hierarchical relationship;
a second obtaining module, configured to obtain a category code of the parent category and category code states of the at least two sub-categories;
a first encoding module for assigning a hierarchical encoding to the target category according to the category encoding status of the at least two sub-categories;
the second encoding module is used for generating the class code of the target class according to the class code of the parent class and the hierarchical code of the target class;
a storage module to store a category code for the target category, the category code for use in searching for category information associated with the target category.
CN202010109043.9A 2020-02-21 2020-02-21 Category encoding method and device Active CN111339193B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010109043.9A CN111339193B (en) 2020-02-21 2020-02-21 Category encoding method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010109043.9A CN111339193B (en) 2020-02-21 2020-02-21 Category encoding method and device

Publications (2)

Publication Number Publication Date
CN111339193A true CN111339193A (en) 2020-06-26
CN111339193B CN111339193B (en) 2023-06-27

Family

ID=71185346

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010109043.9A Active CN111339193B (en) 2020-02-21 2020-02-21 Category encoding method and device

Country Status (1)

Country Link
CN (1) CN111339193B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113569101A (en) * 2021-07-28 2021-10-29 上海数慧系统技术有限公司 Service information processing method and device
CN117555494A (en) * 2024-01-12 2024-02-13 南京荧火泰讯信息科技有限公司 Coding management system for signal processing board

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102819536A (en) * 2011-09-27 2012-12-12 金蝶软件(中国)有限公司 Processing method and device of tree type data
CN103279544A (en) * 2013-06-05 2013-09-04 中国电子科技集团公司第十五研究所 Method and device for storing and inquiring tree structure data in relational database
WO2015104451A1 (en) * 2014-01-07 2015-07-16 Nokia Technologies Oy Method and apparatus for video coding and decoding
CN105447123A (en) * 2009-12-01 2016-03-30 富志杰 Data classification, storage and query methods
CN106851295A (en) * 2011-07-11 2017-06-13 太阳专利托管公司 Coding method and code device
CN106878715A (en) * 2011-06-27 2017-06-20 太阳专利托管公司 Coding method and code device
CN109215796A (en) * 2018-08-14 2019-01-15 平安医疗健康管理股份有限公司 Searching method, device, computer equipment and storage medium
CN110263043A (en) * 2019-06-24 2019-09-20 苏州睿威博科技有限公司 Date storage method, data query method, apparatus and storage medium
CN110705528A (en) * 2019-11-25 2020-01-17 支付宝(杭州)信息技术有限公司 Identity coding method and device and feeding material identity coding method and device
CN110781676A (en) * 2019-09-30 2020-02-11 腾讯科技(深圳)有限公司 Text processing method, device and system, electronic equipment and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105447123A (en) * 2009-12-01 2016-03-30 富志杰 Data classification, storage and query methods
CN106878715A (en) * 2011-06-27 2017-06-20 太阳专利托管公司 Coding method and code device
CN106851295A (en) * 2011-07-11 2017-06-13 太阳专利托管公司 Coding method and code device
CN102819536A (en) * 2011-09-27 2012-12-12 金蝶软件(中国)有限公司 Processing method and device of tree type data
CN103279544A (en) * 2013-06-05 2013-09-04 中国电子科技集团公司第十五研究所 Method and device for storing and inquiring tree structure data in relational database
WO2015104451A1 (en) * 2014-01-07 2015-07-16 Nokia Technologies Oy Method and apparatus for video coding and decoding
CN109215796A (en) * 2018-08-14 2019-01-15 平安医疗健康管理股份有限公司 Searching method, device, computer equipment and storage medium
CN110263043A (en) * 2019-06-24 2019-09-20 苏州睿威博科技有限公司 Date storage method, data query method, apparatus and storage medium
CN110781676A (en) * 2019-09-30 2020-02-11 腾讯科技(深圳)有限公司 Text processing method, device and system, electronic equipment and storage medium
CN110705528A (en) * 2019-11-25 2020-01-17 支付宝(杭州)信息技术有限公司 Identity coding method and device and feeding material identity coding method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
施航海;王琰;罗鹏杰;: "图书类别的多层表示学习", 图书馆论坛, vol. 38, no. 08, pages 129 - 134 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113569101A (en) * 2021-07-28 2021-10-29 上海数慧系统技术有限公司 Service information processing method and device
CN117555494A (en) * 2024-01-12 2024-02-13 南京荧火泰讯信息科技有限公司 Coding management system for signal processing board
CN117555494B (en) * 2024-01-12 2024-03-22 南京荧火泰讯信息科技有限公司 Coding management system for signal processing board

Also Published As

Publication number Publication date
CN111339193B (en) 2023-06-27

Similar Documents

Publication Publication Date Title
US11431486B2 (en) System or method to implement consensus on read on distributed ledger/blockchain
US11038771B2 (en) Systems, methods, and apparatuses for implementing a metadata driven rules engine on blockchain using distributed ledger technology (DLT)
US11811769B2 (en) Systems, methods, and apparatuses for implementing a declarative, metadata driven, cryptographically verifiable multi-network (multi-tenant) shared ledger
CN110727712B (en) Data processing method and device based on block chain network, electronic equipment and storage medium
US8239954B2 (en) Access control based on program properties
CN108694189B (en) Management of commonly owned database systems
CN109347868B (en) Information verification method, device and storage medium
US11893009B2 (en) Blockchain database management system
CN110543545A (en) file management method and device based on block chain and storage medium
CN110705683A (en) Random forest model construction method and device, electronic equipment and storage medium
US20210073796A1 (en) Method of selective authentication of a blockchain user with a smart contract
CN111274268A (en) Internet of things data transmission method, device, medium and electronic equipment
US20190199689A1 (en) Securing data objects through blockchain computer programs
CN111177246A (en) Service data processing method and device
CN110544042A (en) Book management method and device based on block chain network
CN111339193B (en) Category encoding method and device
US11409724B2 (en) Hashed balanced tree data structure
CN111241195B (en) Database processing method, device, equipment and storage medium of distributed system
CN115114372A (en) Data processing method, device and equipment based on block chain and readable storage medium
CN112766998A (en) Data processing method and device for business activities
CN113011960A (en) Block chain-based data access method, device, medium and electronic equipment
CN116070191A (en) Information processing method and device, storage medium, and program product
CN113364821A (en) Functional service access method, device and storage medium
CN112612482A (en) Method, device, equipment and storage medium for executing intelligent contract
CN110765210B (en) Authentication method, device, equipment and medium based on block chain

Legal Events

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40024722

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant