clintropolis commented on code in PR #19682:
URL: https://github.com/apache/druid/pull/19682#discussion_r3583764322


##########
server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerPartialRuleLoadTest.java:
##########
@@ -289,6 +291,101 @@ void 
testLoadEagerlyDownloadsBaseDependencyOfSelectedProjection() throws Excepti
     );
   }
 
+  @Test
+  void testLoadPartialReturnsDataSegmentAndLoadProfileWithRealizedBytes() 
throws Exception
+  {
+    // load() on the partial-load path returns a DataSegmentAndLoadProfile 
carrying a PartialLoadProfile.forLoaded with
+    // the actual on-disk footprint. Under a projection rule, that footprint 
is metadata header + rule-selected
+    // projection bundle + __base (transitive dependency pinned via the 
projection's parent-hold). Anything less
+    // would under-report to the coordinator: the historical downloads __base 
as part of the rule (see
+    // awaitEagerDownloadsOrClearRule's dep expansion), so its bytes belong in 
the announcement's loadedBytes.
+    manager = makeManager(true, true);
+    final StorageLocation location = manager.getLocations().get(0);
+
+    final DataSegment loaded = 
manager.load(partialWrapperSegment(List.of(AGG_BUNDLE)));
+
+    Assertions.assertInstanceOf(
+        DataSegmentAndLoadProfile.class,
+        loaded,
+        "load on the partial-rule path must return a DataSegmentAndLoadProfile 
so the announcer can report actual footprint"
+    );
+    final PartialLoadProfile profile = ((DataSegmentAndLoadProfile) 
loaded).profile();
+    Assertions.assertEquals(FINGERPRINT, profile.fingerprint(), "profile's 
fingerprint must match the applied rule");
+
+    // Sum the parts we expect: metadata + AGG_BUNDLE (rule-selected) + __base 
(transitive dep).
+    final PartialSegmentMetadataCacheEntry metadata = 
weakReservedMetadata(location, SEGMENT_ID);
+    final PartialSegmentBundleCacheEntry aggEntry = location.getCacheEntry(
+        new PartialSegmentBundleCacheEntryIdentifier(SEGMENT_ID, AGG_BUNDLE)
+    );
+    final PartialSegmentBundleCacheEntry baseEntry = location.getCacheEntry(
+        new PartialSegmentBundleCacheEntryIdentifier(SEGMENT_ID, 
Projections.BASE_TABLE_PROJECTION_NAME)
+    );
+    Assertions.assertNotNull(aggEntry, "rule-selected projection bundle should 
be present");
+    Assertions.assertNotNull(baseEntry, "transitive __base dependency should 
be present");
+    final long expectedRealizedBytes = metadata.getSize() + aggEntry.getSize() 
+ baseEntry.getSize();
+
+    Assertions.assertEquals(
+        Long.valueOf(expectedRealizedBytes),
+        profile.loadedBytes(),
+        "profile's loadedBytes must include metadata + rule-selected 
projection + __base dependency; missing any of "
+        + "these would under-report the on-disk footprint to the coordinator"
+    );
+    Assertions.assertTrue(
+        baseEntry.getSize() > 0,
+        "sanity check: __base's size should be non-zero (so the dep-inclusion 
assertion is meaningful)"
+    );
+  }
+  @Test
+  void testRealizedBytesIncludesPinnedBaseDependency() throws Exception
+  {
+    manager = makeManager(true, true);
+    final StorageLocation location = manager.getLocations().get(0);
+
+    manager.load(partialWrapperSegment(List.of(AGG_BUNDLE)));
+
+    final PartialSegmentMetadataCacheEntry metadata = 
weakReservedMetadata(location, SEGMENT_ID);
+    final long metadataBytes = metadata.getSize();
+    final long aggBytes = bundleEntry(location, AGG_BUNDLE).getSize();
+    final long baseBytes = bundleEntry(location, 
Projections.BASE_TABLE_PROJECTION_NAME).getSize();
+
+    Assertions.assertTrue(baseBytes > 0, "base dependency must occupy real 
on-disk bytes");
+
+    final long realized = metadata.getRealizedBytes();
+
+    Assertions.assertEquals(
+        metadataBytes + aggBytes + baseBytes,
+        realized,
+        String.format(

Review Comment:
   heh no worries, will fix up shortly 



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

Reply via email to