示例#1
0
  public boolean init(StepMetaInterface smi, StepDataInterface sdi) {
    meta = (IngresVectorwiseLoaderMeta) smi;
    data = (IngresVectorwiseLoaderData) sdi;

    if (super.init(smi, sdi)) {
      if (Const.isEmpty(meta.getDelimiter())) {
        data.separator = data.getBytes("|");
      } else {
        data.separator = data.getBytes(meta.getDelimiter());
      }

      data.newline = data.getBytes("\n");
      data.semicolon = data.getBytes(";");
      data.doubleQuote = data.getBytes("\"");

      // Schema-table combination...
      data.schemaTable =
          meta.getDatabaseMeta()
              .getQuotedSchemaTableCombination(null, environmentSubstitute(meta.getTablename()));

      data.encoding = environmentSubstitute(meta.getEncoding());
      data.isEncoding = !Const.isEmpty(environmentSubstitute(meta.getEncoding()));

      data.byteBuffer = null;

      String bufferSizeString = environmentSubstitute(meta.getBufferSize());
      data.bufferSize =
          Const.isEmpty(bufferSizeString) ? 5000 : Const.toInt(bufferSizeString, 5000);

      if (meta.isTruncatingTable() && meta.getDatabaseMeta() != null) {

        // Connect to Vectorwise over standard JDBC and truncate the table
        //
        Database db = new Database(this, meta.getDatabaseMeta());
        try {
          db.connect();
          db.execStatement(
              "CALL VECTORWISE( COMBINE '" + data.schemaTable + " - " + data.schemaTable + "' )");

          // Just to make sure VW gets the message
          //
          db.execStatement(
              "CALL VECTORWISE( COMBINE '" + data.schemaTable + " - " + data.schemaTable + "' )");
          log.logDetailed(
              "Table " + data.schemaTable + " was truncated using a 'combine' statement.");
        } catch (Exception e) {
          log.logError("Error truncating table", e);
          return false;
        } finally {
          db.disconnect();
        }
      }

      return true;
    }
    return false;
  }