SNAP Library 3.0, User Reference  2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TRowIterator Class Reference

Iterator class for TTable rows. More...

#include <table.h>

Public Member Functions

 TRowIterator ()
 Default constructor. More...
 
 TRowIterator (TInt RowIdx, const TTable *TablePtr)
 Constructs iterator to row RowIds of TablePtr. More...
 
 TRowIterator (const TRowIterator &RowI)
 Copy constructor. More...
 
TRowIteratoroperator++ (int)
 Increments the iterator. More...
 
TRowIteratorNext ()
 Increments the iterator (For Python compatibility). More...
 
bool operator< (const TRowIterator &RowI) const
 Checks if this iterator points to a row that is before the one pointed by RowI. More...
 
bool operator== (const TRowIterator &RowI) const
 Checks if this iterator points to the same row pointed by RowI. More...
 
TInt GetRowIdx () const
 Gets the id of the row pointed by this iterator. More...
 
TInt GetIntAttr (TInt ColIdx) const
 Returns value of integer attribute specified by integer column index for current row. More...
 
TFlt GetFltAttr (TInt ColIdx) const
 Returns value of floating point attribute specified by float column index for current row. More...
 
TStr GetStrAttr (TInt ColIdx) const
 Returns value of string attribute specified by string column index for current row. More...
 
TInt GetStrMapById (TInt ColIdx) const
 Returns integer mapping of a string attribute value specified by string column index for current row. More...
 
TInt GetIntAttr (const TStr &Col) const
 Returns value of integer attribute specified by attribute name for current row. More...
 
TFlt GetFltAttr (const TStr &Col) const
 Returns value of float attribute specified by attribute name for current row. More...
 
TStr GetStrAttr (const TStr &Col) const
 Returns value of string attribute specified by attribute name for current row. More...
 
TInt GetStrMapByName (const TStr &Col) const
 Returns integer mapping of string attribute specified by attribute name for current row. More...
 
TBool CompareAtomicConst (TInt ColIdx, const TPrimitive &Val, TPredComp Cmp)
 Compares value in column ColIdx with given primitive Val. More...
 
TBool CompareAtomicConstTStr (TInt ColIdx, const TStr &Val, TPredComp Cmp)
 Compares value in column ColIdx with given TStr Val. More...
 

Private Attributes

TInt CurrRowIdx
 Physical row index of current row pointed by iterator. More...
 
const TTableTable
 Reference to table containing this row. More...
 

Detailed Description

Iterator class for TTable rows.

An iterator class to iterate over all currently existing rows. Iteration over the rows should be done using only this iterator.

Definition at line 339 of file table.h.

Constructor & Destructor Documentation

TRowIterator::TRowIterator ( )
inline

Default constructor.

Definition at line 344 of file table.h.

344 : CurrRowIdx(0), Table(NULL) {}
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TRowIterator::TRowIterator ( TInt  RowIdx,
const TTable TablePtr 
)
inline

Constructs iterator to row RowIds of TablePtr.

Definition at line 346 of file table.h.

346 : CurrRowIdx(RowIdx), Table(TablePtr) {}
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TRowIterator::TRowIterator ( const TRowIterator RowI)
inline

Copy constructor.

Definition at line 348 of file table.h.

348 : CurrRowIdx(RowI.CurrRowIdx), Table(RowI.Table) {}
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340

Member Function Documentation

TBool TRowIterator::CompareAtomicConst ( TInt  ColIdx,
const TPrimitive Val,
TPredComp  Cmp 
)

Compares value in column ColIdx with given primitive Val.

Definition at line 190 of file table.cpp.

190  {
191  TBool Result;
192  switch (Val.GetType()) {
193  case atInt:
194  Result = TPredicate::EvalAtom(GetIntAttr(ColIdx), Val.GetInt(), Cmp);
195  break;
196  case atFlt:
197  Result = TPredicate::EvalAtom(GetFltAttr(ColIdx), Val.GetFlt(), Cmp);
198  break;
199  case atStr:
200  Result = TPredicate::EvalStrAtom(GetStrAttr(ColIdx), Val.GetStr(), Cmp);
201  break;
202  default:
203  Result = TBool(false);
204  }
205  return Result;
206 }
TFlt GetFltAttr(TInt ColIdx) const
Returns value of floating point attribute specified by float column index for current row...
Definition: table.cpp:159
TInt GetIntAttr(TInt ColIdx) const
Returns value of integer attribute specified by integer column index for current row.
Definition: table.cpp:155
TStr GetStrAttr(TInt ColIdx) const
Returns value of string attribute specified by string column index for current row.
Definition: table.cpp:163
static TBool EvalStrAtom(const TStr &Val1, const TStr &Val2, TPredComp Cmp)
Compare atomic string values Val1 and Val2 using predicate Cmp.
Definition: table.h:123
Definition: gbase.h:23
TStr GetStr() const
Definition: table.h:237
TInt GetInt() const
Definition: table.h:235
TAttrType GetType() const
Definition: table.h:238
Definition: gbase.h:23
static TBool EvalAtom(T Val1, T Val2, TPredComp Cmp)
Compare atomic values Val1 and Val2 using predicate Cmp.
Definition: table.h:110
bool Cmp(const int &RelOp, const TRec &Rec1, const TRec &Rec2)
Definition: bd.h:426
Definition: gbase.h:23
Definition: dt.h:881
TFlt GetFlt() const
Definition: table.h:236
TBool TRowIterator::CompareAtomicConstTStr ( TInt  ColIdx,
const TStr Val,
TPredComp  Cmp 
)

Compares value in column ColIdx with given TStr Val.

Definition at line 208 of file table.cpp.

208  {
209  TBool Result;
210  //printf("string compare\n");
211  Result = TPredicate::EvalStrAtom(GetStrAttr(ColIdx), Val, Cmp);
212  return Result;
213 }
TStr GetStrAttr(TInt ColIdx) const
Returns value of string attribute specified by string column index for current row.
Definition: table.cpp:163
static TBool EvalStrAtom(const TStr &Val1, const TStr &Val2, TPredComp Cmp)
Compare atomic string values Val1 and Val2 using predicate Cmp.
Definition: table.h:123
bool Cmp(const int &RelOp, const TRec &Rec1, const TRec &Rec2)
Definition: bd.h:426
Definition: dt.h:881
TFlt TRowIterator::GetFltAttr ( TInt  ColIdx) const

Returns value of floating point attribute specified by float column index for current row.

Definition at line 159 of file table.cpp.

159  {
160  return Table->FltCols[ColIdx][CurrRowIdx];
161 }
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
TVec< TFltV > FltCols
Data columns of floating point attributes.
Definition: table.h:569
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TFlt TRowIterator::GetFltAttr ( const TStr Col) const

Returns value of float attribute specified by attribute name for current row.

Definition at line 172 of file table.cpp.

172  {
173  TInt ColIdx = Table->GetColIdx(Col);
174  return Table->FltCols[ColIdx][CurrRowIdx];
175 }
TInt GetColIdx(const TStr &ColName) const
Gets index of column ColName among columns of the same type in the schema.
Definition: table.h:1004
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
Definition: dt.h:1044
TVec< TFltV > FltCols
Data columns of floating point attributes.
Definition: table.h:569
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TInt TRowIterator::GetIntAttr ( TInt  ColIdx) const

Returns value of integer attribute specified by integer column index for current row.

Definition at line 155 of file table.cpp.

155  {
156  return Table->IntCols[ColIdx][CurrRowIdx];
157 }
TVec< TIntV > IntCols
Next[i] is the successor of row i. Table iterators follow the order dictated by Next ...
Definition: table.h:568
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TInt TRowIterator::GetIntAttr ( const TStr Col) const

Returns value of integer attribute specified by attribute name for current row.

Definition at line 167 of file table.cpp.

167  {
168  TInt ColIdx = Table->GetColIdx(Col);
169  return Table->IntCols[ColIdx][CurrRowIdx];
170 }
TInt GetColIdx(const TStr &ColName) const
Gets index of column ColName among columns of the same type in the schema.
Definition: table.h:1004
TVec< TIntV > IntCols
Next[i] is the successor of row i. Table iterators follow the order dictated by Next ...
Definition: table.h:568
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
Definition: dt.h:1044
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TInt TRowIterator::GetRowIdx ( ) const

Gets the id of the row pointed by this iterator.

Definition at line 151 of file table.cpp.

151  {
152  return CurrRowIdx;
153 }
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TStr TRowIterator::GetStrAttr ( TInt  ColIdx) const

Returns value of string attribute specified by string column index for current row.

Definition at line 163 of file table.cpp.

163  {
164  return Table->GetStrVal(ColIdx, CurrRowIdx);
165 }
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
TStr GetStrVal(TInt ColIdx, TInt RowIdx) const
Gets the value in column with id ColIdx at row RowIdx.
Definition: table.h:636
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TStr TRowIterator::GetStrAttr ( const TStr Col) const

Returns value of string attribute specified by attribute name for current row.

Definition at line 177 of file table.cpp.

177  {
178  return Table->GetStrVal(Col, CurrRowIdx);
179 }
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
TStr GetStrVal(TInt ColIdx, TInt RowIdx) const
Gets the value in column with id ColIdx at row RowIdx.
Definition: table.h:636
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TInt TRowIterator::GetStrMapById ( TInt  ColIdx) const

Returns integer mapping of a string attribute value specified by string column index for current row.

Definition at line 186 of file table.cpp.

186  {
187  return Table->StrColMaps[ColIdx][CurrRowIdx];
188 }
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
TVec< TIntV > StrColMaps
Data columns of integer mappings of string attributes.
Definition: table.h:570
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TInt TRowIterator::GetStrMapByName ( const TStr Col) const

Returns integer mapping of string attribute specified by attribute name for current row.

Definition at line 181 of file table.cpp.

181  {
182  TInt ColIdx = Table->GetColIdx(Col);
183  return Table->StrColMaps[ColIdx][CurrRowIdx];
184 }
TInt GetColIdx(const TStr &ColName) const
Gets index of column ColName among columns of the same type in the schema.
Definition: table.h:1004
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
TVec< TIntV > StrColMaps
Data columns of integer mappings of string attributes.
Definition: table.h:570
Definition: dt.h:1044
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TRowIterator & TRowIterator::Next ( )

Increments the iterator (For Python compatibility).

Definition at line 135 of file table.cpp.

135  {
137  //Assert(CurrRowIdx != TTable::Invalid);
138  return *this;
139 }
const TTable * Table
Reference to table containing this row.
Definition: table.h:341
TIntV Next
A vector describing the logical order of the rows.
Definition: table.h:565
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
TRowIterator & TRowIterator::operator++ ( int  )

Increments the iterator.

Definition at line 131 of file table.cpp.

131  {
132  return this->Next();
133 }
TRowIterator & Next()
Increments the iterator (For Python compatibility).
Definition: table.cpp:135
bool TRowIterator::operator< ( const TRowIterator RowI) const

Checks if this iterator points to a row that is before the one pointed by RowI.

Definition at line 141 of file table.cpp.

141  {
142  if (CurrRowIdx == TTable::Last) { return false; }
143  if (RowI.CurrRowIdx == TTable::Last) { return true; }
144  return CurrRowIdx < RowI.CurrRowIdx;
145 }
static const TInt Last
Special value for Next vector entry - last row in table.
Definition: table.h:497
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340
bool TRowIterator::operator== ( const TRowIterator RowI) const

Checks if this iterator points to the same row pointed by RowI.

Definition at line 147 of file table.cpp.

147  {
148  return CurrRowIdx == RowI.CurrRowIdx;
149 }
TInt CurrRowIdx
Physical row index of current row pointed by iterator.
Definition: table.h:340

Member Data Documentation

TInt TRowIterator::CurrRowIdx
private

Physical row index of current row pointed by iterator.

Definition at line 340 of file table.h.

const TTable* TRowIterator::Table
private

Reference to table containing this row.

Definition at line 341 of file table.h.


The documentation for this class was generated from the following files: