public class Tuple
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected TableSchema |
schema
Every tuple points to its TableSchema of origin this field should be
ignored once a table is computed
|
protected java.util.Map<java.lang.String,java.lang.String> |
values
tuple contents are a map that pairs (column name, value)
|
Constructor and Description |
---|
Tuple(Table table)
create an empty tuple for the given table
|
Tuple(TableSchema schema)
create an empty tuple for the given schema
|
Modifier and Type | Method and Description |
---|---|
Tuple |
copy(TableSchema newSchema)
returns a (deep) copy of a tuple; precondition: newSchema and tableSchema
must have identically defined sets of columns; the schemas may have
different names
|
Tuple |
copy(Tuple from)
copies all column values from tuple into 'this' tuple
|
Tuple |
copy(Tuple from,
ColumnCorrespondence cor)
copies column values in 'from' tuple to 'this' tuple
|
Tuple |
copy(Tuple from,
java.util.List<Column> columns)
copies selected column values from existing tuple
|
boolean |
equals(Tuple t)
does 'this' tuple equal the given tuple requires 'this' and given tuple
to belong to the same schema and have the same column values
|
java.lang.String |
get(java.lang.String columnName)
returns value of given columnName; if columnName unrecognized, Error is
thrown
|
boolean |
getBool(java.lang.String columnName)
return boolean value of a column with columnName; no checking is done to
know if column value can be converted into a boolean
|
java.util.List<Column> |
getColumns()
Method delegates to TableSchema.getColumns()
|
double |
getDouble(java.lang.String columnName)
return double value of a column with columnName; no checking is done to
know if column value can be converted into an double
|
float |
getFloat(java.lang.String columnName)
return float value of a column with columnName; no checking is done to
know if column value can be converted into a float
|
java.lang.String |
getId()
return value of first column of tuple
|
int |
getInt(java.lang.String columnName)
return int value of column with columnName; no checking is done to know
if column value can be converted into an int
|
java.lang.String |
getNull(java.lang.String columnName)
returns null if string content of columnName is "null" otherwise string
column value is returned
|
TableSchema |
getSchema()
returns TableSchema of 'this' tuple
|
boolean |
hasSameValuesAs(Tuple t)
are all (col,val) pairs in 'this' tuple also in the given tuple?
|
boolean |
in(Table table)
is 'this' tuple in the given table?
|
boolean |
is(java.lang.String columnName)
does columnName have boolean true?
|
boolean |
is(java.lang.String columnName,
double value)
does columnName have double value?
|
boolean |
is(java.lang.String columnName,
float value)
does columnName have float value?
|
boolean |
is(java.lang.String columnName,
int value)
does columnName have integer value?
|
boolean |
is(java.lang.String columnName,
java.lang.String... values)
does columnName have any of these values
|
boolean |
is(java.lang.String columnName,
java.lang.String value)
does columnName have value?
|
void |
isComplete()
asserts that a tuple has its full complement of values.
|
boolean |
isNull(java.lang.String columnName)
is value of columnName "null"? Remember: nulls in an MDELite database are
"null" strings, not java null or ""
|
Table |
join(java.lang.String leftJoinCol,
Table rightTable,
java.lang.String rightJoinCol)
this is a table constructor that takes the join of one Lefttable tuple on
the leftJoinCol with rightTable on the rightJoinCol.
|
boolean |
joinExists(java.lang.String leftJoinCol,
Table rightTable,
java.lang.String rightJoinCol)
returns true if there exists a tuple that satisfies "this".thisJoinkey ==
rightTable.rightJoinCol; returns false otherwise
|
Tuple |
joinFirst(java.lang.String leftJoinCol,
Table rightTable,
java.lang.String rightJoinCol)
returns the first tuple of rightTable that joins with 'this', where
"this".thisJoinkey == rightTable.rightJoinCol; returns null otherwise;
technically this is a rightSemiJoinFirst operation
|
Tuple |
joinFirstEH(java.lang.String thisJoinKey,
Table otherTable,
java.lang.String otherJoinKey)
same as joinFirst, except an Error is thrown if no tuple of otherTable is
found.
|
boolean |
notIn(Table table)
is 'this' tuple NOT in the given table?
|
static Tuple |
parseTupleDecl(java.lang.String line,
int lineno,
TableSchema ts)
parses a line at lineno, expecting to parse a legal prolog tuple
declaration that conforms to table schema ts
|
void |
print()
print tuple to System.out
|
void |
print(java.io.PrintStream out)
print tuple to PrintStream out
|
Tuple |
project(TableSchema superTableSchema)
projects 'this' tuple to the set of columns of a super table schema; if
table schemas do not match, tuple.getName() throws an Error projection
retains the first set of columns -- columns that are removed are at the
end of a tuple
|
Table |
rightSemiJoin(java.lang.String leftJoinCol,
Table rightTable,
java.lang.String rightJoinCol)
this takes the RightSemiJoin of 'this' left tuple on the leftJoinCol with
rightTable on the rightJoinCol.
|
Tuple |
set(java.lang.String columnName,
boolean value)
sets a column with columnName to have the given boolean value
|
Tuple |
set(java.lang.String columnName,
double value)
sets a column with columnName to have the given double value
|
Tuple |
set(java.lang.String columnName,
float value)
sets a column with columnName to have the given float value
|
Tuple |
set(java.lang.String columnName,
int value)
sets a column with columnName to have the given int value
|
Tuple |
set(java.lang.String columnName,
java.lang.String value)
sets a column with columnName to have the given string value
|
Tuple |
setNull(java.lang.String columnName)
sets a column with columnName to have "null" value
|
void |
setNulls(TableSchema ts)
Add the (column,null) pairs of tuple t to the existing tuple.
|
Tuple |
setValues(java.lang.String... vals)
adds a list of values, in order in which their columns are defined, to an
empty tuple.
|
Tuple |
setValues(Tuple t)
Add the (column,value) pairs of tuple t to the existing tuple.
|
int |
size()
returns current number of (column,value) pairs in this tuple.
|
java.lang.String |
toString()
converts tuple into a string; throws error if # of columns of tuple do
not match # of columns in table schema
|
protected final TableSchema schema
protected final java.util.Map<java.lang.String,java.lang.String> values
public Tuple(TableSchema schema)
schema
- tuple schema to instantiatepublic Tuple(Table table)
table
- -- table to which tuple should conformpublic java.lang.String get(java.lang.String columnName)
columnName
- -- name of column to readpublic java.lang.String getId()
public int getInt(java.lang.String columnName)
columnName
- -- name of column to readpublic double getDouble(java.lang.String columnName)
columnName
- -- name of column to readpublic float getFloat(java.lang.String columnName)
columnName
- -- name of column to readpublic boolean getBool(java.lang.String columnName)
columnName
- -- name of column to readpublic java.lang.String getNull(java.lang.String columnName)
columnName
- -- name of column to readpublic boolean isNull(java.lang.String columnName)
columnName
- -- name of column to checkpublic boolean is(java.lang.String columnName, java.lang.String value)
columnName
- -- name of column to checkvalue
- -- value column should havepublic boolean is(java.lang.String columnName, java.lang.String... values)
columnName
- -- name of column to checkvalues
- -- set of values the column might havepublic boolean is(java.lang.String columnName, int value)
columnName
- -- name of column to checkvalue
- -- integer value column should havepublic boolean is(java.lang.String columnName, float value)
columnName
- -- name of column to checkvalue
- -- float value column should havepublic boolean is(java.lang.String columnName, double value)
columnName
- -- name of column to checkvalue
- -- double value column should havepublic boolean is(java.lang.String columnName)
columnName
- -- name of column to checkpublic Tuple set(java.lang.String columnName, java.lang.String value)
columnName
- -- name of column to updatevalue
- -- value to replacepublic Tuple set(java.lang.String columnName, int value)
columnName
- -- name of column to updatevalue
- -- value to replacepublic Tuple set(java.lang.String columnName, double value)
columnName
- -- name of column to updatevalue
- -- value to replacepublic Tuple set(java.lang.String columnName, float value)
columnName
- -- name of column to updatevalue
- -- value to replacepublic Tuple set(java.lang.String columnName, boolean value)
columnName
- -- name of column to updatevalue
- -- value to replacepublic Tuple setNull(java.lang.String columnName)
columnName
- -- name of column to updatepublic Tuple copy(Tuple from, java.util.List<Column> columns)
from
- -- tuple whose values are to be copiedcolumns
- -- columns to copypublic Tuple copy(Tuple from)
from
- -- tuple from whichpublic Tuple copy(Tuple from, ColumnCorrespondence cor)
from
- -- tuple to copy values fromcor
- -- correspondence of 'from' tuple and 'this' tuple columnspublic Tuple copy(TableSchema newSchema)
newSchema
- -- returned tuple copy must be instance of this schemapublic TableSchema getSchema()
public int size()
public java.util.List<Column> getColumns()
public Tuple project(TableSchema superTableSchema)
superTableSchema
- -- schema of supertable to project topublic void isComplete()
public boolean equals(Tuple t)
t
- -- tuple to comparepublic boolean hasSameValuesAs(Tuple t)
t
- -- tuple to comparepublic Tuple setValues(Tuple t)
t
- -- tuple whose (column, value) pairs are to be added to tuple
'this' used in table joins; not exported outside of packagepublic void setNulls(TableSchema ts)
ts
- -- table schema to which tuple t conforms.public Tuple setValues(java.lang.String... vals)
vals
- is list of values to add to an empty tuplepublic static Tuple parseTupleDecl(java.lang.String line, int lineno, TableSchema ts)
line
- to parselineno
- line number of the linets
- table schema for tuple to conformpublic void print(java.io.PrintStream out)
out
- where to printpublic void print()
public java.lang.String toString()
toString
in class java.lang.Object
public Table join(java.lang.String leftJoinCol, Table rightTable, java.lang.String rightJoinCol)
leftJoinCol
- -- join key of inner tablerightTable
- -- outer table of joinrightJoinCol
- -- join key of outer tablepublic Table rightSemiJoin(java.lang.String leftJoinCol, Table rightTable, java.lang.String rightJoinCol)
leftJoinCol
- -- join key of inner tablerightTable
- -- outer table of joinrightJoinCol
- -- join key of outer tablepublic boolean joinExists(java.lang.String leftJoinCol, Table rightTable, java.lang.String rightJoinCol)
rightTable
- -- the other table to which 'this' is to be joinedleftJoinCol
- -- the join key of 'this' tablerightJoinCol
- -- the join key of rightTablepublic Tuple joinFirst(java.lang.String leftJoinCol, Table rightTable, java.lang.String rightJoinCol)
rightTable
- -- the other table to which 'this' is to be joinedleftJoinCol
- -- the join key of 'this' tablerightJoinCol
- -- the join key of rightTablepublic Tuple joinFirstEH(java.lang.String thisJoinKey, Table otherTable, java.lang.String otherJoinKey)
otherTable
- -- the other table to which 'this' is to be joinedthisJoinKey
- -- the join key of 'this' tableotherJoinKey
- -- the join key of otherTablepublic boolean in(Table table)
table
- -- to searchpublic boolean notIn(Table table)
table
- -- to search