@Override protected void setField(Object record, String name, int position, Object o) { ((SpecificRecord)record).put(position, o); } @Override
@Override public E compose(List<S> subEntities) { E entity; try { entity = entityConstructor.newInstance(); } catch (Throwable e) { LOG.error( "Error trying to construct entity of type: " + entityClass.getName(), e); throw new DatasetException(e); } int cnt = 0; for (S subEntity : subEntities) { if (subEntity != null) { entity.put(cnt, subEntity); } cnt++; } return entity; }
@Override public E compose(List<S> subEntities) { E entity; try { entity = entityConstructor.newInstance(); } catch (Throwable e) { LOG.error( "Error trying to construct entity of type: " + entityClass.getName(), e); throw new DatasetException(e); } int cnt = 0; for (S subEntity : subEntities) { if (subEntity != null) { entity.put(cnt, subEntity); } cnt++; } return entity; }
@Override public E compose(List<S> subEntities) { E entity; try { entity = entityConstructor.newInstance(); } catch (Throwable e) { LOG.error( "Error trying to construct entity of type: " + entityClass.getName(), e); throw new DatasetException(e); } int cnt = 0; for (S subEntity : subEntities) { if (subEntity != null) { entity.put(cnt, subEntity); } cnt++; } return entity; }
/** * updates the timestamp if the schema has an 'updated' field * @param value */ private void setTimestamp(T value, String field) { Schema.Field f = value.getSchema().getField(field); if (f != null) { value.put(f.pos(), System.currentTimeMillis()); } }
@Override public void put(String field, Object value) { int fieldPos = specificRecord.getSchema().getField(field).pos(); specificRecord.put(fieldPos, value); }
@Override public void put(String field, Object value) { int fieldPos = specificRecord.getSchema().getField(field).pos(); specificRecord.put(fieldPos, value); }
@Override public void put(String field, Object value) { int fieldPos = specificRecord.getSchema().getField(field).pos(); specificRecord.put(fieldPos, value); }
public Row<T, K> clone() { Schema schema = value.getSchema(); T newvalue; try { newvalue = (T) Class.forName(schema.getFullName()).newInstance(); } catch (Exception e) { throw new AvroBaseException("Could not clone row", e); } for (Schema.Field field : schema.getFields()) { int pos = field.pos(); newvalue.put(pos, value.get(pos)); } return new Row<T, K>(newvalue, row, version); } }
private T getAvroObject(DBObject ro) { BasicDBObject vo = (BasicDBObject) ro.get("value"); Class c = SpecificData.get().getClass(readerSchema); T ao; try { ao = (T) c.newInstance(); for (Schema.Field field : readerSchema.getFields()) { String name = field.name(); Object v = vo.get(name); if (v instanceof byte[]) { v = ByteBuffer.wrap((byte[]) v); } ao.put(field.pos(), v); } } catch (Exception e) { throw new AvroBaseException("Could not create object", e); } return ao; }
if (fieldElement != null) { final Object fieldValue = fromJsonNode(fieldElement, field.schema()); record.put(field.pos(), fieldValue); } else if (field.defaultValue() != null) { record.put(field.pos(), fromJsonNode(field.defaultValue(), field.schema())); } else { throw new IOException(String.format(