:: AlphaComponent ::

NOTE User defined types not implemented in EclairJS

User-defined type for {@link Vector} which allows easy interaction with SQL
via {@link module:eclairjs/sql.DataFrame}.
@classdesc
@class
@memberof module:eclairjs/ml/linalg
507050
function (jvmObject) {

        this.logger = Logger.getLogger("VectorUDT_js");
        if (!jvmObject) {
            jvmObject = new org.apache.spark.ml.linalg.VectorUDT();
        }
        JavaWrapper.call(this, jvmObject);

    }
1195256
function(hljs) {
  var KEYWORDS =
    'false synchronized int abstract float private char boolean static null if const ' +
    'for true while long throw strictfp finally protected import native final return void ' +
    'enum else break transient new catch instanceof byte super volatile case assert short ' +
    'package default double public try this switch continue throws';
  return {
    aliases: ['jsp'],
    keywords: KEYWORDS,
    illegal: /<\//,
    contains: [
      {
        className: 'javadoc',
        begin: '/\\*\\*', end: '\\*/',
        contains: [{
          className: 'javadoctag', begin: '(^|\\s)@[A-Za-z]+'
        }],
        relevance: 10
      },
      hljs.C_LINE_COMMENT_MODE,
      hljs.C_BLOCK_COMMENT_MODE,
      hljs.APOS_STRING_MODE,
      hljs.QUOTE_STRING_MODE,
      {
        beginKeywords: 'protected public private', end: /[{;=]/,
        keywords: KEYWORDS,
        contains: [
          {
            className: 'class',
            beginKeywords: 'class interface', endsWithParent: true, excludeEnd: true,
            illegal: /[:"\[\]]/,
            contains: [
              {
                beginKeywords: 'extends implements',
                relevance: 10
              },
              hljs.UNDERSCORE_TITLE_MODE
            ]
          },
          {
            begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true,
            contains: [
              hljs.UNDERSCORE_TITLE_MODE
            ]
          }
        ]
      },
      hljs.C_NUMBER_MODE,
      {
        className: 'annotation', begin: '@[A-Za-z]+'
      }
    ]
  };
}
1317667
public final TreeModelFilter<SQLPPTriplesMap> type() throws RecognitionException {
        TreeModelFilter<SQLPPTriplesMap> value = null;


        try {
            // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:69:3: ( ID | TEXT | TARGET | SOURCE | FUNCT | PRED )
            int alt4=6;
            switch ( input.LA(1) ) {
            case ID:
                {
                alt4=1;
                }
                break;
            case TEXT:
                {
                alt4=2;
                }
                break;
            case TARGET:
                {
                alt4=3;
                }
                break;
            case SOURCE:
                {
                alt4=4;
                }
                break;
            case FUNCT:
                {
                alt4=5;
                }
                break;
            case PRED:
                {
                alt4=6;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 4, 0, input);

                throw nvae;

            }

            switch (alt4) {
                case 1 :
                    // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:69:5: ID
                    {
                    match(input,ID,FOLLOW_ID_in_type120); 

                     value = new MappingIDTreeModelFilter();

                    }
                    break;
                case 2 :
                    // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:70:5: TEXT
                    {
                    match(input,TEXT,FOLLOW_TEXT_in_type133); 

                     value = new MappingStringTreeModelFilter(); 

                    }
                    break;
                case 3 :
                    // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:71:5: TARGET
                    {
                    match(input,TARGET,FOLLOW_TARGET_in_type144); 

                     value = new MappingHeadVariableTreeModelFilter();

                    }
                    break;
                case 4 :
                    // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:72:5: SOURCE
                    {
                    match(input,SOURCE,FOLLOW_SOURCE_in_type153); 

                     value = new MappingSQLStringTreeModelFilter();

                    }
                    break;
                case 5 :
                    // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:73:5: FUNCT
                    {
                    match(input,FUNCT,FOLLOW_FUNCT_in_type162); 

                     value = new MappingFunctorTreeModelFilter();

                    }
                    break;
                case 6 :
                    // C:\\Project\\Obdalib\\obdalib-parent\\obdalib-core\\src\\main\\java\\it\\unibz\\inf\\obda\\gui\\swing\\utils\\MappingFilter.g:74:5: PRED
                    {
                    match(input,PRED,FOLLOW_PRED_in_type172); 

                     value = new MappingPredicateTreeModelFilter();

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return value;
    }
377107
function createPrimaryTypeChecker(type) {

    return createChainableChecker(function (data, dataName, componentName, fullDataName) {

        var dataValue = data[dataName];
        var dataType = getDataType(dataValue);

        if (dataType !== type) {
            throw new Error('[SAN ERROR] '
                + 'Invalid ' + componentName + ' data `' + fullDataName + '` of type'
                + '(' + dataType + ' supplied to ' + componentName + ', '
                + 'expected ' + type + ')'
            );
        }

    });

}
622749
function getColumnType(columnDefinitions, columnName) {
    Validate.isObject(columnDefinitions);
    Validate.notNull(columnDefinitions);
    Validate.isString(columnName);
    Validate.notNullOrEmpty(columnName);

    for (var column in columnDefinitions) {
        if (column.toLowerCase() === columnName.toLowerCase()) {
            return columnDefinitions[column];
        }
    }
}
1152112
private Content getTypeColumn(VariableElement member) {
        Content anchor = getMarkerAnchor(currentTypeElement.getQualifiedName() +
                "." + member.getSimpleName());
        Content tdType = HtmlTree.TD(HtmlStyle.colFirst, anchor);
        Content code = new HtmlTree(HtmlTag.CODE);
        for (Modifier mod : member.getModifiers()) {
            Content modifier = new StringContent(mod.toString());
            code.addContent(modifier);
            code.addContent(Contents.SPACE);
        }
        Content type = getLink(new LinkInfoImpl(configuration,
                LinkInfoImpl.Kind.CONSTANT_SUMMARY, member.asType()));
        code.addContent(type);
        tdType.addContent(code);
        return tdType;
    }
640187
private void init_jdbcTypes() throws SQLException
    {
        ReportQuery q = (ReportQuery) getQueryObject().getQuery();
        m_jdbcTypes = new int[m_attributeCount];
        
        // try to get jdbcTypes from Query
        if (q.getJdbcTypes() != null)
        {
            m_jdbcTypes = q.getJdbcTypes();
        }
        else
        {
            ResultSetMetaData rsMetaData = getRsAndStmt().m_rs.getMetaData();
            for (int i = 0; i < m_attributeCount; i++)
            {
                m_jdbcTypes[i] = rsMetaData.getColumnType(i + 1);
            }
            
        }
    }
1371254
SimpleTypeInformation<V> getTypeInformation(int mindim, int maxdim) {
    if(mindim > maxdim) {
      throw new AbortException("No vectors were read from the input file - cannot determine vector data type.");
    }
    if(mindim == maxdim) {
      String[] colnames = null;
      if(columnnames != null && mindim <= columnnames.size()) {
        colnames = new String[mindim];
        int j = 0;
        for(int i = 0; i < mindim; i++) {
          if(isLabelColumn(i)) {
            continue;
          }
          colnames[j] = columnnames.get(i);
          j++;
        }
        if(j != mindim) {
          colnames = null; // Did not work
        }
      }
      return new VectorFieldTypeInformation<>(factory, mindim, colnames);
    }
    // Variable dimensionality - return non-vector field type
    return new VectorTypeInformation<>(factory, factory.getDefaultSerializer(), mindim, maxdim);
  }
1356166
@Override
    public void ger(char order, double alpha, INDArray X, INDArray Y, INDArray A) {
        if (Nd4j.getExecutioner().getProfilingMode() == OpExecutioner.ProfilingMode.ALL)
            OpProfiler.getInstance().processBlasCall(false, A, X, Y);

        // FIXME: int cast

        if (X.data().dataType() == DataType.DOUBLE) {
            DefaultOpExecutioner.validateDataType(DataType.DOUBLE, A, X, Y);
            dger(order, (int) A.rows(), (int) A.columns(), alpha, X, X.stride(-1), Y, Y.stride(-1), A, (int) A.size(0));
        } else {
            DefaultOpExecutioner.validateDataType(DataType.FLOAT, A, X, Y);
            sger(order, (int) A.rows(), (int) A.columns(), (float) alpha, X, X.stride(-1), Y, Y.stride(-1), A, (int) A.size(0));
        }

        OpExecutionerUtil.checkForAny(A);
    }
930292
static TypeInformation schemaToTypeInfo(TypeDescription schema) {
		switch (schema.getCategory()) {
			case BOOLEAN:
				return BasicTypeInfo.BOOLEAN_TYPE_INFO;
			case BYTE:
				return BasicTypeInfo.BYTE_TYPE_INFO;
			case SHORT:
				return BasicTypeInfo.SHORT_TYPE_INFO;
			case INT:
				return BasicTypeInfo.INT_TYPE_INFO;
			case LONG:
				return BasicTypeInfo.LONG_TYPE_INFO;
			case FLOAT:
				return BasicTypeInfo.FLOAT_TYPE_INFO;
			case DOUBLE:
				return BasicTypeInfo.DOUBLE_TYPE_INFO;
			case DECIMAL:
				return BasicTypeInfo.BIG_DEC_TYPE_INFO;
			case STRING:
			case CHAR:
			case VARCHAR:
				return BasicTypeInfo.STRING_TYPE_INFO;
			case DATE:
				return SqlTimeTypeInfo.DATE;
			case TIMESTAMP:
				return SqlTimeTypeInfo.TIMESTAMP;
			case BINARY:
				return PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO;
			case STRUCT:
				List<TypeDescription> fieldSchemas = schema.getChildren();
				TypeInformation[] fieldTypes = new TypeInformation[fieldSchemas.size()];
				for (int i = 0; i < fieldSchemas.size(); i++) {
					fieldTypes[i] = schemaToTypeInfo(fieldSchemas.get(i));
				}
				String[] fieldNames = schema.getFieldNames().toArray(new String[]{});
				return new RowTypeInfo(fieldTypes, fieldNames);
			case LIST:
				TypeDescription elementSchema = schema.getChildren().get(0);
				TypeInformation<?> elementType = schemaToTypeInfo(elementSchema);
				// arrays of primitive types are handled as object arrays to support null values
				return ObjectArrayTypeInfo.getInfoFor(elementType);
			case MAP:
				TypeDescription keySchema = schema.getChildren().get(0);
				TypeDescription valSchema = schema.getChildren().get(1);
				TypeInformation<?> keyType = schemaToTypeInfo(keySchema);
				TypeInformation<?> valType = schemaToTypeInfo(valSchema);
				return new MapTypeInfo<>(keyType, valType);
			case UNION:
				throw new UnsupportedOperationException("UNION type is not supported yet.");
			default:
				throw new IllegalArgumentException("Unknown type " + schema);
		}
	}
1135742
@Override
    public void axpy(long n, double alpha, INDArray x, INDArray y) {
        BaseSparseNDArray sparseX = (BaseSparseNDArray) x;
        DataBuffer pointers = sparseX.getVectorCoordinates();
        switch (x.data().dataType()) {
            case DOUBLE:
                DefaultOpExecutioner.validateDataType(DataType.DOUBLE, x);
                DefaultOpExecutioner.validateDataType(DataType.DOUBLE, y);
                daxpyi(n, alpha, x, pointers, y);
                break;
            case FLOAT:
                DefaultOpExecutioner.validateDataType(DataType.FLOAT, x);
                DefaultOpExecutioner.validateDataType(DataType.FLOAT, y);
                saxpyi(n, alpha, x, pointers, y);
                break;
            case HALF:
                DefaultOpExecutioner.validateDataType(DataType.HALF, x);
                DefaultOpExecutioner.validateDataType(DataType.HALF, y);
                haxpyi(n, alpha, x, pointers, y);
                break;
            default:
                throw new UnsupportedOperationException();
        }
    }
754350
VoltXMLElement voltAnnotateFunctionXML(VoltXMLElement exp)
    {
        // XXX Should this throw HSQLParseException instead?
        assert(getType() == OpTypes.SQL_FUNCTION);

        exp.attributes.put("name", name);
        exp.attributes.put("valuetype", dataType.getNameString());
        if (parameterArg != -1) {
            exp.attributes.put("result_type_parameter_index", String.valueOf(parameterArg));
        }
        int volt_funcType = funcType;

        String implied_argument = null;
        int keywordConstant = 0;

        switch (funcType) {
        case FUNC_SUBSTRING_CHAR :
            // A little tweaking is needed here because VoltDB wants to define separate functions for 2-argument and 3-argument SUBSTRING
            if (nodes.length == 2 || nodes[2] == null) {
                volt_funcType = FUNC_VOLT_SUBSTRING_CHAR_FROM;
            }
            exp.attributes.put("function_id", String.valueOf(volt_funcType));
            return exp;

            // A little tweaking is needed in some other cases because VoltDB
        	// wants to define separate functions for each leading keyword
        	// argument, eliminating the hard-coded node[0] value.

        case FUNC_TRIM_CHAR :
            implied_argument = null;
            keywordConstant = ((Integer) nodes[0].valueData).intValue();
            switch (keywordConstant) {

                case Tokens.BOTH :
                    implied_argument = "BOTH";
                    break;

                case Tokens.LEADING :
                    implied_argument = "LEADING";
                    break;

                case Tokens.TRAILING :
                    implied_argument = "TRAILING";
                    break;

                default :
                    throw Error.runtimeError(ErrorCode.U_S0500,
                                             "FunctionSQL");
            }
            assert(implied_argument != null);
            exp.attributes.put("function_id", String.valueOf(keywordConstant + SQL_TRIM_VOLT_FUNC_OFFSET));
            exp.attributes.put("implied_argument", implied_argument);
            // Having accounted for the first argument, remove it from the child expression list.
            exp.children.remove(0);
            return exp;

        case FUNC_EXTRACT :
            implied_argument = null;
            keywordConstant = ((Integer) nodes[0].valueData).intValue();
            switch (keywordConstant) {
            case Tokens.DAY_NAME :
            // case DTIType.DAY_NAME :
                implied_argument = "DAY_NAME";
                break;
            case Tokens.MONTH_NAME :
            // case DTIType.MONTH_NAME :
                implied_argument = "MONTH_NAME";
                break;
            case Tokens.QUARTER :
            // case DTIType.QUARTER :
                implied_argument = "QUARTER";
                break;
            case Tokens.DAY_OF_YEAR :
            // case DTIType.DAY_OF_YEAR :
                implied_argument = "DAY_OF_YEAR";
                break;
            case Tokens.WEEKDAY :
                implied_argument = "WEEKDAY";
                break;
            case Tokens.DAY_OF_WEEK :
            // case DTIType.DAY_OF_WEEK :
                implied_argument = "DAY_OF_WEEK";
                break;
            case Tokens.WEEK:
                keywordConstant = Tokens.WEEK_OF_YEAR;
            case Tokens.WEEK_OF_YEAR :
            // case DTIType.WEEK_OF_YEAR :
                implied_argument = "WEEK_OF_YEAR";
                break;
            case Types.SQL_INTERVAL_YEAR :
                implied_argument = "INTERVAL_YEAR";
                break;
            case Types.SQL_INTERVAL_MONTH :
                implied_argument = "SQL_INTERVAL_MONTH";
                break;
            case Types.SQL_INTERVAL_DAY :
                implied_argument = "SQL_INTERVAL_DAY";
                break;
            case Types.SQL_INTERVAL_HOUR :
                implied_argument = "SQL_INTERVAL_HOUR";
                break;
            case Types.SQL_INTERVAL_MINUTE :
                implied_argument = "SQL_INTERVAL_MINUTE";
                break;
            case Types.SQL_INTERVAL_SECOND :
                implied_argument = "SQL_INTERVAL_SECOND";
                break;
            case Tokens.YEAR :
                implied_argument = "YEAR";
                break;
            case Tokens.MONTH :
                implied_argument = "MONTH";
                break;
            case Tokens.DAY_OF_MONTH :
            // case DTIType.DAY_OF_MONTH :
                keywordConstant = Tokens.DAY;
            case Tokens.DAY :
                implied_argument = "DAY";
                break;
            case Tokens.HOUR :
                implied_argument = "HOUR";
                break;
            case Tokens.MINUTE :
                implied_argument = "MINUTE";
                break;
            case Tokens.SECOND :
                implied_argument = "SECOND";
                break;
            case Tokens.SECONDS_MIDNIGHT :
            // case DTIType.SECONDS_MIDNIGHT :
                implied_argument = "SECONDS_MIDNIGHT";
                break;
            case Tokens.TIMEZONE_HOUR :
            // case DTIType.TIMEZONE_HOUR :
                implied_argument = "TIMEZONE_HOUR";
                break;
            case Tokens.TIMEZONE_MINUTE :
            // case DTIType.TIMEZONE_MINUTE :
                implied_argument = "TIMEZONE_MINUTE";
                break;
            default :
                throw Error.runtimeError(ErrorCode.U_S0500, "DateTimeTypeForVoltDB: " + String.valueOf(keywordConstant));
            }

            assert(implied_argument != null);
            exp.attributes.put("function_id", String.valueOf(keywordConstant + SQL_EXTRACT_VOLT_FUNC_OFFSET));
            exp.attributes.put("implied_argument", implied_argument);
            // Having accounted for the first argument, remove it from the child expression list.
            exp.children.remove(0);
            return exp;

        case FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_SINCE_EPOCH :
            implied_argument = null;
            keywordConstant = ((Integer) nodes[0].valueData).intValue();
            int since_epoch_func = -1;
            switch (keywordConstant) {
            case Tokens.SECOND :
                implied_argument = "SECOND";
                since_epoch_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_SINCE_EPOCH_SECOND;
                break;
            case Tokens.MILLIS :
            case Tokens.MILLISECOND:
                implied_argument = "MILLISECOND";
                since_epoch_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_SINCE_EPOCH_MILLISECOND;
                break;
            case Tokens.MICROS :
            case Tokens.MICROSECOND :
                implied_argument = "MICROSECOND";
                since_epoch_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_SINCE_EPOCH_MICROSECOND;
                break;
            default:
                throw Error.runtimeError(ErrorCode.U_S0500, "DateTimeTypeForVoltDB: " + String.valueOf(keywordConstant));
            }

            assert(implied_argument != null);
            assert(-1 != since_epoch_func);
            exp.attributes.put("function_id", String.valueOf(since_epoch_func));
            exp.attributes.put("implied_argument", implied_argument);

            // Having accounted for the first argument, remove it from the child expression list.
            exp.children.remove(0);
            return exp;

        case FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TO_TIMESTAMP :
            implied_argument = null;
            keywordConstant = ((Integer) nodes[0].valueData).intValue();
            int to_timestamp_func = -1;
            switch (keywordConstant) {
            case Tokens.SECOND :
                implied_argument = "SECOND";
                to_timestamp_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TO_TIMESTAMP_SECOND;
                break;
            case Tokens.MILLIS :
            case Tokens.MILLISECOND :
                implied_argument = "MILLISECOND";
                to_timestamp_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TO_TIMESTAMP_MILLISECOND;
                break;
            case Tokens.MICROS :
            case Tokens.MICROSECOND :
                implied_argument = "MICROSECOND";
                to_timestamp_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TO_TIMESTAMP_MICROSECOND;
                break;
            default:
                throw Error.runtimeError(ErrorCode.U_S0500, "DateTimeTypeForVoltDB: " + String.valueOf(keywordConstant));
            }

            assert(-1 != to_timestamp_func);
            exp.attributes.put("function_id", String.valueOf(to_timestamp_func));
            exp.attributes.put("implied_argument", implied_argument);

            // Having accounted for the first argument, remove it from the child expression list.
            exp.children.remove(0);
            return exp;

        case FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TRUNCATE_TIMESTAMP :
            implied_argument = null;
            keywordConstant = ((Integer) nodes[0].valueData).intValue();
            int truncate_func = -1;
            switch (keywordConstant) {
            case Tokens.YEAR :
                implied_argument = "YEAR";
                truncate_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TRUNCATE_YEAR;
                break;
            case Tokens.QUARTER :
                implied_argument = "QUARTER";
                truncate_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TRUNCATE_QUARTER;
                break;
            case Tokens.MONTH :
                implied_argument = "MONTH";
                truncate_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TRUNCATE_MONTH;
                break;
            case Tokens.DAY :
                implied_argument = "DAY";
                truncate_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TRUNCATE_DAY;
                break;
            case Tokens.HOUR :
                implied_argument = "HOUR";
                truncate_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TRUNCATE_HOUR;
                break;
            case Tokens.MINUTE :
                implied_argument = "MINUTE";
                truncate_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TRUNCATE_MINUTE;
                break;
            case Tokens.SECOND :
                implied_argument = "SECOND";
                truncate_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TRUNCATE_SECOND;
                break;
            case Tokens.MILLIS:
            case Tokens.MILLISECOND :
                implied_argument = "MILLISECOND";
                truncate_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TRUNCATE_MILLISECOND;
                break;
            case Tokens.MICROS:
            case Tokens.MICROSECOND :
                implied_argument = "MICROSECOND";
                truncate_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_TRUNCATE_MICROSECOND;
                break;
            default:
                throw Error.runtimeError(ErrorCode.U_S0500, "DateTimeTypeForVoltDB: " + String.valueOf(keywordConstant));
            }

            assert(implied_argument != null);
            assert(-1 != truncate_func);
            exp.attributes.put("function_id", String.valueOf(truncate_func));
            exp.attributes.put("implied_argument", implied_argument);

            // Having accounted for the first argument, remove it from the child expression list.
            exp.children.remove(0);
            return exp;

        case FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DISTANCE :
            Type leftChildType = nodes[0].dataType;
            Type rightChildType = nodes[1].dataType;

            // in here the only cases needed to be handled are distance between polygon-to-point
            // and point-to-point.
            assert(leftChildType.isGeographyType() || leftChildType.isGeographyPointType());
            assert(rightChildType.isGeographyPointType());

            if (leftChildType.isGeographyType()) {
                exp.attributes.put("function_id", String.valueOf(FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DISTANCE_POLYGON_POINT));
            }
            else {
                exp.attributes.put("function_id", String.valueOf(FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DISTANCE_POINT_POINT));
            }
            return exp;

        case FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DWITHIN:
            Type firstArgType = nodes[0].dataType;
            Type secondArgType = nodes[1].dataType;
            Type thirdArgType = nodes[2].dataType;

            // valid first and second arguments are geo types
            // third argument, distance, is a numeric type
            // resolveTypes() has logic to perform the type-validity for arguments
            assert(firstArgType.isGeographyType() || firstArgType.isGeographyPointType());
            assert(secondArgType.isGeographyPointType());
            assert(thirdArgType.isNumberType());

            if (firstArgType.isGeographyType()) {
                exp.attributes.put("function_id", String.valueOf(FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DWITHIN_POLYGON_POINT));
            }
            else {
                exp.attributes.put("function_id", String.valueOf(FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DWITHIN_POINT_POINT));
            }
            return exp;

        case FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_ASTEXT:
            // only valid types for asText are geography and geography-point
            // resolveTypes in FunctionForVoltDB will block any other types
            // as unsupported types
            assert(nodes[0].dataType.isGeographyPointType() || nodes[0].dataType.isGeographyType());

            if (nodes[0].dataType.isGeographyPointType()) {
                exp.attributes.put("function_id", String.valueOf(FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_ASTEXT_GEOGRAPHY_POINT));
            }
            else {
                exp.attributes.put("function_id", String.valueOf(FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_ASTEXT_GEOGRAPHY));
            }
            return exp;

        case FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DATEADD :
            implied_argument = null;
            keywordConstant = ((Integer) nodes[0].valueData).intValue();
            int dateadd_func = -1;
            switch (keywordConstant) {
            case Tokens.YEAR :
                implied_argument = "YEAR";
                dateadd_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DATEADD_YEAR;
                break;
            case Tokens.QUARTER :
                implied_argument = "QUARTER";
                dateadd_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DATEADD_QUARTER;
                break;
            case Tokens.MONTH :
                implied_argument = "MONTH";
                dateadd_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DATEADD_MONTH;
                break;
            case Tokens.DAY :
                implied_argument = "DAY";
                dateadd_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DATEADD_DAY;
                break;
            case Tokens.HOUR :
                implied_argument = "HOUR";
                dateadd_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DATEADD_HOUR;
                break;
            case Tokens.MINUTE :
                implied_argument = "MINUTE";
                dateadd_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DATEADD_MINUTE;
                break;
            case Tokens.SECOND :
                implied_argument = "SECOND";
                dateadd_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DATEADD_SECOND;
                break;
            case Tokens.MILLIS:
            case Tokens.MILLISECOND :
                implied_argument = "MILLISECOND";
                dateadd_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DATEADD_MILLISECOND;
                break;
            case Tokens.MICROS:
            case Tokens.MICROSECOND :
                implied_argument = "MICROSECOND";
                dateadd_func = FunctionForVoltDB.FunctionDescriptor.FUNC_VOLT_DATEADD_MICROSECOND;
                break;
            default:
                throw Error.runtimeError(ErrorCode.U_S0500, "DateTimeTypeForVoltDB: " + String.valueOf(keywordConstant));
            }

            assert(implied_argument != null);
            assert(-1 != dateadd_func);
            exp.attributes.put("function_id", String.valueOf(dateadd_func));
            exp.attributes.put("implied_argument", implied_argument);

            // Having accounted for the first argument, remove it from the child expression list.
            exp.children.remove(0);
            return exp;

        default :
            if (voltDisabled != null) {
                exp.attributes.put("disabled", voltDisabled);
            }
            exp.attributes.put("function_id", String.valueOf(volt_funcType));
            return exp;
        }
    }
798425
public static List<ColumnDefinition> fromSchema(UntypedResultSet serializedColumns, String ksName, String cfName, AbstractType<?> rawComparator, boolean isSuper)
    {
        List<ColumnDefinition> cds = new ArrayList<>();
        for (UntypedResultSet.Row row : serializedColumns)
        {
            Kind kind = row.has(KIND)
                      ? Kind.deserialize(row.getString(KIND))
                      : Kind.REGULAR;

            Integer componentIndex = null;
            if (row.has(COMPONENT_INDEX))
                componentIndex = row.getInt(COMPONENT_INDEX);
            else if (kind == Kind.CLUSTERING_COLUMN && isSuper)
                componentIndex = 1; // A ColumnDefinition for super columns applies to the column component

            // Note: we save the column name as string, but we should not assume that it is an UTF8 name, we
            // we need to use the comparator fromString method
            AbstractType<?> comparator = getComponentComparator(rawComparator, componentIndex, kind);
            ColumnIdentifier name = new ColumnIdentifier(comparator.fromString(row.getString(COLUMN_NAME)), comparator);

            AbstractType<?> validator;
            try
            {
                validator = TypeParser.parse(row.getString(TYPE));
            }
            catch (RequestValidationException e)
            {
                throw new RuntimeException(e);
            }

            IndexType indexType = null;
            if (row.has(INDEX_TYPE))
                indexType = IndexType.valueOf(row.getString(INDEX_TYPE));

            Map<String, String> indexOptions = null;
            if (row.has(INDEX_OPTIONS))
                indexOptions = FBUtilities.fromJsonMap(row.getString(INDEX_OPTIONS));

            String indexName = null;
            if (row.has(INDEX_NAME))
                indexName = row.getString(INDEX_NAME);

            cds.add(new ColumnDefinition(ksName, cfName, name, validator, indexType, indexOptions, indexName, componentIndex, kind));
        }

        return cds;
    }
1311096
private void parseTableSchemaFromXML(String tableName,
                                         StmtCommonTableScanShared tableScan,
                                         VoltXMLElement voltXMLElement) {
        assert("table".equals(voltXMLElement.name));
        List<VoltXMLElement> columnSet = voltXMLElement.findChildren("columns");
        assert(columnSet.size() == 1);
        columnSet = columnSet.get(0).children;
        for (int idx = 0; idx < columnSet.size(); idx += 1) {
            VoltXMLElement columnXML = columnSet.get(idx);
            assert("column".equals(columnXML.name));
            String columnName = columnXML.attributes.get("name");
            // If valuetype is not defined, then we will get type
            // "none", about which typeFromString will complain.
            // Note that the types may be widened from the type
            // of the base query of a recursive common table.  This
            // happens if the corresponding type in the recursive
            // query is wider than that of the base case.  But
            // HSQL will have taken care of this for us, so we
            // will not see the widening here.
            VoltType valueType = VoltType.typeFromString(columnXML.getStringAttribute("valuetype", "none"));
            Integer columnIndex = columnXML.getIntAttribute("index", null);
            assert(columnIndex != null);
            // These appear to be optional.  Certainly "bytes"
            // only appears if the type is variably sized.
            Integer size = columnXML.getIntAttribute("size", 0);
            Boolean inBytes = columnXML.getBoolAttribute("bytes", null);
            // This TVE holds the metadata.
            TupleValueExpression tve = new TupleValueExpression(tableName, tableName, columnName, columnName, columnIndex);
            tve.setValueType(valueType);
            tve.setDifferentiator(idx);
            if (size == 0) {
                if (valueType.isVariableLength()) {
                    size = valueType.defaultLengthForVariableLengthType();
                }
                else {
                    size = valueType.getLengthInBytesForFixedTypes();
                }
            }
            tve.setValueSize(size);
            if (inBytes != null) {
                tve.setInBytes(inBytes);
            }
            // There really is no aliasing going on here, so the table
            // name and column name are the same as the table alias and
            // column alias.
            SchemaColumn schemaColumn = new SchemaColumn(tableName, tableName, columnName, columnName, tve, idx);
            tableScan.addOutputColumn(schemaColumn);
        }
    }
595911
private void initObjectTypes(Properties info) throws SQLException {
    // Add in the types that come packaged with the driver.
    // These can be overridden later if desired.
    addDataType("box", org.postgresql.geometric.PGbox.class);
    addDataType("circle", org.postgresql.geometric.PGcircle.class);
    addDataType("line", org.postgresql.geometric.PGline.class);
    addDataType("lseg", org.postgresql.geometric.PGlseg.class);
    addDataType("path", org.postgresql.geometric.PGpath.class);
    addDataType("point", org.postgresql.geometric.PGpoint.class);
    addDataType("polygon", org.postgresql.geometric.PGpolygon.class);
    addDataType("money", org.postgresql.util.PGmoney.class);
    addDataType("interval", org.postgresql.util.PGInterval.class);

    Enumeration<?> e = info.propertyNames();
    while (e.hasMoreElements()) {
      String propertyName = (String) e.nextElement();
      if (propertyName.startsWith("datatype.")) {
        String typeName = propertyName.substring(9);
        String className = info.getProperty(propertyName);
        Class<?> klass;

        try {
          klass = Class.forName(className);
        } catch (ClassNotFoundException cnfe) {
          throw new PSQLException(
              GT.tr("Unable to load the class {0} responsible for the datatype {1}",
                  className, typeName),
              PSQLState.SYSTEM_ERROR, cnfe);
        }

        addDataType(typeName, klass.asSubclass(PGobject.class));
      }
    }
  }
325956
function toSQL(method) {
    method = method || this.method;
    var val = this[method]();
    var defaults = {
      method: method,
      options: assign({}, this.options),
      bindings: this.formatter.bindings
    };
    if (typeof val === 'string') {
      val = { sql: val };
    }

    if (method === 'select' && this.single.as) {
      defaults.as = this.single.as;
    }
    var out = assign(defaults, val);
    debug(out);
    return out;
  }
318982
function (column, value, fromDatabase) {
            var colSchema, clazz = this._static;
            if (((fromDatabase && clazz.typecastOnLoad) || (!fromDatabase && clazz.typecastOnAssignment)) && !isUndefinedOrNull(this.schema) && !isUndefinedOrNull((colSchema = this.schema[column]))) {
                var type = colSchema.type;
                if (value === "" && clazz.typecastEmptyStringToNull === true && !isUndefinedOrNull(type) && ["string", "blob", "text"].indexOf(type) === -1) {
                    value = null;
                }
                var raiseOnError = clazz.raiseOnTypecastError;
                if (raiseOnError === true && isUndefinedOrNull(value) && colSchema.allowNull === false) {
                    throw new ModelError("null is not allowed for the " + column + " column on model " + clazz.tableName);
                }
                try {
                    value = clazz.db.typecastValue(type, value);
                } catch (e) {
                    if (raiseOnError === true) {
                        throw e;
                    }
                }
            }
            return value;
        }