test_class.file: smart-hadoop-support/smart-hadoop/src/test/java/org/smartdata/hdfs/action/TestMergeFileAction.java
test_class.identifier: TestMergeFileAction
test_class.superclass: extends MiniClusterHarness
test_case.body: @Test
    public void testLocalFileMerge() throws Exception {
      final String srcPath = "/testMerge";
      final String file1 = "file1";
      final String file2 = "file2";
      final String target = "/target";
  
      dfs.mkdirs(new Path(srcPath));
      dfs.mkdirs(new Path(target));
      //write to DISK
      //write 40 Bytes to file1 and 50 Byte to file2. then concat them
      FSDataOutputStream out1 = dfs.create(new Path(srcPath + "/" + file1));
      for (int i = 0; i < 60; i++) {
        out1.writeByte(1);
      }
      out1.close();
  
      out1 = dfs.create(new Path(srcPath + "/" + file2));
      for (int i = 0; i < 50; i++) {
        out1.writeByte(2);
      }
      out1.close();
  
      MergeFileAction mergeFileAction = new MergeFileAction();
      mergeFileAction.setDfsClient(dfsClient);
      mergeFileAction.setContext(smartContext);
      Map<String, String> args = new HashMap<>();
      args.put(MergeFileAction.FILE_PATH, srcPath + "/" +
          file1 + "," + dfs.getUri() + srcPath + "/" + "file2");
      args.put(MergeFileAction.DEST_PATH, target);
      mergeFileAction.init(args);
      mergeFileAction.run();
  
      Assert.assertTrue(mergeFileAction.getExpectedAfterRun());
      Assert.assertTrue(dfsClient.exists(target));
      //read and check file
      FSDataInputStream in = dfs.open(new Path(target),50);
      for (int i = 0; i < 60; i++) {
        Assert.assertTrue(in.readByte() == 1);
      }
      for (int i = 0; i < 50; i++) {
        Assert.assertTrue(in.readByte() == 2);
      }
    }
test_case.class_method_signature: TestMergeFileAction.testLocalFileMerge()
test_case.full_signature: @Test public void testLocalFileMerge()
test_case.identifier: testLocalFileMerge
test_case.invocations: mkdirs mkdirs create writeByte close create writeByte close setDfsClient setContext put getUri put init run assertTrue getExpectedAfterRun assertTrue exists open assertTrue readByte assertTrue readByte
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testLocalFileMerge()
focal_class.declarator: LOG = LoggerFactory.getLogger(MergeFileAction.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(MergeFileAction.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: DEST_PATH = "-dest"
focal_class.modifier: public static final
focal_class.original_string: public static final String DEST_PATH = "-dest";
focal_class.type: String
focal_class.var_name: DEST_PATH
focal_class.declarator: BUF_SIZE = "-bufSize"
focal_class.modifier: public static final
focal_class.original_string: public static final String BUF_SIZE = "-bufSize";
focal_class.type: String
focal_class.var_name: BUF_SIZE
focal_class.declarator: srcPathList
focal_class.modifier: private
focal_class.original_string: private LinkedList<String> srcPathList;
focal_class.type: LinkedList<String>
focal_class.var_name: srcPathList
focal_class.declarator: bufferSize = 64 * 1024
focal_class.modifier: private
focal_class.original_string: private int bufferSize = 64 * 1024;
focal_class.type: int
focal_class.var_name: bufferSize
focal_class.declarator: target
focal_class.modifier: private
focal_class.original_string: private String target;
focal_class.type: String
focal_class.var_name: target
focal_class.file: smart-hadoop-support/smart-hadoop/src/main/java/org/smartdata/hdfs/action/MergeFileAction.java
focal_class.identifier: MergeFileAction
focal_class.class_method_signature: MergeFileAction.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: MergeFileAction.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: MergeFileAction.mergeFiles(LinkedList<String> srcFiles, String dest)
focal_class.full_signature: private boolean mergeFiles(LinkedList<String> srcFiles, String dest)
focal_class.identifier: mergeFiles
focal_class.modifiers: private
focal_class.parameters: (LinkedList<String> srcFiles, String dest)
focal_class.return: boolean
focal_class.signature: boolean mergeFiles(LinkedList<String> srcFiles, String dest)
focal_class.class_method_signature: MergeFileAction.getSourceInputStream(String src)
focal_class.full_signature: private InputStream getSourceInputStream(String src)
focal_class.identifier: getSourceInputStream
focal_class.modifiers: private
focal_class.parameters: (String src)
focal_class.return: InputStream
focal_class.signature: InputStream getSourceInputStream(String src)
focal_class.class_method_signature: MergeFileAction.getTargetOutputStream(String dest)
focal_class.full_signature: private OutputStream getTargetOutputStream(String dest)
focal_class.identifier: getTargetOutputStream
focal_class.modifiers: private
focal_class.parameters: (String dest)
focal_class.return: OutputStream
focal_class.signature: OutputStream getTargetOutputStream(String dest)
focal_class.superclass: extends HdfsAction
focal_method.body: @Override
    public void init(Map<String, String> args) {
      super.init(args);
      String allSrcPath = args.get(FILE_PATH);
  
      String[] allSrcPathArr = allSrcPath.split(",");
      srcPathList = new LinkedList<String>(Arrays.asList(allSrcPathArr));
  
      if (args.containsKey(DEST_PATH)) {
        this.target = args.get(DEST_PATH);
      }
      if (args.containsKey(BUF_SIZE)) {
        bufferSize = Integer.valueOf(args.get(BUF_SIZE));
      }
    }
focal_method.class_method_signature: MergeFileAction.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 get split asList containsKey get containsKey valueOf 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)