Part 6: Remove query-parser entirely.

This commit is contained in:
Nick Alexander 2018-05-31 15:02:32 -07:00
parent 47441f56dc
commit d4166cc67c
23 changed files with 3 additions and 142 deletions

View file

@ -58,9 +58,6 @@ path = "query"
[dependencies.mentat_query_algebrizer]
path = "query-algebrizer"
[dependencies.mentat_query_parser]
path = "query-parser"
[dependencies.mentat_query_projector]
path = "query-projector"

View file

@ -133,12 +133,12 @@ To run tests use:
# Run tests for everything.
cargo test --all
# Run tests for just the query-parser folder (specify the crate, not the folder),
# Run tests for just the query-algebrizer folder (specify the crate, not the folder),
# printing debug output.
cargo test -p mentat_query_parser -- --nocapture
cargo test -p mentat_query_algebrizer -- --nocapture
````
For most `cargo` commands you can pass the `-p` argument to run the command just on that package. So, `cargo build -p mentat_query_parser` will build just the "query-parser" folder.
For most `cargo` commands you can pass the `-p` argument to run the command just on that package. So, `cargo build -p mentat_query_algebrizer` will build just the "query-algebrizer" folder.
## What are all of these crates?
@ -189,10 +189,6 @@ Mentat has two main inputs: reads (queries) and writes (transacts). Just as `men
### Query processing
#### `mentat_query_parser`
This is a `combine` parser that uses `mentat_parser_utils` and `mentat_query` to turn a stream of EDN values into a more usable representation of a query.
#### `mentat_query_algebrizer`
This is the biggest piece of the query engine. It takes a parsed query, which at this point is _independent of a database_, and combines it with the current state of the schema and data. This involves translating keywords into attributes, abstract values into concrete values with a known type, and producing an `AlgebraicQuery`, which is a representation of how a query's Datalog semantics can be satisfied as SQL table joins and constraints over Mentat's SQL schema. An algebrized query is tightly coupled with both the disk schema and the vocabulary present in the store when the work is done.

View file

@ -12,9 +12,5 @@ path = "../core"
[dependencies.mentat_query]
path = "../query"
# Only for tests.
[dev-dependencies.mentat_query_parser]
path = "../query-parser"
[dev-dependencies]
itertools = "0.7"

View file

@ -86,8 +86,6 @@ impl ConjoiningClauses {
#[cfg(test)]
mod testing {
extern crate mentat_query_parser;
use std::collections::BTreeSet;
use super::*;

View file

@ -751,8 +751,6 @@ fn union_types(into: &mut BTreeMap<Variable, ValueTypeSet>,
#[cfg(test)]
mod testing {
extern crate mentat_query_parser;
use super::*;
use mentat_core::{

View file

@ -651,8 +651,6 @@ impl ConjoiningClauses {
#[cfg(test)]
mod testing {
extern crate mentat_query_parser;
use super::*;
use std::collections::BTreeMap;

View file

@ -96,7 +96,6 @@ pub(crate) fn validate_not_join(not_join: &NotJoin) -> Result<()> {
mod tests {
extern crate mentat_core;
extern crate mentat_query;
extern crate mentat_query_parser;
use self::mentat_query::{
Keyword,

View file

@ -11,7 +11,6 @@
extern crate mentat_core;
extern crate mentat_query;
extern crate mentat_query_algebrizer;
extern crate mentat_query_parser;
mod utils;

View file

@ -11,7 +11,6 @@
extern crate mentat_core;
extern crate mentat_query;
extern crate mentat_query_algebrizer;
extern crate mentat_query_parser;
mod utils;

View file

@ -11,7 +11,6 @@
extern crate mentat_core;
extern crate mentat_query;
extern crate mentat_query_algebrizer;
extern crate mentat_query_parser;
mod utils;

View file

@ -11,7 +11,6 @@
extern crate mentat_core;
extern crate mentat_query;
extern crate mentat_query_algebrizer;
extern crate mentat_query_parser;
mod utils;

View file

@ -1,17 +0,0 @@
[package]
name = "mentat_query_parser"
version = "0.0.1"
workspace = ".."
[dependencies]
combine = "2.3.2"
error-chain = { git = "https://github.com/rnewman/error-chain", branch = "rnewman/sync" }
[dependencies.edn]
path = "../edn"
[dependencies.mentat_parser_utils]
path = "../parser-utils"
[dependencies.mentat_query]
path = "../query"

View file

@ -1,2 +0,0 @@
See <https://github.com/mozilla/mentat/wiki/Querying> for a description of
what's going on in this crate, as well as `query` and `query-executor`.

View file

@ -1,49 +0,0 @@
// Copyright 2018 Mozilla
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
#![allow(dead_code)]
use edn;
use mentat_parser_utils::{
ValueParseError,
};
error_chain! {
types {
Error, ErrorKind, ResultExt, Result;
}
foreign_links {
EdnParseError(edn::parse::ParseError);
}
errors {
DuplicateVariableError {
description("duplicate variable")
display("duplicates in variable list")
}
FindParseError(e: ValueParseError) {
description(":find parse error")
display(":find parse error")
}
UnknownLimitVar(var: edn::PlainSymbol) {
description("limit var not present in :in")
display("limit var {} not present in :in", var)
}
InvalidLimit(val: edn::Value) {
description("limit value not valid")
display("expected natural number, got {}", val)
}
}
}

View file

@ -1,28 +0,0 @@
// Copyright 2016 Mozilla
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
#![allow(unused_imports)]
#[macro_use]
extern crate error_chain;
extern crate edn;
#[macro_use]
extern crate mentat_parser_utils;
mod errors;
pub use errors::{
Error,
ErrorKind,
Result,
ResultExt,
};

View file

@ -29,10 +29,6 @@ path = "../query-algebrizer"
[dependencies.mentat_query_pull]
path = "../query-pull"
# Only for tests.
[dev-dependencies.mentat_query_parser]
path = "../query-parser"
[dependencies.mentat_query_sql]
path = "../query-sql"

View file

@ -11,7 +11,6 @@
extern crate mentat_core;
extern crate mentat_query;
extern crate mentat_query_algebrizer;
extern crate mentat_query_parser;
extern crate mentat_query_projector;
use mentat_core::{

View file

@ -27,7 +27,3 @@ path = "../query-sql"
[dependencies.mentat_sql]
path = "../sql"
# Only for tests.
[dev-dependencies.mentat_query_parser]
path = "../query-parser"

View file

@ -17,7 +17,3 @@ path = "../query"
[dependencies.mentat_query_algebrizer]
path = "../query-algebrizer"
# Only for tests.
[dev-dependencies.mentat_query_parser]
path = "../query-parser"

View file

@ -18,10 +18,6 @@ path = "../query"
[dependencies.mentat_query_algebrizer]
path = "../query-algebrizer"
# Only for tests.
[dev-dependencies.mentat_query_parser]
path = "../query-parser"
[dependencies.mentat_query_projector]
path = "../query-projector"

View file

@ -11,7 +11,6 @@
extern crate mentat_core;
extern crate mentat_query;
extern crate mentat_query_algebrizer;
extern crate mentat_query_parser;
extern crate mentat_query_projector;
extern crate mentat_query_translator;
extern crate mentat_sql;

View file

@ -24,7 +24,6 @@ use mentat_core::{
use mentat_db;
use mentat_query;
use mentat_query_algebrizer;
use mentat_query_parser;
use mentat_query_projector;
use mentat_query_pull;
use mentat_query_translator;
@ -46,7 +45,6 @@ error_chain! {
links {
DbError(mentat_db::Error, mentat_db::ErrorKind);
QueryError(mentat_query_algebrizer::Error, mentat_query_algebrizer::ErrorKind); // Let's not leak the term 'algebrizer'.
QueryParseError(mentat_query_parser::Error, mentat_query_parser::ErrorKind);
ProjectorError(mentat_query_projector::errors::Error, mentat_query_projector::errors::ErrorKind);
PullError(mentat_query_pull::errors::Error, mentat_query_pull::errors::ErrorKind);
TranslatorError(mentat_query_translator::Error, mentat_query_translator::ErrorKind);

View file

@ -25,7 +25,6 @@ extern crate mentat_core;
extern crate mentat_db;
extern crate mentat_query;
extern crate mentat_query_algebrizer;
extern crate mentat_query_parser;
extern crate mentat_query_projector;
extern crate mentat_query_pull;
extern crate mentat_query_translator;