Class FennelUtil

  extended by net.sf.farrago.fennel.FennelUtil

public abstract class FennelUtil
extends Object

Static utility methods related to Fennel storage. Historically, these methods were refactored from FennelRelUtil to remove their dependency on the Farrago query package.

$Id: //open/dev/farrago/src/net/sf/farrago/fennel/ $
John Pham

Constructor Summary
Method Summary
static FennelTupleDescriptor convertRowTypeToFennelTupleDesc(RelDataType rowType)
          Creates a FennelTupleDescriptor for a RelDataType which is a row.
static FennelStandardTypeDescriptor convertSqlTypeToFennelType(RelDataType sqlType)
          Converts a SQL type to a Fennel type.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public FennelUtil()
Method Detail


public static FennelTupleDescriptor convertRowTypeToFennelTupleDesc(RelDataType rowType)
Creates a FennelTupleDescriptor for a RelDataType which is a row.

rowType - row type descriptor
generated tuple descriptor


public static FennelStandardTypeDescriptor convertSqlTypeToFennelType(RelDataType sqlType)
Converts a SQL type to a Fennel type.

The mapping is as follows:

SQL type Fennel type Comments
SqlTypeName.TINYINT INT_8  
SqlTypeName.SMALLINT INT_16  
SqlTypeName.INTEGER INT_32  
SqlTypeName.DECIMAL(precision, scale) INT_64

We use a scaled integer representation. For example, the DECIMAL(6, 2) value 1234.5 would be represented as an INT_32 value 123450 (which is 1234.5 10 ^ 2)

SqlTypeName.DATE INT_64 Milliseconds since the epoch.
SqlTypeName.TIME INT_64 Milliseconds since midnight.
SqlTypeName.TIMESTAMP INT_64 Milliseconds since the epoch.
Timestamp with timezone   Not implemented. We will probably use a user-defined type consisting of a TIMESTAMP and a VARCHAR.
SqlTypeName.INTERVAL_DAY_TIME INT_64 Not implemented.

All types of day-time interval are represented in the same way: an integer milliseconds value. For example, INTERVAL '1' HOUR and INTERVAL '3600' MINUTE are both represented as 3,600,000.

TBD: How to represent fractions of seconds smaller than a millisecond, for example, INTERVAL SECOND(6).

SqlTypeName.INTERVAL_YEAR_MONTH INT_64 Not implemented.

All types of year-month interval are represented in the same way: an integer value which holds the number of months. For example, INTERVAL '2' YEAR and INTERVAL '24' MONTH are both represented as 24.

SqlTypeName.BIGINT INT_64  
SqlTypeName.VARCHAR(precision) VARCHAR or UNICODE_VARCHAR depending on character set  
SqlTypeName.VARBINARY(precision) VARBINARY  
SqlTypeName.MULTISET VARBINARY The fields are serialized into the VARBINARY field in the standard Fennel serialization format. There is no 'count' field. To deduce the number of records, deserialize values until you reach the length of the field. Of course, this requires that every value takes at least one byte.

The length of a multiset value is limited by the capacity of the VARBINARY datatype. This limitation will be lifted when LONG VARBINARY is implemented.

SqlTypeName.ROW   The fields are 'flattened' so that they become top-level fields of the relation.

If the row is nullable, then all fields will be nullable after flattening. An extra 'null indicator' field is added to discriminate between a NULL row and a not-NULL row which happens to have all fields NULL.

SqlTypeName.CHAR(precision) CHAR or CHAR depending on character set  
SqlTypeName.BINARY(precision) BINARY  
SqlTypeName.REAL REAL