WO2020211236A1 - 基于b+树的读写冲突解决方法、装置及存储介质 - Google Patents

基于b+树的读写冲突解决方法、装置及存储介质 Download PDF

Info

Publication number
WO2020211236A1
WO2020211236A1 PCT/CN2019/102188 CN2019102188W WO2020211236A1 WO 2020211236 A1 WO2020211236 A1 WO 2020211236A1 CN 2019102188 W CN2019102188 W CN 2019102188W WO 2020211236 A1 WO2020211236 A1 WO 2020211236A1
Authority
WO
WIPO (PCT)
Prior art keywords
root node
read
address
data
data set
Prior art date
Application number
PCT/CN2019/102188
Other languages
English (en)
French (fr)
Inventor
刘洪晔
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020211236A1 publication Critical patent/WO2020211236A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2308Concurrency control
    • G06F16/2315Optimistic concurrency control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance

Definitions

  • This application relates to the field of data processing technology, and in particular to a method, device and computer-readable storage medium for resolving read-write conflicts based on B+ trees.
  • this application provides a B+ tree-based read-write conflict resolution method applied to an electronic device, and the method includes:
  • Index construction step construct an index file for the target data set, the index file adopts the B+ tree data structure and records the root node address of the B+ tree twice in the file header;
  • Writing step when performing a write operation on the target data set, add the data identifier, storage address or delete identifier corresponding to the write operation to the end node of the B+ tree, and create copies of each layer for the end node
  • the parent node after the parent node of each level copy records the child node address, sequentially modify the root node address of the file header;
  • Reading step when performing a read operation on the target data set, determine whether the root node address of the file header is the same, if they are the same, access the root node with any or the default root node address, and proceed one by one
  • the layer accesses the corresponding child node, and obtains the storage address or delete identifier of the data to be read according to the data identifier in the read operation instruction in the corresponding leaf node, and obtains the data to be read according to the acquired storage address or according to the delete identifier
  • the deletion status of the data to be read is acquired, and the read operation is completed; otherwise, the read operation is performed using the root node address respectively, and the read operation is completed with the available root node address.
  • the present application also provides an electronic device that includes a memory and a processor, the memory includes a data read-write conflict resolution program, and the data read-write conflict resolution program is executed by the processor to implement the following steps:
  • Index construction step construct an index file for the target data set, the index file adopts the B+ tree data structure and records the root node address of the B+ tree twice in the file header;
  • Writing step add the data identifier, storage address or delete identifier corresponding to the write operation to the end node of the B+ tree, create each level of replica parent node for the end node, and record the child node in each level of replica parent node After the address, sequentially modify the root node address of the file header;
  • Reading step when receiving a read operation instruction for the target data set, determine whether the root node address of the file header is the same, if they are the same, access the root node with any or default root node address , And access the corresponding child nodes layer by layer, obtain the storage address or delete flag of the data to be read according to the data identifier in the read operation instruction in the corresponding leaf node, and obtain the data or the deletion identifier according to the obtained storage address.
  • the deletion status of the data to be read is obtained according to the deletion identifier, and the read operation is completed; otherwise, the read operation is performed using the root node address respectively, and the read operation is completed with the available root node address.
  • the present application also provides a computer-readable storage medium in which a data read-write conflict resolution program is stored.
  • the data read-write conflict resolution program is executed by a processor, the B+ tree-based read as described above is realized. Write any steps in the conflict resolution method.
  • the B+ tree-based read-write conflict resolution method, device and computer-readable storage medium construct an index file for the target data set, adopt the B+ tree data structure in the index file and record B+ twice in the file header
  • the root node address of the tree and then, when performing a write operation on the target data set, the data identifier, storage address, or deletion identifier corresponding to the write operation is added to the end node of the B+ tree, which is the end node Create replica parent nodes of each level, after each level of replica parent nodes record the child node addresses, sequentially modify the root node address of the file header, replace the root node address with the replica root node address, and use the replica root node address As the new root node.
  • the read operation when performing a read operation on the target data set, first determine whether the root node address of the file header is the same, if they are the same, access the root node with any or default root node address, and layer by layer Access the corresponding child node, obtain the storage address or delete identifier of the data to be read according to the data identifier in the read operation instruction in the corresponding leaf node, and obtain the data to be read according to the acquired storage address or obtain the information according to the delete identifier
  • the read operation is completed; otherwise, the root node address is used to perform the read operation, and the available root node address is used to complete the read operation. In this application, all historical data are retained.
  • the user Before replacing all the root node addresses with the duplicate root node addresses, the user uses the original root node addresses to read the historical data normally, and replaces all the root node addresses. After the root node address is the copy, the user uses the new root node address to read the new version data. Therefore, with this application, data read-write conflicts can be resolved and user experience can be improved. By assigning a unique target data set version number to each root node address of the same file header, this application can also realize historical data backtracking.
  • FIG. 1 is a schematic diagram of an embodiment of an electronic device of this application
  • FIG. 2 is a program module diagram of an embodiment of the data read-write conflict resolution program in FIG. 1;
  • Fig. 3 is a schematic diagram of the B+ tree and the parent node of each level copy of the end node in the application;
  • FIG. 4 is a schematic flowchart of an embodiment of a method for resolving read-write conflicts based on a B+ tree in this application.
  • B+ tree It is a data structure commonly used in databases and file systems, and is commonly used to store directory or index information.
  • the B+ tree includes a root node, indexes at all levels, and multiple leaf nodes.
  • the root node is the entrance of the B+ tree, and the B+ tree can be entered through the root node.
  • Each child node on the B+ tree is divided into internal nodes and leaf nodes.
  • the root node and internal nodes do not store data and are only used for indexing.
  • the root node and internal nodes can be collectively referred to as non-leaf nodes.
  • Node depth indicates the path length from any node to the root node. For example, the depth of the root node is 0, the depth of the second level node is 1, and so on.
  • the leaf node with the smallest amount of stored data is called the end node of the B+ tree. Because the B+ tree is a balanced tree, the end node can be determined when the B+ tree is operated.
  • the second-level node is called the first-level child node of the root node
  • the third-level node is called the second-level child node of the root node.
  • the parent nodes of each level of the leaf node refer to the corresponding non-leaf nodes of each level, including the root node, which will not be repeated here.
  • This application provides an electronic device.
  • FIG. 1 it is a schematic diagram of an embodiment of the electronic device 1 of this application.
  • the electronic device 1 uses the data read-write conflict resolution program 10 provided in the present application to construct an index file for the target data set, and perform read and write operations on the target data set, which can avoid reading failures or jams.
  • the electronic device 1 may be a terminal device with storage and computing functions, such as a server, a smart phone, a tablet computer, a portable computer, and a desktop computer.
  • the server when the electronic device 1 is a server, the server may be one or more of a rack server, a blade server, a tower server, or a cabinet server.
  • the electronic device 1 includes a memory 11, a processor 12 and a network interface 13.
  • the memory 11 includes at least one type of readable storage medium.
  • the at least one type of readable storage medium may be a non-volatile storage medium such as flash memory, hard disk, multimedia card, card-type memory, and the like.
  • the readable storage medium may be an internal storage unit of the electronic device 1, such as a hard disk of the electronic device 1.
  • the readable storage medium may also be the external memory 11 of the electronic device 1, such as a plug-in hard disk or a smart memory card (Smart Media Card, SMC) equipped on the electronic device 1. , Secure Digital (SD) card, Flash Card (Flash Card), etc.
  • SD Secure Digital
  • Flash Card Flash Card
  • the memory 11 stores the program code of the data read-write conflict resolution program 10, the index file constructed for the target data set, and the like.
  • the memory 11 can also be used to temporarily store data that has been output or will be output.
  • the target data set in the present application may be stored in the memory 11, or may be stored in other electronic devices or systems that establish a communication connection with the electronic device 1.
  • the processor 12 may be a central processing unit (CPU), a microprocessor or other data processing chip, and is used to run the program code stored in the memory 11, for example, execute the data read/write conflict resolution program 10, etc.
  • CPU central processing unit
  • microprocessor or other data processing chip
  • the network interface 13 may include a standard wired interface and a wireless interface (such as a Wi-Fi interface). It is usually used to establish a communication connection between the electronic device 1 and other electronic devices or systems.
  • FIG. 1 only shows an electronic device 1 with components 11-13 and a data read-write conflict resolution program 10. However, it should be understood that it is not required to implement all the illustrated components, and more or fewer components may be implemented instead.
  • the electronic device 1 may also include an input unit such as a keyboard (Keyboard), a voice input device such as a microphone (Microphone) and other devices with a voice recognition function, and a voice output device such as audio, earphones, etc. Users can use these devices and equipment to read and write the target data set.
  • an input unit such as a keyboard (Keyboard)
  • a voice input device such as a microphone (Microphone) and other devices with a voice recognition function
  • a voice output device such as audio, earphones, etc. Users can use these devices and equipment to read and write the target data set.
  • the electronic device 1 may also include a display, which may also be called a display screen or a display unit.
  • a display may also be called a display screen or a display unit.
  • it may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an organic light-emitting diode (OLED) display, etc.
  • the display is used for displaying information processed in the electronic device 1 and for displaying a visualized user interface.
  • the electronic device 1 further includes a touch sensor.
  • the area provided by the touch sensor for the user to perform a touch operation is called a touch area.
  • the touch sensor described here may be a resistive touch sensor, a capacitive touch sensor, or the like.
  • the touch sensor includes not only a contact type touch sensor, but also a proximity type touch sensor and the like.
  • the touch sensor may be a single sensor, or may be, for example, a plurality of sensors arranged in an array. The user can start the data read-write conflict resolution program 10 by touching the touch area.
  • the electronic device 1 may also include a radio frequency (RF) circuit, a sensor, an audio circuit, a wired interface, a wireless interface, and so on, which will not be repeated here.
  • RF radio frequency
  • the processor 12 may implement the following steps when executing the data read-write conflict resolution program 10 stored in the memory 11:
  • Index construction step construct an index file for the target data set, the index file adopts the B+ tree data structure and records the root node address of the B+ tree twice in the file header;
  • Writing step when performing a write operation on the target data set, add the data identifier, storage address or delete identifier corresponding to the write operation to the end node of the B+ tree, and create copies of each layer for the end node
  • the parent node after the parent node of each level copy records the child node address, sequentially modify the root node address of the file header;
  • Reading step when performing a read operation on the target data set, determine whether the root node address of the file header is the same, if they are the same, access the root node with any or the default root node address, and proceed one by one
  • the layer accesses the corresponding child node, and obtains the storage address or delete identifier of the data to be read according to the data identifier in the read operation instruction in the corresponding leaf node, and obtains the data to be read according to the acquired storage address or according to the delete identifier
  • the deletion status of the data to be read is acquired, and the read operation is completed; otherwise, the read operation is performed using the root node address respectively, and the read operation is completed with the available root node address.
  • FIG. 2 For a detailed description of the above steps, please refer to the following FIG. 2 about the program module diagram of the data read-write conflict resolution program 10 embodiment and FIG. 4 for the description of the flowchart of the embodiment of the read-write conflict resolution method.
  • the data read-write conflict resolution program 10 may be divided into multiple modules, and the multiple modules are stored in the memory 12 and executed by the processor 13 to complete the application.
  • the module referred to in this application refers to a series of computer program instruction segments that can complete specific functions.
  • FIG. 2 it is a program module diagram of an embodiment of the data read-write conflict resolution program 10 in FIG. 1.
  • the data read-write conflict resolution program 10 can be divided into: an index building module 110, a writing module 120, and a reading module 130.
  • the index building module 110 is used to build an index file for the target data set.
  • the index file adopts a B+ tree data structure, and the file header repeatedly records the address of the root node of the B+ tree.
  • the root node address and the child node address are represented by pointers. In the case of repetitive operations, using pointers can significantly improve the reading speed of the index file.
  • the previous root node address may be called the first root node address
  • the subsequent root node address may be called the second root node address
  • the target data set may be live video A collection of images displayed by the platform on the website homepage or live broadcast list. These images can be thumbnails generated by the video live broadcast platform intercepting video pictures at a certain frequency or in a predetermined manner. Each thumbnail can be assigned a unique Data identification (for example, image number), the thumbnail is stored in a predetermined database, and then the data identification, storage address or deletion identification of the thumbnail is written into the index file as an index.
  • the deletion indicator indicates that the corresponding data is in a deleted state.
  • the write module 120 is configured to add the data identifier, storage address, or delete identifier corresponding to the write operation to the end node of the B+ tree, and create the parent node of each level of replica for the end node, and the replica at each level After the parent node records the address of the child node, it sequentially modifies the root node address of the file header.
  • the writing module 120 may be responsible for updating the index file after the target data set is added (INSERT), deleted (DELETE), and updated (UPDATE), or it may be locally or locally in the electronic device 1. Assist other electronic devices with storage functions to complete the operations of adding, deleting and updating the target data set.
  • the target data set is a set of images displayed on the website homepage or live broadcast list of the live video platform.
  • adding target data to the target data set that is, adding a condensed image to the database where the image set is located.
  • the writing module 120 adds the data identification (for example, image number), storage address or deletion identification corresponding to the added thumbnail to the end node of the B+ tree.
  • the deletion identifier is used to indicate that the corresponding data is in a deleted state. Because each non-leaf node stores the child node address of its child node, when the end node changes, the child node address recorded by the non-leaf node as the parent node of each layer may need to change.
  • the writing module 120 sequentially and continuously modifies the second root node address and the first root node address to the new root node address, That is, the root node address of the duplicate root node, which will serve as the new root node, and the target data set will be replaced from the old version to the new version.
  • the newly added thumbnail will be displayed on the website homepage or live broadcast list of the live video platform. It can be understood that, similar to the child node address, the new root node address and the original root node address may be the same or different.
  • FIG. 3 it is a schematic diagram of the B+ tree and the parent node of each layer copy of the end node in this application.
  • the B+ tree shown in the figure has three levels, the first level node is the root node, and the third level node is the leaf node.
  • each level will be created for the end node of the B+ tree in the index file
  • the duplicate parent node and then record the child node address of its child node at each layer of the duplicate parent node layer by layer, and after the copy root node has recorded its child node address, the root node address of the file header is sequentially and continuously modified , That is, replace the root node address with the address of the duplicate root node.
  • the duplicate root node will serve as the new entry of the B+ tree, that is, the new root node.
  • the arrow in the figure indicates the pointer corresponding to the address of the child node stored in each node.
  • the write module 120 adds the data identifier and storage address corresponding to the updated and modified data to the B+ tree The end node.
  • the updated thumbnail will replace the original thumbnail and displayed on the website homepage or live broadcast list of the live video platform. in.
  • the writing module 120 when performing a deletion operation on the target data set, the writing module 120 adds the deletion identifier and the data identifier of the deleted data to the end node of the B+ tree.
  • the deleted thumbnail after replacing the root node address of the index file header with the address of the duplicate root node, the deleted thumbnail will no longer be displayed on the website homepage or the live broadcast list of the video live broadcast platform.
  • the reading module 130 is configured to receive a data reading instruction sent by a user, access the index file of the target data set, and complete the data reading operation.
  • the data read instruction includes a data identifier.
  • the read module 130 accesses the index file of the target data set according to the data read instruction, and first determines the index Whether the first root node address and the second root node address in the file header are the same, if they are the same, use any or default root node address, for example, the first root node address to visit the root node, and visit the corresponding layer by layer
  • the child node, in the corresponding leaf node obtains the storage address or deletion identifier of the data to be read according to the data identifier, and obtains the data to be read according to the obtained storage address or obtains the deletion of the data to be read according to the deletion identifier State, complete the read operation; if the first root node address and the second root node address are different, use the first root node address and
  • first root node address and the second root node address are sequentially and continuously modified by the writing module 120, there are three reasons that cause the first root node address and the second root node address to be different.
  • the duration of the first two cases is very short, and the probability of the third case is very small, so it may not be considered that abnormalities occur during the modification of the first root node address and the second root node address.
  • the first root node address and the second root node address are inconsistent, there is one and only one root node address in the available state, so the user can complete the read operation of the target data set at any time. Read failure or freeze due to read-write conflict.
  • the deletion operation is performed on the target data set, that is, after the root node address in the header of the index file is replaced with the address of the copy root node
  • the reading module 130 receives the user's
  • the index file of the target data set will be accessed according to the data read instruction, and the delete identification will be obtained according to the data identification in the data read instruction, prompting the data to be read It has been deleted and cannot be displayed.
  • the data read-write conflict resolution program 10 may also include a version recording module and a historical data backtracking module.
  • the version recording module may assign a unique target data set version number to each root node address of the same file header, and record the target data set version number, the time of each version update, and the corresponding root node Address, the recorded version number of the record target data set, the time of each version update, and the corresponding root node address are stored in the memory 11;
  • the historical data backtracking module can be based on the version update time and/or the target data set version No., use the corresponding root node address to obtain the target data set of the corresponding version, and trace the historical data.
  • this application also provides a B+ tree-based read-write conflict resolution method.
  • FIG. 4 it is a schematic flowchart of an embodiment of a method for resolving read-write conflicts based on a B+ tree in this application.
  • the processor 12 of the electronic device 1 executes the data read-write conflict resolution program 10 stored in the memory 11 to implement the following steps of the B+ tree-based read-write conflict resolution method:
  • the index building module 110 builds an index file for the target data set.
  • the index file adopts a B+ tree data structure, and the file header repeatedly records the address of the root node of the B+ tree.
  • the target data set is a set of images displayed on the website homepage or live streaming list of the live video platform as described above
  • the leaf nodes of the B+ tree record all image data Identification (such as image number), storage address or deletion identification.
  • the deletion flag is used to indicate that the corresponding data is in a deleted state, that is, the corresponding image is no longer displayed on the website homepage or live broadcast list on the live video platform.
  • Step S320 When performing a write operation on the target data set, the write module 120 adds the data identifier, storage address or deletion identifier corresponding to the write operation to the end node of the B+ tree, and creates Each layer duplicates the parent node, and after the each layer duplicate parent node records the child node address, the root node address of the file header is sequentially modified.
  • the write operation includes operations such as adding, deleting, updating and modifying the target data set.
  • the data identifier and storage address of the added data are added to the end node of the B+ tree; if the target data set is deleted, the data identifier of the deleted data is corresponding to the data delete instruction The instruction identifier of is added to the end node of the B+ tree; assuming that an update modification operation is performed on the target data set, the data identifier corresponding to the data involved in the update modification operation and the storage address of the updated and modified data are added to the B+ tree The end node.
  • the deleted data is only marked as deleted in the database, and the relevant data is not deleted from the database; when the target data set is updated and modified, the updated data The data does not cover the original data, the content and storage location of the original data in the database have not changed, but the updated and modified data is added to the database.
  • the above operations follow the idea that everything is appended so that historical data can be traced back.
  • the index file it also follows the idea that everything is appended.
  • the write operation will not cause changes to other leaf nodes in the B+ tree, but add the data identifier, storage address or delete identifier corresponding to the write operation at the end node. .
  • the write operation also does not cause changes to the parent nodes of each level of the end node, but creates each level of replica parent nodes for the end node, including the replica root node, and records the address of the child node in the replica parent node of each level After that, the root node address of the file header is sequentially modified.
  • Step S330 When performing a read operation on the target data set, the reading module 130 determines whether the root node addresses of the file headers are the same, and if they are the same, access the root node with any or default root node address , And access the corresponding child node layer by layer to complete the read operation, otherwise, use the root node address to perform the read operation respectively, and complete the read operation with the available root node address.
  • the reading module 130 receives a data reading instruction that includes a data identifier. The reading module 130 accesses the index file of the target data set according to the data reading instruction, and first determines the root of the index file header.
  • node addresses are the same, if they are the same, use any or default root node address to access the root node, and access the corresponding child nodes layer by layer, and obtain the storage address of the data to be read in the corresponding leaf node according to the data identifier Or delete the identifier, and obtain the data to be read according to the acquired storage address or obtain the deletion status of the data to be read according to the deletion identifier, and complete the read operation; if the first root node address and the second root node address are different, Then, the first root node address and the second root node address are respectively used to access the corresponding root node, and the data reading operation is completed with the available root node address.
  • the available state of the root node address please refer to the above detailed introduction of the reading module 130, which will not be repeated here.
  • the corresponding root node address is used to obtain the target data set of the corresponding version.
  • this application also provides a computer-readable storage medium, which may be a hard disk, a multimedia card, an SD card, a flash memory card, an SMC, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, etc., or any combination of several.
  • a computer-readable storage medium which may be a hard disk, a multimedia card, an SD card, a flash memory card, an SMC, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), portable compact disk read-only memory (CD-ROM), USB memory, etc., or any combination of several.
  • the specific implementation of the computer-readable storage medium of the present application is substantially the same as the above-mentioned B+ tree-based read-write conflict resolution method and the specific implementation of the electronic device 1. Please refer to the above-mentioned Figure 2 for the data read-write conflict resolution program 10 embodiment The program module diagram and the detailed introduction of the flowchart of the embodiment of the method for resolving the read-write conflict in FIG. 4 will not be repeated here.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种基于B+树的读写冲突解决方法、程序、装置及存储介质。该方法包括:为目标数据集构建索引文件,该索引文件采用B+树的数据结构,且在文件头部记录两次B+树的根节点地址(S310);在对目标数据集执行写操作时,将写操作对应的数据标识、存储地址或删除标识添加到B+树的末尾节点,为末尾节点创建各层副本父节点,在各层副本父节点记录子节点地址后,依次修改所述文件头部的根节点地址(S320);在对目标数据集执行读操作时,判断所述文件头部的根节点地址是否相同,若相同,则以任一或默认的所述根节点地址访问根节点,并逐层访问对应的子节点,完成读操作,否则,分别利用所述根节点地址进行读操作,以可用的根节点地址完成读操作(S330)。

Description

基于B+树的读写冲突解决方法、装置及存储介质
本申请基于巴黎公约申明享有2019年4月17日递交的申请号为CN201910307497.4、名称为“基于B+树的读写冲突解决方法、装置及计算机可读存储介质”的中国专利申请的优先权,该中国专利申请的整体内容以参考的方式结合在本申请中。
技术领域
本申请涉及数据处理技术领域,尤其涉及一种基于B+树的读写冲突解决方法、装置及计算机可读存储介质。
背景技术
在数据管理系统中,所有事务均是通过读写操作来存取数据库中的数据资源,当多个事务同时访问同一数据资源时,为了避免可能造成的脏读、幻读等问题,需要对数据资源进行加锁处理。例如,视频直播平台通常会按照一定频率或某种预先确定的方式截取视频中的图片生成缩略图,并将缩略图展示在平台主页或者直播列表中,在更新缩略图的过程中,缩略图文件会被加写锁。在该写锁被释放之前,用户无法正常读取缩略图,可能造成卡顿或读取失败,影响用户体验。随着视频直播平台用户数量的激增,出现这种读写冲突的可能性越来越大。如何克服这种读写冲突,已成为亟待解决的问题。
发明内容
鉴于以上原因,有必要提供一种数据读写冲突的解决方法、装置及计算机可读存储介质,以较小的系统开销解决数据读写冲突,提高用户体验。
为实现上述目的,本申请提供一种基于B+树的读写冲突解决方法,应用于电子装置,该方法包括:
索引构建步骤:为目标数据集构建索引文件,该索引文件采用B+树的数据结构且在文件头部记录两次B+树的根节点地址;
写入步骤:在对所述目标数据集执行写操作时,将所述写操作对应的数据标识、存储地址或删除标识添加到所述B+树的末尾节点,为所述末尾节点 创建各层副本父节点,在所述各层副本父节点记录子节点地址后,依次修改所述文件头部的根节点地址;及
读取步骤:在对所述目标数据集执行读操作时,判断所述文件头部的根节点地址是否相同,若相同,则以任一或默认的所述根节点地址访问根节点,并逐层访问对应的子节点,在对应的叶子节点中根据读操作指令中的数据标识获取待读取数据的存储地址或删除标识,并根据获取的存储地址获取待读取数据或根据所述删除标识获知待读取数据的删除状态,完成读操作,否则,分别利用所述根节点地址进行读操作,以可用的根节点地址完成读操作。
本申请还提供一种电子装置,该电子装置包括存储器和处理器,所述存储器中包括数据读写冲突解决程序,所述数据读写冲突解决程序被所述处理器执行时实现如下步骤:
索引构建步骤:为目标数据集构建索引文件,该索引文件采用B+树的数据结构且在文件头部记录两次B+树的根节点地址;
写入步骤:将写操作对应的数据标识、存储地址或删除标识添加到所述B+树的末尾节点,为所述末尾节点创建各层副本父节点,在所述各层副本父节点记录子节点地址后,依次修改所述文件头部的根节点地址;及
读取步骤:在接收到对所述目标数据集的读操作指令时,判断所述文件头部的根节点地址是否相同,若相同,则以任一或默认的所述根节点地址访问根节点,并逐层访问对应的子节点,在对应的叶子节点中根据所述读操作指令中的数据标识获取待读取数据的存储地址或删除标识,并根据获取的存储地址获取待读取数据或根据所述删除标识获知待读取数据的删除状态,完成读操作,否则,分别利用所述根节点地址进行读操作,以可用的根节点地址完成读操作。
本申请还提供一种计算机可读存储介质,该计算机可读存储介质中存储有数据读写冲突解决程序,该数据读写冲突解决程序被处理器执行时实现如上所述的基于B+树的读写冲突解决方法中的任意步骤。
本申请提供的基于B+树的读写冲突解决方法、装置及计算机可读存储介质,通过为目标数据集构建索引文件,在索引文件中采用B+树的数据结构且在文件头部记录两次B+树的根节点地址,然后,在对所述目标数据集执行写操作时,将所述写操作对应的数据标识、存储地址或删除标识添加到所述B+ 树的末尾节点,为所述末尾节点创建各层副本父节点,在所述各层副本父节点记录子节点地址后,依次修改所述文件头部的根节点地址,将所述根节点地址替换为副本根节点地址,以副本根节点作为新的根节点。同时,在对所述目标数据集执行读操作时,先判断所述文件头部的根节点地址是否相同,若相同,则以任一或默认的所述根节点地址访问根节点,并逐层访问对应的子节点,在对应的叶子节点中根据读操作指令中的数据标识获取待读取数据的存储地址或删除标识,并根据获取的存储地址获取待读取数据或根据所述删除标识获知待读取数据的删除状态,完成读操作,否则,分别利用所述根节点地址进行读操作,以可用的根节点地址完成读操作。在本申请中,所有历史数据均得以保留,在将所述根节点地址全部替换为副本根节点地址之前,用户利用原来的根节点地址正常读取历史数据,在将所述根节点地址全部替换为副本根节点地址之后,用户利用新的根节点地址读取新版本数据。因此,利用本申请,可以解决数据读写冲突,提高用户体验。通过为每个相同的所述文件头部的根节点地址分配一个唯一的目标数据集版本号,本申请还可以实现历史数据回溯。
附图说明
图1为本申请电子装置一实施例的示意图;
图2为图1中数据读写冲突解决程序一实施例的程序模块图;
图3为本申请中B+树及其末尾节点的各层副本父节点的示意图;
图4为本申请基于B+树的读写冲突解决方法一实施例的流程示意图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
为了使本申请的目的、技术方案和优点更加清楚明白,下面将结合若干附图及实施例,对本申请进行进一步的详细说明。应当理解的是,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所 有其他实施例,都属于本申请保护的范围。
为了便于理解,首先对本申请实施例涉及的技术术语进行解释:
B+树:是一种常用在数据库和文件系统中的数据结构,常用来存储目录或索引信息。B+树包括根节点、各级索引以及多个叶子节点,其中根节点是B+树的入口,通过根节点可以进入B+树。B+树上的各个子节点分为内部节点和叶子节点,根节点和内部节点不保存数据,只用来索引,根节点和内部节点可以统称为非叶子结点。
节点深度:表示任意节点到根节点的路径长度。例如,根节点深度为0,第二层节点深度为1,以此类推。
在本申请中,将存放数据量最小的叶子节点称为B+树的末尾节点,因为B+树是一种平衡树,所以在对B+树进行操作时,末尾节点是可以确定的。将第二层节点称作根节点的第一层子节点,将第三层节点称作根节点的第二层子节点。类似地,叶子节点的各层父节点指的是对应的各层非叶子结点,包括根节点,在此不再赘述。
本申请提供一种电子装置。参照图1所示,为本申请电子装置1一实施例的示意图。在该实施例中,电子装置1利用本申请提供的数据读写冲突解决程序10为目标数据集构建索引文件,并对目标数据集进行读写操作,可以避免读取失败或卡顿。
所述电子装置1可以是服务器、智能手机、平板电脑、便携计算机、桌上型计算机等具有存储和运算功能的终端设备。在一个实施例中,当电子装置1为服务器时,该服务器可以是机架式服务器、刀片式服务器、塔式服务器或机柜式服务器等的一种或几种。
所述电子装置1包括存储器11、处理器12及网络接口13。
其中,所述存储器11包括至少一种类型的可读存储介质。所述至少一种类型的可读存储介质可为如闪存、硬盘、多媒体卡、卡型存储器等的非易失性存储介质。在一些实施例中,所述可读存储介质可以是所述电子装置1的内部存储单元,例如该电子装置1的硬盘。在另一些实施例中,所述可读存储介质也可以是所述电子装置1的外部存储器11,例如所述电子装置1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。
在本实施例中,所述存储器11存储所述数据读写冲突解决程序10的程序代码、为目标数据集构建的索引文件等。所述存储器11还可以用于暂时地存储已经输出或者将要输出的数据。本申请中的目标数据集可以存储在所述存储器11中,也可以存储在与所述电子装置1建立通信连接的其他电子设备或系统中。
所述处理器12可以是一中央处理器(Central Processing Unit,CPU),微处理器或其他数据处理芯片,用于运行存储器11中存储的程序代码,例如执行数据读写冲突解决程序10等。
网络接口13可以包括标准的有线接口、无线接口(如WI-FI接口)。通常用于在该电子装置1与其他电子设备或系统之间建立通信连接。
图1仅示出了具有组件11-13和数据读写冲突解决程序10的电子装置1。但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。
可选地,所述电子装置1还可以包括输入单元比如键盘(Keyboard),语音输入装置比如麦克风(Microphone)等具有语音识别功能的设备以及语音输出装置比如音响、耳机等。用户可以利用这些装置和设备对目标数据集进行读写操作。
可选地,所述电子装置1还可以包括显示器,也可以称为显示屏或显示单元。在一些实施例中可以是LED显示器、液晶显示器、触控式液晶显示器以及有机发光二极管(Organic Light-Emitting Diode,OLED)显示器等。显示器用于显示在电子装置1中处理的信息以及用于显示可视化的用户界面。
可选地,该电子装置1还包括触摸传感器。所述触摸传感器所提供的供用户进行触摸操作的区域称为触控区域。此外,这里所述的触摸传感器可以为电阻式触摸传感器、电容式触摸传感器等。而且,所述触摸传感器不仅包括接触式的触摸传感器,也可包括接近式的触摸传感器等。此外,所述触摸传感器可以为单个传感器,也可以为例如阵列布置的多个传感器。用户可以通过触摸所述触控区域启动数据读写冲突解决程序10。
该电子装置1还可以包括射频(Radio Frequency,RF)电路、传感器、音频电路、有线接口和无线接口等等,在此不再赘述。
在上述实施例中,处理器12执行存储器11中存储的数据读写冲突解决程序10时可以实现如下步骤:
索引构建步骤:为目标数据集构建索引文件,该索引文件采用B+树的数据结构且在文件头部记录两次B+树的根节点地址;
写入步骤:在对所述目标数据集执行写操作时,将所述写操作对应的数据标识、存储地址或删除标识添加到所述B+树的末尾节点,为所述末尾节点创建各层副本父节点,在所述各层副本父节点记录子节点地址后,依次修改所述文件头部的根节点地址;及
读取步骤:在对所述目标数据集执行读操作时,判断所述文件头部的根节点地址是否相同,若相同,则以任一或默认的所述根节点地址访问根节点,并逐层访问对应的子节点,在对应的叶子节点中根据读操作指令中的数据标识获取待读取数据的存储地址或删除标识,并根据获取的存储地址获取待读取数据或根据所述删除标识获知待读取数据的删除状态,完成读操作,否则,分别利用所述根节点地址进行读操作,以可用的根节点地址完成读操作。
关于上述步骤的详细介绍,请参照下述图2关于数据读写冲突解决程序10实施例的程序模块图以及图4关于读写冲突解决方法实施例的流程图的说明。
在其他实施例中,数据读写冲突解决程序10可以被分割为多个模块,该多个模块被存储于存储器12中,并由处理器13执行,以完成本申请。本申请所称的模块是指能够完成特定功能的一系列计算机程序指令段。
参照图2所示,为图1中数据读写冲突解决程序10一实施例的程序模块图。在本实施例中,所述数据读写冲突解决程序10可以被分割为:索引构建模块110、写入模块120和读取模块130。
所述索引构建模块110,用于为目标数据集构建索引文件。具体地,所述索引文件采用B+树的数据结构,且文件头部重复记录有B+树的根节点地址。我们将多层B+树的根节点和内部结点统称为非叶子结点,所述B+树的非叶子结点中记录有其子节点的子节点地址。所述根节点地址和子节点地址用指针表示,在重复性操作的情况下,使用指针可以明显改善索引文件的读取速度。在本实施例中,可将在前的所述根节点地址称作第一根节点地址,将在 后的所述根节点地址称作第二根节点地址,所述目标数据集可以为视频直播平台在网站主页或直播列表中展示的图像构成的集合,这些图像可以为视频直播平台按照一定频率或某种预先确定的方式截取视频图片生成的缩略图,可以为每张缩略图分配一个唯一的数据标识(例如图像编号),将缩略图存储在预先确定的数据库中,然后将缩略图的数据标识、存储地址或删除标识作为索引写入索引文件中。所述删除标识表示对应的数据处于删除状态。
所述写入模块120,用于将写操作对应的数据标识、存储地址或删除标识添加到所述B+树的末尾节点,为所述末尾节点创建各层副本父节点,在所述各层副本父节点记录子节点地址后,依次修改所述文件头部的根节点地址。具体地,写入模块120可以负责对所述目标数据集进行增添(INSERT)、删除(DELETE)和更新修改(UPDATE)操作之后的索引文件的更新操作,也可以在所述电子装置1本地或协助其他具有存储功能的电子设备完成对所述目标数据集的增添、删除和更新修改操作。
在本实施例中,假设所述目标数据集为视频直播平台在网站主页或直播列表中展示的图像构成的集合,在向所述目标数据集增添目标数据,即向图像集合所在数据库中增添缩略图时,所述写入模块120将增添的缩略图对应的数据标识(例如图像编号)、存储地址或删除标识添加到所述B+树的末尾节点中。所述删除标识用于表示对应的数据处于删除状态。因为每个非叶子结点中存有其子节点的子节点地址,所以,当末尾节点发生变动时,作为其各层父节点的非叶子结点记录的子节点地址可能需要发生改变。为了保证数据读取的连贯性,克服读写冲突,在本申请中,我们保留所述末尾节点的各层父节点中记录的子节点地址,并为所述末尾节点创建各层副本父节点,在所述各层副本父节点中记录子节点地址。可以理解的是,所述末尾节点对应的所述各层父节点和各层副本父节点记录的子节点地址可能相同也可能不同,本申请通过为末尾节点创建各层副本父节点来记录对所述目标数据集进行写操作时所述子节点地址可能发生的改变。在所述各层副本父节点,包括副本根节点记录完子节点地址之后,写入模块120依次且连续地将所述第二根节点地址和第一根节点地址修改为新的根节点地址,即副本根节点的根节点地址,所述副本根节点将作为新的根节点,目标数据集完成从旧版本到新版本的替换。在本实施例中,新增添的缩略图将被展示在所述视频直播平台的网 站主页或直播列表中。可以理解的是,与所述子节点地址类似,新的根节点地址与原来的根节点地址可能相同也可能不同。
参照图3所示,为本申请中B+树及其末尾节点的各层副本父节点的示意图。图中所示的B+树共有三层,第一层节点为根节点,第三层节点为叶子节点,在对目标数据集执行写操作时,将为索引文件中B+树的末尾节点创建各层副本父节点,然后逐层在所述各层副本父节点记录其子节点的子节点地址,当在副本根节点记录完其子节点地址之后,再依次且连续地修改文件头部的根节点地址,即将所述根节点地址替换为所述副本根节点的地址,替换完成后,副本根节点将作为B+树的新入口,即新的根节点。图中箭头表示各节点中存储的子节点地址对应的指针。
与向所述目标数据集增添目标数据类似,在对所述目标数据集执行更新修改操作时,所述写入模块120将更新修改后的数据对应的数据标识和存储地址添加到所述B+树的末尾节点。在本实施例中,在将索引文件头部的根节点地址替换为副本根节点的地址之后,更新修改后的缩略图将代替原来的缩略图显示在所述视频直播平台的网站主页或直播列表中。
需要说明的是,在对所述目标数据集执行删除操作时,所述写入模块120将删除标识和被删除数据的数据标识添加到所述B+树的末尾节点。在本实施例中,在将索引文件头部的根节点地址替换为副本根节点的地址之后,被删除的缩略图将不再在所述视频直播平台的网站主页或直播列表中显示。
所述读取模块130,用于接收用户发送的数据读取指令,访问目标数据集的索引文件,完成数据读取操作。具体地,所述数据读取指令中包括数据标识,所述读取模块130在接收到用户发送的数据读取指令后,根据所述数据读取指令访问目标数据集的索引文件,先判断索引文件头部的所述第一根节点地址和第二根节点地址是否相同,若相同,则以任一或默认的根节点地址,例如第一根节点地址访问根节点,并逐层访问对应的子节点,在对应的叶子节点中根据所述数据标识获取待读取数据的存储地址或删除标识,并根据获取的存储地址获取待读取数据或根据所述删除标识获知待读取数据的删除状态,完成读操作;若所述第一根节点地址和第二根节点地址不同,则分别利用所述第一根节点地址和第二根节点地址访问对应的根节点,并逐层访问对应的子节点,在对应的叶子节点中根据所述数据标识获取待读取数据的存储 地址或删除标识,并根据获取的存储地址获取待读取数据或根据所述删除标识获知待读取数据的删除状态,完成读操作。因为所述第一根节点地址和第二根节点地址是被所述写入模块120依次连续修改的,所以导致所述第一根节点地址和第二根节点地址不同的原因有三种。其一,所述第一根节点地址在修改中;其二,所述第二根节点地址在修改中;其三,所述第一根节点地址和第二根节点地址均修改完成,但在修改过程中发生异常,造成修改后的所述第一根节点地址和第二根节点地址不一致。可以理解的是,前两种情况的持续时间很短,第三种情况发生的概率很小,因此可以不考虑在所述第一根节点地址和第二根节点地址的修改过程中均发生异常的情况,在所述第一根节点地址和第二根节点地址不一致的情况下,有且只有一个根节点地址处于可用状态,故用户随时可以完成对所述目标数据集的读操作,不会由于读写冲突造成读取失败或卡顿。
需要说明的是,在对所述目标数据集执行完删除操作后,即在将索引文件头部的根节点地址替换为副本根节点的地址之后,当所述读取模块130在接收到用户发送的对被删除数据的数据读取指令时,将根据所述数据读取指令访问目标数据集的索引文件,并根据所述数据读取指令中的数据标识获取到删除标识,提示待读取数据已被删除,无法显示。
在另一个实施例中,所述数据读写冲突解决程序10还可以包括版本记录模块和历史数据回溯模块。例如,所述版本记录模块可以为每个相同的所述文件头部的根节点地址分配一个唯一的目标数据集版本号,记录目标数据集版本号、每个版本更新的时间以及对应的根节点地址,将记录的记录目标数据集版本号、每个版本更新的时间以及对应的根节点地址存储在所述存储器11中;所述历史数据回溯模块可以根据版本更新时间和/或目标数据集版本号,利用对应的根节点地址获取对应版本的目标数据集,对历史数据进行回溯。
此外,本申请还提供一种基于B+树的读写冲突解决方法。参照图4所示,为本申请基于B+树的读写冲突解决方法的一实施例的流程示意图。电子装置1的处理器12执行存储器11中存储的数据读写冲突解决程序10时实现基于B+树的读写冲突解决方法的如下步骤:
步骤S310,索引构建模块110为目标数据集构建索引文件。具体地,所 述索引文件采用B+树的数据结构,且文件头部重复记录有B+树的根节点地址。在本实施例中,假设所述目标数据集为如前所述的视频直播平台在网站主页或直播列表中展示的图像构成的集合,则所述B+树的叶子节点中记录有所有图像的数据标识(例如图像编号)、存储地址或删除标识。所述删除标识用于表示对应的数据处于删除状态,即对应的图像已不在视频直播平台在网站主页或直播列表中展示。
步骤S320,在对所述目标数据集执行写操作时,写入模块120将所述写操作对应的数据标识、存储地址或删除标识添加到所述B+树的末尾节点,为所述末尾节点创建各层副本父节点,并在所述各层副本父节点记录子节点地址后,依次修改所述文件头部的根节点地址。具体地,所述写操作包括对目标数据集的增添、删除和更新修改等操作。假设对目标数据集进行增添操作,则将增添数据的数据标识和存储地址添加到所述B+树的末尾节点;假设对目标数据集进行删除操作,则将删除数据的数据标识和数据删除指令对应的指令标识添加到所述B+树的末尾节点;假设对目标数据集进行更新修改操作,则将该更新修改操作涉及数据对应的数据标识以及更新修改后的数据的存储地址添加到所述B+树的末尾节点。
需要说明的是,在对目标数据集进行删除操作时,在数据库中仅将删除数据标记为删除状态,并未从数据库中删除相关数据;在对目标数据集进行更新修改操作时,更新修改后的数据并未覆盖原来的数据,原来的数据在数据库中的内容和存储位置等均未改变,只是在数据库中增添更新修改后的数据。上述操作遵循一切皆追加的思想,以便历史数据回溯。类似的,在索引文件中,亦遵循一切皆追加的思想,写操作不会引起所述B+树中其他叶子节点的改变,而是在末尾节点添加写操作对应的数据标识、存储地址或删除标识。写操作也不会引起所述末尾节点的各层父节点的改变,而是为所述末尾节点创建各层副本父节点,包括副本根节点,并在所述各层副本父节点记录子节点地址后,依次修改所述文件头部的根节点地址。
步骤S330,在对所述目标数据集执行读操作时,读取模块130判断所述文件头部的根节点地址是否相同,若相同,则以任一或默认的所述根节点地址访问根节点,并逐层访问对应的子节点,完成读操作,否则,分别利用所述根节点地址进行读操作,以可用的根节点地址完成读操作。例如,读取模 块130接收数据读取指令,所述数据读取指令中包括数据标识,读取模块130根据所述数据读取指令访问目标数据集的索引文件,先判断索引文件头部的根节点地址是否相同,若相同,则以任一或默认的根节点地址访问根节点,并逐层访问对应的子节点,在对应的叶子节点中根据所述数据标识获取待读取数据的存储地址或删除标识,并根据获取的存储地址获取待读取数据或根据所述删除标识获知待读取数据的删除状态,完成读操作;若所述第一根节点地址和第二根节点地址不同,则分别利用所述第一根节点地址和第二根节点地址访问对应的根节点,以可用的根节点地址完成数据读取操作。关于根节点地址可用状态的解释请参照上述关于所述读取模块130的详细介绍,在此不再赘述。
在其他实施例中,电子装置1的处理器12执行存储器11中存储的数据读写冲突解决程序10时还实现基于B+树的读写冲突解决方法的如下步骤:
为每个相同的所述文件头部的根节点地址分配一个唯一的目标数据集版本号,记录目标数据集版本号、每个版本更新的时间以及对应的根节点地址;
根据版本更新时间和/或目标数据集版本号,利用对应的根节点地址获取对应版本的目标数据集。
此外,本申请还提供一种计算机可读存储介质,该计算机可读存储介质可以是硬盘、多媒体卡、SD卡、闪存卡、SMC、只读存储器(ROM)、可擦除可编程只读存储器(EPROM)、便携式紧致盘只读存储器(CD-ROM)、USB存储器等等中的任意一种或者几种的任意组合。
本申请之计算机可读存储介质的具体实施方式与上述基于B+树的读写冲突解决方法和电子装置1的具体实施方式大致相同,请参照上述图2关于数据读写冲突解决程序10实施例的程序模块图以及图4关于读写冲突解决方法实施例的流程图的详细介绍,在此不再赘述。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现 为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本申请要求的保护范围之内。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质中,包括若干指令用以使得电子装置执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种基于B+树的读写冲突解决方法,应用于电子装置,其特征在于,该方法包括:
    索引构建步骤:为目标数据集构建索引文件,该索引文件采用B+树的数据结构且在文件头部记录两次B+树的根节点地址;
    写入步骤:在对所述目标数据集执行写操作时,将所述写操作对应的数据标识、存储地址或删除标识添加到所述B+树的末尾节点,为所述末尾节点创建各层副本父节点,在所述各层副本父节点记录子节点地址后,依次修改所述文件头部的根节点地址;及
    读取步骤:在对所述目标数据集执行读操作时,判断所述文件头部的根节点地址是否相同,若相同,则以任一或默认的所述根节点地址访问根节点,并逐层访问对应的子节点,在对应的叶子节点中根据读操作指令中的数据标识获取待读取数据的存储地址或删除标识,并根据获取的存储地址获取待读取数据或根据所述删除标识获知待读取数据的删除状态,完成读操作,否则,分别利用所述根节点地址进行读操作,以可用的根节点地址完成读操作。
  2. 如权利要求1所述的基于B+树的读写冲突解决方法,其特征在于,在所述写入步骤中,所述副本父节点包括副本根节点,在所述副本根节点记录子节点地址后,依次将所述文件头部的根节点地址替换为所述副本根节点的地址,将所述副本根节点作为新的根节点。
  3. 如权利要求1所述的基于B+树的读写冲突解决方法,其特征在于,所述写操作包括对所述目标数据集的增添、删除和更新修改操作。
  4. 如权利要求1所述的基于B+树的读写冲突解决方法,其特征在于,所述根节点地址和子节点地址用指针表示。
  5. 如权利要求1所述的基于B+树的读写冲突解决方法,其特征在于,所述目标数据集包括视频直播平台在网站主页或直播列表中展示的图像构成的集合。
  6. 如权利要求1所述的基于B+树的读写冲突解决方法,其特征在于,所述读取步骤还包括:在对所述目标数据集执行完删除操作后,当接收到用户发送的对被删除数据的数据读取指令时,将根据所述数据读取指令访问目 标数据集的索引文件,并根据所述数据读取指令中的数据标识获取到删除标识,提示待读取数据已被删除,无法显示。
  7. 如权利要求1至4中任意一项所述的基于B+树的读写冲突解决方法,其特征在于,该方法还包括:
    为每个相同的所述文件头部的根节点地址分配一个唯一的目标数据集版本号,记录目标数据集版本号、每个版本更新的时间以及对应的根节点地址;
    根据版本更新时间和/或目标数据集版本号,利用对应的根节点地址获取对应版本的目标数据集。
  8. 一种电子装置,包括存储器和处理器,其特征在于,所述存储器中包括数据读写冲突解决程序,所述数据读写冲突解决程序被所述处理器执行时实现如下步骤:
    索引构建步骤:为目标数据集构建索引文件,该索引文件采用B+树的数据结构且在文件头部记录两次B+树的根节点地址;
    写入步骤:将写操作对应的数据标识、存储地址或删除标识添加到所述B+树的末尾节点,为所述末尾节点创建各层副本父节点,在所述各层副本父节点记录子节点地址后,依次修改所述文件头部的根节点地址;及
    读取步骤:在接收到对所述目标数据集的读操作指令时,判断所述文件头部的根节点地址是否相同,若相同,则以任一或默认的所述根节点地址访问根节点,并逐层访问对应的子节点,在对应的叶子节点中根据所述读操作指令中的数据标识获取待读取数据的存储地址或删除标识,并根据获取的存储地址获取待读取数据或根据所述删除标识获知待读取数据的删除状态,完成读操作,否则,分别利用所述根节点地址进行读操作,以可用的根节点地址完成读操作。
  9. 如权利要求8所述的电子装置,其特征在于,在所述写入步骤中,所述副本父节点包括副本根节点,在所述副本根节点记录子节点地址后,依次将所述文件头部的根节点地址替换为所述副本根节点的地址,将所述副本根节点作为新的根节点。
  10. 如权利要求8所述的电子装置,其特征在于,所述写操作包括对所述目标数据集的增添、删除和更新修改操作。
  11. 如权利要求8所述的电子装置,其特征在于,所述根节点地址和子 节点地址用指针表示。
  12. 如权利要求8所述的电子装置,其特征在于,所述目标数据集包括视频直播平台在网站主页或直播列表中展示的图像构成的集合。
  13. 如权利要求8所述的电子装置,其特征在于,所述读取步骤还包括:在对所述目标数据集执行完删除操作后,当接收到用户发送的对被删除数据的数据读取指令时,将根据所述数据读取指令访问目标数据集的索引文件,并根据所述数据读取指令中的数据标识获取到删除标识,提示待读取数据已被删除,无法显示。
  14. 如权利要求8至11中任意一项所述的电子装置,其特征在于,所述数据读写冲突解决程序被所述处理器执行时还实现如下步骤:
    为每个相同的所述文件头部的根节点地址分配一个唯一的目标数据集版本号,记录目标数据集版本号、每个版本更新的时间以及对应的根节点地址;
    根据版本更新时间和/或目标数据集版本号,利用对应的根节点地址获取对应版本的目标数据集。
  15. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中包括数据读写冲突解决程序,所述数据读写冲突解决程序被处理器执行时实现如下步骤:
    索引构建步骤:为目标数据集构建索引文件,该索引文件采用B+树的数据结构且在文件头部记录两次B+树的根节点地址;
    写入步骤:将写操作对应的数据标识、存储地址或删除标识添加到所述B+树的末尾节点,为所述末尾节点创建各层副本父节点,在所述各层副本父节点记录子节点地址后,依次修改所述文件头部的根节点地址;及
    读取步骤:在接收到对所述目标数据集的读操作指令时,判断所述文件头部的根节点地址是否相同,若相同,则以任一或默认的所述根节点地址访问根节点,并逐层访问对应的子节点,在对应的叶子节点中根据所述读操作指令中的数据标识获取待读取数据的存储地址或删除标识,并根据获取的存储地址获取待读取数据或根据所述删除标识获知待读取数据的删除状态,完成读操作,否则,分别利用所述根节点地址进行读操作,以可用的根节点地址完成读操作。
  16. 如权利要求15所述的计算机存储介质,其特征在于,在所述写入步 骤中,所述副本父节点包括副本根节点,在所述副本根节点记录子节点地址后,依次将所述文件头部的根节点地址替换为所述副本根节点的地址,将所述副本根节点作为新的根节点。
  17. 如权利要求15所述的计算机存储介质,其特征在于,所述写操作包括对所述目标数据集的增添、删除和更新修改操作。
  18. 如权利要求15所述的计算机存储介质,其特征在于,所述根节点地址和子节点地址用指针表示。
  19. 如权利要求15所述的计算机存储介质,其特征在于,所述读取步骤还包括:在对所述目标数据集执行完删除操作后,当接收到用户发送的对被删除数据的数据读取指令时,将根据所述数据读取指令访问目标数据集的索引文件,并根据所述数据读取指令中的数据标识获取到删除标识,提示待读取数据已被删除,无法显示。
  20. 如权利要求15至18中任意一项所述的计算机存储介质,其特征在于,所述数据读写冲突解决程序被所述处理器执行时还实现如下步骤:
    为每个相同的所述文件头部的根节点地址分配一个唯一的目标数据集版本号,记录目标数据集版本号、每个版本更新的时间以及对应的根节点地址;
    根据版本更新时间和/或目标数据集版本号,利用对应的根节点地址获取对应版本的目标数据集。
PCT/CN2019/102188 2019-04-17 2019-08-23 基于b+树的读写冲突解决方法、装置及存储介质 WO2020211236A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910307497.4A CN110162525B (zh) 2019-04-17 2019-04-17 基于b+树的读写冲突解决方法、装置及存储介质
CN201910307497.4 2019-04-17

Publications (1)

Publication Number Publication Date
WO2020211236A1 true WO2020211236A1 (zh) 2020-10-22

Family

ID=67639371

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/102188 WO2020211236A1 (zh) 2019-04-17 2019-08-23 基于b+树的读写冲突解决方法、装置及存储介质

Country Status (2)

Country Link
CN (1) CN110162525B (zh)
WO (1) WO2020211236A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112699138A (zh) * 2021-01-06 2021-04-23 常州微亿智造科技有限公司 线程间的数据更新方法、装置和存储介质
CN113609076A (zh) * 2021-08-04 2021-11-05 杭州海康威视数字技术股份有限公司 一种文件存储方法和文件读取方法
CN113672255A (zh) * 2021-07-31 2021-11-19 新华三大数据技术有限公司 一种分布式存储软件升级方法及装置
CN113986782A (zh) * 2021-11-05 2022-01-28 西北工业大学 一种树状组织的缓存结构及其应用

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111190861B (zh) * 2019-12-27 2023-06-30 中移(杭州)信息技术有限公司 热点文件管理方法、服务器及计算机可读存储介质
CN111538864B (zh) * 2020-03-25 2023-03-31 新华三技术有限公司合肥分公司 一种减少Buildrun消耗的方法及装置
CN111597185B (zh) * 2020-04-01 2023-04-28 深圳英飞拓仁用信息有限公司 一种基于树状结构资源分布的实时状态数快速统计方法
CN115190136B (zh) * 2021-04-21 2024-03-01 统信软件技术有限公司 一种数据存储方法、数据传输方法及计算设备
CN114254068B (zh) * 2022-02-28 2022-08-09 杭州未名信科科技有限公司 一种数据流转方法和系统
CN114282074B (zh) * 2022-03-04 2022-08-16 阿里云计算有限公司 数据库操作方法、装置、设备及存储介质
CN114791913A (zh) * 2022-04-26 2022-07-26 北京人大金仓信息技术股份有限公司 数据库的共享内存缓冲池处理方法、存储介质与设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060122996A1 (en) * 2003-05-30 2006-06-08 Microsoft Corporation Positional access using a b-tree
CN101339527A (zh) * 2008-07-28 2009-01-07 华中科技大学 影子内存的备份方法及装置
CN102722449A (zh) * 2012-05-24 2012-10-10 中国科学院计算技术研究所 基于SSD的Key-Value型本地存储方法及系统
CN103518364A (zh) * 2013-03-19 2014-01-15 华为技术有限公司 分布式存储系统的数据更新方法及服务器

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7865485B2 (en) * 2003-09-23 2011-01-04 Emc Corporation Multi-threaded write interface and methods for increasing the single file read and write throughput of a file server
KR100922389B1 (ko) * 2007-07-04 2009-10-19 삼성전자주식회사 플래시 메모리를 위한 색인 스킴
US8290996B2 (en) * 2010-07-30 2012-10-16 International Business Machines Corporation Data sharing for file clones using reverse ditto references
US9720926B2 (en) * 2014-08-04 2017-08-01 Cohesity, Inc. Read operations in a tree-based distributed file system
US9792309B2 (en) * 2014-08-04 2017-10-17 Cohesity, Inc. Write operations in a tree-based distributed file system
US9720947B2 (en) * 2014-08-04 2017-08-01 Cohesity, Inc. Backup operations in a tree-based distributed file system
CN104932953B (zh) * 2015-06-04 2017-11-21 华为技术有限公司 一种数据分发方法、数据存储方法、相关装置以及系统
CN107430546B (zh) * 2015-06-26 2020-04-21 华为技术有限公司 一种文件更新方法及存储设备
US10025806B2 (en) * 2015-08-27 2018-07-17 Vmware, Inc. Fast file clone using copy-on-write B-tree
CN105868396A (zh) * 2016-04-19 2016-08-17 上海交通大学 内存文件系统的多版本控制方法
CN106250321B (zh) * 2016-07-28 2019-03-01 盛科网络(苏州)有限公司 2r1w存储器的数据处理方法及数据处理系统
US10254996B1 (en) * 2018-08-10 2019-04-09 Cohesity, Inc. Fast migration of metadata

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060122996A1 (en) * 2003-05-30 2006-06-08 Microsoft Corporation Positional access using a b-tree
CN101339527A (zh) * 2008-07-28 2009-01-07 华中科技大学 影子内存的备份方法及装置
CN102722449A (zh) * 2012-05-24 2012-10-10 中国科学院计算技术研究所 基于SSD的Key-Value型本地存储方法及系统
CN103518364A (zh) * 2013-03-19 2014-01-15 华为技术有限公司 分布式存储系统的数据更新方法及服务器

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112699138A (zh) * 2021-01-06 2021-04-23 常州微亿智造科技有限公司 线程间的数据更新方法、装置和存储介质
CN113672255A (zh) * 2021-07-31 2021-11-19 新华三大数据技术有限公司 一种分布式存储软件升级方法及装置
CN113609076A (zh) * 2021-08-04 2021-11-05 杭州海康威视数字技术股份有限公司 一种文件存储方法和文件读取方法
CN113986782A (zh) * 2021-11-05 2022-01-28 西北工业大学 一种树状组织的缓存结构及其应用
CN113986782B (zh) * 2021-11-05 2024-05-14 西北工业大学 一种树状组织的缓存结构及其应用

Also Published As

Publication number Publication date
CN110162525B (zh) 2023-09-26
CN110162525A (zh) 2019-08-23

Similar Documents

Publication Publication Date Title
WO2020211236A1 (zh) 基于b+树的读写冲突解决方法、装置及存储介质
US20150302111A1 (en) Method and Apparatus for Constructing File System in Key-Value Storage System, and Electronic Device
US8938430B2 (en) Intelligent data archiving
JP2020502626A (ja) データベース・システムにおけるテスト・データの形成及び動作
US20180144061A1 (en) Edge store designs for graph databases
US10678784B2 (en) Dynamic column synopsis for analytical databases
CN109471851B (zh) 数据处理方法、装置、服务器和存储介质
US10528534B2 (en) Method and system for deduplicating data
CN109460406B (zh) 一种数据处理方法及装置
CN109491962B (zh) 一种文件目录树管理方法及相关装置
CN115544183A (zh) 数据可视化方法、装置、计算机设备和存储介质
WO2021189766A1 (zh) 数据可视化方法及相关设备
US20180075074A1 (en) Apparatus and method to correct index tree data added to existing index tree data
CN113779286B (zh) 管理图数据的方法及装置
CN112559913B (zh) 一种数据处理方法、装置、计算设备及可读存储介质
CN112347324A (zh) 一种文档查询方法、装置、电子设备及存储介质
CN111639087A (zh) 数据库中数据更新方法、装置和电子设备
US20180144060A1 (en) Processing deleted edges in graph databases
US20200104391A1 (en) Ensuring integrity of records in a not only structured query language database
CN115544981A (zh) 文档处理方法、装置、电子设备、存储介质及程序产品
KR101828466B1 (ko) 파일시스템을 기반으로 하는 저장장치에서 객체기반 스토리지 인터페이스를 제공하는 방법 및 장치
US20220083507A1 (en) Trust chain for official data and documents
US11256679B2 (en) Systems and methods for storing object state on hash chains
CN113806803A (zh) 一种数据存储方法、系统、终端设备及存储介质
JP4112282B2 (ja) 関係データベース構築装置および方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19924854

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19924854

Country of ref document: EP

Kind code of ref document: A1