Package eu.stratosphere.core.fs

Examples of eu.stratosphere.core.fs.FileInputSplit


   
    if (!(split instanceof FileInputSplit)) {
      throw new IllegalArgumentException("File Input Formats can only be used with FileInputSplits.");
    }
   
    final FileInputSplit fileSplit = (FileInputSplit) split;
   
    this.splitStart = fileSplit.getStart();
    this.splitLength = fileSplit.getLength();

    if (LOG.isDebugEnabled()) {
      LOG.debug("Opening input split " + fileSplit.getPath() + " [" + this.splitStart + "," + this.splitLength + "]");
    }

   
    // open the split in an asynchronous thread
    final InputSplitOpenThread isot = new InputSplitOpenThread(fileSplit, this.openTimeout);
    isot.start();
   
    try {
      this.stream = isot.waitForCompletion();
      // Wrap stream in a extracting (decompressing) stream if file ends with .deflate.
      if(fileSplit.getPath().getName().endsWith(DEFLATE_SUFFIX)) {
        this.stream = new InflaterInputStreamFSInputWrapper(stream);
      }
     
    }
    catch (Throwable t) {
      throw new IOException("Error opening the Input Split " + fileSplit.getPath() +
          " [" + splitStart + "," + splitLength + "]: " + t.getMessage(), t);
    }
   
    // get FSDataInputStream
    if (this.splitStart != 0) {
View Full Code Here


  }

  @Test
  public void testOpen() throws IOException {
    final String myString = "my mocked line 1\nmy mocked line 2\n";
    final FileInputSplit split = createTempFile(myString)
   
    int bufferSize = 5;
    format.setBufferSize(bufferSize);
    format.open(split);
    assertEquals(0, format.splitStart);
View Full Code Here

  }

  @Test
  public void testRead() throws IOException {
    final String myString = "my key|my val$$$my key2\n$$ctd.$$|my value2";
    final FileInputSplit split = createTempFile(myString);
   
    final Configuration parameters = new Configuration();
   
    format.setDelimiter("$$$");
    format.configure(parameters);
View Full Code Here

 
  @Test
  public void testRead2() throws IOException {
    // 2. test case
    final String myString = "my key|my val$$$my key2\n$$ctd.$$|my value2";
    final FileInputSplit split = createTempFile(myString);
   
    final Configuration parameters = new Configuration();
    // default delimiter = '\n'
   
    format.configure(parameters);
View Full Code Here

   
    OutputStreamWriter wrt = new OutputStreamWriter(new FileOutputStream(this.tempFile));
    wrt.write(contents);
    wrt.close();
   
    return new FileInputSplit(0, new Path(this.tempFile.toURI().toString()), 0, this.tempFile.length(), new String[] {"localhost"});
  }
View Full Code Here

    final FileSystem fs = FileSystem.get(normalizedPath.toUri());
    FileStatus fileStatus = fs.getFileStatus(normalizedPath);

    BlockLocation[] blocks = fs.getFileBlockLocations(fileStatus, 0, fileStatus.getLen());
    inputFormat.open(new FileInputSplit(0, new Path(path), 0, fileStatus.getLen(), blocks[0].getHosts()));
    return inputFormat;
  }
View Full Code Here

        // get the block locations and make sure they are in order with respect to their offset
        final BlockLocation[] blocks = fs.getFileBlockLocations(file, pos, remainingLength);
        Arrays.sort(blocks);

        inputSplits.add(new FileInputSplit(inputSplits.size(), file.getPath(), pos, remainingLength,
          blocks[0].getHosts()));
      }
    }

    if (inputSplits.size() < minNumSplits) {
      LOG.warn(String.format(
        "With the given block size %d, the file %s cannot be split into %d blocks. Filling up with empty splits...",
        blockSize, this.filePath, minNumSplits));
      FileStatus last = files.get(files.size() - 1);
      final BlockLocation[] blocks = fs.getFileBlockLocations(last, 0, last.getLen());
      for (int index = files.size(); index < minNumSplits; index++) {
        inputSplits.add(new FileInputSplit(index, last.getPath(), last.getLen(), 0, blocks[0].getHosts()));
      }
    }

    return inputSplits.toArray(new FileInputSplit[0]);
  }
View Full Code Here

      // take the samples
      while (samplesTaken < numSamples && fileNum < allFiles.size()) {
        // make a split for the sample and use it to read a record
        FileStatus file = allFiles.get(fileNum);
        FileInputSplit split = new FileInputSplit(0, file.getPath(), offset, file.getLen() - offset, null);

        // we open the split, read one line, and take its length
        try {
          open(split);
          if (readLine()) {
View Full Code Here

TOP

Related Classes of eu.stratosphere.core.fs.FileInputSplit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.