accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] keith-turner commented on a change in pull request #604: Greatly simplify FileOperations
Date Thu, 16 Aug 2018 15:53:41 GMT
keith-turner commented on a change in pull request #604: Greatly simplify FileOperations
URL: https://github.com/apache/accumulo/pull/604#discussion_r210632005
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/file/FileOperations.java
 ##########
 @@ -234,283 +207,314 @@ public FileSystem getFileSystem() {
       return fs;
     }
 
-    protected void setConfiguration(Configuration fsConf) {
-      this.fsConf = fsConf;
-    }
-
     public Configuration getConfiguration() {
       return fsConf;
     }
 
-    public AccumuloConfiguration getTableConfiguration() {
-      return tableConfiguration;
+    public RateLimiter getRateLimiter() {
+      return rateLimiter;
     }
 
-    /** Check for null parameters. */
-    protected void validate() {
-      Objects.requireNonNull(getFilename());
-      Objects.requireNonNull(getFileSystem());
-      Objects.requireNonNull(getConfiguration());
-      Objects.requireNonNull(getTableConfiguration());
+    public String getCompression() {
+      return compression;
     }
-  }
 
-  /** Builder interface parallel to {@link FileAccessOperation}. */
-  protected interface FileAccessOperationBuilder<SubbuilderType> extends NeedsFile<SubbuilderType>,
-      NeedsFileSystem<SubbuilderType>, NeedsTableConfiguration<SubbuilderType>
{
-    // no optional/generic methods.
-  }
+    public FSDataOutputStream getOutputStream() {
+      return outputStream;
+    }
 
-  /**
-   * Operation object for performing {@code getFileSize()} operations.
-   */
-  protected class GetFileSizeOperation extends FileAccessOperation<GetFileSizeOperation>
-      implements GetFileSizeOperationBuilder {
-    /** Return the size of the file. */
-    @Override
-    public long execute() throws IOException {
-      validate();
-      return getFileSize(this);
+    public boolean isAccumuloStartEnabled() {
+      return enableAccumuloStart;
     }
-  }
 
-  /**
-   * Builder interface for {@link GetFileSizeOperation}, allowing execution of {@code getFileSize()}
-   * operations.
-   */
-  public interface GetFileSizeOperationBuilder
-      extends FileAccessOperationBuilder<GetFileSizeOperationBuilder> {
-    /** Return the size of the file. */
-    long execute() throws IOException;
+    public BlockCache getDataCache() {
+      return dataCache;
+    }
+
+    public BlockCache getIndexCache() {
+      return indexCache;
+    }
+
+    public Cache<String,Long> getFileLenCache() {
+      return fileLenCache;
+    }
+
+    public boolean isSeekToBeginning() {
+      return seekToBeginning;
+    }
+
+    public CryptoService getCryptoService() {
+      return cryptoService;
+    }
+
+    public Range getRange() {
+      return range;
+    }
+
+    public Set<ByteSequence> getColumnFamilies() {
+      return columnFamilies;
+    }
+
+    public boolean isRangeInclusive() {
+      return inclusive;
+    }
   }
 
   /**
-   * Options common to all {@code FileOperation}s which perform reading or writing.
+   * Helper class extended by both writers and readers.
    */
-  protected static class FileIOOperation<SubclassType extends FileIOOperation<SubclassType>>
-      extends FileAccessOperation<SubclassType> {
-    private RateLimiter rateLimiter;
+  public class FileHelper {
+    protected AccumuloConfiguration tableConfiguration;
+    protected String filename;
+    protected FileSystem fs;
+    protected Configuration fsConf;
+    protected RateLimiter rateLimiter;
+
+    protected FileHelper fs(FileSystem fs) {
+      Objects.requireNonNull(fs);
+      this.fs = fs;
+      return this;
+    }
+
+    protected FileHelper fsConf(Configuration fsConf) {
+      Objects.requireNonNull(fsConf);
+      this.fsConf = fsConf;
 
 Review comment:
   These two lines could be written as one line ` this.fsConf = Objects.requireNonNull(fsConf)`

----------------------------------------------------------------
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

Mime
View raw message