Skip to content

Commit

Permalink
Remove RequiredOptionReader.
Browse files Browse the repository at this point in the history
  • Loading branch information
rdblue committed Jan 1, 2024
1 parent 16e734b commit 03a81cf
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions core/src/main/java/org/apache/iceberg/avro/ValueReaders.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ public static ValueReader<Object> union(List<ValueReader<?>> readers) {
return new UnionReader(readers);
}

public static ValueReader<Object> optionalAsRequired(List<ValueReader<?>> readers, String name) {
return new RequiredOptionReader(name, readers);
}

public static ValueReader<Long> positions() {
return new PositionReader();
}
Expand Down Expand Up @@ -557,40 +553,6 @@ public void skip(Decoder decoder) throws IOException {
}
}

private static class RequiredOptionReader implements ValueReader<Object> {
private final String name;
private final ValueReader<?>[] readers;

private RequiredOptionReader(String name, List<ValueReader<?>> readers) {
this.name = name;
this.readers = new ValueReader[readers.size()];
for (int i = 0; i < this.readers.length; i += 1) {
this.readers[i] = readers.get(i);
}
}

@Override
public Object read(Decoder decoder, Object reuse) throws IOException {
int index = decoder.readIndex();
return checkNonNull(readers[index].read(decoder, reuse));
}

@Override
public void skip(Decoder decoder) throws IOException {
int index = decoder.readIndex();
readers[index].skip(decoder);
}

private Object checkNonNull(Object value) {
if (null == value) {
throw new NullPointerException(
String.format("Read a null value in required field: %s", name));
}

return value;
}
}

private static class UnionReader implements ValueReader<Object> {
private final ValueReader[] readers;

Expand Down

0 comments on commit 03a81cf

Please sign in to comment.