Closed Ravendocker closed 3 years ago
Hey @Ravendocker :)
I'll upload it tomorrow to
npm
to make its usage easier. I'll also add a quick guide to the README.In the meantime, you can look at our benchmarks code to understand how the code is used (e.g.: Insertion benchmark)
so nice.Thanks for u. The performance of I2B+ tree is so good that i want to apply other research.
It has been a tough last couple of days, but I promise I'll do it this weekend 😉
Hey @Ravendocker,
I have added an usage example in the README :)
The package is now also published in npm
so you can install by using npm install i2bplustree
Hey @Ravendocker,
Are you able to use the I2B+tree? Can I close this? :)
Hey @Ravendocker,
Are you able to use the I2B+tree? Can I close this? :)
No,im sorry. I npm install i2bplustree according your guide.But it doesn't work.
Hey @Ravendocker,
Are you able to use the I2B+tree? Can I close this? :)
I2B+_test.ts:22:21 - error TS2339: Property 'upperBound' does not exist on type 'MyInterval'.
22 return this.upperBound == int.getUpperBound() &&
I2B+_test.ts:22:39 - error TS2339: Property 'getUpperBound' does not exist on type 'MyInterval'.
22 return this.upperBound == int.getUpperBound() &&
I2B+_test.ts:23:18 - error TS2339: Property 'lowerBound' does not exist on type 'MyInterval'.
23 this.lowerBound == int.getLowerBound() &&
I2B+_test.ts:23:36 - error TS2339: Property 'getLowerBound' does not exist on type 'MyInterval'.
23 this.lowerBound == int.getLowerBound() &&
I2B+_test.ts:24:36 - error TS2339: Property 'getProperty' does not exist on type 'MyInterval'.
24 this.myProperty == int.getProperty();
Hey @Ravendocker
So there is actually a typo in the code in the README, I will fix it.
Nonetheless, you can already use this ✅ I created a JS playgroun with which you can interact so you can see what it works: https://codesandbox.io/s/i2bplustree-example-u1vqq?file=/src/index.js
The code in there:
import { IBplusTree, FlatInterval } from "i2bplustree";
// Create a class that inherits from the FlatInterval
class MyInterval extends FlatInterval {
constructor(val1, val2, myPropertyValue) {
super(val1, val2);
// This is just an example property
// Like this there could be many more
this.myProperty = myPropertyValue;
}
getProperty() {
return this.getProperty;
}
// This is just an example method
exampleMethod() {
// Do stuff
}
// Equals method to be overriden
// (currently with a bug, makes `search` method not work)
equals(int) {
return (
this.upperBound === int.getUpperBound() &&
this.lowerBound === int.getLowerBound()
);
}
}
// Now we create our I2BplusTree object and insert a `MyInterval` object
const threshold = 30;
const alpha = 0.2;
const tree = new IBplusTree(threshold, alpha);
// Introduce an object
tree.insert(new MyInterval(0, 2, "example-property"));
console.log(tree.exists(new MyInterval(0, 2, "diff-property")));
console.log(tree.search(0, 2));
/**
And do many other operations such as:
- Delete an interval from the tree
- Delete all intervals contained in a range
- Verify if an interval exists in the tree
- Search all intervals with equal bounds to the ones provided
- Find the first interval that intersects the given bounds
- Find all intervals intersecting the given range
- Find all intervals contained in the given range
*/
In the process, I also found a small bug that at the moment makes it impossible to utilise newly added properties to your Interval class in the equals
comparison. I have opened #5 to handle it!
Hey @Ravendocker
So there is actually a typo in the code in the README, I will fix it.
Nonetheless, you can already use this ✅ I created a JS playgroun with which you can interact so you can see what it works: https://codesandbox.io/s/i2bplustree-example-u1vqq?file=/src/index.js
The code in there:
import { IBplusTree, FlatInterval } from "i2bplustree"; // Create a class that inherits from the FlatInterval class MyInterval extends FlatInterval { constructor(val1, val2, myPropertyValue) { super(val1, val2); // This is just an example property // Like this there could be many more this.myProperty = myPropertyValue; } getProperty() { return this.getProperty; } // This is just an example method exampleMethod() { // Do stuff } // Equals method to be overriden // (currently with a bug, makes `search` method not work) equals(int) { return ( this.upperBound === int.getUpperBound() && this.lowerBound === int.getLowerBound() ); } } // Now we create our I2BplusTree object and insert a `MyInterval` object const threshold = 30; const alpha = 0.2; const tree = new IBplusTree(threshold, alpha); // Introduce an object tree.insert(new MyInterval(0, 2, "example-property")); console.log(tree.exists(new MyInterval(0, 2, "diff-property"))); console.log(tree.search(0, 2)); /** And do many other operations such as: - Delete an interval from the tree - Delete all intervals contained in a range - Verify if an interval exists in the tree - Search all intervals with equal bounds to the ones provided - Find the first interval that intersects the given bounds - Find all intervals intersecting the given range - Find all intervals contained in the given range */
In the process, I also found a small bug that at the moment makes it impossible to utilise newly added properties to your Interval class in the
equals
comparison. I have opened #5 to handle it!
Hey,my friend The CodeSandbox is running smoothly. So nice of you. I'm not very good with TypeScript and bring some troubles for you. And I want to implementation in CentOS using C++. This will allow more people to use it better.
Hey @Ravendocker :)
I'll upload it tomorrow to
npm
to make its usage easier. I'll also add a quick guide to the README.In the meantime, you can look at our benchmarks code to understand how the code is used (e.g.: Insertion benchmark)