Writing method of distributed file system and electronic equipment
By using linked list arrays and request identification methods in distributed file systems, the problem of data access conflicts in multi-screen collaboration scenarios is solved, and the efficiency of multiple terminals collaborative writing data is achieved.
Patent Information
- Application Number
- CN202310975556.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-03
- Publication Date
- 2025-02-14
AI Technical Summary
In multi-screen collaboration scenarios, when multiple terminals access the same file at the same time, data access conflicts are prone to occur. The prior art usually adopts access interception methods, resulting in low efficiency in collaborative writing of data.
By introducing linked list arrays and request identifications in the distributed file system, the target address and storage node of the data content are determined, and the data content of multiple terminals is stored and written into the target file by parallel writing.
It effectively solves the problem of data access conflicts when multiple terminals jointly access target files, improves the efficiency of multiple terminals collaboratively writing data, and avoids data access conflicts.
Smart Images

Figure CN119441170A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of terminal technology, and in particular to a distributed file system writing method and electronic device. Background Art
[0002] In the scenario of multi-screen collaboration, it usually involves multiple terminals accessing a file on the same terminal at the same time. For example, there is an office file on terminal A, and terminal B and terminal C need to write data to the file at the same time. At this time, there is a data access conflict problem.
[0003] At present, in order to avoid data access conflicts, the system default access interception method is generally adopted, that is, when terminal B accesses the file, other terminals A and C are prohibited from accessing the file. In this way, the efficiency of multiple terminals collaboratively writing data is not high, which affects the user experience. Summary of the invention
[0004] The embodiments of the present application provide a distributed file system writing method and electronic device to solve the data access conflict problem in a scenario where multiple terminals collaboratively access the same file, and improve the efficiency of collaborative data writing by multiple terminals.
[0005] In a first aspect, an embodiment of the present application provides a distributed file system writing method, which is applied to a first electronic device, including:
[0006] Acquire data request information of a target file sent by a second electronic device that is communicatively connected to the first electronic device, the data request information including a request identifier and first data content;
[0007] Determine a target address of the first data content according to the request identifier and the linked list array corresponding to the target file;
[0008] Determine a target linked list corresponding to the target address in the linked list array, and if there is a second data content in the memory space of the target linked list, store the second data content and the first data content in a storage node of the target linked list according to a preset storage rule; the target linked list includes a plurality of storage nodes, and the plurality of storage nodes are sequentially stored in a continuous memory space;
[0009] The data contents stored in each linked list of the linked list array are written into the target file in parallel; the data contents include first data contents and second data contents.
[0010] In a second aspect, an embodiment of the present application provides a distributed file system writing method, which is applied to a second electronic device, including:
[0011] In response to a user-initiated write operation instruction for a target file in a first electronic device, obtaining a request identifier corresponding to the second electronic device and a first data content corresponding to the user's write operation instruction for the target file; the first electronic device and the second electronic device are in communication connection with each other;
[0012] Sending data request information of the target file to the first electronic device, the data request information including a request identifier and first data content.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, characterized in that it includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect above are implemented.
[0014] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect above are implemented.
[0015] The distributed file system writing method provided in the embodiment of the present application determines the target address of the first data content according to the request identifier before writing the data content in the target file according to the data request information sent by the second electronic device, determines the storage node of the first data content according to the storage status of the data content in the target linked list corresponding to the target address, and then writes the data content stored in each linked list of the linked list array into the target file in parallel to solve the data access conflict problem when multiple second electronic devices access the target file together. Compared with the existing access interception method, by adopting the method provided in the embodiment of the present application, multiple second electronic devices can jointly write to the target file, and at the same time, data access conflicts can be avoided, which is conducive to improving the efficiency of collaborative data writing by multiple terminals.
[0016] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] Figure 1 A schematic diagram of a possible application scenario provided by an embodiment of the present application is shown;
[0019] Figure 2 A schematic diagram of a process flow of a distributed file system writing method provided in an embodiment of the present application is shown;
[0020] Figure 3 A schematic diagram of the data structure of a data request packet provided in an embodiment of the present application is shown;
[0021] Figure 4 A schematic diagram of the data storage structure of a linked list array provided in an embodiment of the present application is shown;
[0022] Figure 5 A schematic diagram of a flow chart of another distributed file system writing method provided in an embodiment of the present application is shown;
[0023] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0024] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0025] Figure 1 A schematic diagram of a possible application scenario provided by an embodiment of the present application is shown. As shown in the figure, in a multi-screen collaboration scenario, when terminal B and terminal C access files of terminal A, they can obtain access services through the interface provided by the agent program.
[0026] Here, the agent program is also called agent technology, which is a technology similar to middleware. In this field, middleware technology is a type of software program between application software and system software, which is used in distributed scenarios. Agent technology is an application running on a multi-screen collaborative terminal. The program is embedded in the system operating environment of multi-screen collaboration, between application software and system software, and uses the interface provided by the system to provide corresponding services for the application software.
[0027] In order to avoid data access conflicts when multiple terminals access the same file, the relevant technology proposes a solution that can use agent (third-party application) technology to handle multiple users reading and writing files at the same time. Specifically, a hardware device network disk system is introduced to copy files accessed by multiple users on the hardware device network disk system, and then the copy files are updated to the server through a certain sequence. Users access the copy files on the hardware device network disk system to perform read and write operations. Since this solution requires the introduction of new hardware devices, the cost consumption is increased. In addition, the core of this solution is to solve the problem of data access conflicts through the network disk system. What users actually access is the copy files on the hardware device network disk system, and they do not have access to the latest file content. The update of file content can easily lead to the failure of writing the copy file. Therefore, the collaborative access method introduced by introducing new hardware devices is not suitable for multi-screen collaborative scenarios.
[0028] To this end, for the multi-screen collaboration scenario, an embodiment of the present application provides a distributed file system writing method. Before writing the data content in the target file according to the data request information sent by the second electronic device, the target address of the first data content is determined according to the request identifier, and the storage node of the first data content is determined according to the storage status of the data content in the target linked list corresponding to the target address, and then the data content stored in each linked list of the linked list array is written in parallel to the target file, so as to solve the data access conflict problem when multiple second electronic devices access the target file together. Compared with the above-mentioned method of copying files accessed by multiple users by introducing a hardware device network disk system, the solution provided by this embodiment can save costs and reduce the possibility of data writing failure due to target file updates.
[0029] Figure 2 A flow chart of a method for writing a distributed file system provided by an embodiment of the present application is shown. The execution subject of the method may be a first electronic device, and a second electronic device connected to the first electronic device in communication performs a data writing operation on a target file stored in the first electronic device. As shown in the figure, the method 200 may include the following steps:
[0030] S201: Acquire data request information of a target file sent by a second electronic device that is communicatively connected to the first electronic device, where the data request information includes a request identifier and first data content;
[0031] S202: Determine a target address of the first data content according to the request identifier and the linked list array corresponding to the target file;
[0032] S203: determining a target linked list corresponding to the target address in the linked list array, and if the memory space of the target linked list contains second data content, storing the second data content and the first data content in a storage node of the target linked list according to a preset storage rule; the target linked list includes a plurality of storage nodes, and the plurality of storage nodes are sequentially stored in a continuous memory space;
[0033] S204: writing the data contents stored in each linked list of the linked list array into the target file in parallel; the data contents include first data contents and second data contents.
[0034] This is explained with specific examples. Figure 1 As shown, in the scenario of multi-screen collaboration, terminals such as mobile phones, tablets, PCs, etc. are operating systems that can run agent programs. The agent program can be pre-embedded in the multi-screen collaboration operating environment, so that in the scenario where multiple terminals access the same terminal, the data access request is processed through the agent program.
[0035] The agent program of terminal A obtains data request information of a target file sent by terminal B or terminal C, the data request information including but not limited to a request identifier, first data content, etc., wherein the request identifier is a unique identifier of the data request information. According to the request identifier and the linked list array corresponding to the target file, a target address of the first data content is determined, the linked list array includes a plurality of linked lists, each linked list has a unique address, and according to the determined target address, a target linked list corresponding to the target address can be obtained.
[0036] Furthermore, when the second data content exists in the memory space of the target linked list, the second data content and the first data content are stored in the storage node of the target linked list according to the preset storage rule, and the multiple storage nodes of the target linked list are sequentially stored in the continuous memory space to ensure the continuity of the data content. Finally, the data content stored in each linked list of the linked list array is written to the target file in parallel.
[0037] Through research, it is found that in the scenario of multi-screen collaboration, the root cause of data access conflicts is that the data storage addresses are the same. Therefore, this embodiment determines the target address of the first data content according to the request identifier, and then connects the obtained first data content in the form of a single linked list in the data structure. In this way, the problem of data access conflicts when multiple terminals jointly access the target file can be solved. Compared with the existing access interception method, by adopting the method provided in the embodiment of the present application, multiple second electronic devices can jointly write to the target file, and at the same time, the occurrence of data access conflicts can be reduced, which is conducive to improving the efficiency of collaborative data writing by multiple terminals.
[0038] In a possible implementation, in the above step S201, obtaining data request information of a target file sent by a second electronic device that is communicatively connected to the first electronic device includes:
[0039] A data request packet sent by the second electronic device is received, wherein the data request packet includes protocol data and data request information; and the data request packet is parsed according to the protocol data to obtain the data request information of the target file.
[0040] The following is a specific example. When a user initiates a write request to a file in terminal A, the agent program on terminal B or terminal C will encapsulate the write request into a data request packet, such as Figure 3 As shown, the data request packet may include a device identifier (device ID), a read / write operation identifier (read / write operation ID), a data identifier (data ID), a data type, data content, and other protocol data.
[0041] Device identification, usually the MAC address of the device, is used to indicate the unique key value of the terminal. The data of the request data packet can use the key value as the device ID;
[0042] A read / write operation identifier, used to indicate whether the data in the data request packet is a read operation or a write operation. In this embodiment, it is a write operation ID.
[0043] Data identification, a unique key value used to indicate the data content, is the same as the device ID value and serves as a unique value for multiple data packets under the terminal;
[0044] Data type, used to indicate the type of data sent by the terminal, which may include text type data, picture type data, voice type data, etc.;
[0045] Other protocol data, including protocol data of other network communications.
[0046] The data request packet can be understood as an extension packet of the network communication protocol data packet extended by the agent program. Terminal A receives the data request packet, parses the data request packet according to the protocol data, and obtains the data request information of the target file.
[0047] Furthermore, in the above step S202, determining the target address of the first data content according to the request identifier and the linked list array corresponding to the target file includes:
[0048] Determine the key value of the hash table according to the device identifier and the data identifier; and determine the target address of the first data content according to the key value of the hash table and the linked list array corresponding to the target file.
[0049] In a specific implementation, the agent program at the receiving end parses the received data request packet, combines the device ID and the data ID into the key value of the hash table, determines that it is writing data from the operation type ID, and determines that it is text content from the data type, so the copy logic of the text content is executed to take the first data content as the value of the hash table and encapsulate it into data in the form of Key-Value. Then, according to the key value of the hash table and the linked list array corresponding to the target file, the target address of the first data content is determined.
[0050] The target address of the first data content may be determined in the following manner:
[0051] Obtain a hash function corresponding to the linked list array; and determine a target address of the first data content according to the hash function and a key value of the hash table.
[0052] In a specific implementation, a hash function such as H(K)=K mod N, K is the Key value of the above hash table, and N is the number of linked lists in the linked list array. The target address of the first data content is determined according to the hash function and the key value of the hash table.
[0053] In a possible implementation, in the above step S203, storing the second data content and the first data content in the storage node of the target linked list according to a preset storage rule includes:
[0054] Acquire the first storage node where the second data content is located;
[0055] The first data content is stored in a second storage node of the target linked list, where the second storage node is the next storage node adjacent to the first storage node.
[0056] In the specific implementation, Figure 4 As shown, the data in the encapsulated Key-Value format is used as an element, the Key value is composed of the device ID and the data ID, and the Value value is the first data content. The Key-Value is used as an element of the linked list. When adding an element, the Key value is calculated by the hash function, and the target linked list corresponding to the Key value in the linked list array is determined. If the memory space of the target linked list contains the second data content, that is, there is duplicate data, it is added in the form of a linked list to the next storage node adjacent to the first storage node where the current duplicate data is located. In this way, while avoiding the data access conflict problem when multiple second electronic devices access the target file together, the continuity of the stored data is ensured.
[0057] Furthermore, after determining the target linked list corresponding to the target address in the linked list array, and before writing the data contents stored in each linked list of the linked list array into the target file in parallel, the method further includes:
[0058] When the second data content does not exist in the memory space of the target linked list, the first data content is stored in the memory space.
[0059] In a specific implementation, if the memory space of the target linked list does not contain the second data content, that is, there is no duplicate data, the first data content is directly stored in the memory space of the target linked list.
[0060] Finally, traverse each linked list in the linked list array, extract the data content stored in each linked list, and write them into the target file in parallel.
[0061] Figure 5 A flow chart of another distributed file system writing method provided in an embodiment of the present application is shown. The execution subject of the method may be a second electronic device. As shown in the figure, the method 500 may include the following steps:
[0062] S501: In response to a user-initiated instruction to write a target file in a first electronic device, obtaining a request identifier corresponding to the second electronic device and first data content corresponding to the user's instruction to write the target file; the first electronic device and the second electronic device are in communication connection with each other;
[0063] S502: Sending data request information of the target file to the first electronic device.
[0064] Among them, the data request information includes a request identifier (such as a device identifier, a data identifier, etc.), a read / write operation identifier, a data type, a first data content, etc.; the device identifier is usually the MAC address of the device, which is used to indicate the unique Key value of the sending terminal; the data identifier is used to indicate the unique Key value of the data content, which, like the device identifier, serves as the unique value of multiple data packets under the second electronic device; the read / write operation identifier is used to indicate whether the data content in this data request packet is a read operation or a write operation, and in this embodiment it is a write operation identifier; the data type is used to indicate the type of data sent by the second electronic device, which may include text type data, picture type data, voice type data, etc.
[0065] In a specific implementation, the second electronic device responds to a write operation instruction initiated by a user on a target file in the first electronic device, obtains a request identifier corresponding to the second electronic device and a first data content corresponding to the user's write operation instruction for the target file, and sends the request identifier and the first data content to the first electronic device, so that the first electronic device performs a data write operation on the target file in response to the write operation instruction.
[0066] In a possible implementation, in the above step S502, sending the data request information of the target file to the first electronic device includes:
[0067] Encapsulating the data request information into a data request packet according to the preset network communication protocol data;
[0068] The data request packet is sent to the first electronic device, wherein the data request packet includes protocol data and data request information.
[0069] In a specific implementation, the data request information can be encapsulated into a data request packet by presetting the network communication protocol data, and the data request packet is sent to the first electronic device. The data request packet can be understood as an extension packet that the agent program extends the network communication protocol data packet. The first electronic device receives the data request packet, parses the data request packet according to the protocol data, and obtains the data request information of the target file.
[0070] Let's explain with a specific example. Assuming the target file is an Excel file, in a multi-screen collaboration scenario, when terminals B and C need to write to the Excel file of terminal A, the agent programs on terminals B and C will first encapsulate the write requests of B and C into a data request packet. The data request packet contains the device ID of the MAC address of the sending device, the write operation ID, the data ID generated by a random algorithm, the data type is Excel text, the specific data content, and other network protocol data.
[0071] After receiving the data request packet sent by terminal B and terminal C, the agent program of terminal A parses the data request packet, combines the device ID and data ID as the Key value of the subsequent chain address method hash table element, obtains the read and write operation ID as the write operation, obtains the data type as excel text, and executes the copy of the excel text data content as the Value value of the hash table.
[0072] The address value of the hash table is obtained through the hash function. If there is no element at the address, it is directly stored at the address. If there is already an element at the address, it is connected to the back of the repeated element in the form of a linked list to form a single linked list. After all the parsed data request packets are processed in this way, N single linked lists will be obtained.
[0073] Finally, traverse each singly linked list in the linked list array, extract the elements stored in the linked list, obtain the Value value, that is, the data content, and write the data content into the Excel file. The hash table can be traversed repeatedly. If there is no element, it will be skipped; if there is an element, the traversal of the singly linked list will be performed.
[0074] An embodiment of the present application provides a writing method for a distributed file system. Before writing data content in a target file according to data request information sent by a second electronic device, a target address of the first data content is determined according to a request identifier, and a storage node of the first data content is determined according to the storage status of the data content in a target linked list corresponding to the target address, and then the data content stored in each linked list of the linked list array is written in parallel to the target file to solve the data access conflict problem when multiple second electronic devices access the target file together. Compared with the existing access interception method, by adopting the method provided by the embodiment of the present application, multiple second electronic devices can jointly perform write operations on the target file, and at the same time, the occurrence of data access conflicts can be reduced, which is conducive to improving the efficiency of collaborative data writing by multiple terminals.
[0075] Figure 6 A schematic diagram of the hardware structure of an electronic device that implements the embodiment of the present application is shown. Referring to the figure, at the hardware level, the electronic device includes a processor, and optionally, an internal bus, a network interface, and a memory. Among them, the memory may include a memory, such as a high-speed random access memory (Random-Access Memory, RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage, etc. Of course, the electronic device may also include hardware required for other services.
[0076] The processor, the network interface and the memory may be interconnected through an internal bus, which may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one bidirectional arrow is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0077] The memory stores the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0078] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a device for locating the target user at the logical level. The processor executes the program stored in the memory and specifically performs: Figure 2 or Figure 5 The method disclosed in the illustrated embodiment realizes the functions and beneficial effects of each method described in the foregoing method embodiments, which will not be described in detail here.
[0079] The above application Figure 2 or Figure 5 The method disclosed in the illustrated embodiment may be implemented in a processor or by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method may be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present application may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in a decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0080] The computer device can also execute the methods described in the foregoing method embodiments, and realize the functions and beneficial effects of the methods described in the foregoing method embodiments, which will not be repeated here.
[0081] Of course, in addition to software implementation methods, the electronic device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0082] The embodiment of the present application also provides a computer-readable storage medium, wherein the computer-readable medium stores one or more programs, and when the one or more programs are executed by an electronic device including multiple application programs, the electronic device executes Figure 2 or Figure 5 The method disclosed in the illustrated embodiment realizes the functions and beneficial effects of each method described in the foregoing method embodiments, which will not be described in detail here.
[0083] The computer-readable storage medium includes a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0084] Furthermore, an embodiment of the present application also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, and when the program instructions are executed by a computer, the following process is implemented: Figure 2 or Figure 5 The method disclosed in the illustrated embodiment realizes the functions and beneficial effects of each method described in the foregoing method embodiments, which will not be described in detail here.
[0085] The embodiments of the present application can be applied to various electronic device collaboration or interconnection scenarios, including: collaboration and interconnection between mobile phones and laptops / tablet computers; collaboration and interconnection between mobile terminals and smart TVs / displays; collaboration and interconnection between mobile phones or tablet computers and in-car entertainment systems; collaboration and interconnection between mobile terminals and smart conference systems, etc., so as to meet the needs of users in various scenarios such as smart homes, smart offices, and smart travel.
[0086] In short, the above is only a preferred embodiment of the present application and does not limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0087] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0088] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0089] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0090] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A method for writing a distributed file system, characterized in that: Applied to a first electronic device, the method includes: Acquire data request information of a target file sent by a second electronic device that is communicatively connected to the first electronic device, the data request information including a request identifier and first data content; Determine a target address of the first data content according to the request identifier and the linked list array corresponding to the target file; Determine a target linked list corresponding to the target address in the linked list array, and if there is a second data content in the memory space of the target linked list, store the second data content and the first data content in a storage node of the target linked list according to a preset storage rule; the target linked list includes a plurality of storage nodes, and the plurality of storage nodes are sequentially stored in a continuous memory space; The data contents stored in each linked list of the linked list array are written into the target file in parallel; the data contents include first data contents and second data contents.
2. The method according to claim 1, characterized in that The step of obtaining data request information of a target file sent by a second electronic device that is communicatively connected to the first electronic device includes: receiving a data request packet sent by the second electronic device, wherein the data request packet includes protocol data and data request information; The data request packet is parsed according to the protocol data to obtain data request information of the target file.
3. The method according to claim 1, characterized in that The request identifier includes a device identifier and a data identifier; and determining the target address of the first data content according to the request identifier and the linked list array corresponding to the target file includes: Determine the key value of the hash table according to the device identifier and the data identifier; The target address of the first data content is determined according to the key value of the hash table and the linked list array corresponding to the target file.
4. The method according to claim 3, characterized in that The determining the target address of the first data content according to the key value of the hash table and the linked list array corresponding to the target file includes: Obtaining the hash function corresponding to the linked list array; Determine a target address of the first data content according to the hash function and the key value of the hash table.
5. The method according to claim 1, characterized in that The storing the second data content and the first data content in the storage node of the target linked list according to a preset storage rule includes: Acquire the first storage node where the second data content is located; The first data content is stored in a second storage node of the target linked list, where the second storage node is the next storage node adjacent to the first storage node.
6. The method according to any one of claims 1 to 5, characterized in that: After determining the target linked list corresponding to the target address in the linked list array, and before writing the data contents stored in each linked list of the linked list array into the target file in parallel, the method further includes: When the second data content does not exist in the memory space of the target linked list, the first data content is stored in the memory space.
7. A method for writing a distributed file system, characterized in that: Applied to a second electronic device, the method includes: In response to a user-initiated write operation instruction for a target file in a first electronic device, obtaining a request identifier corresponding to the second electronic device and a first data content corresponding to the user's write operation instruction for the target file; the first electronic device and the second electronic device are in communication connection with each other; Sending data request information of the target file to the first electronic device, the data request information including a request identifier and first data content.
8. The method according to claim 7, characterized in that The sending the data request information of the target file to the first electronic device includes: Encapsulating the data request information into a data request packet according to the preset network communication protocol data; The data request packet is sent to the first electronic device, wherein the data request packet includes protocol data and data request information.
9. An electronic device, characterized in that: The electronic device comprises a display screen, a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the method according to any one of claims 1 to 8 is implemented.
10. A readable storage medium storing a program or an instruction, characterized in that: When the program or instruction runs on an electronic device, the program or instruction is executed by a processor to implement the method according to any one of claims 1 to 8.
Citation Information
Cited By
Writing method for distributed file system, and electronic device
EP4742053A1