@Override @SuppressWarnings("unchecked") public IndexedRecord convertToAvro(List row) { IndexedRecord indexedRecord = new GenericData.Record(getSchema()); for (int i = 0; i < row.size(); i++) { Object value = avroConverters[i].convertToAvro(row.get(i)); indexedRecord.put(i, value); } return indexedRecord; }
/** * Is not supported */ @Override public ResultSet convertToDatum(IndexedRecord value) { throw new UnmodifiableAdapterException("not supported"); }
@Override public DatumT apply(AvroT value) { return elementConverter.convertToDatum(value); } }
@Override public List<DatumT> convertToDatum(List<AvroT> value) { return Collections.unmodifiableList(new WrappedList<>(value, new LambdaConvertToDatumFunction<>(elementConverter), new LambdaConvertToAvroFunction<>(elementConverter))); }
@Override public Map<String, DatumT> convertToDatum(Map<String, AvroT> value) { return Collections.unmodifiableMap( new WrappedValueMap<>(value, new ConvertAvroList.LambdaConvertToDatumFunction<>(elementConverter), new ConvertAvroList.LambdaConvertToAvroFunction<>(elementConverter))); }
@Override public Set<Map.Entry<KeyT, OutT>> entrySet() { Set<Map.Entry<KeyT, InT>> in = mWrapped.entrySet(); return new WrappedSet<>(in, new LambdaConvertToMappedValueEntry(), new LambdaUnwrapMappedValueEntry()); }
/** * Set the container type for this factory. This automatically initializes the {@link Schema} using the inferrers. * * @param containerType A container type can be used to access the field types. */ public void setContainerDataSpec(ContainerDataSpecT containerType) { this.containerDataSpec = containerType; setSchemaFromContainerDataSpec(containerType); }
/** * @param datumClass The class of the instances that this factory knows how to create IndexedRecords for. This must * be an Avro-compatible class since it's instances will be directly inserted into the output records without * validation. * @param fieldSchema The schema that the datum class can be converted to. This will be the schema of the single * field in the generated {@link IndexedRecord}s. */ public SingleColumnIndexedRecordConverter(Class<DatumT> datumClass, Schema fieldSchema) { this(datumClass, fieldSchema, createRecordName(datumClass), "field"); }
@Override public IndexedRecord getCurrent() throws NoSuchElementException { if (!_started) { throw new NoSuchElementException("Reader was not started"); } if (!_hasMore) { throw new NoSuchElementException( "Resource does not have more elements"); } try { AvroConverter<Object, IndexedRecord> avroConverter = getConverter(); return avroConverter.convertToAvro(getCurrentJsonNode()); } catch (IOException ioe) { throw new ComponentException(ioe); } }
@Override public void put(int i, Object v) { throw new IndexedRecordConverter.UnmodifiableAdapterException(); } }
@Override public List<AvroT> convertToAvro(List<DatumT> value) { return Collections.unmodifiableList(new WrappedList<>(value, new LambdaConvertToAvroFunction<>(elementConverter), new LambdaConvertToDatumFunction<>(elementConverter))); }
@Override public Map<String, AvroT> convertToAvro(Map<String, DatumT> value) { return Collections .unmodifiableMap(new WrappedValueMap<>(value, new ConvertAvroList.LambdaConvertToAvroFunction<>(elementConverter), new ConvertAvroList.LambdaConvertToDatumFunction<>(elementConverter))); }
_stringStringConverter.convertToAvro(exception.getMessage()));
@Override public void put(int i, Object v) { throw new IndexedRecordConverter.UnmodifiableAdapterException(); } }
JsonNode resourceJsonNode = field.getValue(); Object value = avroConverters[pos].convertToAvro( resourceJsonNode.asText());
@Override public void put(int i, Object v) { throw new UnmodifiableAdapterException(); } }
@Override public AvroT apply(DatumT value) { return elementConverter.convertToAvro(value); } }
@Override public void put(int i, Object v) { throw new IndexedRecordConverter.UnmodifiableAdapterException(); } }
@Override public SObject convertToDatum(IndexedRecord value) { throw new UnmodifiableAdapterException(); }
@Override public SObject convertToDatum(IndexedRecord value) { throw new UnmodifiableAdapterException(); }