Package eu.stratosphere.core.fs

Examples of eu.stratosphere.core.fs.FileInputSplit


    final long splitLength = inFile.length() / noSplits;
    long pos = 0;

    for (int i = 0; i < noSplits - 1; i++) {
      tmp[i] = new FileInputSplit(i, new Path(path), pos, splitLength, hosts);
      pos += splitLength;
    }

    tmp[noSplits - 1] = new FileInputSplit(noSplits - 1, new Path(path), pos, inFile.length() - pos, hosts);

    this.inputSplits = tmp;
  }
View Full Code Here


        while (bytesUnassigned > maxBytesForLastSplit) {
          // get the block containing the majority of the data
          blockIndex = getBlockIndexForPosition(blocks, position, halfSplit, blockIndex);
          // create a new split
          final FileInputSplit fis = new FileInputSplit(splitNum++, file.getPath(), position, splitSize,
            blocks[blockIndex]
              .getHosts());
          inputSplits.add(fis);

          // adjust the positions
          position += splitSize;
          bytesUnassigned -= splitSize;
        }

        // assign the last split
        if (bytesUnassigned > 0) {
          blockIndex = getBlockIndexForPosition(blocks, position, halfSplit, blockIndex);
          final FileInputSplit fis = new FileInputSplit(splitNum++, file.getPath(), position,
            bytesUnassigned,
            blocks[blockIndex].getHosts());
          inputSplits.add(fis);
        }
      } else {
        // special case with a file of zero bytes size
        final BlockLocation[] blocks = fs.getFileBlockLocations(file, 0, 0);
        String[] hosts;
        if (blocks.length > 0) {
          hosts = blocks[0].getHosts();
        } else {
          hosts = new String[0];
        }
        final FileInputSplit fis = new FileInputSplit(splitNum++, file.getPath(), 0, 0, hosts);
        inputSplits.add(fis);
      }
    }

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

      fail();
      e.printStackTrace();
    }
    writer.invoke();

    final FileInputSplit split = new FileInputSplit(0, new Path(this.file.toURI().toString()), 0,
      this.file.length(), null);
    when(this.environment.getInputSplitProvider()).thenReturn(this.inputSplitProvider);
    when(this.inputSplitProvider.getNextInputSplit()).thenReturn(split, (FileInputSplit) null);

    FileLineReader reader = new FileLineReader();
View Full Code Here

      // Create and populate instance specific split list
      instanceSplitList = new PriorityQueue<FileInputSplitList.QueueElem>();
      final Iterator<FileInputSplit> it = this.masterSet.iterator();
      while (it.hasNext()) {

        final FileInputSplit split = it.next();
        final String[] hostNames = split.getHostNames();
        if (hostNames == null) {
          instanceSplitList.add(new QueueElem(split, Integer.MAX_VALUE));

        } else {
View Full Code Here

    final Iterator<FileInputSplit> splitIterator = getFileInputSplits();

    while (splitIterator.hasNext()) {

      final FileInputSplit split = splitIterator.next();

      long start = split.getStart();
      long length = split.getLength();

      final FileSystem fs = FileSystem.get(split.getPath().toUri());

      final FSDataInputStream fdis = fs.open(split.getPath());

      final LineReader lineReader = new LineReader(fdis, start, length, (1024 * 1024));

      byte[] line = lineReader.readLine();

View Full Code Here

    final Iterator<FileInputSplit> splitIterator = getFileInputSplits();

    while (splitIterator.hasNext()) {

      final FileInputSplit split = splitIterator.next();

      final long start = split.getStart();
      final long length = split.getLength();

      final FileSystem fs = FileSystem.get(split.getPath().toUri());

      final FSDataInputStream fdis = fs.open(split.getPath());

      final LineReader lineReader = new LineReader(fdis, start, length, (1024 * 1024));

      byte[] line = lineReader.readLine();

View Full Code Here

  }

  @Test
  public void testOpen() throws IOException {
    final int[] fileContent = {1,2,3,4,5,6,7,8};
    final FileInputSplit split = createTempFile(fileContent)
 
    final Configuration parameters = new Configuration();
    parameters.setInteger(FixedLengthInputFormat.RECORDLENGTH_PARAMETER_KEY, 8);
   
    format.configure(parameters);
View Full Code Here

  }
 
  @Test
  public void testRead() throws IOException {
    final int[] fileContent = {1,2,3,4,5,6,7,8};
    final FileInputSplit split = createTempFile(fileContent);
   
    final Configuration parameters = new Configuration();
   
    parameters.setInteger(FixedLengthInputFormat.RECORDLENGTH_PARAMETER_KEY, 8);
   
View Full Code Here

 
 
  @Test
  public void testReadFail() throws IOException {
    final int[] fileContent = {1,2,3,4,5,6,7,8,9};
    final FileInputSplit split = createTempFile(fileContent);
   
    final Configuration parameters = new Configuration();
    parameters.setInteger(FixedLengthInputFormat.RECORDLENGTH_PARAMETER_KEY, 8);
   
    format.configure(parameters);
View Full Code Here

      dos.writeInt(i);
    }
   
    dos.close();
     
    return new FileInputSplit(0, new Path(this.tempFile.toURI().toString()), 0, this.tempFile.length(), new String[] {"localhost"});
  }
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.