@Override public void acceptInstance(InstanceEvent e){
  if (e.getStatus() == InstanceEvent.FORMAT_AVAILABLE) {
    m_connectedFormat=e.getStructure();
    m_stopRequested.set(false);
    try {
      init(new Instances(e.getStructure(),0));
    }
 catch (    IllegalArgumentException ex) {
      if (m_log != null) {
        String message="ERROR: There is a problem with the incoming instance structure";
        stopWithErrorMessage(message,ex);
        return;
      }
    }
    String buffSize=m_bufferSize;
    try {
      buffSize=m_env.substitute(buffSize);
      m_bufferSizeI=Integer.parseInt(buffSize);
    }
 catch (    Exception ex) {
      ex.printStackTrace();
    }
    m_incrementalBuffer=new ArrayList<InstanceHolder>(m_bufferSizeI);
    m_bufferFiles=new ArrayList<File>();
    m_streamCounter=0;
    return;
  }
  m_busy=true;
  if (e.getInstance() != null) {
    if (m_streamCounter == 0) {
      if (m_log != null) {
        m_log.statusMessage(statusMessagePrefix() + "Starting streaming sort...");
        m_log.logMessage("[Sorter] " + statusMessagePrefix() + " Using streaming buffer size: "+ m_bufferSizeI);
      }
    }
    InstanceHolder tempH=new InstanceHolder();
    tempH.m_instance=e.getInstance();
    tempH.m_fileNumber=-1;
    if (m_stringAttIndexes != null) {
      copyStringAttVals(tempH);
    }
    m_incrementalBuffer.add(tempH);
    m_streamCounter++;
  }
  if (e.getInstance() == null || e.getStatus() == InstanceEvent.BATCH_FINISHED) {
    emitBufferedInstances();
    return;
  }
 else   if (m_incrementalBuffer.size() == m_bufferSizeI) {
    try {
      sortBuffer(true);
    }
 catch (    Exception ex) {
      String msg=statusMessagePrefix() + "ERROR: unable to write to temp file.";
      stopWithErrorMessage(msg,ex);
      m_busy=false;
      return;
    }
  }
  m_busy=false;
}

@ Override public void acceptInstance ( InstanceEvent e ) { if ( e . getStatus ( ) == InstanceEvent . FORMAT_AVAILABLE ) { m_connectedFormat = e . getStructure ( ) ; m_stopRequested . set ( false ) ; try { init ( new Instances ( e . getStructure ( ) , 0 ) ) ; } catch ( IllegalArgumentException ex ) { if ( m_log != null ) { String message = "ERROR: There is a problem with the incoming instance structure" ; stopWithErrorMessage ( message , ex ) ; return ; } } String buffSize = m_bufferSize ; try { buffSize = m_env . substitute ( buffSize ) ; m_bufferSizeI = Integer . parseInt ( buffSize ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } m_incrementalBuffer = new ArrayList < InstanceHolder > ( m_bufferSizeI ) ; m_bufferFiles = new ArrayList < File > ( ) ; m_streamCounter = 0 ; return ; } m_busy = true ; if ( e . getInstance ( ) != null ) { if ( m_streamCounter == 0 ) { if ( m_log != null ) { m_log . statusMessage ( statusMessagePrefix ( ) + "Starting streaming sort..." ) ; m_log . logMessage ( "[Sorter] " + statusMessagePrefix ( ) + " Using streaming buffer size: " + m_bufferSizeI ) ; } } InstanceHolder tempH = new InstanceHolder ( ) ; tempH . m_instance = e . getInstance ( ) ; tempH . m_fileNumber = - 1 ; if ( m_stringAttIndexes != null ) { copyStringAttVals ( tempH ) ; } m_incrementalBuffer . add ( tempH ) ; m_streamCounter ++ ; } if ( e . getInstance ( ) == null || e . getStatus ( ) == InstanceEvent . BATCH_FINISHED ) { emitBufferedInstances ( ) ; return ; } else if ( m_incrementalBuffer . size ( ) == m_bufferSizeI ) { try { sortBuffer ( true ) ; } catch ( Exception ex ) { String msg = statusMessagePrefix ( ) + "ERROR: unable to write to temp file." ; stopWithErrorMessage ( msg , ex ) ; m_busy = false ; return ; } } m_busy = false ; }
accept and process an instance event
