Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6026dc
commit f8a2d43
Showing
4 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require "../term" | ||
|
||
module ReQL | ||
class InfoTerm < Term | ||
infix_inspect "info" | ||
|
||
def check | ||
expect_args 1 | ||
end | ||
end | ||
|
||
class Evaluator | ||
def eval_term(term : InfoTerm) | ||
target = eval(term.args[0]) | ||
|
||
case target.reql_type | ||
when "TABLE" | ||
table = target.as_table | ||
storage = table.storage | ||
|
||
Datum.new({ | ||
"db" => { | ||
"id" => "", # TODO | ||
"name" => table.db.name, | ||
"type" => "DB", | ||
}, | ||
"doc_count_estimates" => [ | ||
storage.is_a?(Storage::PhysicalTable) ? storage.estimated_count : 0, | ||
], | ||
"id" => "", # TODO | ||
"indexes" => storage.is_a?(Storage::PhysicalTable) ? storage.get_index_list : [] of String, | ||
"name" => table.name, | ||
"primary_key" => storage.primary_key, | ||
"type" => "TABLE", | ||
}) | ||
else | ||
raise "BUG: .info() not implemented for #{target.reql_type}" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,5 +222,9 @@ module Storage | |
end | ||
end | ||
end | ||
|
||
def estimated_count | ||
@manager.kv.estimated_table_count(@table.info.id) | ||
end | ||
end | ||
end |