Vertica::ValueRangeReader Class Reference

This class represents the value ranges of the arguments of a UDSF, one range per argument. More...

Inheritance diagram for Vertica::ValueRangeReader:

Vertica::VerticaValueRange List of all members.

Public Member Functions

bool canHaveNulls (size_t idx)
 Indicates if there can be NULL values in the range.
const vbool * getBoolPtrLo (size_t idx)
 Get a pointer to a BOOLEAN value from a range bound.
const vbool * getBoolPtrUp (size_t idx)
const vbool & getBoolRefLo (size_t idx)
 Get a reference to a BOOLEAN value from a range bound.
const vbool & getBoolRefUp (size_t idx)
template<class T, BoundType b>
const T * getColPtr (size_t idx)
template<class T, BoundType b>
T * getColPtrForWrite (size_t idx)
const DateADT * getDatePtrLo (size_t idx)
 Get a pointer to a DATE value from a range bound.
const DateADT * getDatePtrUp (size_t idx)
const DateADT & getDateRefLo (size_t idx)
 Get a reference to a DATE value from a range bound.
const DateADT & getDateRefUp (size_t idx)
const vfloat * getFloatPtrLo (size_t idx)
 Get a pointer to a FLOAT value from a range bound.
const vfloat * getFloatPtrUp (size_t idx)
const vfloat & getFloatRefLo (size_t idx)
 Get a reference to a FLOAT value from a range bound.
const vfloat & getFloatRefUp (size_t idx)
const Interval * getIntervalPtrLo (size_t idx)
 Get a pointer to an INTERVAL value from a range bound.
const Interval * getIntervalPtrUp (size_t idx)
const Interval & getIntervalRefLo (size_t idx)
 Get a reference to an INTERVAL value from a range bound.
const Interval & getIntervalRefUp (size_t idx)
const IntervalYM * getIntervalYMPtrLo (size_t idx)
 Get a pointer to a INTERVAL YEAR TO MONTH value from a range bound.
const IntervalYM * getIntervalYMPtrUp (size_t idx)
const IntervalYM & getIntervalYMRefLo (size_t idx)
 Get a reference to an INTERVAL YEAR TO MONTH value from a range bound.
const IntervalYM & getIntervalYMRefUp (size_t idx)
const vint * getIntPtrLo (size_t idx)
 Get a pointer to an INTEGER value from a range bound.
const vint * getIntPtrUp (size_t idx)
const vint & getIntRefLo (size_t idx)
 Get a reference to an INTEGER value from a range bound.
const vint & getIntRefUp (size_t idx)
const VNumeric * getNumericPtrLo (size_t idx)
 Get a pointer to a VNumeric value from a range bound.
const VNumeric * getNumericPtrUp (size_t idx)
const VNumeric & getNumericRefLo (size_t idx)
 Get a reference to a VNumeric value from a range bound.
const VNumeric & getNumericRefUp (size_t idx)
size_t getNumRanges () const
 Retrieve the number of range arguments.
const VerticaType & getRangeType (size_t idx) const
 Returns the data type of the values in a range.
EE::ValueSort getSortedness (size_t idx)
 Gets the sortedness of values in a range.
const VString * getStringPtrLo (size_t idx)
 Get a pointer to a VString value from a range bound.
const VString * getStringPtrUp (size_t idx)
const VString & getStringRefLo (size_t idx)
 Get a reference to an VString value from a range bound.
const VString & getStringRefUp (size_t idx)
const TimeADT * getTimePtrLo (size_t idx)
 Get a pointer to a TIME value from a range bound.
const TimeADT * getTimePtrUp (size_t idx)
const TimeADT & getTimeRefLo (size_t idx)
 Get a reference to a TIME value from a range bound.
const TimeADT & getTimeRefUp (size_t idx)
const Timestamp * getTimestampPtrLo (size_t idx)
 Get a pointer to a TIMESTAMP value from a range bound.
const Timestamp * getTimestampPtrUp (size_t idx)
const Timestamp & getTimestampRefLo (size_t idx)
 Get a reference to a TIMESTAMP value from a range bound.
const Timestamp & getTimestampRefUp (size_t idx)
const TimestampTz * getTimestampTzPtrLo (size_t idx)
 Get a pointer to a TIMESTAMP WITH TIMEZONE value from a range bound.
const TimestampTz * getTimestampTzPtrUp (size_t idx)
const TimestampTz & getTimestampTzRefLo (size_t idx)
 Get a reference to a TIMESTAMP WITH TIMEZONE value from a range bound.
const TimestampTz & getTimestampTzRefUp (size_t idx)
const TimeTzADT * getTimeTzPtrLo (size_t idx)
 Get a pointer to a TIME WITH TIMEZONE value from a range bound.
const TimeTzADT * getTimeTzPtrUp (size_t idx)
const TimeTzADT & getTimeTzRefLo (size_t idx)
 Get a reference to a TIME WITH TIMEZONE value from a range bound.
const TimeTzADT & getTimeTzRefUp (size_t idx)
bool hasBounds (size_t idx)
 Check if this range has lower and upper bounds set.
bool isNull (int idx)
 Check if all values in the idx'th input range are NULL.
 ValueRangeReader (size_t narg)

Protected Types

enum  BoundType { LO_BOUND, UP_BOUND }
 LO_BOUND
 UP_BOUND

Protected Member Functions

void addArg (char *loBound, char *upBound, const VerticaType &dt, EE::ValueSort sortedness, bool canHaveNulls)
void setCanHaveNulls (size_t idx, bool u)
 Set a flag to indicate that some values in this range can be NULL.
void setSortedness (size_t idx, EE::ValueSort s)
 Set the sortedness of values in the range.

Protected Attributes

size_t narg
std::vector< ValueRange > ranges
std::vector< VString > svWrappersLo
std::vector< VString > svWrappersUp
std::vector< VNumeric > vnWrappersLo
std::vector< VNumeric > vnWrappersUp

Friends

class EE::VEval

Detailed Description

This class represents the value ranges of the arguments of a UDSF, one range per argument.

Instances of this class are used to let UDSF developers specify the output range of UDSFs via the optional ScalarFunction::getOutputRange() function.


Member Function Documentation

void Vertica::VerticaValueRange::addArg ( char *  loBound,
char *  upBound,
const VerticaType &  dt,
EE::ValueSort  sortedness,
bool  canHaveNulls 
) [inline, protected, inherited]

Add a value range of a particular function argument

Parameters:
loBound Base location to find the lower bound data
upBound Base location to find the upper bound data
sortedness Sortedness of values in the range
dt The data type of range bounds

bool Vertica::VerticaValueRange::canHaveNulls ( size_t  idx  )  [inline, inherited]

Indicates if there can be NULL values in the range.

Parameters:
idx the range argument number.
Returns:
TRUE if some range values can be NULL, else FALSE.

const vbool* Vertica::ValueRangeReader::getBoolPtrLo ( size_t  idx  )  [inline]

Get a pointer to a BOOLEAN value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A pointer to the retrieved value cast as a BOOLEAN.

const vbool& Vertica::ValueRangeReader::getBoolRefLo ( size_t  idx  )  [inline]

Get a reference to a BOOLEAN value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a reference to the idx'th argument, cast as BOOLEAN.

const DateADT* Vertica::ValueRangeReader::getDatePtrLo ( size_t  idx  )  [inline]

Get a pointer to a DATE value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A pointer to the retrieved value cast as a DATE.

const DateADT& Vertica::ValueRangeReader::getDateRefLo ( size_t  idx  )  [inline]

Get a reference to a DATE value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a reference to the idx'th argument, cast as DATE.

const vfloat* Vertica::ValueRangeReader::getFloatPtrLo ( size_t  idx  )  [inline]

Get a pointer to a FLOAT value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A pointer to the retrieved value cast as a FLOAT.

const vfloat& Vertica::ValueRangeReader::getFloatRefLo ( size_t  idx  )  [inline]

Get a reference to a FLOAT value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A reference to the idx'th argument, cast as FLOAT.

const Interval* Vertica::ValueRangeReader::getIntervalPtrLo ( size_t  idx  )  [inline]

Get a pointer to an INTERVAL value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A pointer to the retrieved value cast as an INTERVAL.

const Interval& Vertica::ValueRangeReader::getIntervalRefLo ( size_t  idx  )  [inline]

Get a reference to an INTERVAL value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a reference to the idx'th argument, cast as an INTERVAL.

const IntervalYM* Vertica::ValueRangeReader::getIntervalYMPtrLo ( size_t  idx  )  [inline]

Get a pointer to a INTERVAL YEAR TO MONTH value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A point to the retrieved value cast as a INTERVAL YEAR TO MONTH.

const IntervalYM& Vertica::ValueRangeReader::getIntervalYMRefLo ( size_t  idx  )  [inline]

Get a reference to an INTERVAL YEAR TO MONTH value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a reference to the idx'th argument, cast as INTERVAL YEAR TO MONTH.

const vint* Vertica::ValueRangeReader::getIntPtrLo ( size_t  idx  )  [inline]

Get a pointer to an INTEGER value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a pointer to a chosen bound value, cast appropriately.
Example:
 const vint *a = range->getIntPtrLo(0); // gets a pointer to the lower bound of 1st arg

const vint& Vertica::ValueRangeReader::getIntRefLo ( size_t  idx  )  [inline]

Get a reference to an INTEGER value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a reference to the chosen bound value, cast as INTEGER.
Example:

 const vint& a = range->getIntRefUp(0); // get upper bound of the 1st range argument

const VNumeric* Vertica::ValueRangeReader::getNumericPtrLo ( size_t  idx  )  [inline]

Get a pointer to a VNumeric value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A pointer to the retrieved value cast as a Numeric.

const VNumeric& Vertica::ValueRangeReader::getNumericRefLo ( size_t  idx  )  [inline]

Get a reference to a VNumeric value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a reference to the idx'th argument, cast as VNumeric.

size_t Vertica::VerticaValueRange::getNumRanges (  )  const [inline, inherited]

Retrieve the number of range arguments.

Returns:
the number of range arguments held by this object.

const VerticaType& Vertica::VerticaValueRange::getRangeType ( size_t  idx  )  const [inline, inherited]

Returns the data type of the values in a range.

Parameters:
idx The index of the range
Returns:
a VerticaType object describing the data type of the range values.

EE::ValueSort Vertica::VerticaValueRange::getSortedness ( size_t  idx  )  [inline, inherited]

Gets the sortedness of values in a range.

Parameters:
idx the range argument number.
Returns:
the range sortedness. Possible values are: EE::SORT_UNORDERED - Unsorted EE::SORT_MONOTONIC_INCREASING - Ascending EE::SORT_MONOTONIC_DECREASING - Descending EE::SORT_CONSTANT - Single value

const VString* Vertica::ValueRangeReader::getStringPtrLo ( size_t  idx  )  [inline]

Get a pointer to a VString value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A pointer to the retrieved value cast as a VString.

const VString& Vertica::ValueRangeReader::getStringRefLo ( size_t  idx  )  [inline]

Get a reference to an VString value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a reference to the idx'th argument, cast as VString.
Note:
the returned object is a variable-length prefix of the actual string values in the range. For example, if the range values are {'abc', 'abb', 'bc', 'cab'} the range bounds may be like: Lo='a' and Up='cb'. In the example, the upper bound is not even a prefix of any value in the range, but all values in the range are greater than or equal than Lo and less than or equal to Up.

const TimeADT* Vertica::ValueRangeReader::getTimePtrLo ( size_t  idx  )  [inline]

Get a pointer to a TIME value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A pointer to the retrieved value cast as a TIME.

const TimeADT& Vertica::ValueRangeReader::getTimeRefLo ( size_t  idx  )  [inline]

Get a reference to a TIME value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a reference to the idx'th argument, cast as TIME.

const Timestamp* Vertica::ValueRangeReader::getTimestampPtrLo ( size_t  idx  )  [inline]

Get a pointer to a TIMESTAMP value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A pointer to the retrieved value cast as a TIMESTAMP.

const Timestamp& Vertica::ValueRangeReader::getTimestampRefLo ( size_t  idx  )  [inline]

Get a reference to a TIMESTAMP value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a reference to the idx'th argument, cast as TIMESTAMP.

const TimestampTz* Vertica::ValueRangeReader::getTimestampTzPtrLo ( size_t  idx  )  [inline]

Get a pointer to a TIMESTAMP WITH TIMEZONE value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A pointer to the retrieved value cast as a TIMESTAMP WITH TIMEZONE.

const TimestampTz& Vertica::ValueRangeReader::getTimestampTzRefLo ( size_t  idx  )  [inline]

Get a reference to a TIMESTAMP WITH TIMEZONE value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a reference to the idx'th argument, cast as TIMESTAMP WITH TIMEZONE.

const TimeTzADT* Vertica::ValueRangeReader::getTimeTzPtrLo ( size_t  idx  )  [inline]

Get a pointer to a TIME WITH TIMEZONE value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
A pointer to the retrieved value cast as a TIME WITH TIMEZONE.

const TimeTzADT& Vertica::ValueRangeReader::getTimeTzRefLo ( size_t  idx  )  [inline]

Get a reference to a TIME WITH TIMEZONE value from a range bound.

Parameters:
idx The argument number to retrieve the range bound.
Returns:
a reference to the idx'th argument, cast as TIME WITH TIMEZONE.

bool Vertica::ValueRangeReader::hasBounds ( size_t  idx  )  [inline]

Check if this range has lower and upper bounds set.

Note:
Callers of the get reference or get pointer functions should always first call this method, and only access the range bounds when this function returns TRUE.
Example:
   if (rangeReader.hasBounds(0)) { // Check if bounds of the 1st range argument are set
     // OK to access bounds
     const vint& i = rangeReader.getIntRefLo(0);
     const vint& j = rangeReader.getIntRefUp(0);
   }

Returns:
TRUE if the range bounds are safe to access, else FALSE.

bool Vertica::ValueRangeReader::isNull ( int  idx  )  [inline]

Check if all values in the idx'th input range are NULL.

Parameters:
idx The argument range number.
Returns:
true if all values in the range are NULL, false otherwise.

void Vertica::VerticaValueRange::setCanHaveNulls ( size_t  idx,
bool  u 
) [inline, protected, inherited]

Set a flag to indicate that some values in this range can be NULL.

Parameters:
idx The argument range number.
u true if there can be NULL values in the range, else false.

void Vertica::VerticaValueRange::setSortedness ( size_t  idx,
EE::ValueSort  s 
) [inline, protected, inherited]

Set the sortedness of values in the range.

Parameters:
idx The range argument number.
s The sortedness value to set. Possible values are: EE::SORT_UNORDERED - Unsorted EE::SORT_MONOTONIC_INCREASING - Ascending EE::SORT_MONOTONIC_DECREASING - Descending EE::SORT_CONSTANT - Single value
Example:
 range.setSortedness(0, EE:SORT_CONSTANT); // defines a single-valued range