test_class.file: smart-hadoop-support/smart-hadoop/src/test/java/org/smartdata/hdfs/action/TestSmallFileCompactAction.java
test_class.identifier: TestSmallFileCompactAction
test_class.superclass: extends MiniClusterHarness
test_case.body: @Test
    public void testAction() throws Exception {
      Path path = new Path("/test/small_files/");
      dfs.mkdirs(path);
      long sumFileLen = 0L;
      List<String> smallFileList = new ArrayList<>();
      for (int i = 0; i < 3; i++) {
        String fileName = "/test/small_files/file_" + i;
        FSDataOutputStream out = dfs.create(new Path(fileName), (short) 1);
        long fileLen = 10 + (int) (Math.random() * 11);
        byte[] buf = new byte[20];
        Random rb = new Random(2018);
        int bytesRemaining = (int) fileLen;
        while (bytesRemaining > 0) {
          rb.nextBytes(buf);
          int bytesToWrite = (bytesRemaining < buf.length) ? bytesRemaining : buf.length;
          out.write(buf, 0, bytesToWrite);
          bytesRemaining -= bytesToWrite;
        }
        out.close();
        sumFileLen += fileLen;
        smallFileList.add(fileName);
      }
  
      Assert.assertTrue(dfsClient.exists("/test/small_files/file_0"));
      Assert.assertTrue(dfsClient.exists("/test/small_files/file_1"));
      Assert.assertTrue(dfsClient.exists("/test/small_files/file_2"));
  
      SmallFileCompactAction smallFileCompactAction = new SmallFileCompactAction();
      smallFileCompactAction.setDfsClient(dfsClient);
      smallFileCompactAction.setContext(smartContext);
      Map<String , String> args = new HashMap<>();
      args.put(SmallFileCompactAction.FILE_PATH , new Gson().toJson(smallFileList));
      args.put(SmallFileCompactAction.CONTAINER_FILE, "/test/small_files/container_file");
      smallFileCompactAction.init(args);
      smallFileCompactAction.run();
      Assert.assertTrue(dfsClient.exists("/test/small_files/container_file"));
      HdfsFileStatus containerFileInfo = dfsClient.getFileInfo(
          "/test/small_files/container_file");
      Assert.assertEquals(sumFileLen, containerFileInfo.getLen());
    }
test_case.class_method_signature: TestSmallFileCompactAction.testAction()
test_case.full_signature: @Test public void testAction()
test_case.identifier: testAction
test_case.invocations: mkdirs create random nextBytes write close add assertTrue exists assertTrue exists assertTrue exists setDfsClient setContext put toJson put init run assertTrue exists getFileInfo assertEquals getLen
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testAction()
focal_class.declarator: status = 0f
focal_class.modifier: private
focal_class.original_string: private float status = 0f;
focal_class.type: float
focal_class.var_name: status
focal_class.declarator: conf = null
focal_class.modifier: private
focal_class.original_string: private Configuration conf = null;
focal_class.type: Configuration
focal_class.var_name: conf
focal_class.declarator: smallFiles = null
focal_class.modifier: private
focal_class.original_string: private String smallFiles = null;
focal_class.type: String
focal_class.var_name: smallFiles
focal_class.declarator: containerFile = null
focal_class.modifier: private
focal_class.original_string: private String containerFile = null;
focal_class.type: String
focal_class.var_name: containerFile
focal_class.declarator: containerFilePermission = null
focal_class.modifier: private
focal_class.original_string: private String containerFilePermission = null;
focal_class.type: String
focal_class.var_name: containerFilePermission
focal_class.declarator: xAttrName = null
focal_class.modifier: private
focal_class.original_string: private String xAttrName = null;
focal_class.type: String
focal_class.var_name: xAttrName
focal_class.declarator: CONTAINER_FILE = "-containerFile"
focal_class.modifier: public static final
focal_class.original_string: public static final String CONTAINER_FILE = "-containerFile";
focal_class.type: String
focal_class.var_name: CONTAINER_FILE
focal_class.declarator: CONTAINER_FILE_PERMISSION = "-containerFilePermission"
focal_class.modifier: public static final
focal_class.original_string: public static final String CONTAINER_FILE_PERMISSION = "-containerFilePermission";
focal_class.type: String
focal_class.var_name: CONTAINER_FILE_PERMISSION
focal_class.file: smart-hadoop-support/smart-hadoop/src/main/java/org/smartdata/hdfs/action/SmallFileCompactAction.java
focal_class.identifier: SmallFileCompactAction
focal_class.class_method_signature: SmallFileCompactAction.init(Map<String, String> args)
focal_class.full_signature: @Override public void init(Map<String, String> args)
focal_class.identifier: init
focal_class.modifiers: @Override public
focal_class.parameters: (Map<String, String> args)
focal_class.return: void
focal_class.signature: void init(Map<String, String> args)
focal_class.class_method_signature: SmallFileCompactAction.execute()
focal_class.full_signature: @Override protected void execute()
focal_class.identifier: execute
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void execute()
focal_class.class_method_signature: SmallFileCompactAction.truncateAndSetXAttr(String path, CompactFileState compactFileState)
focal_class.full_signature: private void truncateAndSetXAttr(String path, CompactFileState compactFileState)
focal_class.identifier: truncateAndSetXAttr
focal_class.modifiers: private
focal_class.parameters: (String path, CompactFileState compactFileState)
focal_class.return: void
focal_class.signature: void truncateAndSetXAttr(String path, CompactFileState compactFileState)
focal_class.class_method_signature: SmallFileCompactAction.getCheckSumByteArray(String path, long length)
focal_class.full_signature: private byte[] getCheckSumByteArray(String path, long length)
focal_class.identifier: getCheckSumByteArray
focal_class.modifiers: private
focal_class.parameters: (String path, long length)
focal_class.return: byte[]
focal_class.signature: byte[] getCheckSumByteArray(String path, long length)
focal_class.class_method_signature: SmallFileCompactAction.getProgress()
focal_class.full_signature: @Override public float getProgress()
focal_class.identifier: getProgress
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: float
focal_class.signature: float getProgress()
focal_class.superclass: extends HdfsAction
focal_method.body: @Override
    public void init(Map<String, String> args) {
      super.init(args);
      this.conf = getContext().getConf();
      this.xAttrName = SmartConstants.SMART_FILE_STATE_XATTR_NAME;
      this.smallFiles = args.get(FILE_PATH);
      this.containerFile = args.get(CONTAINER_FILE);
      this.containerFilePermission = args.get(CONTAINER_FILE_PERMISSION);
    }
focal_method.class_method_signature: SmallFileCompactAction.init(Map<String, String> args)
focal_method.full_signature: @Override public void init(Map<String, String> args)
focal_method.identifier: init
focal_method.invocations: init getConf getContext get get get
focal_method.modifiers: @Override public
focal_method.parameters: (Map<String, String> args)
focal_method.return: void
focal_method.signature: void init(Map<String, String> args)