ctubbsii commented on a change in pull request #492: fixes #467 cache file lengths URL: https://github.com/apache/accumulo/pull/492#discussion_r189289932
########## File path: core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java ########## @@ -281,17 +288,47 @@ public Reader(FileSystem fs, Path dataFile, Configuration conf, BlockCache data, this._bc = new BCFile.Reader(this, fsin, len, conf, accumuloConfiguration); } + private static long getFileLen(Cache<String,Long> fileLenCache, final FileSystem fs, + final Path path) throws IOException { + try { + return fileLenCache.get(path.getName(), new Callable<Long>() { + @Override + public Long call() throws Exception { + return fs.getFileStatus(path).getLen(); + } + }); + } catch (ExecutionException e) { + throw new IOException("Failed to get " + path + " len from cache ", e); + } + } + private synchronized BCFile.Reader getBCFile(AccumuloConfiguration accumuloConfiguration) throws IOException { if (closed) throw new IllegalStateException("File " + fileName + " is closed"); if (_bc == null) { // lazily open file if needed - Path path = new Path(fileName); + final Path path = new Path(fileName); + RateLimitedInputStream fsIn = new RateLimitedInputStream(fs.open(path), this.readLimiter); fin = fsIn; - init(fsIn, fs.getFileStatus(path).getLen(), conf, accumuloConfiguration); + + if (fileLenCache != null) { + try { Review comment: Would be good to handle a larger file, too. Sometimes users replace a corrupt file with a duplicate of another from the table. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services