Module: Bmg

Defined in:
lib/bmg.rb,
lib/bmg/sql.rb,
lib/bmg/type.rb,
lib/bmg/error.rb,
lib/bmg/reader.rb,
lib/bmg/sequel.rb,
lib/bmg/writer.rb,
lib/bmg/algebra.rb,
lib/bmg/version.rb,
lib/bmg/database.rb,
lib/bmg/operator.rb,
lib/bmg/relation.rb,
lib/bmg/reader/csv.rb,
lib/bmg/summarizer.rb,
lib/bmg/writer/csv.rb,
lib/bmg/reader/xlsx.rb,
lib/bmg/sql/builder.rb,
lib/bmg/sql/dialect.rb,
lib/bmg/sql/grammar.rb,
lib/bmg/sql/version.rb,
lib/bmg/writer/xlsx.rb,
lib/bmg/sql/relation.rb,
lib/bmg/support/keys.rb,
lib/bmg/database/xlsx.rb,
lib/bmg/operator/join.rb,
lib/bmg/operator/page.rb,
lib/bmg/sql/processor.rb,
lib/bmg/operator/group.rb,
lib/bmg/operator/image.rb,
lib/bmg/operator/minus.rb,
lib/bmg/operator/union.rb,
lib/bmg/relation/empty.rb,
lib/bmg/relation/proxy.rb,
lib/bmg/relation/spied.rb,
lib/bmg/sql/nodes/expr.rb,
lib/bmg/sql/nodes/join.rb,
lib/bmg/summarizer/avg.rb,
lib/bmg/summarizer/max.rb,
lib/bmg/summarizer/min.rb,
lib/bmg/summarizer/sum.rb,
lib/bmg/database/sequel.rb,
lib/bmg/operator/allbut.rb,
lib/bmg/operator/extend.rb,
lib/bmg/operator/rename.rb,
lib/bmg/operator/unwrap.rb,
lib/bmg/sequel/relation.rb,
lib/bmg/sql/nodes/union.rb,
lib/bmg/summarizer/last.rb,
lib/bmg/operator/project.rb,
lib/bmg/operator/rxmatch.rb,
lib/bmg/operator/ungroup.rb,
lib/bmg/reader/text_file.rb,
lib/bmg/sql/nodes/except.rb,
lib/bmg/summarizer/count.rb,
lib/bmg/summarizer/first.rb,
lib/bmg/support/ordering.rb,
lib/bmg/algebra/shortcuts.rb,
lib/bmg/operator/autowrap.rb,
lib/bmg/operator/matching.rb,
lib/bmg/operator/restrict.rb,
lib/bmg/sequel/translator.rb,
lib/bmg/sql/nodes/literal.rb,
lib/bmg/sql/processor/all.rb,
lib/bmg/summarizer/concat.rb,
lib/bmg/summarizer/stddev.rb,
lib/bmg/operator/constants.rb,
lib/bmg/operator/summarize.rb,
lib/bmg/operator/transform.rb,
lib/bmg/relation/in_memory.rb,
lib/bmg/sql/nodes/table_as.rb,
lib/bmg/sql/nodes/with_exp.rb,
lib/bmg/sql/processor/bind.rb,
lib/bmg/sql/processor/clip.rb,
lib/bmg/sql/processor/join.rb,
lib/bmg/sql/processor/star.rb,
lib/bmg/summarizer/by_proc.rb,
lib/bmg/summarizer/collect.rb,
lib/bmg/sql/nodes/func_call.rb,
lib/bmg/sql/nodes/intersect.rb,
lib/bmg/sql/nodes/left_join.rb,
lib/bmg/sql/nodes/with_spec.rb,
lib/bmg/sql/processor/merge.rb,
lib/bmg/sql/processor/where.rb,
lib/bmg/summarizer/distinct.rb,
lib/bmg/summarizer/multiple.rb,
lib/bmg/summarizer/value_by.rb,
lib/bmg/summarizer/variance.rb,
lib/bmg/database/data_folder.rb,
lib/bmg/operator/shared/nary.rb,
lib/bmg/sql/nodes/cross_join.rb,
lib/bmg/sql/nodes/inner_join.rb,
lib/bmg/sql/nodes/name_intro.rb,
lib/bmg/sql/nodes/select_exp.rb,
lib/bmg/sql/nodes/summarizer.rb,
lib/bmg/sql/nodes/table_name.rb,
lib/bmg/sql/processor/extend.rb,
lib/bmg/sql/processor/rename.rb,
lib/bmg/summarizer/bucketize.rb,
lib/bmg/operator/not_matching.rb,
lib/bmg/operator/shared/unary.rb,
lib/bmg/relation/materialized.rb,
lib/bmg/sequel/type_inference.rb,
lib/bmg/sql/nodes/column_name.rb,
lib/bmg/sql/nodes/from_clause.rb,
lib/bmg/sql/nodes/select_item.rb,
lib/bmg/sql/nodes/select_list.rb,
lib/bmg/sql/nodes/select_star.rb,
lib/bmg/sql/nodes/subquery_as.rb,
lib/bmg/sql/processor/flatten.rb,
lib/bmg/sql/processor/reorder.rb,
lib/bmg/summarizer/percentile.rb,
lib/bmg/summarizer/positional.rb,
lib/bmg/support/tuple_algebra.rb,
lib/bmg/operator/autosummarize.rb,
lib/bmg/operator/shared/binary.rb,
lib/bmg/sql/nodes/limit_clause.rb,
lib/bmg/sql/nodes/set_operator.rb,
lib/bmg/sql/nodes/where_clause.rb,
lib/bmg/sql/processor/distinct.rb,
lib/bmg/sql/processor/order_by.rb,
lib/bmg/sql/nodes/offset_clause.rb,
lib/bmg/sql/nodes/order_by_term.rb,
lib/bmg/sql/processor/constants.rb,
lib/bmg/sql/processor/from_self.rb,
lib/bmg/sql/processor/requalify.rb,
lib/bmg/sql/processor/semi_join.rb,
lib/bmg/sql/processor/summarize.rb,
lib/bmg/sql/processor/transform.rb,
lib/bmg/sql/nodes/qualified_name.rb,
lib/bmg/sql/nodes/range_var_name.rb,
lib/bmg/sql/nodes/set_quantifier.rb,
lib/bmg/sql/nodes/group_by_clause.rb,
lib/bmg/sql/nodes/native_table_as.rb,
lib/bmg/sql/nodes/order_by_clause.rb,
lib/bmg/summarizer/distinct_count.rb,
lib/bmg/support/tuple_transformer.rb,
lib/bmg/relation/in_memory/mutable.rb,
lib/bmg/sql/processor/join_support.rb,
lib/bmg/sql/processor/limit_offset.rb,
lib/bmg/support/output_preferences.rb,
lib/bmg/sequel/predicate_translator.rb,
lib/bmg/sql/support/from_clause_orderer.rb

Defined Under Namespace

Modules: Algebra, Operator, Ordering, Reader, Relation, Sequel, Sql, TupleAlgebra, Version, Writer Classes: Database, Error, InvalidUpdateError, Keys, MisuseError, NotSuchRelationError, NotSupportedError, OneError, OutputPreferences, Summarizer, TupleTransformer, Type, TypeError, UnknownAttributesError

Constant Summary collapse

Leaf =

Deprecated

Relation::InMemory
VERSION =
"#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"

Class Method Summary collapse

Class Method Details

.csv(path, options = {}, type = Type::ANY) ⇒ Object



22
23
24
# File 'lib/bmg.rb', line 22

def csv(path, options = {}, type = Type::ANY)
  Reader::Csv.new(type, path, options).spied(main_spy)
end

.excel(path, options = {}, type = Type::ANY) ⇒ Object



37
38
39
# File 'lib/bmg.rb', line 37

def excel(path, options = {}, type = Type::ANY)
  Reader::Excel.new(type, path, options).spied(main_spy)
end

.in_memory(enumerable, type = Type::ANY) ⇒ Object



12
13
14
# File 'lib/bmg.rb', line 12

def in_memory(enumerable, type = Type::ANY)
  Relation::InMemory.new(type, enumerable).spied(main_spy)
end

.json(path, options = {}, type = Type::ANY) ⇒ Object



27
28
29
# File 'lib/bmg.rb', line 27

def json(path, options = {}, type = Type::ANY)
  in_memory(path.load.map{|tuple| TupleAlgebra.symbolize_keys(tuple) })
end

.main_spyObject



42
43
44
# File 'lib/bmg.rb', line 42

def main_spy
  @main_spy
end

.main_spy=(spy) ⇒ Object



47
48
49
# File 'lib/bmg.rb', line 47

def main_spy=(spy)
  @main_spy = spy
end

.mutable(enumerable, type = Type::ANY) ⇒ Object



7
8
9
# File 'lib/bmg.rb', line 7

def mutable(enumerable, type = Type::ANY)
  Relation::InMemory::Mutable.new(type, enumerable).spied(main_spy)
end

.sequel(source, sequel_db = nil, type = nil) ⇒ Object

Builds a Relation that uses Sequel for managing real data accesses.

Supported signatures:

# Table name, providing the Sequel's Database object
Bmg.sequel(:suppliers, DB)

# Sequel dataset object, embedding the Database object
# `from_self` will be used at compilation time, you don't
# need to call it yourself.
Bmg.sequel(DB[:suppliers])

# Similar, but with with a pure SQL query
Bmg.sequel(DB[%Q{SELECT ... FROM ...}])

# All signatures above with an explicit type object, e.g.:
Bmg.sequel(:suppliers, DB, Type::ANY)
Bmg.sequel(DB[:suppliers], Type::ANY)


58
59
60
# File 'lib/bmg/sequel.rb', line 58

def sequel(source, sequel_db = nil, type = nil)
  Sequel.sequel(source, sequel_db, type)
end

.sql(table, type = Type::ANY) ⇒ Object

module Sql



10
11
12
13
14
# File 'lib/bmg/sql.rb', line 10

def sql(table, type = Type::ANY)
  builder = Sql::Builder.new
  sexpr = builder.select_star_from(table)
  Sql::Relation.new(type, builder, sexpr).spied(main_spy)
end

.text_file(path, options = {}, type = Type::ANY) ⇒ Object



17
18
19
# File 'lib/bmg.rb', line 17

def text_file(path, options = {}, type = Type::ANY)
  Reader::TextFile.new(type, path, options).spied(main_spy)
end

.yaml(path, options = {}, type = Type::ANY) ⇒ Object



32
33
34
# File 'lib/bmg.rb', line 32

def yaml(path, options = {}, type = Type::ANY)
  in_memory(path.load.map{|tuple| TupleAlgebra.symbolize_keys(tuple) })
end