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

Function/arithmetic expressions in queries #75

Open
fekad opened this issue Nov 1, 2019 · 2 comments
Open

Function/arithmetic expressions in queries #75

fekad opened this issue Nov 1, 2019 · 2 comments

Comments

@fekad
Copy link
Contributor

fekad commented Nov 1, 2019

The idea is that such Functions/arithmetic expressions can only be calcualted on-the-fly during the queries:

functions:

  • count(pbc) > 2
  • any(Z > 14)
  • date("19-02-03")
  • any(norm(forces, 2) > 3)

arithmetics:

  • energy/natoms > -2.0 which is equilaent to
  • energy > -2.0 * natoms where are proerties on both side

mixture:

  • sum(Z = 14 or Z=6) > natoms

Possible solution:

  1. It is relatively easy to parse the query but is way more difficult to compile it into an eg.: mongo query. One possible solution is to precalculate and store them in some kind of cache for all the expressions. In this case, the reconstructed query itself contains regular terms only. (Note: the cache may need to be cleaned occasionally)

  2. Another possible way is the usage of the exec command. A snippet of python code generates a new property which is directly queriable. This could be the return value of (multiple) simple or (few) complex expression.

Note: The first option could provide better performance if the precalculation can happen within the mongo framework (JAVA) but it takes huge development effort to implement it. If the precalculation part happens in Python the two methods have the same performance.

@fekad
Copy link
Contributor Author

fekad commented Nov 15, 2019

Decision: although the grammar still contains all the features, but their implementation will raise an error because right now there is a new alternative way to use complex queries (#79).

@gabor1
Copy link
Contributor

gabor1 commented Jan 13, 2021

#79 partly helps this in the meantime

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

No branches or pull requests

2 participants