public class Table
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected TableSchema |
schema
each table points to its tablesSchema "schema"
|
Constructor and Description |
---|
Table(TableSchema schema)
create an empty table for TableSchema schema
|
Modifier and Type | Method and Description |
---|---|
Table |
add(Tuple t)
adds tuple t to 'this' table; throws error the schema of the tuple does
not match the schema of the table to which it is being added Untested
precondition: that the schema of the tuple conforms to the schema of the
table
|
Table |
copy(TableSchema tableSchema)
dup Table by copying each tuple and returning the copied Table.
|
Table |
copyForSelfJoins(java.lang.String copyTableName)
this method copies a table t for use in self-joins; the original table t
is copied and renamed to copyTableName
|
void |
delete(java.lang.String key,
java.lang.String value)
finds tuple with (key,value) pair and deletes the first
|
Table |
filter(java.util.function.Predicate<Tuple> p)
return a Table from a given Table that satisfies predicate p
|
java.util.List<Column> |
getColumns()
returns list of columns of the table; delegates to getColumns of
TableSchema
|
static java.lang.String |
getCSVName(java.lang.String pathName)
returns the name of a csv file, sans ".csv" and any directory information
linux example: "a/b/c.csv" returns "c" windoze example: "a\b\c.csv"
returns "c"
|
DBSchema |
getDBSchema()
returns the DBSchema of this table.
|
DBSchema |
getDBSchemaEH()
returns the DBSchema of this table.
|
Tuple |
getFirst(java.util.function.Predicate<Tuple> p)
return first tuple in table that satisfies predicate p
|
Tuple |
getFirstEH(java.util.function.Predicate<Tuple> p)
return first tuple in table that satisfies predicate p
|
java.lang.String |
getName()
returns name of table, which always equals the name of its table schema
|
TableSchema |
getSchema()
returns schema of table
|
java.util.List<Table> |
getSubTables()
returns list of table + its subtables to search note: this method is
really executed once.
|
static Table |
join(Table innerTable,
java.lang.String innerJoinKey,
Table outerTable,
java.lang.String outerJoinKey)
this is a table constructor that takes the equijoin of innerTable on the
innerJoinKey (column name) with outerTable on the outerJoinKey (column
name).
|
<S> S |
map(java.util.function.Function<Table,S> f)
transform a table to an object of type S
|
void |
print(java.io.PrintStream out)
print table to PrintStream out
|
Table |
project(java.util.List<Column> cols)
project Table to a list of cols
|
Table |
project(java.lang.String... colNames)
project Table to an array of column names.
|
Table |
project(TableSchema superTableSchema)
projects a Table to the set of columns of a super table schema if given
superTableSchema does not match any tuple in the list an Error is thrown
|
static Table |
readTable(java.lang.String tableFilePath)
reads and parses a prolog table from given string filename.
|
int |
size()
returns number of tuples in this table
|
Table |
sort(java.lang.String columnName)
sort 'this' Table on column with columnName
|
java.util.stream.Stream<Tuple> |
stream()
convert table into a stream of Tuples
|
TupleList |
tuples()
return list of Tuples of this table and all of its subtables no
projection is done to ensure that all tuples have exactly and only the
columns of its parents.
|
TupleList |
tuplesLocal()
return only the tuples of this table, and none of its subtables Generally
not used; tuples() is preferred
|
void |
writeTable(java.lang.String tablePathName)
general writeTable file utility -- if filename ends in ".csv"
then the table will be written in CSV format.
|
protected final TableSchema schema
public Table(TableSchema schema)
schema
- -- the schema to which the table should conformpublic Table copyForSelfJoins(java.lang.String copyTableName)
copyTableName
- -- postfix name distinguisherpublic static Table readTable(java.lang.String tableFilePath)
tableFilePath
- is the filename of the Prolog databasepublic <S> S map(java.util.function.Function<Table,S> f)
S
- -- return type, should not be Table or subclass of Tablef
- -- a function that maps a Table to Spublic Table filter(java.util.function.Predicate<Tuple> p)
p
- -- predicate to satisfypublic Table project(TableSchema superTableSchema)
superTableSchema
- -- schema of supertable to project topublic Table project(java.util.List<Column> cols)
cols
- - List of columnspublic Table project(java.lang.String... colNames)
colNames
- - List of column namespublic static Table join(Table innerTable, java.lang.String innerJoinKey, Table outerTable, java.lang.String outerJoinKey)
innerTable
- -- inner table of joininnerJoinKey
- -- join key of inner tableouterTable
- -- outer table of joinouterJoinKey
- -- join key of outer tablepublic Table copy(TableSchema tableSchema)
tableSchema
- -- table schema of the listpublic Table sort(java.lang.String columnName)
columnName
- -- name of (string) column to sortpublic Table add(Tuple t)
t
- is tuple to addpublic void delete(java.lang.String key, java.lang.String value)
key
- -- columnvalue
- -- column valuepublic DBSchema getDBSchema()
public DBSchema getDBSchemaEH()
public java.lang.String getName()
public TableSchema getSchema()
public java.util.List<Column> getColumns()
public TupleList tuples()
public TupleList tuplesLocal()
public Tuple getFirst(java.util.function.Predicate<Tuple> p)
p
- - filter or query, usually over a key fieldpublic Tuple getFirstEH(java.util.function.Predicate<Tuple> p)
p
- - filter or query, usually over a key fieldpublic int size()
public java.util.List<Table> getSubTables()
public static java.lang.String getCSVName(java.lang.String pathName)
pathName
- is the path-name to a csv filepublic void print(java.io.PrintStream out)
out
- -- PrintStream to output printpublic void writeTable(java.lang.String tablePathName)
tablePathName
- -- file path namepublic java.util.stream.Stream<Tuple> stream()