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

idea: support high entropy matches #10

Open
dominictarr opened this issue Apr 30, 2018 · 7 comments
Open

idea: support high entropy matches #10

dominictarr opened this issue Apr 30, 2018 · 7 comments

Comments

@dominictarr
Copy link
Collaborator

in secure scuttlebutt, there are many values that are high entropy - i.e. ids (both feeds and messages and blobs). Since these are essentially random, there is no reason to query them as ranges, usually they are retrived as exact queries.

for example, you could request all replies in a thread like this:

[{$filter: { value: {content: { root: <thread_id> } } } }]

this is a valid query, but would unfortunately produce a full-scan (i.e. read the entire database, a very inefficient query!).

Currently, we have indexes that match a given path, but we could also have indexes that match a given value. This index would match a particular value where ever it appears in the object. So this query would return replies and likes and backlinks, like https://github.com/ssbc/ssb-backlinks does. and then these would be filtered out (which would generally be an efficient query!). This means we could replace backlinks and do pretty much all the message queries via ssb-query.

@arj03 @mmckegg @mixmix

@mixmix
Copy link
Member

mixmix commented Apr 30, 2018 via email

@dominictarr
Copy link
Collaborator Author

@mixmix in the mean time, a much better way to do that would to use backlinks and http://npm.im/pull-merge to combine into one stream.

@dominictarr
Copy link
Collaborator Author

or pull-many if you don't care about the relative order of the substreams

@mixmix
Copy link
Member

mixmix commented May 1, 2018

I read the README of pull-merge and pull-many and it looks like both of them merge in ways that aren't ideal ... or the examples are unclear.

e.g. I don't want all comments from BlogA, then all comments from BlogB... or one of one then one of the other... I want a stream as they happened in time so I can make an infinite scroller.

How hard would it be to add $in to map-filter-reduce e.g.

{ 
  $filter: { 
    value: { 
      content: { 
        root: { 
          $in: [ '@ye4awsdas', '@mmsasdas']
        }
      }
    }
  }
}

@dominictarr
Copy link
Collaborator Author

@mixmix pull-merge takes a compare function, so you can use that to interleave the messages in order you want.

@dominictarr
Copy link
Collaborator Author

oh, the sub streams should already be in that order, to do a streaming merge, else you need to buffer the streams and then sort them.

@mixmix
Copy link
Member

mixmix commented May 7, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants