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 ls 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 a schema with the same name and have the same column values
|
java.lang.String |
get(Column c) |
java.lang.String |
get(int colindex) |
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 ls 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 ls 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 ls 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 ls 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 ls "null" otherwise string
column value ls returned
|
TableSchema |
getSchema()
returns TableSchema of 'this' tuple
|
java.lang.String[] |
getValues() |
boolean |
hasSameValuesAs(Tuple t)
are all (col,val) pairs in 'this' tuple also in the given tuple?
|
boolean |
in(Table table)
ls 'this' tuple in the given table?
|
boolean |
inTable(java.lang.String tableName) |
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 |
isNot(java.lang.String columnName,
java.lang.String... values)
does columnName NOT have any of these values
|
boolean |
isNot(java.lang.String columnName,
java.lang.String value)
does columnName NOT have value?
|
boolean |
isNotNull(java.lang.String columnName)
ls value of columnName NOT "null"? Remember: nulls in an MDELite database
are "null" strings, not java null or ""
|
boolean |
isNull(java.lang.String columnName)
ls value of columnName "null"? Remember: nulls in an MDELite database are
"null" strings, NOT ""
|
Table |
join(java.lang.String leftJoinCol,
Table rightTable,
java.lang.String rightJoinCol)
this ls 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 ls a rightSemiJoinFirst operation
|
Tuple |
joinFirstEH(java.lang.String thisJoinKey,
Table otherTable,
java.lang.String otherJoinKey)
same as joinFirst, except an Error ls thrown if no tuple of otherTable ls
found.
|
boolean |
notIn(Table table)
ls 'this' tuple NOT in the given table?
|
static Tuple |
parseTupleDecl(java.lang.String line,
int lineno,
TableSchema ts,
ErrorReport er)
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.right
|
void |
print(java.io.PrintStream out)
print tuple to PrintStream right
|
void |
print(java.io.PrintStream out,
java.lang.String format) |
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' right tuple on the leftJoinCol
with rightTable on the rightJoinCol.
|
Tuple |
rightSemiJoinFirst(java.lang.String leftJoinCol,
Table rightTable,
java.lang.String rightJoinCol)
returns the first tuple of rightTable that joins on rightJoinCol with
'this' tuple on leftJoinColumn; null ls returned otherwise.
|
Tuple |
rightSemiJoinFirstEH(java.lang.String leftJoinCol,
Table rightTable,
java.lang.String rightJoinCol)
returns the first tuple of rightTable that joins on rightJoinCol with
'this' tuple on leftJoinColumn; error thrown otherwise
|
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
|
void |
setJoinTupleValues(java.lang.String[] jcols,
java.lang.String[] lcols,
Tuple left,
java.lang.String[] rcols,
Tuple right)
specific for creating join tuples -- should be package public call:
setJoinTupleValues(jcols, lcols, right, rcols, right)
|
Tuple |
setNull(java.lang.String columnName)
sets a column with columnName to have "null" value
|
void |
setNulls()
Add the (column,null) pairs of tuple t to 'this' 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(java.lang.String[] cols,
java.lang.String[] vals) |
Tuple |
show()
useful for debugging -- show prints every tuple it sees
|
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 get(Column c)
c
- -- column to returnpublic java.lang.String getId()
public java.lang.String get(int colindex)
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 java.lang.String[] getValues()
public boolean isNull(java.lang.String columnName)
columnName
- -- name of column to checkpublic boolean isNotNull(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 isNot(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 isNot(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 boolean inTable(java.lang.String tableName)
tableName
- -- name of possible supertablepublic 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 void setNulls()
public void setJoinTupleValues(java.lang.String[] jcols, java.lang.String[] lcols, Tuple left, java.lang.String[] rcols, Tuple right)
jcols
- array of column names of the joined (crossproduct) schemalcols
- array of column names of the right schemaleft
- right tuplercols
- array of column names of the right schemaright
- right tuplepublic Tuple setValues(java.lang.String... vals)
vals
- ls list of values to add to an empty tuplepublic Tuple setValues(java.lang.String[] cols, java.lang.String[] vals)
public static Tuple parseTupleDecl(java.lang.String line, int lineno, TableSchema ts, ErrorReport er)
line
- to parselineno
- line number of the linets
- table schema for tuple to conformer
- error reporterpublic void print(java.io.PrintStream out)
out
- where to printpublic final void print(java.io.PrintStream out, java.lang.String format)
public void print()
public Tuple show()
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 Tuple rightSemiJoinFirst(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 Tuple rightSemiJoinFirstEH(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' ls 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' ls 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' ls 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