Java Code Examples for org.apache.calcite.avatica.AvaticaUtils#toCamelCase()

The following examples show how to use org.apache.calcite.avatica.AvaticaUtils#toCamelCase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalciteMetaImpl.java    From Quicksql with MIT License 6 votes vote down vote up
private <E> MetaResultSet createResultSet(Enumerable<E> enumerable,
    Class clazz, String... names) {
  final List<ColumnMetaData> columns = new ArrayList<>();
  final List<Field> fields = new ArrayList<>();
  final List<String> fieldNames = new ArrayList<>();
  for (String name : names) {
    final int index = fields.size();
    final String fieldName = AvaticaUtils.toCamelCase(name);
    final Field field;
    try {
      field = clazz.getField(fieldName);
    } catch (NoSuchFieldException e) {
      throw new RuntimeException(e);
    }
    columns.add(columnMetaData(name, index, field.getType(), false));
    fields.add(field);
    fieldNames.add(fieldName);
  }
  //noinspection unchecked
  final Iterable<Object> iterable = (Iterable<Object>) (Iterable) enumerable;
  return createResultSet(Collections.emptyMap(),
      columns, CursorFactory.record(clazz, fields, fieldNames),
      new Frame(0, true, iterable));
}
 
Example 2
Source File: KylinMeta.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
private MetaResultSet createResultSet(List iterable, Class clazz, String... names) {
    final List<ColumnMetaData> columns = new ArrayList<ColumnMetaData>();
    final List<Field> fields = new ArrayList<Field>();
    final List<String> fieldNames = new ArrayList<String>();
    for (String name : names) {
        final int index = fields.size();
        final String fieldName = AvaticaUtils.toCamelCase(name);
        final Field field;
        try {
            field = clazz.getField(fieldName);
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        }
        columns.add(columnMetaData(name, index, field.getType(), true));
        fields.add(field);
        fieldNames.add(fieldName);
    }

    CursorFactory cursorFactory = CursorFactory.record(clazz, fields, fieldNames);
    Signature signature = new Signature(columns, "", null, Collections.<String, Object> emptyMap(), cursorFactory, StatementType.SELECT);
    StatementHandle sh = this.createStatement(connection().handle);
    Frame frame = new Frame(0, true, iterable);

    return MetaResultSet.create(connection().id, sh.id, true, signature, frame);
}
 
Example 3
Source File: QuarkMetaImpl.java    From quark with Apache License 2.0 6 votes vote down vote up
private <E> MetaResultSet createResultSet(Enumerable<E> enumerable,
    Class clazz, String... names) {
  final List<ColumnMetaData> columns = new ArrayList<>();
  final List<Field> fields = new ArrayList<>();
  final List<String> fieldNames = new ArrayList<>();
  for (String name : names) {
    final int index = fields.size();
    final String fieldName = AvaticaUtils.toCamelCase(name);
    final Field field;
    try {
      field = clazz.getField(fieldName);
    } catch (NoSuchFieldException e) {
      throw new RuntimeException(e);
    }
    columns.add(columnMetaData(name, index, field.getType(), false));
    fields.add(field);
    fieldNames.add(fieldName);
  }
  //noinspection unchecked
  final Iterable<Object> iterable = (Iterable<Object>) (Iterable) enumerable;
  return createResultSet(Collections.<String, Object>emptyMap(),
      columns, CursorFactory.record(clazz, fields, fieldNames),
      new Frame(0, true, iterable));
}
 
Example 4
Source File: KylinMeta.java    From kylin with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
private MetaResultSet createResultSet(List iterable, Class clazz, String... names) {
    final List<ColumnMetaData> columns = new ArrayList<ColumnMetaData>();
    final List<Field> fields = new ArrayList<Field>();
    final List<String> fieldNames = new ArrayList<String>();
    for (String name : names) {
        final int index = fields.size();
        final String fieldName = AvaticaUtils.toCamelCase(name);
        final Field field;
        try {
            field = clazz.getField(fieldName);
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        }
        columns.add(columnMetaData(name, index, field.getType(), true));
        fields.add(field);
        fieldNames.add(fieldName);
    }

    CursorFactory cursorFactory = CursorFactory.record(clazz, fields, fieldNames);
    Signature signature = new Signature(columns, "", null, Collections.<String, Object> emptyMap(), cursorFactory, StatementType.SELECT);
    StatementHandle sh = this.createStatement(connection().handle);
    Frame frame = new Frame(0, true, iterable);

    return MetaResultSet.create(connection().id, sh.id, true, signature, frame);
}
 
Example 5
Source File: CalciteMetaImpl.java    From calcite with Apache License 2.0 6 votes vote down vote up
private <E> MetaResultSet createResultSet(Enumerable<E> enumerable,
    Class clazz, String... names) {
  Objects.requireNonNull(names);
  final List<ColumnMetaData> columns = new ArrayList<>(names.length);
  final List<Field> fields = new ArrayList<>(names.length);
  final List<String> fieldNames = new ArrayList<>(names.length);
  for (String name : names) {
    final int index = fields.size();
    final String fieldName = AvaticaUtils.toCamelCase(name);
    final Field field;
    try {
      field = clazz.getField(fieldName);
    } catch (NoSuchFieldException e) {
      throw new RuntimeException(e);
    }
    columns.add(columnMetaData(name, index, field.getType(), false));
    fields.add(field);
    fieldNames.add(fieldName);
  }
  //noinspection unchecked
  final Iterable<Object> iterable = (Iterable<Object>) (Iterable) enumerable;
  return createResultSet(Collections.emptyMap(),
      columns, CursorFactory.record(clazz, fields, fieldNames),
      new Frame(0, true, iterable));
}
 
Example 6
Source File: QuidemTest.java    From Quicksql with MIT License 5 votes vote down vote up
private Method findMethod(String path) {
  // E.g. path "sql/agg.iq" gives method "testSqlAgg"
  String methodName =
      AvaticaUtils.toCamelCase(
          "test_" + path.replace(File.separatorChar, '_').replaceAll("\\.iq$", ""));
  Method m;
  try {
    m = getClass().getMethod(methodName);
  } catch (NoSuchMethodException e) {
    m = null;
  }
  return m;
}
 
Example 7
Source File: QuidemTest.java    From calcite with Apache License 2.0 5 votes vote down vote up
private Method findMethod(String path) {
  // E.g. path "sql/agg.iq" gives method "testSqlAgg"
  final String path1 = path.replace(File.separatorChar, '_');
  final String path2 = PATTERN.matcher(path1).replaceAll("");
  String methodName = AvaticaUtils.toCamelCase("test_" + path2);
  Method m;
  try {
    m = getClass().getMethod(methodName, String.class);
  } catch (NoSuchMethodException e) {
    m = null;
  }
  return m;
}