Skip to content

Commit dc533bc

Browse files
committed
trunk: bug-fix to table reading code that meant that when ,p option was used with scp: input, objects were re-read unnecessarily; this caused slowness in extract-segments (thanks to Yenda for noticing the problem).
git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@4895 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
1 parent c2b91ae commit dc533bc

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

‎src/util/kaldi-table-inl.h‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ class RandomAccessTableReaderScriptImpl:
13031303
"not-open object.";
13041304

13051305
if (!((state_ == kHaveObject || state_ == kGaveObject)
1306-
&& key == current_key_)) { // Not already stored...
1306+
&& key == current_key_)) { // Not already stored...
13071307
bool has_key = HasKeyInternal(key, true); // preload.
13081308
if (!has_key)
13091309
KALDI_ERR << "RandomAccessTableReader::Value(), could not get item for key "
@@ -1329,15 +1329,20 @@ class RandomAccessTableReaderScriptImpl:
13291329
}
13301330

13311331
private:
1332-
// HasKeyInternal when called with preload == false just tells us whether
1333-
// the key is in the scp. With preload == true, it will also check that
1334-
// we can preload the object from disk (loading from the rxfilename in
1335-
// the scp), and only return true if we can. This function is called
1336-
// both from HasKey and from Value().
1332+
// HasKeyInternal when called with preload == false just tells us whether the
1333+
// key is in the scp. With preload == true, which happens when the ,p
1334+
// (permissive) option is given in the rspecifier, it will also check that we
1335+
// can preload the object from disk (loading from the rxfilename in the scp),
1336+
// and only return true if we can. This function is called both from HasKey
1337+
// and from Value().
13371338
virtual bool HasKeyInternal(const std::string &key, bool preload) {
13381339
switch (state_) {
13391340
case kUninitialized: case kNotReadScript:
13401341
KALDI_ERR << "HasKey called on RandomAccessTableReader object that is not open.";
1342+
case kHaveObject: case kGaveObject:
1343+
if (key == current_key_)
1344+
return true;
1345+
break;
13411346
default: break;
13421347
}
13431348
KALDI_ASSERT(IsToken(key));

0 commit comments

Comments
 (0)