Sample

int-a3038fed44be-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines49

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.610–1; higher is more readable
Dorn0.7290–1; higher is more readable
Mi0.5490–1; higher is more readable
LLOC14Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol190–20; mean of three runs
BTTF0.6130–1; higher is more readable

Views

Source code

package org.apache.kafka.streams.state.internals; import org.apache.kafka.common.utils.Bytes; import org.apache.kafka.streams.KeyValue; import org.apache.kafka.streams.kstream.Windowed; import org.apache.kafka.streams.state.KeyValueIterator; import static org.apache.kafka.streams.state.HeadersBytesStore.convertToHeaderFormat; /** * This class is used to ensure backward compatibility at DSL level between * {@link org.apache.kafka.streams.state.SessionStoreWithHeaders} and * {@link org.apache.kafka.streams.state.SessionStore}. * <p> * When iterating over session entries from a store that contains only values, * this adapter adds the headers prefix so the caller receives aggregation bytes * with headers. * * @see SessionToHeadersStoreAdapter */ class SessionToHeadersIteratorAdapter implements KeyValueIterator<Windowed<Bytes>, byte[]> { private final KeyValueIterator<Windowed<Bytes>, byte[]> innerIterator; SessionToHeadersIteratorAdapter(final KeyValueIterator<Windowed<Bytes>, byte[]> innerIterator) { this.innerIterator = innerIterator; } @Override public void close() { innerIterator.close(); } @Override public Windowed<Bytes> peekNextKey() { return innerIterator.peekNextKey(); } @Override public boolean hasNext() { return innerIterator.hasNext(); } @Override public KeyValue<Windowed<Bytes>, byte[]> next() { final KeyValue<Windowed<Bytes>, byte[]> keyValue = innerIterator.next(); if (keyValue == null) { return null; } return KeyValue.pair(keyValue.key, convertToHeaderFormat(keyValue.value)); } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.1421.457−46.908
Source linesThe number of non-empty source lines.49+19.6
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.754−7.131

Intercept 8.87 + feature contributions = -25.57 (log-odds).
Score = sigmoid(-25.57) = 0.

Score0.61

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.99.92+0.808
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.50−0.734
Indentation frequencyHow rapidly indentation changes from line to line.39+0.612
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.99.9−0.566
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.48.822+0.273
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.083+0.131

Intercept 0.07 + feature contributions = 0.991 (log-odds).
Score = sigmoid(0.991) = 0.729.

Score0.549
Score14
Run 1

The code is highly readable with clear structure and intent. The class serves a single purpose as a backward-compatibility adapter, and the Javadoc explains its role well. Nesting is minimal, code length is appropriate, and each method performs one action. The only minor issue is the null check in next(), which could be considered a slight defensive redundancy depending on the iterator contract, but it doesn't significantly impact readability.

Run 2

The code is well-structured and easy to read, with a clear purpose described in the Javadoc. The class is focused, with each method delegating to the inner iterator or performing a single transformation. Nesting is minimal, using only a simple null check. The action granularity is appropriate: each method does one thing, and the 'next' method separates retrieval, null check, and conversion into distinct steps. Variable names are expressive ('innerIterator', 'keyValue'), and the overall flow is natural. The only slight weakness is the repeated generic type declarations, which add verbosity but are unavoidable in Java. Overall, the code is concise, maintainable, and clearly conveys its intent.

Run 3

The code is well-structured and follows the Adapter pattern cleanly. It has flat nesting with only one level of conditional logic in the next() method. The purpose is clearly documented with a Javadoc explaining the backward compatibility intent. Methods are concise and delegate appropriately to the inner iterator. Each action is on its own line, and the reading flow is natural—constructor, close, peek, hasNext, then next. The only minor deductions are the null-check in next() which slightly obscures intent (though common for iterator adapters) and the lack of validation for the inner iterator parameter. Overall, this is highly readable code that would be easily understood by most Java developers.

Run 1

Code Structure: A small, cohesive adapter cleanly separates construction, iterator delegation, and value conversion. Nesting: Only one shallow conditional, with an early return keeping the main path flat. Clarity of intent: Descriptive class and method names plus focused documentation explain the compatibility purpose; convertToHeaderFormat clearly communicates the transformation. Code length: Concise, with little unnecessary code and appropriate interface boilerplate. Action granularity: Each statement performs one clear operation; the final return naturally combines conversion and pair construction. Reading flow: Methods follow a straightforward sequence, and next() reads naturally from retrieval to null handling to conversion. Minor formatting improvements, such as blank lines separating the package declaration and import groups, would improve visual organization.

Run 2

Code Structure: A well-organized iterator adapter cleanly separates delegation from value conversion. Nesting: Minimal nesting, with a single guard clause keeping next() easy to follow. Clarity of intent: Descriptive class and method names, explicit types, and useful documentation clearly explain the compatibility purpose. Code length: Concise implementation with no unnecessary logic; delegation methods are appropriate boilerplate. Action granularity: Each statement performs one clear action, and the final return naturally combines conversion with result construction. Reading flow: Constructor, delegation methods, and conversion logic form a predictable sequence. Minor formatting improvements, such as blank lines separating the package declaration and import groups, would improve visual readability.

Run 3

Code Structure: A well-organized adapter with a single responsibility and clearly separated methods. Nesting: Almost entirely flat, with only a simple null-check guard. Clarity of intent: Descriptive class and field names, explicit delegation, and useful documentation explain the compatibility purpose and value conversion. Code length: Concise, with minimal boilerplate required by the iterator interface. Action granularity: Each statement performs one clear action; the final return naturally combines conversion with result construction. Reading flow: The constructor, delegated methods, and transforming next() method follow a coherent sequence. Minor formatting improvements, such as separating the package declaration and import groups with blank lines, would improve scanning.