Package eu.stratosphere.core.io

Examples of eu.stratosphere.core.io.InputSplit


     
      // for each assigned input split
      while (!this.taskCanceled && splitIterator.hasNext())
      {
        // get start and end
        final InputSplit split = splitIterator.next();
       
        OT record = serializer.createInstance();
 
        if (LOG.isDebugEnabled()) {
          LOG.debug(getLogString("Opening input split " + split.toString()));
        }
       
        final InputFormat<OT, InputSplit> format = this.format;
     
        // open input format
        format.open(split);
 
        if (LOG.isDebugEnabled()) {
          LOG.debug(getLogString("Starting to read input from split " + split.toString()));
        }
       
        try {
          // ======= special-case the Record, to help the JIT and avoid some casts ======
          if (record.getClass() == Record.class) {
            Record typedRecord = (Record) record;
            @SuppressWarnings("unchecked")
            final InputFormat<Record, InputSplit> inFormat = (InputFormat<Record, InputSplit>) format;
           
            if (this.output instanceof RecordOutputCollector) {
              // Record going directly into network channels
              final RecordOutputCollector output = (RecordOutputCollector) this.output;
              while (!this.taskCanceled && !inFormat.reachedEnd()) {
                // build next pair and ship pair if it is valid
                typedRecord.clear();
                Record returnedRecord = null;
                if ((returnedRecord = inFormat.nextRecord(typedRecord)) != null) {
                  output.collect(returnedRecord);
                }
              }
            } else if (this.output instanceof ChainedCollectorMapDriver) {
              // Record going to a chained map task
              @SuppressWarnings("unchecked")
              final ChainedCollectorMapDriver<Record, ?> output = (ChainedCollectorMapDriver<Record, ?>) this.output;
             
              // as long as there is data to read
              while (!this.taskCanceled && !inFormat.reachedEnd()) {
                // build next pair and ship pair if it is valid
                typedRecord.clear();
                if ((typedRecord = inFormat.nextRecord(typedRecord)) != null) {
                  // This is where map of UDF gets called
                  output.collect(typedRecord);
                }
              }
            } else {
              // Record going to some other chained task
              @SuppressWarnings("unchecked")
              final Collector<Record> output = (Collector<Record>) this.output;
              // as long as there is data to read
              while (!this.taskCanceled && !inFormat.reachedEnd()) {
                // build next pair and ship pair if it is valid
                typedRecord.clear();
                if ((typedRecord = inFormat.nextRecord(typedRecord)) != null){
                  output.collect(typedRecord);
                }
              }
            }
          } else {
            // general types. we make a case distinction here for the common cases, in order to help
            // JIT method inlining
            if (this.output instanceof OutputCollector) {
              final OutputCollector<OT> output = (OutputCollector<OT>) this.output;
              // as long as there is data to read
              while (!this.taskCanceled && !format.reachedEnd()) {
                // build next pair and ship pair if it is valid
                if ((record = format.nextRecord(record)) != null) {
                  output.collect(record);
                }
              }
            } else if (this.output instanceof ChainedCollectorMapDriver) {
              @SuppressWarnings("unchecked")
              final ChainedCollectorMapDriver<OT, ?> output = (ChainedCollectorMapDriver<OT, ?>) this.output;
              // as long as there is data to read
              while (!this.taskCanceled && !format.reachedEnd()) {
                // build next pair and ship pair if it is valid
                if ((record = format.nextRecord(record)) != null) {
                  output.collect(record);
                }
              }
            } else {
              final Collector<OT> output = this.output;
              // as long as there is data to read
              while (!this.taskCanceled && !format.reachedEnd()) {
                // build next pair and ship pair if it is valid
                if ((record = format.nextRecord(record)) != null) {
                  output.collect(record);
                }
              }
            }
          }
         
          if (LOG.isDebugEnabled() && !this.taskCanceled) {
            LOG.debug(getLogString("Closing input split " + split.toString()));
          }
        } finally {
          // close. We close here such that a regular close throwing an exception marks a task as failed.
          format.close();
        }
View Full Code Here


      @Override
      public boolean hasNext() {

        if (this.nextSplit == null) {

          final InputSplit split = provider.getNextInputSplit();
          if (split != null) {
            @SuppressWarnings("unchecked")
            final T tSplit = (T) split;
            this.nextSplit = tSplit;
            return true;
View Full Code Here

   *        the sequence number of the vertex's request
   * @return the next input split to consume or <code>null</code> if the vertex shall consume no more input splits
   */
  public InputSplit getNextInputSplit(final ExecutionVertex vertex, final int sequenceNumber) {

    InputSplit nextInputSplit = this.inputSplitTracker.getInputSplitFromLog(vertex, sequenceNumber);
    if (nextInputSplit != null) {
      LOG.info("Input split " + nextInputSplit.getSplitNumber() + " for vertex " + vertex + " replayed from log");
      return nextInputSplit;
    }

    final ExecutionGroupVertex groupVertex = vertex.getGroupVertex();
    final InputSplitAssigner inputSplitAssigner = this.assignerCache.get(groupVertex);
    if (inputSplitAssigner == null) {
      final JobID jobID = groupVertex.getExecutionStage().getExecutionGraph().getJobID();
      LOG.error("Cannot find input assigner for group vertex " + groupVertex.getName() + " (job " + jobID + ")");
      return null;
    }

    nextInputSplit = inputSplitAssigner.getNextInputSplit(vertex);
    if (nextInputSplit != null) {
      this.inputSplitTracker.addInputSplitToLog(vertex, sequenceNumber, nextInputSplit);
      LOG.info(vertex + " receives input split " + nextInputSplit.getSplitNumber());
    }

    return nextInputSplit;
  }
View Full Code Here

      final JobID jobID = vertex.getExecutionGraph().getJobID();
      LOG.error("Cannot find split queue for vertex " + vertex.getGroupVertex() + " (job " + jobID + ")");
      return null;
    }

    InputSplit nextSplit = queue.poll();

    if (LOG.isDebugEnabled() && nextSplit != null) {
      LOG.debug("Assigning split " + nextSplit.getSplitNumber() + " to " + vertex);
    }

    return nextSplit;
  }
View Full Code Here

    synchronized (splitStore) {

      for (int i = 0; i < inputSplits.length; ++i) {
        // TODO: Improve this
        final InputSplit inputSplit = inputSplits[i];
        if (!(inputSplit instanceof LocatableInputSplit)) {
          LOG.error("Input split " + i + " of vertex " + groupVertex.getName() + " is of type "
            + inputSplit.getClass() + ", ignoring split...");
          continue;
        }
        splitStore.addSplit((LocatableInputSplit) inputSplit);
      }
View Full Code Here

    synchronized (splitStore) {

      for (int i = 0; i < inputSplits.length; ++i) {
        // TODO: Improve this
        final InputSplit inputSplit = inputSplits[i];
        if (!(inputSplit instanceof FileInputSplit)) {
          LOG.error("Input split " + i + " of vertex " + groupVertex.getName() + " is of type "
            + inputSplit.getClass() + ", ignoring split...");
          continue;
        }
        splitStore.addSplit((FileInputSplit) inputSplit);
      }
View Full Code Here

TOP

Related Classes of eu.stratosphere.core.io.InputSplit

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.