Skip to content

[performance][memory] String copy on hot path #3477

Description

@chernser

Description

getString of the binary format readers sends the value of a String column through DataTypeConverter.stringToString. The method made a StringBuilder, copied the text into it and made a new String from it: three allocations and two copies for each call. For a column that is not an array the result is equal to the text that the method started with.

This PR changes stringToString so that it finds the text first and makes a StringBuilder, with the correct size, only when it adds the quotes for an array column.

  • A String value is returned as it is.
  • A StringValue (the client reads strings as raw bytes) gives the String that the StringValue keeps.
  • A CharSequence, a byte[] and other objects are converted one time, without the StringBuilder.
  • The quoted form for an array column is the same text as before.

More in #3473

Activity

  1. added this to the 0.12.0 milestone on Dec 1, 2026
  2. added
    client
    on Dec 1, 2026
  3. added
    data-types
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clientdata-typesperformance

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions