From d4166cc67c1a9bd2b3a35a67e8c5540ba515eb96 Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Thu, 31 May 2018 15:02:32 -0700 Subject: [PATCH] Part 6: Remove query-parser entirely. --- Cargo.toml | 3 -- README.md | 10 ++--- query-algebrizer/Cargo.toml | 4 -- query-algebrizer/src/clauses/not.rs | 2 - query-algebrizer/src/clauses/or.rs | 2 - query-algebrizer/src/clauses/pattern.rs | 2 - query-algebrizer/src/validate.rs | 1 - query-algebrizer/tests/fulltext.rs | 1 - query-algebrizer/tests/ground.rs | 1 - query-algebrizer/tests/predicate.rs | 1 - query-algebrizer/tests/type_reqs.rs | 1 - query-parser/Cargo.toml | 17 --------- query-parser/README.md | 2 - query-parser/src/errors.rs | 49 ------------------------- query-parser/src/lib.rs | 28 -------------- query-projector/Cargo.toml | 4 -- query-projector/tests/aggregates.rs | 1 - query-pull/Cargo.toml | 4 -- query-sql/Cargo.toml | 4 -- query-translator/Cargo.toml | 4 -- query-translator/tests/translate.rs | 1 - src/errors.rs | 2 - src/lib.rs | 1 - 23 files changed, 3 insertions(+), 142 deletions(-) delete mode 100644 query-parser/Cargo.toml delete mode 100644 query-parser/README.md delete mode 100644 query-parser/src/errors.rs delete mode 100644 query-parser/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index a072e4bb..f9c43124 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/README.md b/README.md index 720ce17d..0acc6822 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/query-algebrizer/Cargo.toml b/query-algebrizer/Cargo.toml index ef1b0965..d544a29d 100644 --- a/query-algebrizer/Cargo.toml +++ b/query-algebrizer/Cargo.toml @@ -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" diff --git a/query-algebrizer/src/clauses/not.rs b/query-algebrizer/src/clauses/not.rs index dfddd879..299c62ec 100644 --- a/query-algebrizer/src/clauses/not.rs +++ b/query-algebrizer/src/clauses/not.rs @@ -86,8 +86,6 @@ impl ConjoiningClauses { #[cfg(test)] mod testing { - extern crate mentat_query_parser; - use std::collections::BTreeSet; use super::*; diff --git a/query-algebrizer/src/clauses/or.rs b/query-algebrizer/src/clauses/or.rs index ad6662d3..53918e52 100644 --- a/query-algebrizer/src/clauses/or.rs +++ b/query-algebrizer/src/clauses/or.rs @@ -751,8 +751,6 @@ fn union_types(into: &mut BTreeMap, #[cfg(test)] mod testing { - extern crate mentat_query_parser; - use super::*; use mentat_core::{ diff --git a/query-algebrizer/src/clauses/pattern.rs b/query-algebrizer/src/clauses/pattern.rs index d713ea7c..7cf62c6a 100644 --- a/query-algebrizer/src/clauses/pattern.rs +++ b/query-algebrizer/src/clauses/pattern.rs @@ -651,8 +651,6 @@ impl ConjoiningClauses { #[cfg(test)] mod testing { - extern crate mentat_query_parser; - use super::*; use std::collections::BTreeMap; diff --git a/query-algebrizer/src/validate.rs b/query-algebrizer/src/validate.rs index 44c4c131..5bac7fde 100644 --- a/query-algebrizer/src/validate.rs +++ b/query-algebrizer/src/validate.rs @@ -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, diff --git a/query-algebrizer/tests/fulltext.rs b/query-algebrizer/tests/fulltext.rs index 083f7121..02bc493f 100644 --- a/query-algebrizer/tests/fulltext.rs +++ b/query-algebrizer/tests/fulltext.rs @@ -11,7 +11,6 @@ extern crate mentat_core; extern crate mentat_query; extern crate mentat_query_algebrizer; -extern crate mentat_query_parser; mod utils; diff --git a/query-algebrizer/tests/ground.rs b/query-algebrizer/tests/ground.rs index a07ed081..b7e8341f 100644 --- a/query-algebrizer/tests/ground.rs +++ b/query-algebrizer/tests/ground.rs @@ -11,7 +11,6 @@ extern crate mentat_core; extern crate mentat_query; extern crate mentat_query_algebrizer; -extern crate mentat_query_parser; mod utils; diff --git a/query-algebrizer/tests/predicate.rs b/query-algebrizer/tests/predicate.rs index 7482deed..6aa0d929 100644 --- a/query-algebrizer/tests/predicate.rs +++ b/query-algebrizer/tests/predicate.rs @@ -11,7 +11,6 @@ extern crate mentat_core; extern crate mentat_query; extern crate mentat_query_algebrizer; -extern crate mentat_query_parser; mod utils; diff --git a/query-algebrizer/tests/type_reqs.rs b/query-algebrizer/tests/type_reqs.rs index a8f5179b..b2cd66a1 100644 --- a/query-algebrizer/tests/type_reqs.rs +++ b/query-algebrizer/tests/type_reqs.rs @@ -11,7 +11,6 @@ extern crate mentat_core; extern crate mentat_query; extern crate mentat_query_algebrizer; -extern crate mentat_query_parser; mod utils; diff --git a/query-parser/Cargo.toml b/query-parser/Cargo.toml deleted file mode 100644 index ffaa753b..00000000 --- a/query-parser/Cargo.toml +++ /dev/null @@ -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" diff --git a/query-parser/README.md b/query-parser/README.md deleted file mode 100644 index feb48f62..00000000 --- a/query-parser/README.md +++ /dev/null @@ -1,2 +0,0 @@ -See for a description of -what's going on in this crate, as well as `query` and `query-executor`. diff --git a/query-parser/src/errors.rs b/query-parser/src/errors.rs deleted file mode 100644 index 990112ba..00000000 --- a/query-parser/src/errors.rs +++ /dev/null @@ -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) - } - } -} diff --git a/query-parser/src/lib.rs b/query-parser/src/lib.rs deleted file mode 100644 index c9a12fa7..00000000 --- a/query-parser/src/lib.rs +++ /dev/null @@ -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, -}; diff --git a/query-projector/Cargo.toml b/query-projector/Cargo.toml index e5e2563e..1bdcc4c1 100644 --- a/query-projector/Cargo.toml +++ b/query-projector/Cargo.toml @@ -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" diff --git a/query-projector/tests/aggregates.rs b/query-projector/tests/aggregates.rs index 0a17ee55..6b148ed3 100644 --- a/query-projector/tests/aggregates.rs +++ b/query-projector/tests/aggregates.rs @@ -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::{ diff --git a/query-pull/Cargo.toml b/query-pull/Cargo.toml index 9b89a6af..cc5e8b68 100644 --- a/query-pull/Cargo.toml +++ b/query-pull/Cargo.toml @@ -27,7 +27,3 @@ path = "../query-sql" [dependencies.mentat_sql] path = "../sql" - -# Only for tests. -[dev-dependencies.mentat_query_parser] -path = "../query-parser" diff --git a/query-sql/Cargo.toml b/query-sql/Cargo.toml index 7b951f11..583612e2 100644 --- a/query-sql/Cargo.toml +++ b/query-sql/Cargo.toml @@ -17,7 +17,3 @@ path = "../query" [dependencies.mentat_query_algebrizer] path = "../query-algebrizer" - -# Only for tests. -[dev-dependencies.mentat_query_parser] -path = "../query-parser" diff --git a/query-translator/Cargo.toml b/query-translator/Cargo.toml index 1edc8728..b729a12d 100644 --- a/query-translator/Cargo.toml +++ b/query-translator/Cargo.toml @@ -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" diff --git a/query-translator/tests/translate.rs b/query-translator/tests/translate.rs index d80e06bf..30306904 100644 --- a/query-translator/tests/translate.rs +++ b/query-translator/tests/translate.rs @@ -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; diff --git a/src/errors.rs b/src/errors.rs index bcf340c6..126faa00 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -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); diff --git a/src/lib.rs b/src/lib.rs index d73b9529..77e4ec32 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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;