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


Java ScalarType类代码示例

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


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

示例1: shortArrays

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void shortArrays() throws Exception {
  final Random r = new Random();
  try (Connection conn = DriverManager.getConnection(url)) {
    ScalarType component = ColumnMetaData.scalar(Types.SMALLINT, "SMALLINT", Rep.SHORT);
    List<Array> arrays = new ArrayList<>();
    // Construct the data
    for (int i = 0; i < 5; i++) {
      List<Short> elements = new ArrayList<>();
      for (int j = 0; j < 5; j++) {
        short value = (short) r.nextInt(Short.MAX_VALUE);
        // 50% of the time, negate the value
        if (0 == r.nextInt(2)) {
          value *= -1;
        }
        elements.add(Short.valueOf(value));
      }
      arrays.add(createArray("SMALLINT", component, elements));
    }
    // Verify read/write
    writeAndReadArrays(conn, "short_arrays", "SMALLINT", component, arrays,
        PRIMITIVE_LIST_VALIDATOR);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:24,代码来源:ArrayTypeTest.java

示例2: shortArraysWithNull

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void shortArraysWithNull() throws Exception {
  final Random r = new Random();
  try (Connection conn = DriverManager.getConnection(url)) {
    ScalarType component = ColumnMetaData.scalar(Types.SMALLINT, "SMALLINT", Rep.SHORT);
    List<Array> arrays = new ArrayList<>();
    // Construct the data
    for (int i = 0; i < 5; i++) {
      List<Short> elements = new ArrayList<>();
      for (int j = 0; j < 4; j++) {
        short value = (short) r.nextInt(Short.MAX_VALUE);
        // 50% of the time, negate the value
        if (0 == r.nextInt(2)) {
          value *= -1;
        }
        elements.add(Short.valueOf(value));
      }
      elements.add(null);
      arrays.add(createArray("SMALLINT", component, elements));
    }
    // Verify read/write
    writeAndReadArrays(conn, "short_arrays", "SMALLINT", component, arrays,
        PRIMITIVE_LIST_VALIDATOR);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:25,代码来源:ArrayTypeTest.java

示例3: longArrays

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void longArrays() throws Exception {
  final Random r = new Random();
  try (Connection conn = DriverManager.getConnection(url)) {
    ScalarType component = ColumnMetaData.scalar(Types.BIGINT, "BIGINT", Rep.LONG);
    List<Array> arrays = new ArrayList<>();
    // Construct the data
    for (int i = 0; i < 5; i++) {
      List<Long> elements = new ArrayList<>();
      for (int j = 0; j < 5; j++) {
        elements.add(r.nextLong());
      }
      arrays.add(createArray("BIGINT", component, elements));
    }
    // Verify read/write
    writeAndReadArrays(conn, "long_arrays", "BIGINT", component, arrays,
        PRIMITIVE_LIST_VALIDATOR);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:19,代码来源:ArrayTypeTest.java

示例4: stringArrays

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void stringArrays() throws Exception {
  try (Connection conn = DriverManager.getConnection(url)) {
    ScalarType component = ColumnMetaData.scalar(Types.VARCHAR, "VARCHAR", Rep.STRING);
    List<Array> arrays = new ArrayList<>();
    // Construct the data
    for (int i = 0; i < 5; i++) {
      List<String> elements = new ArrayList<>();
      for (int j = 0; j < 5; j++) {
        elements.add(i + "_" + j);
      }
      arrays.add(createArray("VARCHAR", component, elements));
    }
    // Verify read/write
    writeAndReadArrays(conn, "string_arrays", "VARCHAR", component, arrays,
        PRIMITIVE_LIST_VALIDATOR);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:18,代码来源:ArrayTypeTest.java

示例5: bigintArrays

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void bigintArrays() throws Exception {
  final Random r = new Random();
  try (Connection conn = DriverManager.getConnection(url)) {
    ScalarType component = ColumnMetaData.scalar(Types.BIGINT, "BIGINT", Rep.LONG);
    List<Array> arrays = new ArrayList<>();
    // Construct the data
    for (int i = 0; i < 3; i++) {
      List<Long> elements = new ArrayList<>();
      for (int j = 0; j < 7; j++) {
        long element = r.nextLong();
        if (r.nextBoolean()) {
          element *= -1;
        }
        elements.add(element);
      }
      arrays.add(createArray("BIGINT", component, elements));
    }
    writeAndReadArrays(conn, "long_arrays", "BIGINT", component, arrays,
        PRIMITIVE_LIST_VALIDATOR);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:22,代码来源:ArrayTypeTest.java

示例6: doubleArrays

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void doubleArrays() throws Exception {
  final Random r = new Random();
  try (Connection conn = DriverManager.getConnection(url)) {
    ScalarType component = ColumnMetaData.scalar(Types.DOUBLE, "DOUBLE", Rep.DOUBLE);
    List<Array> arrays = new ArrayList<>();
    // Construct the data
    for (int i = 0; i < 3; i++) {
      List<Double> elements = new ArrayList<>();
      for (int j = 0; j < 7; j++) {
        double element = r.nextDouble();
        if (r.nextBoolean()) {
          element *= -1;
        }
        elements.add(element);
      }
      arrays.add(createArray("DOUBLE", component, elements));
    }
    writeAndReadArrays(conn, "float_arrays", "DOUBLE", component, arrays,
        PRIMITIVE_LIST_VALIDATOR);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:22,代码来源:ArrayTypeTest.java

示例7: arraysOfByteArrays

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void arraysOfByteArrays() throws Exception {
  final Random r = new Random();
  try (Connection conn = DriverManager.getConnection(url)) {
    ScalarType component = ColumnMetaData.scalar(Types.TINYINT, "TINYINT", Rep.BYTE);
    // [ Array([b, b, b]), Array([b, b, b]), ... ]
    List<Array> arrays = new ArrayList<>();
    // Construct the data
    for (int i = 0; i < 5; i++) {
      List<Byte> elements = new ArrayList<>();
      for (int j = 0; j < 5; j++) {
        byte value = (byte) r.nextInt(Byte.MAX_VALUE);
        // 50% of the time, negate the value
        if (0 == r.nextInt(2)) {
          value *= -1;
        }
        elements.add(Byte.valueOf(value));
      }
      arrays.add(createArray("TINYINT", component, elements));
    }
    // Verify read/write
    writeAndReadArrays(conn, "byte_arrays", "TINYINT", component, arrays, BYTE_ARRAY_VALIDATOR);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:24,代码来源:ArrayTypeTest.java

示例8: varbinaryArrays

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void varbinaryArrays() throws Exception {
  try (Connection conn = DriverManager.getConnection(url)) {
    ScalarType component = ColumnMetaData.scalar(Types.VARBINARY, "VARBINARY", Rep.BYTE_STRING);
    // [ Array(binary, binary, binary), Array(binary, binary, binary), ...]
    List<Array> arrays = new ArrayList<>();
    // Construct the data
    for (int i = 0; i < 5; i++) {
      List<byte[]> elements = new ArrayList<>();
      for (int j = 0; j < 5; j++) {
        elements.add((i + "_" + j).getBytes(UTF_8));
      }
      arrays.add(createArray("VARBINARY", component, elements));
    }
    writeAndReadArrays(conn, "binary_arrays", "VARBINARY", component, arrays,
        BYTE_ARRAY_ARRAY_VALIDATOR);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:18,代码来源:ArrayTypeTest.java

示例9: create

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Override public ResultSet create(AvaticaType elementType, Iterable<Object> elements) {
  // The ColumnMetaData for offset "1" in the ResultSet for an Array.
  ScalarType arrayOffsetType = ColumnMetaData.scalar(Types.INTEGER, "INTEGER", Rep.PRIMITIVE_INT);
  // Two columns (types) in the ResultSet we will create
  List<ColumnMetaData> types = Arrays.asList(ColumnMetaData.dummy(arrayOffsetType, false),
      ColumnMetaData.dummy(elementType, true));
  List<List<Object>> rows = createResultSetRowsForArrayData(elements);
  // `(List<Object>) rows` is a compile error.
  @SuppressWarnings({ "unchecked", "rawtypes" })
  List<Object> untypedRows = (List<Object>) ((List) rows);
  try (ListIteratorCursor cursor = new ListIteratorCursor(rows.iterator())) {
    final String sql = "MOCKED";
    QueryState state = new QueryState(sql);
    Meta.Signature signature = new Meta.Signature(types, sql,
        Collections.<AvaticaParameter>emptyList(), Collections.<String, Object>emptyMap(),
        Meta.CursorFactory.LIST, Meta.StatementType.SELECT);
    AvaticaResultSetMetaData resultSetMetaData = new AvaticaResultSetMetaData(null, sql,
        signature);
    Meta.Frame frame = new Meta.Frame(0, true, untypedRows);
    AvaticaResultSet resultSet = new AvaticaResultSet(null, state, signature, resultSetMetaData,
        timeZone, frame);
    resultSet.execute2(cursor, types);
    return resultSet;
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:26,代码来源:ArrayFactoryImpl.java

示例10: testArrayWithOffsets

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void testArrayWithOffsets() throws Exception {
  // Define the struct type we're creating
  ScalarType intType = ColumnMetaData.scalar(Types.INTEGER, "INTEGER", Rep.INTEGER);
  ArrayImpl.Factory factory = new ArrayFactoryImpl(Unsafe.localCalendar().getTimeZone());
  // Create some arrays from the structs
  Array array1 = factory.createArray(intType, Arrays.<Object>asList(1, 2));
  Array array3 = factory.createArray(intType, Arrays.<Object>asList(4, 5, 6));

  Object[] data = (Object[]) array1.getArray(2, 1);
  assertEquals(1, data.length);
  assertEquals(2, data[0]);
  data = (Object[]) array3.getArray(1, 1);
  assertEquals(1, data.length);
  assertEquals(4, data[0]);
  data = (Object[]) array3.getArray(2, 2);
  assertEquals(2, data.length);
  assertEquals(5, data[0]);
  assertEquals(6, data[1]);
  data = (Object[]) array3.getArray(1, 3);
  assertEquals(3, data.length);
  assertEquals(4, data[0]);
  assertEquals(5, data[1]);
  assertEquals(6, data[2]);
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:25,代码来源:ArrayImplTest.java

示例11: testArrays

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void testArrays() {
  List<Object> serialObj = Arrays.<Object>asList(1, 2, 3, 4);
  ArrayImpl.Factory factory = new ArrayFactoryImpl(Unsafe.localCalendar().getTimeZone());
  ScalarType scalarType = ColumnMetaData.scalar(Types.INTEGER, "INTEGER", Rep.INTEGER);
  Array a1 = factory.createArray(scalarType, serialObj);
  TypedValue tv1 = TypedValue.ofJdbc(Rep.ARRAY, a1, Unsafe.localCalendar());
  Object jdbcObj = tv1.toJdbc(Unsafe.localCalendar());
  assertTrue("The JDBC object is an " + jdbcObj.getClass(), jdbcObj instanceof Array);
  Object localObj = tv1.toLocal();
  assertTrue("The local object is an " + localObj.getClass(), localObj instanceof List);
  Common.TypedValue protoTv1 = tv1.toProto();
  assertEquals(serialObj.size(), protoTv1.getArrayValueCount());
  TypedValue tv1Copy = TypedValue.fromProto(protoTv1);
  Object jdbcObjCopy = tv1Copy.toJdbc(Unsafe.localCalendar());
  assertTrue("The JDBC object is an " + jdbcObjCopy.getClass(), jdbcObjCopy instanceof Array);
  Object localObjCopy = tv1Copy.toLocal();
  assertTrue("The local object is an " + localObjCopy.getClass(), localObjCopy instanceof List);
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:19,代码来源:TypedValueTest.java

示例12: convertColumnMeta

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
private List<ColumnMetaData> convertColumnMeta(SQLResponseStub queryResp) {
    List<ColumnMetaData> metas = new ArrayList<ColumnMetaData>();
    for (int i = 0; i < queryResp.getColumnMetas().size(); i++) {
        SQLResponseStub.ColumnMetaStub scm = queryResp.getColumnMetas().get(i);
        Class columnClass = convertType(scm.getColumnType());
        ScalarType type = ColumnMetaData.scalar(scm.getColumnType(), scm.getColumnTypeName(), Rep.of(columnClass));

        ColumnMetaData meta = new ColumnMetaData(i, scm.isAutoIncrement(), scm.isCaseSensitive(),
                scm.isSearchable(), scm.isCurrency(), scm.getIsNullable(), scm.isSigned(), scm.getDisplaySize(),
                scm.getLabel(), scm.getName(), scm.getSchemaName(), scm.getPrecision(), scm.getScale(),
                scm.getTableName(), scm.getSchemaName(), type, scm.isReadOnly(), scm.isWritable(), scm.isWritable(),
                columnClass.getCanonicalName());

        metas.add(meta);
    }

    return metas;
}
 
开发者ID:apache,项目名称:kylin,代码行数:19,代码来源:KylinClient.java

示例13: simpleArrayTest

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void simpleArrayTest() throws Exception {
  try (Connection conn = DriverManager.getConnection(url)) {
    ScalarType varcharComponent = ColumnMetaData.scalar(Types.VARCHAR, "VARCHAR", Rep.STRING);
    List<Array> varcharArrays = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
      List<String> value = Collections.singletonList(Integer.toString(i));
      varcharArrays.add(createArray("VARCHAR", varcharComponent, value));
    }
    writeAndReadArrays(conn, "varchar_arrays", "VARCHAR(30)",
        varcharComponent, varcharArrays, PRIMITIVE_LIST_VALIDATOR);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:13,代码来源:ArrayTypeTest.java

示例14: booleanArrays

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
@Test public void booleanArrays() throws Exception {
  final Random r = new Random();
  try (Connection conn = DriverManager.getConnection(url)) {
    ScalarType component = ColumnMetaData.scalar(Types.BOOLEAN, "BOOLEAN", Rep.BOOLEAN);
    List<Array> arrays = new ArrayList<>();
    // Construct the data
    for (int i = 0; i < 5; i++) {
      List<Boolean> elements = new ArrayList<>();
      for (int j = 0; j < 5; j++) {
        switch (r.nextInt(3)) {
        case 0:
          elements.add(Boolean.FALSE);
          break;
        case 1:
          elements.add(Boolean.TRUE);
          break;
        case 2:
          elements.add(null);
          break;
        default:
          fail();
        }
      }
      arrays.add(createArray("BOOLEAN", component, elements));
    }
    // Verify we can read and write the data
    writeAndReadArrays(conn, "boolean_arrays", "BOOLEAN", component, arrays,
        PRIMITIVE_LIST_VALIDATOR);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:31,代码来源:ArrayTypeTest.java

示例15: getArrayColumnMetaData

import org.apache.calcite.avatica.ColumnMetaData.ScalarType; //导入依赖的package包/类
private static ColumnMetaData getArrayColumnMetaData(ScalarType componentType, int index,
    String name) {
  ArrayType arrayType = ColumnMetaData.array(componentType, "Array", Rep.ARRAY);
  return new ColumnMetaData(
      index, false, true, false, false, DatabaseMetaData.columnNullable,
      true, -1, name, name, null,
      0, 0, null, null, arrayType, true, false, false,
      "ARRAY");
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:10,代码来源:ProtobufTranslationImplTest.java


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