当前位置: 首页>>代码示例>>Java>>正文


Java RelDataTypeFactory.getDefaultCharset方法代码示例

本文整理汇总了Java中org.apache.calcite.rel.type.RelDataTypeFactory.getDefaultCharset方法的典型用法代码示例。如果您正苦于以下问题:Java RelDataTypeFactory.getDefaultCharset方法的具体用法?Java RelDataTypeFactory.getDefaultCharset怎么用?Java RelDataTypeFactory.getDefaultCharset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.rel.type.RelDataTypeFactory的用法示例。


在下文中一共展示了RelDataTypeFactory.getDefaultCharset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addCharsetAndCollation

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
 * Adds collation and charset to a character type, returns other types
 * unchanged.
 *
 * @param type        Type
 * @param typeFactory Type factory
 * @return Type with added charset and collation, or unchanged type if it is
 * not a char type.
 */
public static RelDataType addCharsetAndCollation(
        RelDataType type,
        RelDataTypeFactory typeFactory) {
    if (!inCharFamily(type)) {
        return type;
    }
    Charset charset = type.getCharset();
    if (charset == null) {
        charset = typeFactory.getDefaultCharset();
    }
    SqlCollation collation = type.getCollation();
    if (collation == null) {
        collation = SqlCollation.IMPLICIT;
    }

    // todo: should get the implicit collation from repository
    //   instead of null
    type =
            typeFactory.createTypeWithCharsetAndCollation(
                    type,
                    charset,
                    collation);
    SqlValidatorUtil.checkCharsetAndCollateConsistentIfCharType(type);
    return type;
}
 
开发者ID:apache,项目名称:kylin,代码行数:35,代码来源:SqlTypeUtil.java

示例2: addCharsetAndCollation

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
 * Adds collation and charset to a character type, returns other types
 * unchanged.
 *
 * @param type        Type
 * @param typeFactory Type factory
 * @return Type with added charset and collation, or unchanged type if it is
 * not a char type.
 */
public static RelDataType addCharsetAndCollation(
    RelDataType type,
    RelDataTypeFactory typeFactory) {
  if (!inCharFamily(type)) {
    return type;
  }
  Charset charset = type.getCharset();
  if (charset == null) {
    charset = typeFactory.getDefaultCharset();
  }
  SqlCollation collation = type.getCollation();
  if (collation == null) {
    collation = SqlCollation.IMPLICIT;
  }

  // todo: should get the implicit collation from repository
  //   instead of null
  type =
      typeFactory.createTypeWithCharsetAndCollation(
          type,
          charset,
          collation);
  SqlValidatorUtil.checkCharsetAndCollateConsistentIfCharType(type);
  return type;
}
 
开发者ID:apache,项目名称:calcite,代码行数:35,代码来源:SqlTypeUtil.java

示例3: createNlsStringType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
/**
 * Creates the type of an {@link org.apache.calcite.util.NlsString}.
 *
 * <p>The type inherits the The NlsString's {@link Charset} and
 * {@link SqlCollation}, if they are set, otherwise it gets the system
 * defaults.
 *
 * @param typeFactory Type factory
 * @param str         String
 * @return Type, including collation and charset
 */
public static RelDataType createNlsStringType(
    RelDataTypeFactory typeFactory,
    NlsString str) {
  Charset charset = str.getCharset();
  if (null == charset) {
    charset = typeFactory.getDefaultCharset();
  }
  SqlCollation collation = str.getCollation();
  if (null == collation) {
    collation = SqlCollation.COERCIBLE;
  }
  RelDataType type =
      typeFactory.createSqlType(
          SqlTypeName.CHAR,
          str.getValue().length());
  type =
      typeFactory.createTypeWithCharsetAndCollation(
          type,
          charset,
          collation);
  return type;
}
 
开发者ID:apache,项目名称:calcite,代码行数:34,代码来源:SqlUtil.java

示例4: createSqlType

import org.apache.calcite.rel.type.RelDataTypeFactory; //导入方法依赖的package包/类
public RelDataType createSqlType(RelDataTypeFactory typeFactory) {
  BitString bitString;
  switch (typeName) {
  case NULL:
  case BOOLEAN:
    RelDataType ret = typeFactory.createSqlType(typeName);
    ret = typeFactory.createTypeWithNullability(ret, null == value);
    return ret;
  case BINARY:
    bitString = (BitString) value;
    int bitCount = bitString.getBitCount();
    return typeFactory.createSqlType(SqlTypeName.BINARY, bitCount / 8);
  case CHAR:
    NlsString string = (NlsString) value;
    Charset charset = string.getCharset();
    if (null == charset) {
      charset = typeFactory.getDefaultCharset();
    }
    SqlCollation collation = string.getCollation();
    if (null == collation) {
      collation = SqlCollation.COERCIBLE;
    }
    RelDataType type =
        typeFactory.createSqlType(
            SqlTypeName.CHAR,
            string.getValue().length());
    type =
        typeFactory.createTypeWithCharsetAndCollation(
            type,
            charset,
            collation);
    return type;

  case INTERVAL_YEAR:
  case INTERVAL_YEAR_MONTH:
  case INTERVAL_MONTH:
  case INTERVAL_DAY:
  case INTERVAL_DAY_HOUR:
  case INTERVAL_DAY_MINUTE:
  case INTERVAL_DAY_SECOND:
  case INTERVAL_HOUR:
  case INTERVAL_HOUR_MINUTE:
  case INTERVAL_HOUR_SECOND:
  case INTERVAL_MINUTE:
  case INTERVAL_MINUTE_SECOND:
  case INTERVAL_SECOND:
    SqlIntervalLiteral.IntervalValue intervalValue =
        (SqlIntervalLiteral.IntervalValue) value;
    return typeFactory.createSqlIntervalType(
        intervalValue.getIntervalQualifier());

  case SYMBOL:
    return typeFactory.createSqlType(SqlTypeName.SYMBOL);

  case INTEGER: // handled in derived class
  case TIME: // handled in derived class
  case VARCHAR: // should never happen
  case VARBINARY: // should never happen

  default:
    throw Util.needToImplement(toString() + ", operand=" + value);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:64,代码来源:SqlLiteral.java


注:本文中的org.apache.calcite.rel.type.RelDataTypeFactory.getDefaultCharset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。