本文整理汇总了Java中org.apache.avro.generic.GenericData.Array类的典型用法代码示例。如果您正苦于以下问题:Java Array类的具体用法?Java Array怎么用?Java Array使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Array类属于org.apache.avro.generic.GenericData包,在下文中一共展示了Array类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: transformAvroArrayToObjectArray
import org.apache.avro.generic.GenericData.Array; //导入依赖的package包/类
private static Object[] transformAvroArrayToObjectArray(Array arr) {
if (arr == null) {
return new Object[0];
}
final Object[] ret = new Object[arr.size()];
final Iterator iterator = arr.iterator();
int i = 0;
while (iterator.hasNext()) {
Object value = iterator.next();
if (value instanceof Record) {
value = ((Record) value).get(0);
}
if (value instanceof Utf8) {
value = ((Utf8) value).toString();
}
ret[i++] = value;
}
return ret;
}
开发者ID:Hanmourang,项目名称:Pinot,代码行数:20,代码来源:AvroQueryGenerator.java
示例2: transformAvroArrayToObjectArray
import org.apache.avro.generic.GenericData.Array; //导入依赖的package包/类
public static Object[] transformAvroArrayToObjectArray(Array arr, FieldSpec spec) {
if (arr == null) {
return new Object[] { getDefaultNullValue(spec) };
}
if (arr.size() == 0) {
return new Object[] { getDefaultNullValue(spec) };
}
final Object[] ret = new Object[arr.size()];
final Iterator iterator = arr.iterator();
int i = 0;
while (iterator.hasNext()) {
Object value = iterator.next();
if (value instanceof Record) {
value = ((Record) value).get(0);
}
if (value instanceof Utf8) {
value = ((Utf8) value).toString();
}
if (value == null) {
value = getDefaultNullValue(spec);
}
ret[i++] = value;
}
return ret;
}
开发者ID:Hanmourang,项目名称:Pinot,代码行数:27,代码来源:AvroRecordReader.java
示例3: transform
import org.apache.avro.generic.GenericData.Array; //导入依赖的package包/类
public GenericRow transform(GenericRecord avroRecord) {
Map<String, Object> rowEntries = new HashMap<String, Object>();
for (String column : indexingSchema.getColumnNames()) {
Object entry = avroRecord.get(column);
if (entry instanceof Utf8) {
entry = ((Utf8) entry).toString();
}
if (entry instanceof Array) {
entry = AvroRecordReader.transformAvroArrayToObjectArray((Array) entry, indexingSchema.getFieldSpecFor(column));
}
if (entry == null && indexingSchema.getFieldSpecFor(column).isSingleValueField()) {
entry = AvroRecordReader.getDefaultNullValue(indexingSchema.getFieldSpecFor(column));
}
rowEntries.put(column, entry);
}
GenericRow row = new GenericRow();
row.init(rowEntries);
return row;
}
开发者ID:Hanmourang,项目名称:Pinot,代码行数:21,代码来源:AvroRecordToPinotRowGenerator.java
示例4: transform
import org.apache.avro.generic.GenericData.Array; //导入依赖的package包/类
@Nonnull
public GenericRow transform(@Nonnull GenericData.Record from, @Nonnull GenericRow to) {
for (FieldSpec fieldSpec : _schema.getAllFieldSpecs()) {
FieldSpec incomingFieldSpec =
fieldSpec.getFieldType() == FieldSpec.FieldType.TIME ? _incomingTimeFieldSpec : fieldSpec;
String fieldName = incomingFieldSpec.getName();
Object avroValue = from.get(fieldName);
if (incomingFieldSpec.isSingleValueField()) {
to.putField(fieldName, AvroUtils.transformAvroValueToObject(avroValue, incomingFieldSpec));
} else {
to.putField(fieldName, AvroUtils.transformAvroArrayToObjectArray((Array) avroValue, incomingFieldSpec));
}
}
return to;
}
开发者ID:linkedin,项目名称:pinot,代码行数:17,代码来源:AvroRecordToPinotRowGenerator.java
示例5: convert
import org.apache.avro.generic.GenericData.Array; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Array<CharSequence> convert(List<String> recommendationList) {
List<CharSequence> recommendationArray = new ArrayList<CharSequence>();;
for (String s : recommendationList) {
recommendationArray.add(s);
}
Array<CharSequence> recomendationArray = new Array<CharSequence>(Schema.createArray(Schema.create(Schema.Type.STRING)), recommendationArray);
return recomendationArray;
}
开发者ID:CodeGerm,项目名称:HBaseMate,代码行数:13,代码来源:CharSequenceArrayToStringListTranslator.java
示例6: reverseConvert
import org.apache.avro.generic.GenericData.Array; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<String> reverseConvert(Array<CharSequence> recommendationArray) {
List<String> recommendationList = new ArrayList<String>();
for (CharSequence ch : recommendationArray) {
recommendationList.add(ch.toString());
}
return recommendationList;
}
开发者ID:CodeGerm,项目名称:HBaseMate,代码行数:13,代码来源:CharSequenceArrayToStringListTranslator.java
示例7: getGenericRow
import org.apache.avro.generic.GenericData.Array; //导入依赖的package包/类
private GenericRow getGenericRow(GenericRecord rawRecord) {
for (final Field field : _dataStream.getSchema().getFields()) {
FieldSpec spec = _schemaExtractor.getSchema().getFieldSpecFor(field.name());
if (spec == null) {
continue;
}
Object value = rawRecord.get(field.name());
if (value == null) {
if (spec.isSingleValueField()) {
value = spec.getDefaultNullValue();
} else {
value = transformAvroArrayToObjectArray((Array) value, spec);
}
} else {
if (value instanceof Utf8) {
value = ((Utf8) value).toString();
}
if (value instanceof Array) {
value = transformAvroArrayToObjectArray((Array) value, spec);
}
}
_fieldMap.put(field.name(), value);
}
_genericRow.init(_fieldMap);
return _genericRow;
}
开发者ID:Hanmourang,项目名称:Pinot,代码行数:28,代码来源:AvroRecordReader.java
注:本文中的org.apache.avro.generic.GenericData.Array类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论