Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

JsonToProtoMessage refactoring #2042

@arturowczarek

Description

@arturowczarek

I read through JsonToProtoMessage and would like refactor it as my first contribution. I'd like to know your opinion about the proposed changes and ask for some explanations.

  1. All the fields should be final and CAPITALIZED (they are all deeply constant)
  2. We should migrate from import org.threeten.bp to java.time. This would require migration of com.google.cloud.bigquery.storage.v1.CivilTimeEncoder. As we support Java 8, we should not need it anymore.
  3. Code like /*ignoreUnknownFields*/ false should be replaced with DONT_IGNORE_UNKNOWN_FIELDS field
  4. The topLevel parameter should be removed
  5. fillField and filRepeatedField switch options should be extracted into methods. And even divided more to help JIT optimise the code.
  6. The failing mechanism in fillRepeatedField should be replaced with throwing exception immediately. Otherwise one may think something can happen along the way to fix the situation. The call should be extracted into method
  7. Two variants of convertJsonToProtoMessage method should be removed as they are used only in tests. The conversion should not support null in TableFieldSchema and FieldDescriptor. I think there is no case when it happens except tests. Is there? If yes, then it should be marked @Nullable
  8. Comparing "true" with toLowerCase() should be replaced by equalsIgnoreCase()
  9. The test should not use asterisks for imports
  10. We should prefer for(X x: xs) over for (int i = 0; i < xs.length; i++) {X x = xs[i];}
  11. The JsonDataHasUnknownFieldException should not be final and have protected constructor at the same time. It should be renamed to DataHasUnknownFieldException to be used by developers for other transformers.
  12. Should we support conversion from JSON strings to booleans, ints, etc.?
  13. Should we allow each element on the list to be of different type? Now it is allowed for some elements in the list to be "true" and some can be true.
  14. For nested fields, there is no need to create additional message builder and ignoring it immediately. Is there?
  15. There is no need to repeatedly check field descriptor type for repeated fields. The loop should be inside of each case. We can further optimise by checking the type of the first element on the list and assume all the files are of the same type.

Please tell me what you think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: bigquerystorageIssues related to the googleapis/java-bigquerystorage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions