CurtHagenlocher commented on code in PR #39146:
URL: https://github.com/apache/arrow/pull/39146#discussion_r1420803430


##########
csharp/src/Apache.Arrow/Ipc/DictionaryMemo.cs:
##########
@@ -107,5 +116,47 @@ public void AddDeltaDictionary(long id, IArrowArray 
deltaDictionary, MemoryAlloc
             IArrowArray dictionary = ArrowArrayConcatenator.Concatenate(new 
List<IArrowArray>{ currentDictionary, deltaDictionary }, allocator);
             AddOrReplaceDictionary(id, dictionary);
         }
+
+        // Returns true if the corresponding dictionaries have been loaded
+        public bool CanLoad(long id)
+        {
+            IArrowType type = GetDictionaryType(id);
+            if (type is NestedType)
+            {
+                NestedTypeVisitor visitor = new NestedTypeVisitor(this);
+                type.Accept(visitor);
+                return visitor.CanLoad;
+            }
+
+            return true;
+        }
+
+        private sealed class NestedTypeVisitor : IArrowTypeVisitor<NestedType>
+        {
+            private readonly DictionaryMemo _memo;
+            public bool CanLoad { get; private set; }
+
+            public NestedTypeVisitor(DictionaryMemo memo)
+            {
+                _memo = memo;
+                CanLoad = true;
+            }
+
+            public void Visit(NestedType type)
+            {
+                foreach (Field field in type.Fields)
+                {
+                    if (field.DataType is DictionaryType && (
+                        !_memo._fieldToId.TryGetValue(field, out long id) ||
+                        !_memo._idToDictionary.TryGetValue(id, out IArrowArray 
array)))
+                    {
+                        CanLoad = false;
+                        break;
+                    }

Review Comment:
   Needs to visit children; there's clearly no test case with three levels of 
nested dictionaries...



-- 
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]

Reply via email to