@@ -234,6 +234,7 @@ class CHThorIndexReadActivityBase : public CHThorActivityBase
234234private:
235235 bool firstMultiPart ();
236236 bool nextMultiPart ();
237+ size32_t getPartBlockedIOSize (IDistributedFilePart &part) const ;
237238 bool setCurrentPart (unsigned whichPart);
238239 void clearTlk () { tlk.clear (); tlManager.clear (); }
239240 void openTlk ();
@@ -274,6 +275,7 @@ class CHThorIndexReadActivityBase : public CHThorActivityBase
274275 bool singlePart = false ; // a single part index, not part of a super file - optimize so never reload the part.
275276 bool localSortKey = false ;
276277 bool initializedFileInfo = false ;
278+ size32_t foreignBlockedIOSize = (size32_t )-1 ;
277279
278280// for layout translation
279281 Owned<const IDynamicTransform> layoutTrans;
@@ -330,6 +332,9 @@ void CHThorIndexReadActivityBase::resolveIndexFilename()
330332{
331333 // A logical filename for the key should refer to a single physical file - either the TLK or a monolithic key
332334 OwnedRoxieString lfn (helper.getFileName ());
335+ CDfsLogicalFileName dlfn;
336+ dlfn.set (lfn);
337+ foreignBlockedIOSize = dlfn.isForeign () ? getForeignBlockedIOSize (helper.hasSegmentMonitors ()) : (size32_t )-1 ;
333338 Owned<ILocalOrDistributedFile> ldFile = resolveLFNIndex (agent, lfn, " IndexRead" , 0 != (helper.getFlags () & TIRoptional),true , AccessMode::tbdRead, defaultPrivilegedUser);
334339 df.set (ldFile ? ldFile->queryDistributedFile () : NULL );
335340 if (!df)
@@ -452,7 +457,8 @@ bool CHThorIndexReadActivityBase::doPreopenLimitFile(unsigned __int64 & count, u
452457IKeyIndex * CHThorIndexReadActivityBase::doPreopenLimitPart (unsigned __int64 & result, unsigned __int64 limit, unsigned part)
453458{
454459 Owned<IKeyIndex> kidx;
455- kidx.setown (openKeyFile (df->queryPart (part)));
460+ IDistributedFilePart & filePart = df->queryPart (part);
461+ kidx.setown (openKeyFile (filePart, getPartBlockedIOSize (filePart)));
456462 if (df->numParts () == 1 )
457463 verifyIndex (kidx);
458464 if (limit != (unsigned ) -1 )
@@ -573,17 +579,20 @@ void CHThorIndexReadActivityBase::killPart()
573579 klManager.clear ();
574580}
575581
582+ size32_t CHThorIndexReadActivityBase::getPartBlockedIOSize (IDistributedFilePart &part) const
583+ {
584+ if (foreignBlockedIOSize != (size32_t )-1 )
585+ return foreignBlockedIOSize;
586+
587+ StringBuffer planeName;
588+ df->getClusterName (part.copyClusterNum (0 ), planeName);
589+ return getIndexBlockedIOSize (planeName, helper.hasSegmentMonitors ());
590+ }
591+
576592bool CHThorIndexReadActivityBase::setCurrentPart (unsigned whichPart)
577593{
578594 IDistributedFilePart &part = df->queryPart (whichPart);
579- size32_t blockedSize = 0 ;
580- if (!helper.hasSegmentMonitors ()) // unfiltered
581- {
582- StringBuffer planeName;
583- df->getClusterName (part.copyClusterNum (0 ), planeName);
584- blockedSize = getBlockedFileIOSize (planeName);
585- }
586- keyIndex.setown (openKeyFile (part, blockedSize));
595+ keyIndex.setown (openKeyFile (part, getPartBlockedIOSize (part)));
587596 if (df->numParts () == 1 )
588597 verifyIndex (keyIndex);
589598 initPart ();
0 commit comments