Skip to content

An implementation of B+Tree (a multiway search tree based on the memory, i.e., all data records are stored in the memory instead of the disk).

License

Notifications You must be signed in to change notification settings

Morgan279/MemoryBasedBPlusTree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

B+Tree

An implementation of B+Tree (a multiway search tree based on the memory, i.e., all data records are stored in the memory instead of the disk).

Getting started

Add dependency (maven) :

<dependency>
  <groupId>xyz.proadap.aliang</groupId>
  <artifactId>MemoryBasedBPlusTree</artifactId>
  <version>1.2.0</version>
</dependency>

Instantiation of BPlusTree

/**
* BPlusTree<K,E>
* K is the genericity of entry that need to be comparable
* E is the genericity of data item that can be any object
*/
BPlusTree<Integer,String> bPlusTree = new BPlusTree<>(16);//instance B+Tree with specific order

//instance B+Tree with default order
BPlusTree<Integer,String> bPlusTree = new BPlusTree<>(); //default order is 9

Features

insert:

bPlusTree.insert(0, "data record 1");
bPlusTree.insert(0, "data record 2");
bPlusTree.insert(1, "data record 3");
bPlusTree.insert(2, "data record 4");
bPlusTree.insert(3, "data record 5");

query:

//query all data records under the entry 0
List<String> queryResult = bPlusTree.query(0);
System.out.println(queryResult); //[data record 2, data record 1]

range query:

//query all data records under the entries [0,3)
List<String> queryResult = bPlusTree.rangeQuery(0, 3);
System.out.println(queryResult); //[data record 2, data record 1, data record 3, data record 4]

update:

//return true if update successfully, false otherwise
bPlusTree.update(0, "data record 2", "data record 12");
System.out.println(bPlusTree.query(0)); //[data record 1, data record 12]

remove:

/**
* remove all data records under the entry
* return true if remove successfully, false otherwise
*/
bPlusTree.remove(1);
System.out.println(bPlusTree.query(1)); //[]

/**
* remove specific data record under the entry (using ".equals()" to determine whether certain data record is the present)
* return true if remove successfully, false otherwise
*/
bPlusTree.remove(0, "data record 12");
System.out.println(bPlusTree.query(0)); //[data record 1]

License

BPlusTree is under the Apache 2.0 license. See the Apache License 2.0 file for details.


If it is helpful for you, you could give me a star to support me.

About

An implementation of B+Tree (a multiway search tree based on the memory, i.e., all data records are stored in the memory instead of the disk).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages