Skip to content

Commit

Permalink
Optimized fastserde enum field deserialization (#500)
Browse files Browse the repository at this point in the history
BUG=FI-13182
Closes #302

Optimize enum field deserialization #499
  • Loading branch information
kcepmada authored Jul 14, 2023
1 parent accc9ed commit ebfd273
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.linkedin.avro.fastserde.primitive.PrimitiveFloatArrayList;
import com.linkedin.avro.fastserde.primitive.PrimitiveIntArrayList;
import com.linkedin.avro.fastserde.primitive.PrimitiveLongArrayList;
import com.linkedin.avroutil1.Enums;
import com.linkedin.avroutil1.compatibility.AvroCompatibilityHelper;
import com.sun.codemodel.JBlock;
import com.sun.codemodel.JClass;
Expand Down Expand Up @@ -463,7 +464,8 @@ public JExpression getEnumValueByIndex(Schema enumSchema, JExpression indexExpr,
.arg(getSchemaExpr.invoke("getEnumSymbols").invoke("get").arg(indexExpr));
}
} else {
return codeModel.ref(AvroCompatibilityHelper.getSchemaFullName(enumSchema)).staticInvoke("values").component(indexExpr);
JClass enumClass = codeModel.ref(AvroCompatibilityHelper.getSchemaFullName(enumSchema));
return codeModel.ref(Enums.class).staticInvoke("getConstant").arg(enumClass.dotclass()).arg(indexExpr);
}
}

Expand Down

0 comments on commit ebfd273

Please sign in to comment.