本文整理汇总了Java中org.apache.kudu.ColumnSchema.getName方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnSchema.getName方法的具体用法?Java ColumnSchema.getName怎么用?Java ColumnSchema.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.kudu.ColumnSchema
的用法示例。
在下文中一共展示了ColumnSchema.getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resultAsRow
import org.apache.kudu.ColumnSchema; //导入方法依赖的package包/类
private Row resultAsRow(RowResult result, KuduTable table) throws KuduException {
List<Object> values = Lists.newArrayList();
for (ColumnSchema columnSchema : table.getSchema().getColumns()) {
String columnName = columnSchema.getName();
if (result.isNull(columnName)) {
values.add(null);
continue;
}
switch (columnSchema.getType()) {
case DOUBLE:
values.add(result.getDouble(columnName));
break;
case FLOAT:
values.add(result.getFloat(columnName));
break;
case INT32:
values.add(result.getInt(columnName));
break;
case INT64:
values.add(result.getLong(columnName));
break;
case STRING:
values.add(result.getString(columnName));
break;
case BOOL:
values.add(result.getBoolean(columnName));
break;
default:
throw new RuntimeException("Unsupported Kudu column type: " + columnSchema.getType());
}
}
Row row = new RowWithSchema(getTableSchema(table), values.toArray());
return row;
}
示例2: schemaFor
import org.apache.kudu.ColumnSchema; //导入方法依赖的package包/类
private StructType schemaFor(KuduTable table) {
List<String> fieldNames = Lists.newArrayList();
List<String> fieldTypes = Lists.newArrayList();
for (ColumnSchema columnSchema : table.getSchema().getColumns()) {
String fieldName = columnSchema.getName();
String fieldType;
switch (columnSchema.getType()) {
case DOUBLE:
fieldType = "double";
break;
case FLOAT:
fieldType = "float";
break;
case INT32:
fieldType = "int";
break;
case INT64:
fieldType = "long";
break;
case STRING:
fieldType = "string";
break;
case BOOL:
fieldType = "boolean";
break;
default:
throw new RuntimeException("Unsupported Kudu column type: " + columnSchema.getType());
}
fieldNames.add(fieldName);
fieldTypes.add(fieldType);
}
StructType tableSchema = RowUtils.structTypeFor(fieldNames, fieldTypes);
return tableSchema;
}
示例3: initCols
import org.apache.kudu.ColumnSchema; //导入方法依赖的package包/类
private void initCols(Schema schema) throws SchemaChangeException {
ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
for (int i = 0; i < schema.getColumnCount(); i++) {
ColumnSchema col = schema.getColumnByIndex(i);
final String name = col.getName();
final Type kuduType = col.getType();
MinorType minorType = TYPES.get(kuduType);
if (minorType == null) {
logger.warn("Ignoring column that is unsupported.", UserException
.unsupportedError()
.message(
"A column you queried has a data type that is not currently supported by the Kudu storage plugin. "
+ "The column's name was %s and its Kudu data type was %s. ",
name, kuduType.toString())
.addContext("column Name", name)
.addContext("plugin", "kudu")
.build(logger));
continue;
}
MajorType majorType;
if (col.isNullable()) {
majorType = Types.optional(minorType);
} else {
majorType = Types.required(minorType);
}
MaterializedField field = MaterializedField.create(name, majorType);
final Class<? extends ValueVector> clazz = TypeHelper.getValueVectorClass(
minorType, majorType.getMode());
ValueVector vector = output.addField(field, clazz);
vector.allocateNew();
ProjectedColumnInfo pci = new ProjectedColumnInfo();
pci.vv = vector;
pci.kuduColumn = col;
pci.index = i;
pciBuilder.add(pci);
}
projectedCols = pciBuilder.build();
}
示例4: extractSettersForResultObject
import org.apache.kudu.ColumnSchema; //导入方法依赖的package包/类
/***
*
* @param parsedQuery The parsed query string
* @return Null if the SQL expression cannot be mapped properly to the POJO fields in which case the SQL string is
* sent to the Error port
*/
public Map<String,Object> extractSettersForResultObject(SQLToKuduPredicatesTranslator parsedQuery)
{
Map<String,String> aliasesUsedForThisQuery = parsedQuery.getKuduSQLParseTreeListener().getAliases();
Map<String,Object> setterMap = new HashMap<>();
Field[] fieldsOfThisPojo = clazzForResultObject.getDeclaredFields();
Set<String> allPojoFieldNamesUsed = new HashSet<>(aliasesUsedForThisQuery.values());
for ( Field aField : fieldsOfThisPojo) {
if (!allPojoFieldNamesUsed.contains(aField.getName())) {
LOG.error("Invalid mapping fo Kudu table column name to the POJO field name " + aField.getName());
return null; // SQL expression will be sent to the error port
}
}
for (ColumnSchema aKuduTableColumn: kuduColNameToSchemaMapping.values()) {
String kuduColumnName = aKuduTableColumn.getName();
switch ( aKuduTableColumn.getType().getDataType().getNumber()) {
case Common.DataType.BINARY_VALUE:
setterMap.put(kuduColumnName,PojoUtils.createSetter(clazzForResultObject,
aliasesUsedForThisQuery.get(kuduColumnName),ByteBuffer.class));
break;
case Common.DataType.BOOL_VALUE:
setterMap.put(kuduColumnName,PojoUtils.createSetterBoolean(clazzForResultObject,
aliasesUsedForThisQuery.get(kuduColumnName)));
break;
case Common.DataType.DOUBLE_VALUE:
setterMap.put(kuduColumnName,PojoUtils.createSetterDouble(clazzForResultObject,
aliasesUsedForThisQuery.get(kuduColumnName)));
break;
case Common.DataType.FLOAT_VALUE:
setterMap.put(kuduColumnName,PojoUtils.createSetterFloat(clazzForResultObject,
aliasesUsedForThisQuery.get(kuduColumnName)));
break;
case Common.DataType.INT8_VALUE:
setterMap.put(kuduColumnName,PojoUtils.createSetterByte(clazzForResultObject,
aliasesUsedForThisQuery.get(kuduColumnName)));
break;
case Common.DataType.INT16_VALUE:
setterMap.put(kuduColumnName,PojoUtils.createSetterShort(clazzForResultObject,
aliasesUsedForThisQuery.get(kuduColumnName)));
break;
case Common.DataType.INT32_VALUE:
setterMap.put(kuduColumnName,PojoUtils.createSetterInt(clazzForResultObject,
aliasesUsedForThisQuery.get(kuduColumnName)));
break;
case Common.DataType.UNIXTIME_MICROS_VALUE:
case Common.DataType.INT64_VALUE:
setterMap.put(kuduColumnName,PojoUtils.createSetterLong(clazzForResultObject,
aliasesUsedForThisQuery.get(kuduColumnName)));
break;
case Common.DataType.STRING_VALUE:
setterMap.put(kuduColumnName,PojoUtils.createSetter(clazzForResultObject,
aliasesUsedForThisQuery.get(kuduColumnName),String.class));
break;
case Common.DataType.UINT8_VALUE:
LOG.error("Unsigned int 8 not supported yet");
throw new RuntimeException("uint8 not supported in Kudu schema yet");
case Common.DataType.UINT16_VALUE:
LOG.error("Unsigned int 16 not supported yet");
throw new RuntimeException("uint16 not supported in Kudu schema yet");
case Common.DataType.UINT32_VALUE:
LOG.error("Unsigned int 32 not supported yet");
throw new RuntimeException("uint32 not supported in Kudu schema yet");
case Common.DataType.UINT64_VALUE:
LOG.error("Unsigned int 64 not supported yet");
throw new RuntimeException("uint64 not supported in Kudu schema yet");
case Common.DataType.UNKNOWN_DATA_VALUE:
LOG.error("unknown data type ( complex types ? ) not supported yet");
throw new RuntimeException("Unknown data type ( complex types ? ) not supported in Kudu schema yet");
default:
LOG.error("unknown type/default ( complex types ? ) not supported yet");
throw new RuntimeException("Unknown type/default ( complex types ? ) not supported in Kudu schema yet");
}
}
return setterMap;
}