Data storage method, electronic equipment and computer readable storage medium

By storing key data and value data in fixed-length byte arrays in cloud computing, the problem of high memory occupancy rate of massive data is solved and efficient memory utilization is achieved.

CN120429296APending Publication Date: 2025-08-05HANGZHOU ALICLOUD FEITIAN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410154000.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-02
Publication Date
2025-08-05

AI Technical Summary

Technical Problem

In cloud computing, the memory cache of massive data leads to a high memory occupancy problem.

Method used

The key data is stored in the first byte array and the value data is stored in the second byte array. The key data is stored uniformly through a fixed length to avoid repeated storing of object header information.

Benefits of technology

It reduces the memory usage rate of massive data and improves the efficiency and accuracy of data storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120429296A_ABST
    Figure CN120429296A_ABST
Patent Text Reader

Abstract

The invention discloses a data storage method, electronic equipment and a computer readable storage medium. The method relates to the field of data processing in cloud computing, and comprises the following steps: obtaining to-be-stored data, the to-be-stored data comprising key data and value data; a first storage position of the key data in a first byte array is determined based on the key data, a second storage position of the value data in a second byte array is determined based on the value data, and the first byte array and the second byte array are located in a memory; storing the value data to a second storage position in the second byte array; the key data and the second storage position are stored in a first byte in the first byte array, and the first byte is used for representing a first preset number of bytes starting from the first storage position in the first byte array. According to the method and the device, the technical problem that the memory occupancy rate is relatively high due to the fact that massive data are cached in the memory in related technologies is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing in cloud computing. Specifically, it relates to a data storage method, an electronic device, and a computer-readable storage medium. Background Art

[0002] In the scenario of cloud computing, there is a vast amount of data to be processed. During the processing, memory is often used to cache data to meet the requirements of efficient processing processes. Currently, the method for storing a vast amount of data usually adopts string storage. When storing a vast amount of data into memory, the string arrays for storing different data are different, and the string arrays of different data all contain object headers. A vast amount of object headers will be stored in memory, which results in a relatively high occupancy rate of memory.

[0003] In response to the above problems, no effective solution has been proposed yet. Summary of the Invention

[0004] Embodiments of this application provide a data storage method, an electronic device, and a computer-readable storage medium to at least solve the technical problem in the related art that when caching a vast amount of data in memory, the occupancy rate of memory is relatively high.

[0005] According to one aspect of the embodiments of this application, a data storage method is provided, including: obtaining data to be stored, where the data to be stored includes: key data and value data; determining a first storage position of the key data in a first byte array based on the key data, and determining a second storage position of the value data in a second byte array based on the value data, where the first byte array and the second byte array are located in memory; storing the value data at the second storage position in the second byte array; storing the key data and the second storage position at the first byte in the first byte array, where the first byte is used to represent a first preset number of bytes starting from the first storage position in the first byte array.

[0006] According to another aspect of the embodiments of this application, a data storage method is further provided, including: responding to an input instruction acting on an operation interface, and displaying the data to be stored on the operation interface, where the data to be stored includes: key data and value data; responding to a storage instruction acting on the operation interface, and displaying a storage result of the data to be stored on the operation interface, where the storage result is generated after storing the value data at the second storage position in the second byte array, and storing the key data and the second storage position at the first byte in the first byte array. The first byte array and the second byte array are located in memory, the first byte is used to represent a first preset number of bytes starting from the first storage position in the first byte array, the first storage position is determined based on the key data, and the second storage position is determined based on the value data.

[0007] According to another aspect of the embodiments of the present application, a data storage method is further provided, including: obtaining the data to be stored by calling a first interface, where the first interface includes a first parameter, and the parameter value of the first parameter includes the data to be stored, and the data to be stored includes: key data and value data; determining a first storage position of the key data in a first byte array based on the key data, and determining a second storage position of the value data in a second byte array based on the value data, where the first byte array and the second byte array are located in the memory; storing the value data to the second storage position in the second byte array; storing the key data and the second storage position to the first byte in the first byte array, where the first byte is used to represent a first preset number of bytes starting from the first storage position in the first byte array; outputting a storage result by calling a second interface, where the second interface includes a second parameter, and the parameter value of the second parameter includes the storage result, and the storage result is used to represent that the storage of the data to be stored is completed.

[0008] According to another aspect of the embodiments of the present application, a data storage device is further provided, including: an obtaining module, configured to obtain the data to be stored, where the data to be stored includes: key data and value data; a determining module, configured to determine a first storage position of the key data in a first byte array based on the key data, and determine a second storage position of the value data in a second byte array based on the value data, where the first byte array and the second byte array are located in the memory; a first storage module, configured to store the value data to the second storage position in the second byte array; a second storage module, configured to store the key data and the second storage position to the first byte in the first byte array, where the first byte is used to represent a first preset number of bytes starting from the first storage position in the first byte array.

[0009] According to another aspect of the embodiments of the present application, a data storage device is further provided, including: a first display module, configured to display the data to be stored on an operation interface in response to an input instruction acting on the operation interface, where the data to be stored includes: key data and value data; a second display module, configured to display a storage result of the data to be stored on the operation interface in response to a storage instruction acting on the operation interface, where the storage result is generated after storing the value data to the second storage position in the second byte array, and storing the key data and the second storage position to the first byte in the first byte array, the first byte array and the second byte array are located in the memory, the first byte is used to represent a first preset number of bytes starting from the first storage position in the first byte array, the first storage position is determined based on the key data, and the second storage data is determined based on the value data.

[0010] According to another aspect of the embodiments of the present application, a data storage device is further provided, including: an acquisition module, configured to acquire data to be stored by invoking a first interface, where the first interface includes a first parameter, and the parameter value of the first parameter includes the data to be stored, and the data to be stored includes: key data and value data; a determination module, configured to determine a first storage position of the key data in a first byte array based on the key data, and determine a second storage position of the value data in a second byte array based on the value data, where the first byte array and the second byte array are located in the memory; a first storage module, configured to store the value data to the second storage position in the second byte array; a second storage module, configured to store the key data and the second storage position to the first byte in the first byte array, where the first byte is used to represent a first preset number of bytes starting from the first storage position in the first byte array; an output module, configured to output a storage result by invoking a second interface, where the second interface includes a second parameter, and the parameter value of the second parameter includes the storage result, and the storage result is used to represent that the storage of the data to be stored is completed.

[0011] According to another aspect of the embodiments of the present application, an electronic device is further provided, including: a memory storing an executable program; a processor configured to run the program, where when the program runs, it executes the method of any one of the above.

[0012] According to another aspect of the embodiments of the present application, a computer-readable storage medium is further provided, where the computer-readable storage medium includes a stored executable program, and when the executable program runs, it controls the device where the storage medium is located to execute the method of any one of the above.

[0013] In the embodiments of the present application, the following method is adopted: acquire data to be stored, where the data to be stored includes: key data and value data; determine a first storage position of the key data in a first byte array based on the key data, and determine a second storage position of the value data in a second byte array based on the value data, where the first byte array and the second byte array are located in the memory; store the value data to the second storage position in the second byte array; store the key data and the second storage position to the first byte in the first byte array, where the first byte is used to represent a first preset number of bytes starting from the first storage position in the first byte array. It is easy to notice that by uniformly storing different key data in a byte array according to a fixed length, there is no need to repeatedly store the object header information of different key data, so as to achieve the purpose of compressing the data in the memory, thereby realizing the technical effect of reducing the occupancy rate of the memory by a large amount of data, and further solving the technical problem in the related art that when caching a large amount of data in the memory, the occupancy rate of the memory is relatively high.

[0014] It is easy to notice that the above general description and the following detailed description are only for exemplifying and explaining the present application, and do not constitute a limitation to the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The drawings described herein are used to provide a further understanding of the present application, and constitute a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application, and do not constitute an improper limitation to the present application. In the drawings:

[0016] Figure 1 is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a data storage method according to an embodiment of the present application;

[0017] Figure 2 is a structure block diagram of a computing environment according to an embodiment of the present application;

[0018] Figure 3 is a structure block diagram of a service mesh according to an embodiment of the present application;

[0019] Figure 4 is a flowchart of a data storage method according to Embodiment 1 of the present application;

[0020] Figure 5 is a flowchart of an optional method for storing data according to Embodiment 1 of the present application;

[0021] Figure 6 is a schematic diagram of an optional first byte array and second byte array according to Embodiment 1 of the present application;

[0022] Figure 7 is a flowchart of a data storage method according to Embodiment 2 of the present application;

[0023] Figure 8 is a schematic diagram of an optional operation interface according to Embodiment 2 of the present application;

[0024] Figure 9 is a flowchart of a data storage method according to Embodiment 3 of the present application;

[0025] Figure 10 is a schematic diagram of a data storage device according to Embodiment 4 of the present application;

[0026] Figure 11 is a schematic diagram of a data storage device according to Embodiment 5 of the present application;

[0027] Figure 12 is a schematic diagram of a data storage device according to Embodiment 5 of the present application;

[0028] Figure 13It is a structural block diagram of an electronic device according to an embodiment of the present application. Detailed implementation manners

[0029] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0030] It should be noted that the terms "first", "second", etc. in the description and claims of the present application and the above-mentioned accompanying drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data used in appropriate cases can be interchanged so that the embodiments of the present application described here can be implemented in an order different from those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0031] First, some nouns or terms that appear during the description of the embodiments of the present application are applicable to the following explanations:

[0032] Byte array: A byte array is a data structure used to store a continuous memory area of a series of byte data. It is usually used to save binary data in memory, such as images, audio, video, files, etc. Each byte in the byte array can be accessed and modified through indexing.

[0033] MD5: message digest algorithm 5, the fifth version of the message digest algorithm, which is a message digest algorithm and belongs to a kind of hash algorithm.

[0034] Embodiment 1

[0035] According to an embodiment of the present application, a data storage method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order from that here.

[0036] The method embodiment provided by the first embodiment of the present application may be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 It is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a data storage method according to an embodiment of the present application. As Figure 1 shown, the computer terminal 10 (or mobile device) may include one or more (shown as 102a, 102b,..., 102n in the figure) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microcontroller unit (MCU) or a field-programmable gate array (FPGA)), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may further include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only illustrative and does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 10 may further include more or fewer components than Figure 1 shown, or have a different configuration from Figure 1 shown.

[0037] It should be noted that the above one or more processors 102 and / or other data processing circuits are generally referred to as "data processing circuits" in this article. The data processing circuit may be embodied in software, hardware, firmware or any other combination in whole or in part. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any one of the other elements in the computer terminal 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit is used for processor control (such as the selection of a variable resistance terminal path connected to an interface).

[0038] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage devices corresponding to the data storage method in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the above-mentioned data storage method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories can be connected to the computer terminal 10 through a network. Examples of the above-mentioned network include but are not limited to the Internet, enterprise intranets, local area networks, mobile communication networks, and combinations thereof.

[0039] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of the computer terminal 10. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one instance, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0040] The display can be, for example, a touch-screen liquid crystal display (Liquid Crystal Display, LCD), and this liquid crystal display enables a user to interact with the user interface of the computer terminal 10 (or mobile device).

[0041] Figure 1 The shown hardware structure block diagram can not only be used as an exemplary block diagram of the above-mentioned computer terminal 10 (or mobile device), but also as an exemplary block diagram of the above-mentioned server. In an optional embodiment, Figure 2 is shown in a block diagram using the above Figure 1 shown computer terminal 10 (or mobile device) as a computing node in the computing environment 201 in one embodiment. Figure 2 is a structural block diagram of a computing environment according to an embodiment of the present application, such as Figure 2As shown, the computing environment 201 includes multiple computing nodes (such as servers, shown as 210-1, 210-2, … in the figure) running on a distributed network. Each computing node contains local processing and memory resources, and end users 202 can remotely run applications or store data in the computing environment 201. Applications can be provided as multiple services 220-1, 220-2, 220-3, and 220-4 in the computing environment 201, representing services "A", "D", "E", and "H" respectively.

[0042] End users 202 can provide and access services through a web browser or other software applications on the client side. In some embodiments, the provision and / or requests of end users 202 can be provided to the ingress gateway 230. The ingress gateway 230 can include a corresponding proxy to handle the provision and / or requests for services (one or more services provided in the computing environment 201).

[0043] Services are provided or deployed according to various virtualization technologies supported by the computing environment 201. In some embodiments, services can be provided based on virtual machine (VM)-based virtualization, container-based virtualization, and / or similar means. VM-based virtualization can simulate a real computer by initializing a virtual machine and execute programs and applications without directly accessing any actual hardware resources. While virtualizing the machine with a virtual machine, according to container-based virtualization, containers can be launched to virtualize the entire operating system (OS) so that multiple workloads can run on a single operating system instance.

[0044] In one embodiment of container-based virtualization, several containers of a service can be assembled into a Pod (for example, a Kubernetes Pod). For example, as Figure 2 shown, service 220-2 can be equipped with one or more Pods 240-1, 240-2, …, 240-N (collectively referred to as Pods). A Pod can include a proxy 245 and one or more containers 242-1, 242-2, …, 242-M (collectively referred to as containers). One or more containers in a Pod handle requests related to one or more corresponding functions of the service, and the proxy 245 generally controls network functions related to the service, such as routing, load balancing, etc. Other services can also be equipped with similar Pods.

[0045] During operation, executing user requests from end users 202 may require invoking one or more services in the computing environment 201, and executing one or more functions of a service may require invoking one or more functions of another service. As Figure 2As shown, service "A" 220-1 receives a user request from end user 202 at ingress gateway 230. Service "A" 220-1 may invoke service "D" 220-2, and service "D" 220-2 may request service "E" 220-3 to perform one or more functions.

[0046] The computing environment described above may be a cloud computing environment where the allocation of resources is managed by a cloud service provider, allowing for the development of functions without concern for implementing, tuning, or scaling servers. This computing environment allows developers to execute code in response to events without building or maintaining complex infrastructure. Services can be segmented into sets of functions that can scale automatically and independently rather than scaling a single hardware device to handle potential loads.

[0047] In another alternative embodiment, Figure 3 is shown in block diagram form an embodiment of a service mesh using the Figure 1 computer terminal 10 (or mobile device) shown above. Figure 3 is a structural block diagram of a service mesh according to an embodiment of the present application, as Figure 3 shown. The service mesh 300 is mainly used to facilitate secure and reliable communication between multiple microservices. A microservice refers to decomposing an application into multiple smaller services or instances and running them on different clusters / machines.

[0048] As Figure 3 shown, the microservices may include application service instance A and application service instance B, and application service instance A and application service instance B form the functional application layer of service mesh 300. In one implementation, application service instance A runs in the form of a container / process 308 on a machine / workload container group 314 (Pod), and application service instance B runs in the form of a container / process 310 on a machine / workload container group 316 (Pod).

[0049] In one implementation, application service instance A may be a product query service, and application service instance B may be a product order placement service.

[0050] As Figure 3As shown, application service instance A and mesh proxy (sidecar) 303 coexist in machine workload container group 314, and application service instance B and mesh proxy 305 coexist in machine workload container 316. Mesh proxy 303 and mesh proxy 305 form the data plane layer (dataplane) of service mesh 300. Among them, mesh proxy 303 and mesh proxy 305 run in the form of container / process 304 and container / process 306 respectively, can receive requests 312 for commodity query services, and there can be two-way communication between mesh proxy 303 and application service instance A, and between mesh proxy 305 and application service instance B. In addition, there can also be two-way communication between mesh proxy 303 and mesh proxy 305.

[0051] In one implementation, the traffic of application service instance A is routed to the appropriate destination through mesh proxy 303, and the network traffic of application service instance B is routed to the appropriate destination through mesh proxy 305. It should be noted that the network traffic mentioned here includes but is not limited to forms such as Hyper Text Transfer Protocol (abbreviated as HTTP), Representational State Transfer (abbreviated as REST), high-performance, general open-source framework (google Remote Procedure Call, gRPC), open-source in-memory data structure storage system (Redis), etc.

[0052] In one implementation, the function of the extended data plane layer can be realized by writing custom filters (Filter) for the proxy (Envoy) in service mesh 300. The service mesh proxy configuration can be to enable the service mesh to correctly proxy service traffic and achieve service interconnection and service governance. Mesh proxy 303 and mesh proxy 305 can be configured to perform at least one of the following functions: service discovery, health checking, routing, load balancing, authentication and authorization, and observability.

[0053] As Figure 3 shown, the service mesh 300 also includes a control plane layer. Among them, the control plane layer can be a group of services running in a dedicated namespace, and these services are hosted by the managed control plane component 301 in machine / workload container group (machine / Pod) 302. As Figure 3As shown in the figure, the managed control plane component 301 communicates bidirectionally with the grid agents 303 and 305. The managed control plane component 301 is configured to perform some control and management functions. For example, the managed control plane component 301 receives the telemetry data transmitted by the grid agents 303 and 305, and can further aggregate this telemetry data. For these services, the managed control plane component 301 can also provide an application programming interface (API) for users to more easily manipulate network behavior, and provide configuration data to the grid agents 303 and 305, etc.

[0054] Under the above operating environment, the present application provides a data storage method as shown in Figure 4 the figure. Figure 4 It is a flowchart of a data storage method according to Embodiment 1 of the present application. As shown in Figure 4 the figure, it includes: a cloud 10 and a client 20, and the cloud 10 communicates with the client 20 through a network. At the cloud, the following operations can be performed: obtaining the data to be stored, determining the first storage location of the key data in the first byte array based on the key data, and determining the second storage location of the value data in the second byte array based on the value data, storing the value data at the second storage location in the second byte array, storing the key data and the second storage location at the first byte in the first byte array to obtain a storage result, and sending the storage result to the client. At the client, the following operations can be performed: sending the data to be stored to the cloud and receiving the storage result returned by the cloud.

[0055] As shown in Figure 4 the figure, the method includes the following steps:

[0056] Step S4:02, obtaining the data to be stored, where the data to be stored includes: key data and value data.

[0057] The above data to be stored can be a large amount of data used for research and applications in fields such as big data analysis, machine learning, and artificial intelligence. Among them, the large amount of data can include, but is not limited to: medical and health data, financial industry data, scientific research data, production and manufacturing data, and user security data. The above key data can be used to search for a large amount of data. For example, it can be an identifier or index for searching a large amount of data. The above value data can be the specific content of the large amount of data associated with the key data.

[0058] In an alternative embodiment, as cloud computing scenarios are increasingly widely applied, the cloud will receive a vast amount of data. During the process of processing this vast amount of data, the cloud often caches the vast amount of data in memory to achieve the purpose of efficient processing. Therefore, in the case where the cloud needs to process a vast amount of data, first, the vast amount of data can be sent to the cloud. After the cloud obtains the vast amount of data, it can store the vast amount of data in memory. Among them, in order to reduce the memory occupancy rate of the vast amount of data, the processing device of the cloud can first obtain the data to be stored from the cloud, process the data to be stored, and then return the compressed data to be stored to memory, thus reducing the memory occupancy rate of the data to be stored. It should be noted that the data to be stored includes key data (key) and value data (value). Among them, the cloud can find the required data through the key and obtain the specific content of the required data through the value.

[0059] Step S404: Determine the first storage location of the key data in the first byte array based on the key data, and determine the second storage location of the value data in the second byte array based on the value data, where the first byte array and the second byte array are located in memory.

[0060] The above-mentioned first byte array can be a byte array for storing key data. Among them, the first byte array includes: object header, instance data, and padding. The above-mentioned first storage location can be the location in the first byte array where the key data is stored, that is, the above-mentioned instance data part. The above-mentioned second byte array can be a byte array for storing value data. Among them, the second byte array includes: object header, instance data, and padding. The second byte array is a two-dimensional byte array. The first-dimensional byte array stores the storage locations of different value data in the second-dimensional byte array, and the second-dimensional byte array stores the specific contents of different value data. For example, when the key data is an English sentence, the English sentence can be stored in the second-dimensional byte array according to characters, with different characters stored in different bytes, and the identifier corresponding to the second-dimensional byte array is stored in the first-dimensional byte array. The above-mentioned second storage location can be the location in the second byte array where the value data is stored, that is, the above-mentioned instance data part.

[0061] In an alternative embodiment, when the processing device in the cloud obtains the data to be stored, it can first determine the first storage location of the key data in the first byte array based on the key data. At the same time, it can also determine the second storage location of the value data in the second byte array based on the value data. It should be noted that in this application, different key data are stored sequentially in the same one-dimensional byte array (i.e., the first byte array) according to a fixed length, and there is no need to store the value data in a two-dimensional byte array like the key data. For example, the processing device in the cloud can first determine, based on the byte size of the key data, the storage location in the first byte array that can completely store the key data, and use this storage location as the first storage location. At the same time, the processing device in the cloud can also determine, based on the byte size of the value data, the storage location in the second byte array that can completely store the value data, and use this storage location as the second storage location. For example, the processing device can obtain the hash value of the key data and sequentially match multiple storage locations in the first byte array based on the hash value of the key data to obtain the first storage location. At the same time, the processing device can also obtain the hash value of the value data and sequentially match multiple storage locations in the second byte array based on the hash value of the value data to obtain the second storage location.

[0062] Optionally, the processing device can first assign different numbers to different key data, and then assign numbers to the value data that correspond one-to-one with the key data. Then, the processing device can determine the storage location in the first byte array that can store the key data based on the number of the key data, and determine the storage location in the second byte array that can store the value data based on the number of the value data. For example, the processing device first determines at least one storage location in the first byte array where no data is stored, and then can number at least one storage location in the first byte array. Among them, the numbers of at least one storage location in the first byte array are the same as the numbers of the key data. Then, the processing device can store the key data with the same number into at least one storage location with the same number based on the number, that is, the first storage location can be obtained. Similarly, the processing device first also determines at least one storage location in the second byte array where no data is stored, and then can number at least one storage location in the second byte array. Among them, the numbers of at least one storage location in the second byte array are the same as the numbers of the value data. Then, the processing device can store the value data with the same number into at least one storage location with the same number based on the number, that is, the second storage location can be obtained.

[0063] Step S406: Store the value data into the second storage location in the second byte array.

[0064] In an alternative embodiment, when the second storage location is determined, the value data can be stored into the second storage location in the second byte array.

[0065] Step S408: Store the key data and the second storage location into the first byte of the first byte array, where the first byte is used to represent a first preset number of bytes starting from the first storage location in the first byte array.

[0066] The above-mentioned first preset number is a fixed number determined according to the structure of the key data. That is to say, the lengths of different key data in the first byte array are all fixed and the same. The specific value is not limited in this embodiment. For example, the value can be 20, or it can be 10, 40, etc. In this embodiment, only 20 is taken as an example for illustration. From the first preset number, it can be seen that the first byte is a byte with a fixed length. For example, it can be 20 bytes, but not limited to this. Among them, when the length of the first byte is 20 bytes, 16 bytes of the 20 bytes are the fixed length of the key data after processing the key data. For example, it can be the information digest result value of the key data, or it can be a 16-byte number assigned to the key data, but not limited to this. Similarly, 4 bytes of the 20 bytes are the number (i.e., the index) of the value data corresponding to the key data in the second byte array. When the length of the first byte is 10 bytes, 8 bytes of the 10 bytes can be a number with a fixed byte length assigned to the key data, and 2 bytes can be a number with a fixed byte length of the value data corresponding to the key data in the second byte array.

[0067] In an optional embodiment, after storing the value data into the second storage location in the second byte array, the second storage location can be converted into data with a fixed byte, that is, the index byte of the value data in the second byte array can be obtained. Secondly, the key data and the index byte of the value data in the second byte data can be stored in the first byte of the first byte array. For example, after storing the value data into the second storage location in the second byte array, first, the second storage location can be converted into a third byte with a fixed length through a message digest algorithm. Secondly, the information digest result value of the key data and the third byte can be encapsulated and stored in the first byte of the first byte array. Another example is that after storing the value data into the second storage location in the second byte array, first, a number with a fixed byte length corresponding to the key data can be assigned to the value data. Secondly, the number with a fixed byte length of the key data and the number with a fixed byte length of the value data can be encapsulated. Then, the encapsulated number with a fixed byte length is stored in the first byte of the first byte array. It should be noted that by using a byte array to replace the string type for storage, when storing multiple key data, there is no need to repeatedly store unnecessary object headers, thereby achieving the effect of compressing the memory occupancy rate.

[0068] Optionally, during the process of processing a large amount of data through the cloud, first, the cloud can obtain a large amount of data from the client. Second, the processing device in the cloud can obtain the hash value of the key data, and match multiple storage positions in the first byte array based on the hash value of the key data to obtain the first storage position. At the same time, the processing device can also obtain the hash value of the value data, and match multiple storage positions in the second byte array based on the hash value of the value data to obtain the second storage position. For example, the processing device can determine the first initial position of the key data in the first byte array based on the hash value of the key data. If it is determined that there is no other data in the first initial position, the first initial position can be used as the first storage position. Similarly, the processing device can also determine the second initial position of the value data in the second byte array based on the hash value of the value data. If it is determined that there is no other data in the second initial position, the second initial position can be used as the second storage position. Then the processing device can store the value data in the second storage position, and obtain the index byte of the value data in the second byte array through the message digest algorithm. At the same time, the processing device can perform message digest algorithm processing on the key data to obtain the message digest result value of the key data. Finally, after encapsulating the message digest result value of the key data and the index byte of the value data in the second byte array, the processing device can store them in the first byte of the first byte array.

[0069] In the embodiment of the present application, the method includes obtaining the data to be stored, where the data to be stored includes: key data and value data; determining the first storage position of the key data in the first byte array based on the key data, and determining the second storage position of the value data in the second byte array based on the value data, where the first byte array and the second byte array are located in the memory; storing the value data in the second storage position in the second byte array; and storing the key data and the second storage position in the first byte of the first byte array, where the first byte is used to represent the first preset number of bytes starting from the first storage position in the first byte array. It is easy to notice that by uniformly storing different key data in a byte array according to a fixed length, there is no need to repeatedly store the object header information of different key data, so the purpose of compressing the data in the memory is achieved, thereby realizing the technical effect of reducing the occupancy rate of the memory by a large amount of data, and further solving the technical problem of high memory occupancy rate when caching a large amount of data in the memory in the related art.

[0070] In the above embodiments of the present application, determining the first storage position of the key data in the first byte array based on the key data includes: determining the first initial position of the key data in the first byte array based on the first hash value of the key data; reading the first data from the second byte in the first byte array, where the second byte is used to represent the first preset number of bytes starting from the first initial position in the first byte array; in the case where the first data is not read from the second byte, determining the first initial position as the first storage position; in the case where the first data is read from the second byte, matching the key data with the first data to determine the first storage position.

[0071] The above first initial position can be the storage position where the key data starts to be stored in the first byte array, which can be represented as m. The above second byte can be a byte with a fixed length starting from the first initial position in the first byte array. The above first data can be the data stored in the second byte in advance.

[0072] In an optional embodiment, the processing device in the cloud can first obtain the first hash value of the key data, and secondly can determine the first initial position m of the key data in the first byte array based on the hash value. Secondly, the processing device can determine the second byte with a fixed length based on the first initial position. For example, the product of the first initial position and the first preset number can be obtained, that is, the second byte with a fixed length can be obtained. And read the first data from the second byte. In the case where the processing device does not read the first data from the second byte, it can be determined that the first initial position is the first storage position. In the case where the processing device reads the first data from the second byte, the processing device can match the key data with the first data to determine the first storage position. For example, in the case where the key data is the same as the first data, the key data can be directly stored in the first initial position, so it can be determined that the first initial position is the first storage position. In the case where the key data is different from the first data, the first initial position can be moved one bit backward to obtain a new first initial position, and the new first data can be obtained from the new second byte, where the new second byte is the first preset number of bytes starting from the new first initial position, and the step of matching the key data with the new first data is repeated until the key data matches the new first data successfully, and it can be determined that the new first initial position at the time of successful matching is the first storage position. In this step, by storing different key data into the same first byte array, not only can the data length of the key data be fixed, but also the occupancy rate of the key data in the memory can be reduced, and subsequently, based on different key data in the same byte array, different value data corresponding to different key data can be quickly and accurately found, improving the search efficiency of the value data.

[0073] In the above embodiments of the present application, determining the first initial position of the key data in the first byte array based on the first hash value of the key data includes: performing a modulo operation on the first hash value and a preset number of bits to obtain the first initial position.

[0074] The above-mentioned preset number of bits can be the number of bits of the initialized key data, and the specific number of bits is determined according to the specific content of the key data, which is not limited in this embodiment.

[0075] In an optional embodiment, after the processing device obtains the first hash value of the key data, it can perform a modulo operation on the first hash value and a preset number of bits. That is, it can take the remainder of the first hash value divided by the preset number of bits n to obtain the first initial position m. In this step, by confirming the first initial position, the first storage position of the key data can be determined.

[0076] In the above embodiments of the present application, matching the key data with the first data to determine the first storage position includes: matching the key data with the first data to obtain a matching result; when the matching result indicates that the key data and the first data match successfully, determining the first initial position as the first storage position; when the matching result indicates that the key data and the first data match fails, moving the first initial position one bit backward, and repeating the steps of reading the first data from the second byte in the first byte array, and when the first data is read from the second byte, matching the key data with the first data to obtain a matching result until the key data and the first data match successfully.

[0077] The above-mentioned matching result is used to indicate whether the key data and the first data match successfully. Among them, when the key data and the first data are equal, it indicates that the key data and the first data match successfully; when the key data and the first data are not equal, it indicates that the key data and the first data match fails.

[0078] In an alternative embodiment, the processing device may first match the key data with the first data to obtain a matching result. When the key data is equal to the first data, the matching result is that the key data and the first data match successfully. At this time, the first initial position can be determined as the first storage position. When the key data is not equal to the first data, the matching result is that the key data and the first data match fails. At this time, the first initial position can be moved one position backward to obtain a new first initial position, and the steps of reading the new first data from the second byte in the first byte array and matching the key data with the new first data to obtain a matching result are repeated. That is, until the key data and the new first data match successfully, the new first initial position at the time of successful matching can be determined as the first storage position. In this step, by comparing the key data with the first data in the first byte array, the key data can be accurately stored, improving the storage accuracy of the key data.

[0079] In the above embodiments of the present application, matching the key data with the first data to obtain a matching result includes: processing the key data using a message digest algorithm to obtain a first message digest result corresponding to the key data, and processing the first data using the message digest algorithm to obtain a second message digest result corresponding to the first data; when the first message digest result and the second message digest result are equal, determining that the matching result is that the key data and the first data match successfully; when the first message digest result and the second message digest result are not equal, determining that the matching result is that the key data and the first data match fails.

[0080] The above message digest algorithm may be the MD5 algorithm. The above first message digest result may be the first MD5 value, and the above second message digest result may be the second MD5 value. It should be noted that since the MD5 algorithm converts input data of any length into a hash value of a fixed length, both the first message digest result and the second message digest result are fixed values.

[0081] In an alternative embodiment, first, the processing device may process the key data using the MD5 algorithm to obtain the first MD5 value. At the same time, the processing device may also process the first data using the MD5 algorithm to obtain the second MD5 value. Second, the processing device may compare the first MD5 value and the second MD5 value. When it is determined that the first MD5 value is equal to the second MD5 value, it can be determined that the matching result is that the key data and the first data match successfully. When the first MD5 value is not equal to the second MD5 value, it can be determined that the matching result is that the key data and the first data match fails. In this step, by converting the key data and the first data into data of a fixed length, the matching efficiency of matching the key data and the first data is improved.

[0082] In the above embodiments of the present application, moving the first initial position one place backward includes: obtaining the sum of the first initial position and a preset value to obtain a target sum value; performing a remainder operation on the target sum value and a preset number of digits to obtain a new first initial position.

[0083] The above preset value is the number of digits to move backward, which is 1 in this embodiment.

[0084] In an alternative embodiment, when the key data fails to match the first data, the sum of the first initial position and a preset value can be obtained to obtain a target sum value. Secondly, a remainder operation can be performed on the target sum value and a preset number of digits. That is, the remainder of the target sum value divided by the preset number of digits n can be obtained, and thus a new first initial position can be obtained.

[0085] In the above embodiments of the present application, determining the second storage position of the value data in the second byte array based on the value data includes: determining the second initial position of the value data in the second byte array based on the second hash value of the value data; reading the second data from the second initial position; in the case where the second data is not read, determining the second initial position as the second storage position; in the case where the second data is read, matching the value data with the second data to determine the second storage position.

[0086] The above second initial position may be the storage position where the value data starts to be stored. The above second data may be the data stored in the second initial position in advance.

[0087] In an optional embodiment, the processing device in the cloud can first obtain the second hash value of the value data. Secondly, it can determine the second initial position of the value data in the second byte array based on the hash value. Then, the processing device can read the second data at the second initial position. In the case where the processing device does not read the second data from the second initial position, it can determine the second initial position as the second storage position. In the case where the processing device reads the second data from the second initial position, the processing device can match the value data with the second data to determine the second storage position. For example, in the case where the value data is the same as the second data, the value data can be directly stored in the second initial position, so the second initial position can be determined as the second storage position. In the case where the value data is different from the second data, the second initial position can be moved one position backward to obtain a new second initial position, and the new second data can be read from the new second initial position, and the step of matching the value data with the new second data can be repeatedly executed until the value data matches the new second data successfully, and the new second initial position at the time of successful matching can be determined as the second storage position. In this step, by storing different value data in the same first-dimensional byte array in the second byte array, not only can the data lengths of different value data be fixed, but also the unnecessary object header information of the value data can be removed, which can reduce the occupancy rate of the value data in the memory.

[0088] In the above embodiments of the present application, determining the second initial position of the value data in the second byte array based on the second hash value of the value data includes: obtaining the difference between the preset value and the preset repetition rate to obtain the target weight, where the preset repetition rate is used to represent the repetition rate of the preset value data appearing repeatedly; obtaining the product of the target weight and the preset number of digits to obtain the target number, where the preset number is used to represent the preset number of key data; performing a modulo operation on the second hash value and the target number to obtain the second initial position.

[0089] The above preset repetition rate can be set in advance by the user and is used to determine the target weight. The specific value is not limited in this embodiment. For example, it is described with 80%, but not limited thereto, and it can also be 60%, 85%, etc. It should be noted that by obtaining the target weight, the key data and the value data can be decoupled. That is, different key data may correspond to the same value data. If the value data corresponding to the key data is stored one by one, there may be duplicate value data, which will lead to occupying the storage space of the memory. Therefore, in this embodiment, by setting the preset repetition rate, the duplicate value data can be stored only once, and by storing the index of the value data, the purpose of obtaining the same value data based on different key data can be achieved.

[0090] In an optional embodiment, the processing device may first obtain the difference between the preset value and the preset repetition rate to obtain the target weight. Secondly, it may obtain the product of the target weight and the preset number of digits to obtain the target number of digits. Finally, it may perform a modulo operation on the second hash value and the target number of digits, that is, it may take the remainder of the second hash value by the target number of digits, and thus obtain the second initial position.

[0091] In the above embodiments of the present application, matching the value data with the second data to determine the second storage position includes: comparing the value data with the second data; when the value data is equal to the second data, determining the second initial position as the second storage position; when the value data is not equal to the second data, moving the second initial position one bit backward, and repeating the step of reading the second data from the second initial position and comparing the value data with the second data when the second data is read until the value data is equal to the second data.

[0092] In an optional embodiment, the processing device may first compare the value data with the second data. When the value data is equal to the second data, it may directly store the value data into the second initial position, so the second initial position may be used as the second storage position. When the value data is not equal to the second data, it may move the second initial position one bit backward to obtain a new second initial position, and repeat the step of reading the second data from the second initial position and comparing the value data with the second data when the second data is read until the value data is equal to the second data. At this time, the storage position where the second data is equal to the value data may be determined as the second storage position. It should be noted that the specific execution steps of moving the second initial position one bit backward are the same as those of moving the first initial position one bit backward, and will not be elaborated here.

[0093] In the above embodiments of the present application, storing the key data and the second storage position into the first byte of the first byte array includes: respectively processing the key data by using a message digest algorithm to obtain a first message digest result corresponding to the key data; converting the second storage position into a second preset number of third bytes; encapsulating the first message digest result and the third bytes to obtain encapsulated data; storing the encapsulated data into the first byte.

[0094] The above-mentioned second preset quantity is a fixed value, which is determined by the fixed length of the first byte and the fixed byte length of the key data. For example, when the fixed length of the first byte is 20 and the fixed byte length of the key data is 16, the second preset quantity can be a fixed 4. When the fixed length of the first byte is 10 and the fixed byte length of the key data is 8, the second preset quantity can be a fixed 2, but not limited to this. From the second preset quantity, it can be known that the byte length of the third byte is a fixed value, where the third byte is the storage number (i.e., storage subscript) of the value data in the second byte array.

[0095] In an optional embodiment, after obtaining the key data and the second storage location, the processing device can process the key data through the MD5 algorithm to obtain the first information digest result MD5(key) corresponding to the key data. At the same time, the processing device can also convert the second storage location into a fixed-length storage subscript of the value data in the second byte array. Then, the processing device can encapsulate the first information digest result and the third byte to obtain the encapsulated data. Finally, the processing device can store the encapsulated data in the first byte. In this step, by storing a large amount of data in the form of a byte array, the memory occupied by the object header of the string when storing data in the form of a string is removed, which can effectively reduce the occupancy rate of a large amount of data in memory.

[0096] Figure 5 is a flowchart of an optional method for storing data according to Embodiment 1 of the present application, as Figure 5 shown, the method includes the following steps:

[0097] Step S51, take the remainder of the hash value of the key data with respect to a preset number of digits n to obtain the first initial position m;

[0098] Step S52, determine whether there is data (i.e., the first data) in the 20 bytes starting from the m*20th byte of the key data (i.e., the second byte). If so, enter step S57. If not, it means that the first storage position of the key data is found, and enter step S53;

[0099] Step S53, obtain the difference between the preset value and the preset repetition rate, and obtain the product of the preset number of digits and the difference. Take the remainder of the hash value of the value data value with respect to the product to obtain the second initial position p;

[0100] Step S54, determine whether there is data in the second initial position. If so, enter step S59. If not, it means that the second storage position of the value data is found, and enter step S55;

[0101] Step S55, store the value data value in the second initial position (i.e., store it in p);

[0102] Step S56: Obtain the hash value of the key data to get the first hash value. Here, the first hash value is 16 bytes, and obtain 4 index bytes of the second storage location, assemble 20 bytes, and store the assembled 20 bytes into the 20 bytes starting from the (m * 20)-th bit in the first byte array of the key data (i.e., the first byte).

[0103] Step S57: Determine whether the data in the first initial position is equal to the key data. If so, enter Step S53; if not, enter Step S58.

[0104] Step S58: Move the first initial position one bit backward to get a new first initial position, take the remainder of the new first initial position with respect to a preset number of bits, and return to Step S52.

[0105] Step S59: Determine whether the data in the second initial position is equal to the value data. If so, enter Step S55; if not, enter Step S510.

[0106] Step S510: Move the second initial position one bit backward to get a new second initial position. At the same time, obtain the difference between the preset value and the preset repetition rate, and obtain the product of the preset number of bits and the difference. Take the remainder of the new second initial position with respect to the product, and return to Step S54.

[0107] Figure 6 It is a schematic diagram of an optional first byte array and second byte array according to Embodiment 1 of the present application. As Figure 6 shown, the first byte array is used to store the data to be stored. Among them, the first byte array includes an object header (MarkWord, ClassPointer, ArrayLength), instance data (byte, that is, key data), and padding. Among them, MarkWord occupies 8 bytes, ClassPointer occupies 4 bytes, ArrayLength occupies 4 bytes, and the instance data occupies the number of key data multiplied by 20 bytes. The padding part is used to fill bytes to ensure that the entire object is a multiple of 8. Therefore, the length range of the bytes occupied by the padding part can be 0 - 7.

[0108] By Figure 6It can be seen that the second byte array contains a first-dimensional byte array and a second-dimensional byte array. Among them, both the first-dimensional byte array and the second-dimensional byte array contain: object header (MarkWord, ClassPointer, ArrayLength), instance data, and padding. Among them, MarkWord occupies 8 bytes, ClassPointer occupies 4 bytes, ArrayLength occupies 4 bytes, and the padding part is used to pad bytes to ensure that the entire object is a multiple of 8. Among them, the instance data in the first-dimensional byte array is byte[], that is, the value data corresponding to the key data. The instance data in the second-dimensional byte array is byte, that is, the specific content of the value data, and the length of the occupied bytes is the character length of the value data multiplied by 2. Among them, the padding part in the first-dimensional byte array occupies 0 or 4 bytes in length. The padding part in the second-dimensional byte array occupies a byte length range of 0-7.

[0109] It can be seen from Figure 6 that the array in the second row is a KV pair storage array composed of key data and value data. In this array, the key data and value data are stored in pairs. Among them, keys stores the number of key data, and values stores the number of value data. It can be seen from Figure 6 that in the KV pair storage array, it also contains an object header (MarkWord, ClassPointer), instance data (keys, that is, the number of key data, values, that is, the number of value data, and the software tool KeyBit for encrypting and decrypting files) and padding. Among them, MarkWord occupies 8 bytes, ClassPointer occupies 4 bytes, the length of the occupied bytes of the key data is the byte length of the first byte array, the length of the occupied bytes of the value data is 4 bytes, and the length of the occupied bytes of KeyBit is 4 bytes.

[0110] Through the data storage method disclosed in the embodiments of the present application, byte array storage is used to replace string storage, and the object header occupied by the string is removed. All keys with a fixed length are placed in a byte array, and the value is a two-dimensional byte array. For 100 million keys, the occupancy of keys is: (2 to the 27th power) * 20 ≈ 2.6G. According to an 80% repetition rate, the occupancy of values is: 2KW * 4 + 2KW * (8 + 4 + 4 + 20 * 2) ≈ 1.2G, with a total of 3.8G.

[0111] That is, in the data storage method of the embodiments of the present application, when storing the key data of the data to be stored, only the object header of the key data needs to be stored in sequence, that is, only MarkWord, ClassPointer, and ArrayLength need to be stored once. Furthermore, the bytes occupied by the object headers in multiple key data can be saved, so the effect of reducing the memory occupancy rate can be achieved.

[0112] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Moreover, the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse.

[0113] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this application is not limited by the described action sequence, because according to this application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0114] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the technical solution of this application, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc), and includes several instructions to enable a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of this application.

[0115] Embodiment 2

[0116] Figure 7 is a flowchart of a data storage method according to Embodiment 2 of this application. As Figure 7 shown, the method includes the following steps:

[0117] Step S702, in response to an input instruction acting on the operation interface, display the data to be stored on the operation interface, where the data to be stored includes: key data and value data;

[0118] Step S704, in response to a storage instruction acting on the operation interface, display the storage result of the data to be stored on the operation interface. The storage result is generated by storing the value data into the second storage location in the second byte array and storing the key data and the second storage location after the first byte in the first byte array. The first byte array and the second byte array are located in the memory. The first byte is used to represent the first preset number of bytes starting from the first storage location in the first byte array. The first storage location is determined based on the key data, and the second storage data is determined based on the value data.

[0119] Figure 8 is a schematic diagram of an optional operation interface according to Embodiment 2 of the present application. As Figure 8 shown, the operation interface includes: an input button, a storage button, and a display area. In an optional embodiment, when a large amount of storage data needs to be stored in the memory, first, the user can perform an operation (such as a pressing operation or a clicking operation) on the input button of the operation interface to generate an input instruction. Secondly, the operation interface responds to the input instruction and can display the data to be stored in the display area of the operation interface. Then, the user can perform an operation (such as a pressing operation or a clicking operation) on the storage button in the operation interface to generate a storage instruction. Finally, the operation interface can respond to the storage instruction and display the storage result of the data to be stored on the operation interface. The data to be stored includes: key data and value data. The storage result is generated by storing the value data into the second storage location in the second byte array and storing the key data and the second storage location after the first byte in the first byte array. The first byte array and the second byte array are located in the memory. The first byte is used to represent the first preset number of bytes starting from the first storage location in the first byte array. The first storage location is determined based on the key data, and the second storage data is determined based on the value data.

[0120] Embodiment 3

[0121] Figure 9 is a flowchart of a data storage method according to Embodiment 3 of the present application. As Figure 9 shown, the method includes the following steps:

[0122] Step S902, obtain the data to be stored by calling the first interface. The first interface includes a first parameter, and the parameter value of the first parameter includes the data to be stored. The data to be stored includes: key data and value data;

[0123] Step S904, determine the first storage location of the key data in the first byte array based on the key data, and determine the second storage location of the value data in the second byte array based on the value data. The first byte array and the second byte array are located in the memory;

[0124] Step S906, store the value data into the second storage location in the second byte array;

[0125] Step S908, store the key data and the second storage location into the first byte of the first byte array, where the first byte is used to represent a first preset number of bytes starting from the first storage location in the first byte array;

[0126] Step S9010, output the storage result by calling the second interface, where the second interface includes a second parameter, and the parameter value of the second parameter includes the storage result, and the storage result is used to represent that the data to be stored is stored successfully.

[0127] The above-mentioned first interface is used to obtain the data to be stored from the client. The above-mentioned second interface is used to output the storage result to the client.

[0128] In an optional embodiment, when the cloud memory needs to store a large amount of data, first, the cloud can obtain the data to be stored from the client by calling the first interface. Secondly, the processing device of the cloud can determine the first storage location of the key data in the first byte array based on the key data, and determine the second storage location of the value data in the second byte array based on the value data. Then, the processing device can store the value data into the second storage location in the second byte array, and at the same time, the processing device can also store the key data and the second storage location into the first byte of the first byte array. Finally, the processing device can output the storage result to the client by calling the second interface.

[0129] Among them, the first interface includes a first parameter, and the parameter value of the first parameter includes the data to be stored, and the data to be stored includes: key data and value data. The first byte array and the second byte array are located in the memory. The first byte is used to represent a first preset number of bytes starting from the first storage location in the first byte array. The second interface includes a second parameter, and the parameter value of the second parameter includes the storage result, and the storage result is used to represent that the data to be stored is stored successfully.

[0130] Embodiment 4

[0131] According to the embodiments of the present application, a data storage device for implementing the above data storage method is further provided. Figure 10 is a schematic diagram of a data storage device according to Embodiment 4 of the present application, as Figure 10 shown, the device includes: an acquisition module 1002, a determination module 1004, a first storage module 1006, and a second storage module 1008.

[0132] Among them, the acquisition module is used to acquire the data to be stored, where the data to be stored includes: key data and value data; the determination module is used to determine the first storage position of the key data in the first byte array based on the key data, and determine the second storage position of the value data in the second byte array based on the value data, where the first byte array and the second byte array are located in the memory; the first storage module is used to store the value data to the second storage position in the second byte array; the second storage module is used to store the key data and the second storage position to the first byte in the first byte array, where the first byte is used to represent the first preset number of bytes starting from the first storage position in the first byte array.

[0133] It should be noted here that the above acquisition module 1002, determination module 1004, first storage module 1006, and second storage module 1008 correspond to steps S402 to S408 in Embodiment 1. The examples and application scenarios implemented by the four modules and the corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1 above. It should be noted that the above modules or units can be hardware components or software components stored in a memory (for example, memory 104) and processed by one or more processors (for example, processors 102a, 102b,..., 102n), and the above modules can also be part of a device and can run in the computer terminal 10 provided in Embodiment 1.

[0134] In the above embodiments of the present application, the determination module includes: a first determination unit, a first reading unit, a second determination unit, and a third determination unit.

[0135] Among them, the first determination unit is used to determine the first initial position of the key data in the first byte array based on the first hash value of the key data; the first reading unit is used to read the first data from the second byte in the first byte array, where the second byte is used to represent the first preset number of bytes starting from the first initial position in the first byte array; the second determination unit is used to determine the first initial position as the first storage position when the first data is not read from the second byte; the third determination unit is used to match the key data with the first data and determine the first storage position when the first data is read from the second byte.

[0136] In the above embodiments of the present application, the first determination unit includes: a first operator unit.

[0137] Among them, the first operator unit is used to perform a remainder operation on the first hash value and a preset number of bits to obtain the first initial position.

[0138] In the above embodiments of the present application, the third determination unit includes: a matching subunit, a first determination subunit, and a first processing subunit.

[0139] Among them, a matching subunit is configured to match key data with first data to obtain a matching result; a first determination subunit is configured to determine a first initial position as a first storage position when the matching result indicates that the key data matches the first data successfully; a first processing subunit is configured to, when the matching result indicates that the key data fails to match the first data, move the first initial position backward by one bit, and repeatedly execute the steps of reading the first data from a second byte in the first byte array, and when the first data is read from the second byte, matching the key data with the first data to obtain a matching result until the key data matches the first data successfully.

[0140] In the above embodiments of the present application, the matching subunit is further configured to: process the key data by using a message digest algorithm to obtain a first message digest result corresponding to the key data, and process the first data by using the message digest algorithm to obtain a second message digest result corresponding to the first data; determine that the matching result is that the key data matches the first data successfully when the first message digest result is equal to the second message digest result; determine that the matching result is that the key data fails to match the first data when the first message digest result is not equal to the second message digest result.

[0141] In the above embodiments of the present application, the first processing subunit is further configured to: obtain a sum of the first initial position and a preset value to obtain a target sum value; perform a modulo operation on the target sum value and a preset number of bits to obtain a new first initial position.

[0142] In the above embodiments of the present application, the determination module further includes: a fourth determination unit, a second reading unit, a fifth determination unit, and a matching unit.

[0143] Among them, the fourth determination unit is configured to determine a second initial position of the value data in the second byte array based on a second hash value of the value data; the second reading unit is configured to read second data from the second initial position; the fifth determination unit is configured to determine the second initial position as a second storage position when the second data is not read; the matching unit is configured to match the value data with the second data when the second data is read to determine the second storage position.

[0144] In the above embodiments of the present application, the fourth determination unit includes: a first obtaining subunit, a second obtaining subunit, and a second operation subunit.

[0145] Among them, the first acquisition subunit is used to obtain the difference between a preset value and a preset repetition rate to obtain a target weight, where the preset repetition rate is used to represent the repetition rate of the occurrence of pre-set value data; the second acquisition subunit is used to obtain the product of the target weight and a preset number of digits to obtain a target number, where the preset number is used to represent the number of pre-set key data; the second operation subunit is used to perform a remainder operation on the second hash value and the target number to obtain a second initial position.

[0146] In the above embodiments of the present application, the matching unit includes: a comparison subunit, a second determination subunit, and a second processing subunit.

[0147] Among them, the comparison subunit is used to compare the value data with the second data; the second determination subunit is used to determine the second initial position as the second storage position when the value data is equal to the second data; the second processing subunit is used to move the second initial position backward by one bit when the value data is not equal to the second data, and repeatedly execute the step of reading the second data from the second initial position and comparing the value data with the second data when the second data is read until the value data is equal to the second data.

[0148] In the above embodiments of the present application, the second storage module includes: a processing unit, a conversion unit, a packaging unit, and a storage unit.

[0149] Among them, the processing unit is used to process the key data respectively by using the information digest algorithm to obtain the first information digest result corresponding to the key data; the conversion unit is used to convert the second storage position into a second preset number of third bytes; the packaging unit is used to package the first information digest result and the third bytes to obtain packaged data; the storage unit is used to store the packaged data in the first byte.

[0150] It should be noted that the preferred implementation schemes involved in the above embodiments of the present application are the same as the schemes, application scenarios, and implementation processes provided in Embodiment 1, but are not limited to the schemes provided in Embodiment 1.

[0151] Embodiment 5

[0152] According to an embodiment of the present application, there is also provided a data storage device for implementing the above data storage method. Figure 11 is a schematic diagram of a data storage device according to Embodiment 5 of the present application, as Figure 11 shown, the device includes: a first display module 1102 and a second display module 1104.

[0153] Among them, the first display module is used to respond to an input instruction acting on the operation interface and display the data to be stored on the operation interface. The data to be stored includes: key data and value data. The second display module is used to respond to a storage instruction acting on the operation interface and display the storage result of the data to be stored on the operation interface. The storage result is generated by storing the value data into the second storage position in the second byte array and storing the key data and the second storage position after the first byte in the first byte array. The first byte array and the second byte array are located in the memory. The first byte is used to represent the first preset number of bytes starting from the first storage position in the first byte array. The first storage position is determined based on the key data, and the second storage data is determined based on the value data.

[0154] It should be noted here that the above-mentioned first display module 1102 and second display module 1104 correspond to steps S02 to S04 in Embodiment 2. The examples and application scenarios implemented by the two modules and the corresponding steps are the same, but are not limited to the content disclosed in the above-mentioned Embodiment 1. It should be noted that the above-mentioned module or unit can be a hardware component or a software component stored in a memory (for example, memory 104) and processed by one or more processors (for example, processors 102a, 102b,..., 102n). The above-mentioned module can also be a part of the device and can run in the computer terminal 10 provided in Embodiment 1.

[0155] It should be noted that the preferred implementation schemes involved in the above embodiments of the present application are the same as the schemes, application scenarios, and implementation processes provided in Embodiment 1, but are not limited to the schemes provided in Embodiment 1.

[0156] Embodiment 6

[0157] According to an embodiment of the present application, there is also provided a data storage device for implementing the above data storage method. Figure 12 It is a schematic diagram of a data storage device according to Embodiment 5 of the present application, as Figure 12 shown. The device includes: an acquisition module 1202, a determination module 1204, a first storage module 1206, a second storage module 1208, and an output module 12010.

[0158] Among them, the acquisition module is used to obtain the data to be stored by calling the first interface. The first interface includes a first parameter, and the parameter value of the first parameter includes the data to be stored. The data to be stored includes: key data and value data. The determination module is used to determine the first storage location of the key data in the first byte array based on the key data, and determine the second storage location of the value data in the second byte array based on the value data. The first byte array and the second byte array are located in the memory. The first storage module is used to store the value data to the second storage location in the second byte array. The second storage module is used to store the key data and the second storage location to the first byte in the first byte array, where the first byte is used to represent the first preset number of bytes starting from the first storage location in the first byte array. The output module is used to output the storage result by calling the second interface. The second interface includes a second parameter, and the parameter value of the second parameter includes the storage result, where the storage result is used to represent that the storage of the data to be stored is completed.

[0159] It should be noted here that the above acquisition module 1202, determination module 1204, first storage module 1206, second storage module 1208, and output module 12010 correspond to steps S02 to step S010 in Embodiment 3. The functions of the five modules and the corresponding steps are the same in terms of the implemented examples and application scenarios, but are not limited to the content disclosed in the above Embodiment 1. It should be noted that the above modules or units can be hardware components or software components stored in a memory (for example, memory 104) and processed by one or more processors (for example, processors 102a, 102b,..., 102n). The above modules can also be part of a device and can run on the computer terminal 10 provided in Embodiment 1.

[0160] It should be noted that the preferred implementation schemes involved in the above embodiments of the present application are the same as the schemes, application scenarios, and implementation processes provided in Embodiment 1, but are not limited to the schemes provided in Embodiment 1.

[0161] Embodiment 7

[0162] An embodiment of the present application can provide an electronic device, and the electronic device can be any computer device in a computer terminal group. Optionally, in this embodiment, the above electronic device can also be replaced with a terminal device such as a mobile terminal.

[0163] Optionally, in this embodiment, the above electronic device can be at least one network device among multiple network devices in a computer network.

[0164] In this embodiment, the above electronic device may execute the program code of the following steps in the data storage method: obtaining data to be stored, where the data to be stored includes: key data and value data; determining a first storage position of the key data in a first byte array based on the key data, and determining a second storage position of the value data in a second byte array based on the value data, where the first byte array and the second byte array are located in the memory; storing the value data to the second storage position in the second byte array; storing the key data and the second storage position to the first byte in the first byte array, where the first byte is used to represent a first preset number of bytes starting from the first storage position in the first byte array.

[0165] Optionally, Figure 13 is a structural block diagram of an electronic device according to an embodiment of the present application. As Figure 13 shown, the electronic device A may include: one or more (only one is shown in the figure) processors 1302, a memory 1304, a storage controller, and a peripheral interface, where the peripheral interface is connected to a radio frequency module, an audio module, and a display.

[0166] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the data storage method and device in the embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implements the above data storage method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory may further include a memory remotely set relative to the processor, and these remote memories can be connected to the terminal A through a network. Examples of the above network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and their combinations.

[0167] The processor may call the information and application programs stored in the memory through a transmission device to execute the following steps: obtaining data to be stored, where the data to be stored includes: key data and value data; determining a first storage position of the key data in a first byte array based on the key data, and determining a second storage position of the value data in a second byte array based on the value data, where the first byte array and the second byte array are located in the memory; storing the value data to the second storage position in the second byte array; storing the key data and the second storage position to the first byte in the first byte array, where the first byte is used to represent a first preset number of bytes starting from the first storage position in the first byte array.

[0168] Optionally, the above-mentioned processor may also execute the program code of the following steps: determining a first initial position of the key data in the first byte array based on a first hash value of the key data; reading first data from a second byte in the first byte array, where the second byte is used to represent a first preset number of bytes starting from the first initial position in the first byte array; in the case where the first data is not read from the second byte, determining the first initial position as a first storage position; in the case where the first data is read from the second byte, matching the key data with the first data to determine the first storage position.

[0169] Optionally, the above-mentioned processor may also execute the program code of the following steps: performing a modulo operation on the first hash value and a preset number of bits to obtain a first initial position.

[0170] Optionally, the above-mentioned processor may also execute the program code of the following steps: matching the key data with the first data to obtain a matching result; in the case where the matching result indicates that the key data and the first data match successfully, determining the first initial position as the first storage position; in the case where the matching result indicates that the key data and the first data do not match successfully, moving the first initial position one bit backward, and repeating the steps of reading the first data from the second byte in the first byte array, and in the case where the first data is read from the second byte, matching the key data with the first data to obtain a matching result, until the key data and the first data match successfully.

[0171] Optionally, the above-mentioned processor may also execute the program code of the following steps: processing the key data using a message digest algorithm to obtain a first message digest result corresponding to the key data, and processing the first data using the message digest algorithm to obtain a second message digest result corresponding to the first data; in the case where the first message digest result and the second message digest result are equal, determining the matching result as that the key data and the first data match successfully; in the case where the first message digest result and the second message digest result are not equal, determining the matching result as that the key data and the first data do not match successfully.

[0172] Optionally, the above-mentioned processor may also execute the program code of the following steps: obtaining a sum of the first initial position and a preset value to obtain a target sum value; performing a modulo operation on the target sum value and a preset number of bits to obtain a new first initial position.

[0173] Optionally, the above-mentioned processor may also execute the program code of the following steps: determining a second initial position of the value data in the second byte array based on a second hash value of the value data; reading second data from the second initial position; in the case where the second data is not read, determining the second initial position as a second storage position; in the case where the second data is read, matching the value data with the second data to determine the second storage position.

[0174] Optionally, the above-mentioned processor may also execute the program code of the following steps: obtain the difference between the preset value and the preset repetition rate to obtain the target weight, where the preset repetition rate is used to represent the repetition rate of the preset value data appearing repeatedly; obtain the product of the target weight and the preset number of digits to obtain the target number, where the preset number is used to represent the number of key data preset; perform a modulo operation on the second hash value and the target number to obtain the second initial position.

[0175] Optionally, the above-mentioned processor may also execute the program code of the following steps: compare the value data with the second data; in the case where the value data is equal to the second data, determine the second initial position as the second storage position; in the case where the value data is not equal to the second data, move the second initial position one bit backward, and repeat the step of reading the second data from the second initial position and comparing the value data with the second data when the second data is read until the value data is equal to the second data.

[0176] Optionally, the above-mentioned processor may also execute the program code of the following steps: process the key data respectively by using the message digest algorithm to obtain the first message digest result corresponding to the key data; convert the second storage position into the third byte of the second preset quantity; encapsulate the first message digest result and the third byte to obtain the encapsulated data; store the encapsulated data into the first byte.

[0177] By adopting the embodiment of the present application, a method for obtaining data to be stored is provided, where the data to be stored includes: key data and value data; determine the first storage position of the key data in the first byte array based on the key data, and determine the second storage position of the value data in the second byte array based on the value data, where the first byte array and the second byte array are located in the memory; store the value data into the second storage position in the second byte array; store the key data and the second storage position into the first byte in the first byte array, where the first byte is used to represent the first preset quantity of bytes starting from the first storage position in the first byte array. It is easy to notice that by uniformly storing different key data in a byte array according to a fixed length, there is no need to repeatedly store the object header information of different key data, so as to achieve the purpose of compressing the data in the memory, thereby realizing the technical effect of reducing the occupancy rate of the memory by massive data, and further solving the technical problem of high occupancy rate of the memory when caching massive data in the memory in the related art.

[0178] Those of ordinary skill in the art can understand that Figure 13The structure shown is only schematic. The electronic device can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a personal digital assistant, and terminal devices such as Mobile Internet Devices (MID), PAD, etc. Figure 13 It does not limit the structure of the above-mentioned electronic device. For example, electronic device A may further include more or fewer components (such as a network interface, a display device, etc.) than those shown Figure 13 in the figure, or have a different configuration from that shown Figure 13 in the figure.

[0179] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, and the storage medium can include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc, etc.

[0180] Embodiment 8

[0181] An embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the above storage medium can be used to store the program code executed by the data storage method provided in the first embodiment above.

[0182] Optionally, in this embodiment, the above storage medium can be located in any one of the computer terminals in a computer terminal group in a computer network, or in any one of the mobile terminals in a mobile terminal group.

[0183] Optionally, in this embodiment, the storage medium is set to store program code for performing the following steps: obtaining data to be stored, where the data to be stored includes: key data and value data; determining a first storage location of the key data in a first byte array based on the key data, and determining a second storage location of the value data in a second byte array based on the value data, where the first byte array and the second byte array are located in memory; storing the value data to the second storage location in the second byte array; storing the key data and the second storage location to the first byte in the first byte array, where the first byte is used to represent a first preset number of bytes starting from the first storage location in the first byte array.

[0184] Optionally, in this embodiment, the storage medium is further configured to store program code for performing the following steps: determining a first initial position of the key data in the first byte array based on a first hash value of the key data; reading first data from a second byte in the first byte array, where the second byte is used to represent a first preset number of bytes starting from the first initial position in the first byte array; in a case where the first data is not read from the second byte, determining the first initial position as a first storage position; in a case where the first data is read from the second byte, matching the key data with the first data to determine the first storage position.

[0185] Optionally, in this embodiment, the storage medium is further configured to store program code for performing the following steps: performing a remainder operation on the first hash value and a preset number of bits to obtain a first initial position.

[0186] Optionally, in this embodiment, the storage medium is further configured to store program code for performing the following steps: matching the key data with the first data to obtain a matching result; in a case where the matching result indicates that the key data and the first data match successfully, determining the first initial position as the first storage position; in a case where the matching result indicates that the key data and the first data do not match successfully, moving the first initial position one bit backward, and repeating the steps of reading the first data from the second byte in the first byte array, and in a case where the first data is read from the second byte, matching the key data with the first data to obtain a matching result until the key data and the first data match successfully.

[0187] Optionally, in this embodiment, the storage medium is further configured to store program code for performing the following steps: processing the key data using a message digest algorithm to obtain a first message digest result corresponding to the key data, and processing the first data using the message digest algorithm to obtain a second message digest result corresponding to the first data; in a case where the first message digest result and the second message digest result are equal, determining the matching result as that the key data and the first data match successfully; in a case where the first message digest result and the second message digest result are not equal, determining the matching result as that the key data and the first data do not match successfully.

[0188] Optionally, in this embodiment, the storage medium is further configured to store program code for performing the following steps: obtaining a sum of the first initial position and a preset value to obtain a target sum value; performing a remainder operation on the target sum value and a preset number of bits to obtain a new first initial position.

[0189] Optionally, in this embodiment, the storage medium is further configured to store program code for performing the following steps: determining a second initial position of the value data in the second byte array based on a second hash value of the value data; reading second data from the second initial position; in a case where the second data is not read, determining the second initial position as a second storage position; in a case where the second data is read, matching the value data with the second data to determine the second storage position.

[0190] Optionally, in this embodiment, the storage medium is further configured to store program code for performing the following steps: obtaining a difference between a preset value and a preset repetition rate to obtain a target weight, where the preset repetition rate is used to represent a repetition rate of the preset value data appearing repeatedly; obtaining a product of the target weight and a preset number of digits to obtain a target number, where the preset number is used to represent a number of preset key data; performing a modulo operation on the second hash value and the target number to obtain the second initial position.

[0191] Optionally, in this embodiment, the storage medium is further configured to store program code for performing the following steps: comparing the value data with the second data; in a case where the value data is equal to the second data, determining the second initial position as the second storage position; in a case where the value data is not equal to the second data, moving the second initial position one bit backward, and repeatedly performing the steps of reading the second data from the second initial position and comparing the value data with the second data in a case where the second data is read until the value data is equal to the second data.

[0192] Optionally, in this embodiment, the storage medium is further configured to store program code for performing the following steps: respectively processing the key data by using a message digest algorithm to obtain a first message digest result corresponding to the key data; converting the second storage position into a third byte of a second preset quantity; encapsulating the first message digest result and the third byte to obtain encapsulated data; storing the encapsulated data into the first byte.

[0193] Embodiment 9

[0194] An embodiment of the present application further provides a computer program product, including a computer program, where the computer program implements the method according to any one of the above when being executed by a processor.

[0195] Optionally, in this embodiment, the computer program product is configured as program code that, when executed by a processor, implements the following steps: obtaining data to be stored, where the data to be stored includes: key data and value data; determining a first storage location of the key data in a first byte array based on the key data, and determining a second storage location of the value data in a second byte array based on the value data, where the first byte array and the second byte array are located in memory; storing the value data at the second storage location in the second byte array; storing the key data and the second storage location at the first byte in the first byte array, where the first byte is used to represent a first preset number of bytes starting from the first storage location in the first byte array.

[0196] Optionally, in this embodiment, the computer program product is further configured as program code that, when executed by a processor, implements the following steps: determining a first initial position of the key data in the first byte array based on a first hash value of the key data; reading first data from a second byte in the first byte array, where the second byte is used to represent a first preset number of bytes starting from the first initial position in the first byte array; in the case where the first data is not read from the second byte, determining the first initial position as the first storage location; in the case where the first data is read from the second byte, matching the key data with the first data to determine the first storage location.

[0197] Optionally, in this embodiment, the computer program product is further configured as program code that, when executed by a processor, implements the following steps: performing a modulo operation on the first hash value and a preset number of bits to obtain the first initial position.

[0198] Optionally, in this embodiment, the computer program product is further configured as program code that, when executed by a processor, implements the following steps: matching the key data with the first data to obtain a matching result; in the case where the matching result indicates that the key data and the first data match successfully, determining the first initial position as the first storage location; in the case where the matching result indicates that the key data and the first data do not match, moving the first initial position one position backward, and repeating the steps of reading the first data from the second byte in the first byte array, and in the case where the first data is read from the second byte, matching the key data with the first data to obtain a matching result, until the key data and the first data match successfully.

[0199] Optionally, in this embodiment, the computer program product is further configured with program code that, when executed by a processor, implements the following steps: processing the key data using a message digest algorithm to obtain a first message digest result corresponding to the key data, and processing the first data using the message digest algorithm to obtain a second message digest result corresponding to the first data; determining that the matching result is that the key data and the first data match successfully when the first message digest result and the second message digest result are equal; and determining that the matching result is that the key data and the first data do not match when the first message digest result and the second message digest result are not equal.

[0200] Optionally, in this embodiment, the computer program product is further configured with program code that, when executed by a processor, implements the following steps: obtaining the sum of the first initial position and a preset value to obtain a target sum value; performing a modulo operation on the target sum value and a preset number of digits to obtain a new first initial position.

[0201] Optionally, in this embodiment, the computer program product is further configured with program code that, when executed by a processor, implements the following steps: determining a second initial position of the value data in the second byte array based on the second hash value of the value data; reading second data from the second initial position; determining that the second initial position is the second storage position when the second data is not read; and matching the value data with the second data and determining the second storage position when the second data is read.

[0202] Optionally, in this embodiment, the computer program product is further configured with program code that, when executed by a processor, implements the following steps: obtaining the difference between a preset value and a preset repetition rate to obtain a target weight, where the preset repetition rate is used to represent the repetition rate of the preset value data appearing repeatedly; obtaining the product of the target weight and a preset number of digits to obtain a target number, where the preset number is used to represent the preset number of key data; and performing a modulo operation on the second hash value and the target number to obtain a second initial position.

[0203] Optionally, in this embodiment, the computer program product is further configured with program code that, when executed by a processor, implements the following steps: comparing the value data with the second data; determining that the second initial position is the second storage position when the value data and the second data are equal; and moving the second initial position one position backward when the value data and the second data are not equal, and repeating the steps of reading the second data from the second initial position and comparing the value data with the second data when the second data is read until the value data and the second data are equal.

[0204] Optionally, in this embodiment, the computer program product is further set to program code that implements the following steps when executed by a processor: Process the key data using a message digest algorithm to obtain a first message digest result corresponding to the key data; Convert the second storage location into a second preset number of third bytes; Package the first message digest result and the third bytes to obtain packaged data; Store the packaged data in the first byte.

[0205] The serial numbers of the embodiments of the present application above are only for description and do not represent the advantages or disadvantages of the embodiments.

[0206] In the above embodiments of the present application, the descriptions of each embodiment have their own emphases. For parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.

[0207] In the several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the units or modules can be in electrical or other forms.

[0208] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0209] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0210] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), mobile hard disks, magnetic disks, or optical discs.

[0211] The above are only the preferred embodiments of this application. It should be noted that for those of ordinary skill in the art, without departing from the principle of this application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of this application.

Claims

1. A data storage method, characterized in that: include: Acquire data to be stored, wherein the data to be stored includes: key data and value data; determining a first storage location of the key data in a first byte array based on the key data, and determining a second storage location of the value data in a second byte array based on the value data, wherein the first byte array and the second byte array are located in a memory; storing the value data in the second storage location in the second byte array; The key data and the second storage location are stored in a first byte in the first byte array, wherein the first byte is used to represent a first preset number of bytes in the first byte array starting from the first storage location.

2. The method according to claim 1, characterized in that Determining a first storage location of the key data in a first byte array based on the key data includes: Determining a first initial position of the key data in the first byte array based on a first hash value of the key data; Reading first data from a second byte in the first byte array, wherein the second byte is used to represent the first preset number of bytes starting from the first initial position in the first byte array; If the first data is not read from the second byte, determining the first initial position as the first storage position; When the first data is read from the second byte, the key data is matched with the first data to determine the first storage location.

3. The method according to claim 2, characterized in that Determining a first initial position of the key data in the first byte array based on the first hash value of the key data includes: A modulo operation is performed on the first hash value and a preset number of digits to obtain the first initial position.

4. The method according to claim 2, characterized in that The matching the key data with the first data to determine the first storage location includes: Matching the key data with the first data to obtain a matching result; If the matching result indicates that the key data and the first data are successfully matched, determining the first initial position as the first storage position; When the matching result indicates that the key data fails to match the first data, the first initial position is moved backward by one position, and the steps of reading the first data from the second byte in the first byte array and matching the key data with the first data when the first data is read from the second byte to obtain the matching result are repeated until the key data successfully matches the first data.

5. The method according to claim 4, characterized in that The matching of the key data with the first data to obtain a matching result includes: Processing the key data using a message digest algorithm to obtain a first message digest result corresponding to the key data, and processing the first data using a message digest algorithm to obtain a second message digest result corresponding to the first data; If the first information digest result and the second information digest result are equal, determining that the matching result is that the key data successfully matches the first data; When the first information digest result and the second information digest result are not equal, it is determined that the matching result is that the key data fails to match the first data.

6. The method according to claim 4, characterized in that The step of moving the first initial position backward by one position comprises: Obtaining the sum of the first initial position and a preset value to obtain a target sum value; A modulo operation is performed on the target sum value and a preset number of digits to obtain a new first initial position.

7. The method according to claim 1, characterized in that Determining a second storage location of the value data in the second byte array based on the value data includes: determining a second initial position of the value data in the second byte array based on a second hash value of the value data; Reading second data from the second initial position; If the second data is not read, determining the second initial position as the second storage position; When the second data is read, the value data is matched with the second data to determine the second storage location.

8. The method according to claim 7, characterized in that The determining, based on the second hash value of the value data, a second initial position of the value data in the second byte array includes: Obtaining a difference between a preset value and a preset repetition rate to obtain a target weight, wherein the preset repetition rate is used to represent a repetition rate at which the preset value data is repeated; Obtaining the product of the target weight and a preset number to obtain a target number, wherein the preset number is used to represent the preset number of the key data; Perform a modulo operation on the second hash value and the target number to obtain the second initial position.

9. The method according to claim 7, characterized in that The matching the value data with the second data to determine the second storage location includes: comparing the value data with the second data; When the value data is equal to the second data, determining the second initial position as the second storage position; When the value data is not equal to the second data, the second initial position is moved backward by one position, and the steps of reading the second data from the second initial position and comparing the value data with the second data when the second data is read are repeated until the value data is equal to the second data.

10. The method according to claim 1, characterized in that Storing the key data and the second storage location to a first byte in the first byte array comprises: Processing the key data respectively using a message digest algorithm to obtain a first message digest result corresponding to the key data; converting the second storage location into a second predetermined number of third bytes; Encapsulating the first information digest result and the third byte to obtain encapsulated data; The packaged data is stored in the first byte.

11. A data storage method, characterized in that: include: In response to an input instruction acting on an operation interface, displaying data to be stored on the operation interface, wherein the data to be stored includes: key data and value data; In response to a storage instruction applied to the operation interface, a storage result of the data to be stored is displayed on the operation interface, wherein the storage result is generated after storing the value data in a second storage position in a second byte array, and storing the key data and the second storage position in a first byte in a first byte array, the first byte array and the second byte array being located in a memory, the first byte being used to represent a first preset number of bytes in the first byte array starting from the first storage position, the first storage position being determined based on the key data, and the second storage data being determined based on the value data.

12. A data storage method, characterized in that: include: Acquire the data to be stored by calling a first interface, wherein the first interface includes a first parameter, a parameter value of the first parameter includes the data to be stored, and the data to be stored includes: key data and value data; determining a first storage location of the key data in a first byte array based on the key data, and determining a second storage location of the value data in a second byte array based on the value data, wherein the first byte array and the second byte array are located in a memory; storing the value data in the second storage location in the second byte array; storing the key data and the second storage location in a first byte of the first byte array, wherein the first byte is used to represent a first preset number of bytes in the first byte array starting from the first storage location; The storage result is output by calling a second interface, wherein the second interface includes a second parameter, and a parameter value of the second parameter includes the storage result, wherein the storage result is used to indicate that the storage of the data to be stored is completed.

13. An electronic device, characterized in that: include: a memory storing an executable program; A processor, configured to run the program, wherein the program executes the method according to any one of claims 1 to 12 when running.

14. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored executable program, wherein when the executable program is run, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 12.

15. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 12.