You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/05/18 13:46:35 UTC

[GitHub] keith-turner commented on a change in pull request #492: fixes #467 cache file lengths

keith-turner commented on a change in pull request #492: fixes #467 cache file lengths
URL: https://github.com/apache/accumulo/pull/492#discussion_r189273493
 
 

 ##########
 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:
   @ctubbsii this code is meant to handle the case you asked about of replacing a file with an empty file.   When using the cache it tries to open the file and if that fails, it clears the cache and tries again.  However  I have not tested this yet.  Plan to test this today.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services