Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Tree filled lower than order is not searchable #13

Merged
merged 1 commit into from
May 15, 2020

Conversation

anuragvohraec
Copy link
Contributor

@anuragvohraec anuragvohraec commented May 12, 2020

Issue being fixed or implemented

As of now if the tree is filled less then order size, one cannot search/delete/replace documents if using $lte to query. Example code:

const {SBTree} = require('sbtree');
const tree = new SBTree({order: 3});

(async()=>{
    await tree.insertDocuments({
        doc_id: '754aeea7c0919797d6eb2710d200eafd',
        key: 'VATEmq',
        value: 4,
        ts: 1588913801357
    })
    const t1 = new Date().getTime()-10000;
    console.log(t1, typeof t1);
    console.log(1588913801357<t1);
    console.log(await tree.deleteDocuments({ts: {$lte: t1}}))
})().then(v=>{
    console.log("Complete");
})

In above code, we create a tree with order size three and filled it with only one elements.
Now if we delete the document using query `{ts: {$lte:t1}} , the single documents though valid for deletio is not found out and deleted/

What was done

The problem seems to be occuring due to leafIndex incrementation below order level.
Have applied a decrement operation to balance the mismatch.

How Has This Been Tested?

Have re-run the sample code, which failed.

Notes

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

@anuragvohraec anuragvohraec changed the title Fixed issue: Tree filled lower than order. Fixed issue: Tree filled lower than order is not searchable May 13, 2020
@Alex-Werner Alex-Werner changed the title Fixed issue: Tree filled lower than order is not searchable fix: Tree filled lower than order is not searchable May 15, 2020
@Alex-Werner Alex-Werner changed the base branch from master to fix/tree-search May 15, 2020 04:37
@Alex-Werner Alex-Werner merged commit 3af516c into Alex-Werner:fix/tree-search May 15, 2020
Alex-Werner added a commit that referenced this pull request May 15, 2020
…14)

* fix: issue with lower fill factor than order for single element tree (#13)

* fix(SBFRoot/findLowerThan): finding document on equal case for lte

Specific case when order is bigger than actual size

* style: formatting

* test: add tests for tree with lower size than order

Co-authored-by: Anurag Vohra <53807480+anuragvohraec@users.noreply.github.com>
Alex-Werner added a commit that referenced this pull request Aug 29, 2020
* chore: update mongo-objectid + exposed it (#16)

* chore: updated mongo-objectid to 1.2.0

* feat: exposed ObjectID

* test: added exposition test

* chore: updated mongo-objectid to 1.2.1

* chore: bump dependencies to latest

fix security issue.

* fix: consistency issue with getDocument on unfound doc (#15)

Match fs adapter comportment

* chore(package): bump to 3.0.0

* fix: issue with lower fill factor than order for single element tree (#14)

* fix: issue with lower fill factor than order for single element tree (#13)

* fix(SBFRoot/findLowerThan): finding document on equal case for lte

Specific case when order is bigger than actual size

* style: formatting

* test: add tests for tree with lower size than order

Co-authored-by: Anurag Vohra <53807480+anuragvohraec@users.noreply.github.com>

* docs: docsify

Co-authored-by: Anurag Vohra <53807480+anuragvohraec@users.noreply.github.com>
Alex-Werner added a commit that referenced this pull request Aug 29, 2020
* chore: update mongo-objectid + exposed it (#16)

* chore: updated mongo-objectid to 1.2.0

* feat: exposed ObjectID

* test: added exposition test

* chore: updated mongo-objectid to 1.2.1

* chore: bump dependencies to latest

fix security issue.

* fix: consistency issue with getDocument on unfound doc (#15)

Match fs adapter comportment

* chore(package): bump to 3.0.0

* fix: issue with lower fill factor than order for single element tree (#14)

* fix: issue with lower fill factor than order for single element tree (#13)

* fix(SBFRoot/findLowerThan): finding document on equal case for lte

Specific case when order is bigger than actual size

* style: formatting

* test: add tests for tree with lower size than order

Co-authored-by: Anurag Vohra <53807480+anuragvohraec@users.noreply.github.com>

* feat: add isReady method + remove waitFor deps (#18)

* feat(SBTree): add isReady method

* feat: moved waitFor to use isReady method

* fix: fslock breaking change

* docs: docsify documentation (#22)

* chore: update mongo-objectid + exposed it (#16)

* chore: updated mongo-objectid to 1.2.0

* feat: exposed ObjectID

* test: added exposition test

* chore: updated mongo-objectid to 1.2.1

* chore: bump dependencies to latest

fix security issue.

* fix: consistency issue with getDocument on unfound doc (#15)

Match fs adapter comportment

* chore(package): bump to 3.0.0

* fix: issue with lower fill factor than order for single element tree (#14)

* fix: issue with lower fill factor than order for single element tree (#13)

* fix(SBFRoot/findLowerThan): finding document on equal case for lte

Specific case when order is bigger than actual size

* style: formatting

* test: add tests for tree with lower size than order

Co-authored-by: Anurag Vohra <53807480+anuragvohraec@users.noreply.github.com>

* docs: docsify

Co-authored-by: Anurag Vohra <53807480+anuragvohraec@users.noreply.github.com>

* tests!: reorganize tests + nested functional

BREAKING: get document unfound returns null instead of {}

* chore: added DS and nyc output to ignored entities

* chore!: return single document as [] + split lodash module

* chore: update dev deps

* style: eslint fix

* fix:  handling on unfound field

* feat!: remove single object as array

* chore: add badges

Co-authored-by: Anurag Vohra <53807480+anuragvohraec@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants