clintropolis commented on code in PR #19072:
URL: https://github.com/apache/druid/pull/19072#discussion_r2880083009
##########
processing/src/main/java/org/apache/druid/segment/nested/NestedDataColumnSupplier.java:
##########
@@ -268,4 +312,87 @@ public <T> T as(Class<T> clazz)
}
return null;
}
+
+ @VisibleForTesting
+ public static class FieldsFixupIndexed implements Indexed<ByteBuffer>
+ {
+ private final Indexed<ByteBuffer> delegate;
+ private final Int2ObjectMap<ByteBuffer> fixup;
+
+ private FieldsFixupIndexed(Indexed<ByteBuffer> delegate,
Int2ObjectMap<ByteBuffer> fixup)
+ {
+ this.delegate = delegate;
+ this.fixup = fixup;
+ }
+
+ @Override
+ public int size()
+ {
+ return delegate.size();
+ }
+
+ @Nullable
+ @Override
+ public ByteBuffer get(int index)
+ {
+ if (fixup.containsKey(index)) {
+ return fixup.get(index).asReadOnlyBuffer();
+ }
+ return delegate.get(index);
+ }
+
+ @Override
+ public int indexOf(@Nullable ByteBuffer value)
+ {
+ for (Int2ObjectMap.Entry<ByteBuffer> entry : fixup.int2ObjectEntrySet())
{
+ if (entry.getValue().equals(value)) {
+ return entry.getIntKey();
+ }
+ }
+ return delegate.indexOf(value);
+ }
+
+ @Nonnull
+ @Override
+ public Iterator<ByteBuffer> iterator()
+ {
+ return new Iterator<>()
+ {
+ int pos = 0;
+ final int size = delegate.size();
+ final Iterator<ByteBuffer> delegateIterator = delegate.iterator();
+
+ @Override
+ public boolean hasNext()
+ {
+ return pos < size;
+ }
+
+ @Override
+ public ByteBuffer next()
+ {
+ if (fixup.containsKey(pos)) {
+ // move delegate iterator forward, but we're going to return our
own value
+ delegateIterator.next();
+ // this is sad, but downstream stuff wants ByteBuffer, and is less
sad than the original bug
+ return fixup.get(pos++).asReadOnlyBuffer();
+ }
+ pos++;
+ return delegateIterator.next();
+ }
+ };
+ }
+
+ @Override
+ public boolean isSorted()
+ {
+ return delegate.isSorted();
Review Comment:
nope, good catch, removed this since we can't guarantee it and added note in
javadocs about it not mattering
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]