public void increment(String category) { increment(category, 1); }
public long stopTimer(String category) { long time = 0; Long startTime = timers.get(category); if (startTime != null) { time = System.currentTimeMillis() - startTime; increment(category, time); } timers.remove(category); return time; }
protected long println(String... data) { long byteCount = 0; for (int i = 0; i < data.length; i++) { if (i != 0) { print(batch, delimiter); byteCount += delimiter.length(); } print(batch, data[i]); byteCount += data[i].length(); } print(batch, "\n"); byteCount += "\n".length(); statistics.get(batch).increment(DataWriterStatisticConstants.BYTECOUNT, byteCount); return byteCount; }
protected void println(String... data) { FileInfo fileInfo = fileInfoByTable.get(table.getFullyQualifiedTableName()); if (fileInfo != null) { try { StringBuilder buffer = new StringBuilder(); for (int i = 0; i < data.length; i++) { if (i != 0) { buffer.append(","); } buffer.append(data[i]); } buffer.append("\n"); fileInfo.outputFileWriter.write(buffer.toString()); long byteCount = buffer.length(); statistics.get(batch).increment(DataWriterStatisticConstants.BYTECOUNT, byteCount); } catch (IOException e) { throw new IoException(e); } } }
protected CsvData buildCsvData(String[] tokens, DataEventType dml) { statistics.increment(DataReaderStatistics.READ_BYTE_COUNT, logDebugAndCountBytes(tokens)); return new CsvData(dml, tokens); }
protected boolean sql(CsvData data) { try { statistics.get(batch).startTimer(DataWriterStatisticConstants.DATABASEMILLIS); String script = data.getParsedData(CsvData.ROW_DATA)[0]; List<String> sqlStatements = getSqlStatements(script); long count = 0; for (String sql : sqlStatements) { sql = preprocessSqlStatement(sql); transaction.prepare(sql); if (log.isDebugEnabled()) { log.debug("About to run: {}", sql); } count += transaction.prepareAndExecute(sql); if (log.isDebugEnabled()) { log.debug("{} rows updated when running: {}", count, sql); } } statistics.get(batch).increment(DataWriterStatisticConstants.SQLCOUNT); statistics.get(batch).increment(DataWriterStatisticConstants.SQLROWSAFFECTEDCOUNT, count); return true; } finally { statistics.get(batch).stopTimer(DataWriterStatisticConstants.DATABASEMILLIS); } }
protected void ignore(DatabaseWriter writer, Conflict conflict) { if (conflict.isResolveRowOnly()) { writer.getStatistics().get(writer.getBatch()) .increment(DataWriterStatisticConstants.IGNORECOUNT); } else { throw new IgnoreBatchException(); } }
statistics.get(batch).increment(DataWriterStatisticConstants.SCRIPTCOUNT); } catch (EvalError e) { throw new RuntimeException(e);
public void end(Batch batch, boolean inError) { this.lastData = null; this.currentDmlStatement = null; if (batch.isIgnored()) { getStatistics().get(batch).increment(DataWriterStatisticConstants.IGNORECOUNT); } if (!inError) { notifyFiltersBatchComplete(); commit(false); } else { rollback(); } }
switch (dataEventType) { case INSERT: statistics.get(batch).increment(DataWriterStatisticConstants.STATEMENTCOUNT); statistics.get(batch).increment(DataWriterStatisticConstants.LINENUMBER); Object[] rowData = platform.getObjectValues(batch.getBinaryEncoding(), getRowData(data, CsvData.ROW_DATA), targetTable.getColumns());
protected void performFallbackToInsert(DatabaseWriter writer, CsvData csvData, Conflict conflict, boolean retransform) { try { beforeResolutionAttempt(conflict); LoadStatus loadStatus = writer.insert(csvData); if (loadStatus != LoadStatus.SUCCESS) { throw new ConflictException(csvData, writer.getTargetTable(), true, conflict); } else { writer.getStatistics().get(writer.getBatch()) .increment(DataWriterStatisticConstants.FALLBACKINSERTCOUNT); } } finally { afterResolutionAttempt(conflict); } }
protected boolean create(CsvData data) { String xml = null; try { transaction.commit(); statistics.get(batch).startTimer(DataWriterStatisticConstants.DATABASEMILLIS); xml = data.getParsedData(CsvData.ROW_DATA)[0]; log.info("About to create table using the following definition: {}", xml); StringReader reader = new StringReader(xml); Database db = DatabaseXmlUtil.read(reader, false); if (writerSettings.isCreateTableAlterCaseToMatchDatabaseDefault()) { platform.alterCaseToMatchDatabaseDefaultCase(db); } if (writerSettings.isAlterTable()) { platform.alterDatabase(db, !writerSettings.isCreateTableFailOnError()); } else { platform.createDatabase(db, writerSettings.isCreateTableDropFirst(), !writerSettings.isCreateTableFailOnError()); } platform.resetCachedTableModel(); statistics.get(batch).increment(DataWriterStatisticConstants.CREATECOUNT); return true; } catch (RuntimeException ex) { log.error("Failed to alter table using the following xml: {}", xml); throw ex; } finally { statistics.get(batch).stopTimer(DataWriterStatisticConstants.DATABASEMILLIS); } }
protected void performFallbackToUpdate(DatabaseWriter writer, CsvData data, Conflict conflict, boolean retransform) { try { beforeResolutionAttempt(conflict); LoadStatus loadStatus = writer.update(data, conflict.isResolveChangesOnly(), false); if (loadStatus != LoadStatus.SUCCESS) { throw new ConflictException(data, writer.getTargetTable(), true, conflict); } else { writer.getStatistics().get(writer.getBatch()) .increment(DataWriterStatisticConstants.FALLBACKUPDATECOUNT); } } finally { afterResolutionAttempt(conflict); } }
lookupDataMap = lookupDataMap == null ? getLookupDataMap(data) : lookupDataMap; long count = execute(data, getLookupKeyData(lookupDataMap, currentDmlStatement)); statistics.get(batch).increment(DataWriterStatisticConstants.DELETECOUNT, count); if (count > 0) { return LoadStatus.SUCCESS;
if (batch != null) { statistics.get(batch) .increment(DataReaderStatistics.READ_BYTE_COUNT, bytesRead); bytesRead = 0;
stats.increment(DataWriterStatisticConstants.TRANSFORMMILLIS, transformTimeInMs);
(targetTable == null && data.getDataEventType() == DataEventType.SQL)) { try { statistics.get(batch).increment(DataWriterStatisticConstants.STATEMENTCOUNT); statistics.get(batch).increment(DataWriterStatisticConstants.LINENUMBER); if (filterBefore(data)) { LoadStatus loadStatus = LoadStatus.SUCCESS; } else { uncommittedCount++; statistics.get(batch).increment(DataWriterStatisticConstants.IGNORECOUNT); checkForEarlyCommit();
getLookupKeyData(getLookupDataMap(data), this.currentDmlStatement)); long count = execute(data, values); statistics.get(batch).increment(DataWriterStatisticConstants.INSERTCOUNT, count); if (count > 0) { return LoadStatus.SUCCESS;