}
// Field by field deserialization
for(int index = 0; index < schema.getFields().size(); index++) {
Deserializer customDeser = customDeserializers[index];
Field field = schema.getField(index);
// Nulls control
if(field.isNullable() && nullsAbsolute.flags[index]) {
// Null field. Nothing to deserialize.
continue;
}
/*
* If we configured the Deserializer to use two Schemas,
* this will give us the real index for the destination Tuple.
* If it gives "UNUSED" it means the field being read is not used.
* We will deal with this depending on wether we read a primitive field or
* a complex data type.
*/
int idx = backwardsCompatibleIndex(index);
switch(field.getType()) {
case INT:
int iVal = WritableUtils.readVInt(input);
if(idx != UNUSED) {
tuple.set(idx, iVal);
} // If the primitive field is not used we just don't set it
break;
case LONG:
long lVal = WritableUtils.readVLong(input);
if(idx != UNUSED) {
tuple.set(idx, lVal);
} // If the primitive field is not used we just don't set it
break;
case DOUBLE:
double dVal = input.readDouble();
if(idx != UNUSED) {
tuple.set(idx, dVal);
} // If the primitive field is not used we just don't set it
break;
case FLOAT:
float fVal = input.readFloat();
if(idx != UNUSED) {
tuple.set(idx, fVal);
} // If the primitive field is not used we just don't set it
break;
case STRING:
if(idx == UNUSED) {
// The field is unused so we use a private cached Tuple for skipping its bytes
readUtf8(input, cachedReadTuple(), index);
} else {
readUtf8(input, tuple, idx);
}
break;
case BOOLEAN:
byte b = input.readByte();
if(idx != UNUSED) {
tuple.set(idx, (b != 0));
} // If the primitive field is not used we just don't set it
break;
case ENUM:
if(idx == UNUSED) {
// The field is unused so we use a private cached Tuple for skipping its bytes
readEnum(input, cachedReadTuple(), field.getObjectClass(), index);
} else {
readEnum(input, tuple, field.getObjectClass(), idx);
}
break;
case BYTES:
if(idx == UNUSED) {
// The field is unused so we use a private cached Tuple for skipping its bytes
readBytes(input, cachedReadTuple(), index);
} else {
readBytes(input, tuple, idx);
}
break;
case OBJECT:
if(idx == UNUSED) {
// The field is unused so we use a private cached Tuple for skipping its bytes
readCustomObject(input, cachedReadTuple(), field.getObjectClass(), index, customDeser);
} else {
readCustomObject(input, tuple, field.getObjectClass(), idx, customDeser);
}
break;
default:
throw new IOException("Not supported type:" + field.getType());
}
}
}