build from InputStream supports

This commit is contained in:
lionsoul2014 2025-12-12 14:29:09 +08:00
parent e11a390afc
commit 6059d63504
1 changed files with 10 additions and 2 deletions

View File

@ -73,9 +73,17 @@ public class ConfigBuilder {
// you must know what you are doing. // you must know what you are doing.
throw new InvalidConfigException("SetXdbInputStream could ONLY be used with cachePolicy = Config.BufferCache"); throw new InvalidConfigException("SetXdbInputStream could ONLY be used with cachePolicy = Config.BufferCache");
} else { } else {
// 1, load the content buffer
final LongByteArray cBuffer = Searcher.loadContentFromInputStream(xdbInputStream);
// return new Config(cachePolicy, ipVersion, null, header, null, cBuffer, searchers); // 2, verify the xdb from the buffer
return null; Searcher.verify(Searcher.loadHeaderFromBuffer(cBuffer), cBuffer.length());
// 3, load the header
final Header header = Searcher.loadHeaderFromBuffer(cBuffer);
// create the config without xdbFile and vIndex
return new Config(cachePolicy, ipVersion, null, header, null, cBuffer, searchers);
} }
// load the header and the cache buffer // load the header and the cache buffer