Class PostgreSqlBulkWriter

All Implemented Interfaces:
Closeable, AutoCloseable, StatementsWriter

public class PostgreSqlBulkWriter extends FileStatementsWriter
Implementation of a StatementsWriter that writes bulk text files for each table, and references them in "COPY INTO".
Author:
Tobias Liefke
  • Field Details

    • log

      private static final org.slf4j.Logger log
    • context

      private final GeneratorContext context
      The current generation context.
    • contextListener

      private final ContextModelListener contextListener
      The current generation context.
    • directory

      private final File directory
      The directory for the bulk files.
    • encoding

      private final Charset encoding
      The encoding of the bulk files.
    • fileNumbers

      private final Map<GeneratorTable,Integer> fileNumbers
      Remembers for each table which files we've already generated.
    • bulkWriters

      private final Map<GeneratorTable,Writer> bulkWriters
      The open bulk files for each table.
    • generatedFiles

      private final List<File> generatedFiles
      All files generated by this writer.
    • statementsCount

      private int statementsCount
      The count of written statements.
  • Constructor Details

    • PostgreSqlBulkWriter

      public PostgreSqlBulkWriter(GeneratorContext context) throws FileNotFoundException
      Creates a new instance for a SQL file with UTF-8 encoding. All bulk files will end up in the same directory as the given file.
      Parameters:
      context - the current generation context
      Throws:
      FileNotFoundException - if the directory is not available
    • PostgreSqlBulkWriter

      public PostgreSqlBulkWriter(GeneratorContext context, File sqlFile) throws FileNotFoundException
      Creates a new instance for a SQL file with UTF-8 encoding. All bulk files will end up in the same directory as the given file.
      Parameters:
      context - the current generation context
      sqlFile - the file that is feeded with all plain statements
      Throws:
      FileNotFoundException - if the directory is not available
    • PostgreSqlBulkWriter

      public PostgreSqlBulkWriter(GeneratorContext context, File sqlFile, Charset encoding) throws FileNotFoundException
      Creates a new instance for a SQL file. All bulk files will end up in the same directory as the given file.
      Parameters:
      context - the current generation context
      sqlFile - the file that is feeded with all plain statements
      encoding - the encoding of all written files
      Throws:
      FileNotFoundException - if the directory is not available
    • PostgreSqlBulkWriter

      public PostgreSqlBulkWriter(GeneratorContext context, File directory, Writer writer, Charset encoding)
      Creates a new instance of PostgreSqlBulkWriter.
      Parameters:
      context - the current generation context
      directory - the directory for the bulk files
      writer - the SQL file which contains the plain and the "COPY" statements
      encoding - The encoding of the bulk files.
  • Method Details