public class MySqlUpsertWriter extends MySqlInsertWriter
DataEndpoint.State
batchedInserts, batchSize, pretty, tableName
currentRecord
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEY
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZE
id, log, name, TIMESTAMP_FORMAT
Constructor and Description |
---|
MySqlUpsertWriter(String table,
File file) |
MySqlUpsertWriter(String table,
File file,
boolean append) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Indicates that this endpoint has finished reading or writing.
|
MySqlUpsertWriter |
setBatchSize(int batchSize)
Sets the number of records to chunk together in batch upserts.
|
MySqlUpsertWriter |
setPretty(boolean pretty)
Indicates if line breaks and indentations should be added to output upsert statement (default false).
Example output (pretty = true): INSERT INTO `tableName` (`col1`, `col2`) |
protected void |
writeRecord(Record record) |
addExceptionProperties, getBatchSize, getSqlValueLiteral, getTableName, isBatchMode, isPretty, setFieldNamesInFirstRow
getFile, getWriter, isAppend, isAutoCloseWriter, isFieldNamesInFirstRow, isFlushOnWrite, setAutoCloseWriter, setFlushOnWrite, write
open, writeImpl
available, getNestedEndpoint, getNestedWriter, getRootEndpoint, getRootWriter
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toString
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
protected void writeRecord(Record record) throws Throwable
writeRecord
in class MySqlInsertWriter
Throwable
public void close()
DataEndpoint
close
in class MySqlInsertWriter
public MySqlUpsertWriter setPretty(boolean pretty)
INSERT INTO `tableName` (`col1`, `col2`)
VALUES (val1, val2),
(val1, val2),
(val1, val2)
ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);
INSERT INTO `tableName` (`col1`, `col2`) VALUES (val1, val2), (val1, val2), (val1, val2) ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);
setPretty
in class MySqlInsertWriter
public MySqlUpsertWriter setBatchSize(int batchSize)
INSERT INTO `tableName` (`col1`, `col2`)
VALUES (val1, val2),
(val1, val2,
(val1, val2)
ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);
Example output (batchSize = 0):
INSERT INTO `tableName` (`col1`, `col2`) VALUES (val1, val2) ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);
INSERT INTO `tableName` (`col1`, `col2`) VALUES (val1, val2) ON DUPLICATE KEY UPDATE `col1` = VALUES(`col1`), `col2` = VALUES(`col2`);
setBatchSize
in class MySqlInsertWriter
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.