Beispiel #1
0
  public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
    meta = (IngresVectorwiseLoaderMeta) smi;
    data = (IngresVectorwiseLoaderData) sdi;

    try {
      Object[] r = getRow(); // Get row from input rowset & set row busy!
      if (r == null) // no more input to be expected...
      {
        setOutputDone();
        // only close output after the first row was processed
        // to prevent error (NPE) on empty rows set
        if (!first) {
          closeOutput();
        }

        return false;
      }

      if (first) {
        first = false;

        // Cache field indexes.
        //
        data.keynrs = new int[meta.getFieldStream().length];
        for (int i = 0; i < data.keynrs.length; i++) {
          data.keynrs[i] = getInputRowMeta().indexOfValue(meta.getFieldStream()[i]);
        }
        data.bulkRowMeta = getInputRowMeta().clone();
        if (meta.isUseStandardConversion()) {
          for (int i = 0; i < data.bulkRowMeta.size(); i++) {
            ValueMetaInterface valueMeta = data.bulkRowMeta.getValueMeta(i);
            if (valueMeta.isStorageNormal()) {
              if (valueMeta.isDate()) {
                valueMeta.setConversionMask("yyyy-MM-dd HH:mm:ss");
              } else if (valueMeta.isNumeric()) {
                valueMeta.setDecimalSymbol(".");
                valueMeta.setGroupingSymbol("");
              }
            }
          }
        }

        // execute the client statement...
        //
        execute(meta);

        // Allocate a buffer
        //
        data.fileChannel = data.fifoOpener.getFileChannel();
        data.byteBuffer = ByteBuffer.allocate(data.bufferSize);
      }

      // check if SQL process is still running before processing row
      if (!checkSqlProcessRunning(data.sqlProcess)) {
        throw new Exception("Ingres SQL process has stopped");
      }

      writeRowToBulk(data.bulkRowMeta, r);
      putRow(getInputRowMeta(), r);
      incrementLinesOutput();

      if (checkFeedback(getLinesOutput()))
        logBasic(
            BaseMessages.getString(PKG, "IngresVectorwiseLoader.Log.LineNumber")
                + getLinesOutput()); //$NON-NLS-1$

      return true;

    } catch (Exception e) {
      logError(
          BaseMessages.getString(PKG, "IngresVectorwiseLoader.Log.ErrorInStep"), e); // $NON-NLS-1$
      setErrors(1);
      stopAll();
      setOutputDone(); // signal end to receiver(s)
      return false;
    }
  }