• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Primitive类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.calcite.linq4j.tree.Primitive的典型用法代码示例。如果您正苦于以下问题:Java Primitive类的具体用法?Java Primitive怎么用?Java Primitive使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Primitive类属于org.apache.calcite.linq4j.tree包,在下文中一共展示了Primitive类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createSyntheticType

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
public Type createSyntheticType(List<Type> types) {
    if (types.isEmpty()) {
        // Unit is a pre-defined synthetic type to be used when there are 0
        // fields. Because all instances are the same, we use a singleton.
        return Unit.class;
    }
    final String name =
            "Record" + types.size() + "_" + syntheticTypes.size();
    final SyntheticRecordType syntheticType =
            new SyntheticRecordType(null, name);
    for (final Ord<Type> ord : Ord.zip(types)) {
        syntheticType.fields.add(
                new RecordFieldImpl(
                        syntheticType,
                        "f" + ord.i,
                        ord.e,
                        !Primitive.is(ord.e),
                        Modifier.PUBLIC));
    }
    return register(syntheticType);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:22,代码来源:JavaTypeFactoryImpl.java


示例2: convert

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
private static Object convert(Object o, Class clazz) {
  if (o == null) {
    return null;
  }
  Primitive primitive = Primitive.of(clazz);
  if (primitive != null) {
    clazz = primitive.boxClass;
  } else {
    primitive = Primitive.ofBox(clazz);
  }
  if (clazz.isInstance(o)) {
    return o;
  }
  if (o instanceof Date && primitive != null) {
    o = ((Date) o).getTime() / DateTimeUtils.MILLIS_PER_DAY;
  }
  if (o instanceof Number && primitive != null) {
    return primitive.number((Number) o);
  }
  return o;
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:Elasticsearch2Enumerator.java


示例3: safeArgList

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
/** Returns e.g. ", ignoreNulls". */
private static StringBuilder safeArgList(StringBuilder buff, Method method) {
  for (Ord<Class<?>> t : Ord.zip(method.getParameterTypes())) {
    if (Primitive.is(t.e)) {
      buff.append(", a").append(t.i);
    } else if (RexNode.class.isAssignableFrom(t.e)) {
      // For RexNode, convert to string, because equals does not look deep.
      //   a1 == null ? "" : a1.toString()
      buff.append(", a").append(t.i).append(" == null ? \"\" : a")
          .append(t.i).append(".toString()");
    } else {
      buff.append(", ") .append(NullSentinel.class.getName())
          .append(".mask(a").append(t.i).append(")");
    }
  }
  return buff;
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:JaninoRelMetadataProvider.java


示例4: copySimpleType

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
private RelDataType copySimpleType(
    RelDataType type,
    boolean nullable) {
  if (type instanceof JavaType) {
    JavaType javaType = (JavaType) type;
    if (SqlTypeUtil.inCharFamily(javaType)) {
      return new JavaType(
          javaType.clazz,
          nullable,
          javaType.charset,
          javaType.collation);
    } else {
      return new JavaType(
          nullable
              ? Primitive.box(javaType.clazz)
              : Primitive.unbox(javaType.clazz),
          nullable);
    }
  } else {
    // REVIEW: RelCrossType if it stays around; otherwise get rid of
    // this comment
    return type;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:RelDataTypeFactoryImpl.java


示例5: createSyntheticType

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
public Type createSyntheticType(List<Type> types) {
  if (types.isEmpty()) {
    // Unit is a pre-defined synthetic type to be used when there are 0
    // fields. Because all instances are the same, we use a singleton.
    return Unit.class;
  }
  final String name =
      "Record" + types.size() + "_" + syntheticTypes.size();
  final SyntheticRecordType syntheticType =
      new SyntheticRecordType(null, name);
  for (final Ord<Type> ord : Ord.zip(types)) {
    syntheticType.fields.add(
        new RecordFieldImpl(
            syntheticType,
            "f" + ord.i,
            ord.e,
            !Primitive.is(ord.e),
            Modifier.PUBLIC));
  }
  return register(syntheticType);
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:JavaTypeFactoryImpl.java


示例6: format

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
private JavaRowFormat format() {
  int fieldCount = getRowType().getFieldCount();
  if (fieldCount == 0) {
    return JavaRowFormat.LIST;
  }
  if (Object[].class.isAssignableFrom(elementType)) {
    return fieldCount == 1 ? JavaRowFormat.SCALAR : JavaRowFormat.ARRAY;
  }
  if (Row.class.isAssignableFrom(elementType)) {
    return JavaRowFormat.ROW;
  }
  if (fieldCount == 1 && (Object.class == elementType
        || Primitive.is(elementType)
        || Number.class.isAssignableFrom(elementType))) {
    return JavaRowFormat.SCALAR;
  }
  return JavaRowFormat.CUSTOM;
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:EnumerableTableScan.java


示例7: ObjectArrayRowBuilder

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
public ObjectArrayRowBuilder(
        ResultSet resultSet, Primitive[] primitives, int[] types)
        throws SQLException {
    this.resultSet = resultSet;
    this.primitives = primitives;
    this.types = types;
    this.columnCount = resultSet.getMetaData().getColumnCount();
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:9,代码来源:JdbcUtils.java


示例8: factory

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
public static Function1<ResultSet, Function0<Object[]>> factory(
        final List<Pair<Primitive, Integer>> list) {
    return new Function1<ResultSet, Function0<Object[]>>() {
        public Function0<Object[]> apply(ResultSet rs) {
            try {
                return new ObjectArrayRowBuilder(
                        rs,
                        Pair.left(list).toArray(new Primitive[list.size()]),
                        IntList.toArray(Pair.right(list)));
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        }
    };
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:16,代码来源:JdbcUtils.java


示例9: fieldClasses

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
private List<Pair<Primitive, Integer>> fieldClasses(
        final JavaTypeFactory typeFactory) {
    final RelDataType rowType = getProtoRowType().apply(typeFactory);
    return Lists.transform(rowType.getFieldList(),
            new Function<RelDataTypeField, Pair<Primitive, Integer>>() {
                public Pair<Primitive, Integer> apply(RelDataTypeField field) {
                    RelDataType type = field.getType();
                    Class clazz = (Class) typeFactory.getJavaClass(type);
                    return Pair.of(Util.first(Primitive.of(clazz), Primitive.OTHER),
                            type.getSqlTypeName().getJdbcOrdinal());
                }
            });
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:14,代码来源:OctopusJdbcTable.java


示例10: explainTerms

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
@Override
public RelWriter explainTerms(RelWriter pw) {

    return super.explainTerms(pw)
            .item("ctx", context == null ? "" : String.valueOf(context.id) + "@" + context.realization)
            .item("fields", Primitive.asList(fields));
}
 
开发者ID:apache,项目名称:kylin,代码行数:8,代码来源:OLAPTableScan.java


示例11: testIsAssignableFrom

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
@Test public void testIsAssignableFrom() {
  assertTrue(Primitive.INT.assignableFrom(Primitive.BYTE));
  assertTrue(Primitive.INT.assignableFrom(Primitive.SHORT));
  assertTrue(Primitive.INT.assignableFrom(Primitive.CHAR));
  assertTrue(Primitive.INT.assignableFrom(Primitive.INT));
  assertTrue(Primitive.INT.assignableFrom(Primitive.SHORT));
  assertFalse(Primitive.INT.assignableFrom(Primitive.LONG));

  assertTrue(Primitive.LONG.assignableFrom(Primitive.BYTE));
  assertTrue(Primitive.LONG.assignableFrom(Primitive.SHORT));
  assertTrue(Primitive.LONG.assignableFrom(Primitive.CHAR));
  assertTrue(Primitive.LONG.assignableFrom(Primitive.INT));
  assertTrue(Primitive.LONG.assignableFrom(Primitive.LONG));

  // SHORT and CHAR cannot be assigned to each other

  assertTrue(Primitive.SHORT.assignableFrom(Primitive.BYTE));
  assertTrue(Primitive.SHORT.assignableFrom(Primitive.SHORT));
  assertFalse(Primitive.SHORT.assignableFrom(Primitive.CHAR));
  assertFalse(Primitive.SHORT.assignableFrom(Primitive.INT));
  assertFalse(Primitive.SHORT.assignableFrom(Primitive.LONG));

  assertFalse(Primitive.CHAR.assignableFrom(Primitive.BYTE));
  assertFalse(Primitive.CHAR.assignableFrom(Primitive.SHORT));
  assertTrue(Primitive.CHAR.assignableFrom(Primitive.CHAR));
  assertFalse(Primitive.CHAR.assignableFrom(Primitive.INT));
  assertFalse(Primitive.CHAR.assignableFrom(Primitive.LONG));

  // cross-family assignments

  assertFalse(Primitive.BOOLEAN.assignableFrom(Primitive.INT));
  assertFalse(Primitive.INT.assignableFrom(Primitive.BOOLEAN));
}
 
开发者ID:apache,项目名称:calcite,代码行数:34,代码来源:PrimitiveTest.java


示例12: testPermute

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
/** Test for {@link Primitive#permute(Object, int[])}. */
@Test public void testPermute() {
  char[] chars = {'a', 'b', 'c', 'd', 'e', 'f', 'g'};
  int[] sources = {1, 2, 3, 4, 5, 6, 0};
  final Object permute = Primitive.CHAR.permute(chars, sources);
  assertTrue(permute instanceof char[]);
  assertEquals("bcdefga", new String((char[]) permute));
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:PrimitiveTest.java


示例13: testArraySort

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
/** Test for {@link Primitive#sortArray(Object)}. */
@Test public void testArraySort() {
  char[] chars = {'m', 'o', 'n', 'o', 'l', 'a', 'k', 'e'};
  Primitive.CHAR.sortArray(chars);
  assertEquals("[a, e, k, l, m, n, o, o]",
      Primitive.CHAR.arrayToString(chars));

  // mixed true and false
  boolean[] booleans0 = {true, false, true, true, false};
  Primitive.BOOLEAN.sortArray(booleans0);
  assertEquals("[false, false, true, true, true]",
      Primitive.BOOLEAN.arrayToString(booleans0));

  // all false
  boolean[] booleans1 = {false, false, false, false, false};
  Primitive.BOOLEAN.sortArray(booleans1);
  assertEquals("[false, false, false, false, false]",
      Primitive.BOOLEAN.arrayToString(booleans1));

  // all true
  boolean[] booleans2 = {true, true, true, true, true};
  Primitive.BOOLEAN.sortArray(booleans2);
  assertEquals("[true, true, true, true, true]",
      Primitive.BOOLEAN.arrayToString(booleans2));

  // empty
  boolean[] booleans3 = {};
  Primitive.BOOLEAN.sortArray(booleans3);
  assertEquals("[]", Primitive.BOOLEAN.arrayToString(booleans3));

  // ranges specified
  boolean[] booleans4 = {true, true, false, false, true, false, false};
  Primitive.BOOLEAN.sortArray(booleans4, 1, 6);
  assertEquals("[true, false, false, false, true, true, false]",
      Primitive.BOOLEAN.arrayToString(booleans4));
}
 
开发者ID:apache,项目名称:calcite,代码行数:37,代码来源:PrimitiveTest.java


示例14: create

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
/** Creates an initial collector of the appropriate kind. */
public static Collector create(Space space, int sketchThreshold) {
  final List<Integer> columnOrdinalList = space.columnOrdinals.asList();
  if (columnOrdinalList.size() == 1) {
    return new SingletonCollector(space, columnOrdinalList.get(0),
        sketchThreshold);
  } else {
    return new CompositeCollector(space,
        (int[]) Primitive.INT.toArray(columnOrdinalList), sketchThreshold);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:ProfilerImpl.java


示例15: toEnumerable

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
private static Enumerable toEnumerable(final Object o) {
  if (o.getClass().isArray()) {
    if (o instanceof Object[]) {
      return Linq4j.asEnumerable((Object[]) o);
    } else {
      return Linq4j.asEnumerable(Primitive.asList(o));
    }
  }
  if (o instanceof Iterable) {
    return Linq4j.asEnumerable((Iterable) o);
  }
  throw new RuntimeException(
      "Cannot convert " + o.getClass() + " into a Enumerable");
}
 
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:ReflectiveSchema.java


示例16: BitSlicedPrimitiveArray

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
BitSlicedPrimitiveArray(
    int ordinal, int bitCount, Primitive primitive, boolean signed) {
  assert bitCount > 0;
  this.ordinal = ordinal;
  this.bitCount = bitCount;
  this.primitive = primitive;
  this.signed = signed;
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:ArrayTable.java


示例17: chooseRep

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
ArrayTable.Representation chooseRep(int ordinal) {
  Primitive primitive = Primitive.of(clazz);
  Primitive boxPrimitive = Primitive.ofBox(clazz);
  Primitive p = primitive != null ? primitive : boxPrimitive;
  if (!containsNull && p != null) {
    switch (p) {
    case FLOAT:
    case DOUBLE:
      return new ArrayTable.PrimitiveArray(ordinal, p, p);
    case OTHER:
    case VOID:
      throw new AssertionError("wtf?!");
    }
    if (canBeLong(min) && canBeLong(max)) {
      return chooseFixedRep(
          ordinal, p, toLong(min), toLong(max));
    }
  }

  // We don't want to use a dictionary if:
  // (a) there are so many values that an object pointer (with one
  //     indirection) has about as many bits as a code (with two
  //     indirections); or
  // (b) if there are very few copies of each value.
  // The condition kind of captures this, but needs to be tuned.
  final int codeCount = map.size() + (containsNull ? 1 : 0);
  final int codeBitCount = log2(nextPowerOf2(codeCount));
  if (codeBitCount < 10 && values.size() > 2000) {
    final ArrayTable.Representation representation =
        chooseFixedRep(-1, Primitive.INT, 0, codeCount - 1);
    return new ArrayTable.ObjectDictionary(ordinal, representation);
  }
  return new ArrayTable.ObjectArray(ordinal);
}
 
开发者ID:apache,项目名称:calcite,代码行数:35,代码来源:ColumnLoader.java


示例18: nullifyType

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
public RelDataType nullifyType(RelDataType type, boolean nullable) {
  if (!nullable) {
    final Primitive primitive = javaPrimitive(type);
    if (primitive != null) {
      return typeFactory.createJavaType(primitive.primitiveClass);
    }
  }
  return typeFactory.createTypeWithNullability(type, nullable);
}
 
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:RexToLixTranslator.java


示例19: javaPrimitive

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
private Primitive javaPrimitive(RelDataType type) {
  if (type instanceof RelDataTypeFactoryImpl.JavaType) {
    return Primitive.ofBox(
        ((RelDataTypeFactoryImpl.JavaType) type).getJavaClass());
  }
  return null;
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:RexToLixTranslator.java


示例20: makeNullable

import org.apache.calcite.linq4j.tree.Primitive; //导入依赖的package包/类
public PhysType makeNullable(boolean nullable) {
  if (!nullable) {
    return this;
  }
  return new PhysTypeImpl(typeFactory,
      typeFactory.createTypeWithNullability(rowType, true),
      Primitive.box(javaRowClass), format);
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:PhysTypeImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JcrTools类代码示例发布时间:2022-05-22
下一篇:
Java SnapshotInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap