Code Monkey home page Code Monkey logo

memorybasedbplustree's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.