Package org.pgcodekeeper.core.loader
Class PgDumpLoader
java.lang.Object
org.pgcodekeeper.core.loader.DatabaseLoader
org.pgcodekeeper.core.loader.PgDumpLoader
Database loader for SQL dump files. Parses SQL scripts using ANTLR and
builds database schema objects with support for different parsing modes
and statement overrides.
- Author:
- fordfrog
-
Constructor Summary
ConstructorsConstructorDescriptionPgDumpLoader(Path inputFile, ISettings settings) Creates a new dump loader for a file path with null progress monitor and no monitoring.PgDumpLoader(Path inputFile, ISettings settings, IMonitor monitor) Creates a new dump loader for a file path with default monitoring level of 1.PgDumpLoader(Path inputFile, ISettings settings, IMonitor monitor, int monitoringLevel) This constructor createsInputStreamProviderusing inputFile parameter.PgDumpLoader(InputStreamProvider input, String inputObjectName, ISettings settings) Creates a new dump loader with null progress monitor and no monitoring.PgDumpLoader(InputStreamProvider input, String inputObjectName, ISettings settings, IMonitor monitor) Creates a new dump loader with default monitoring level of 1.PgDumpLoader(InputStreamProvider input, String inputObjectName, ISettings settings, IMonitor monitor, int monitoringLevel) Creates a new dump loader with full configuration. -
Method Summary
Modifier and TypeMethodDescriptionload()Loads database schema without performing full analysis.loadAsync(AbstractDatabase d, Queue<AntlrTask<?>> antlrTasks) Loads SQL dump asynchronously into the provided database with default schema setup.loadDatabase(AbstractDatabase intoDb, Queue<AntlrTask<?>> antlrTasks) Loads SQL dump into the specified database using ANTLR parsing.voidsetMode(ParserListenerMode mode) Sets the parser listener mode for controlling parsing behavior.voidsetOverridesMap(Map<PgStatement, StatementOverride> overrides) Sets the statement overrides map for customizing parsed statements.Methods inherited from class org.pgcodekeeper.core.loader.DatabaseLoader
createDb, getErrors, loadAndAnalyze
-
Constructor Details
-
PgDumpLoader
public PgDumpLoader(InputStreamProvider input, String inputObjectName, ISettings settings, IMonitor monitor, int monitoringLevel) Creates a new dump loader with full configuration.- Parameters:
input- the input stream provider for the SQL dumpinputObjectName- name of the input object for error reportingsettings- loader settings and configurationmonitor- progress monitor for tracking parsing progressmonitoringLevel- level of progress monitoring detail
-
PgDumpLoader
public PgDumpLoader(InputStreamProvider input, String inputObjectName, ISettings settings, IMonitor monitor) Creates a new dump loader with default monitoring level of 1.- Parameters:
input- the input stream provider for the SQL dumpinputObjectName- name of the input object for error reportingsettings- loader settings and configurationmonitor- progress monitor for tracking parsing progress
-
PgDumpLoader
Creates a new dump loader with null progress monitor and no monitoring.- Parameters:
input- the input stream provider for the SQL dumpinputObjectName- name of the input object for error reportingsettings- loader settings and configuration
-
PgDumpLoader
This constructor createsInputStreamProviderusing inputFile parameter. -
PgDumpLoader
Creates a new dump loader for a file path with default monitoring level of 1.- Parameters:
inputFile- the path to the SQL dump filesettings- loader settings and configurationmonitor- progress monitor for tracking parsing progress
-
PgDumpLoader
Creates a new dump loader for a file path with null progress monitor and no monitoring.- Parameters:
inputFile- the path to the SQL dump filesettings- loader settings and configuration
-
-
Method Details
-
setMode
Sets the parser listener mode for controlling parsing behavior.- Parameters:
mode- the parser listener mode to set
-
setOverridesMap
Sets the statement overrides map for customizing parsed statements.- Parameters:
overrides- map of statement overrides
-
load
Description copied from class:DatabaseLoaderLoads database schema without performing full analysis.- Specified by:
loadin classDatabaseLoader- Returns:
- the loaded database schema
- Throws:
IOException- if database loading failsInterruptedException- if the loading process is interrupted
-
loadAsync
public AbstractDatabase loadAsync(AbstractDatabase d, Queue<AntlrTask<?>> antlrTasks) throws InterruptedException Loads SQL dump asynchronously into the provided database with default schema setup. Creates and adds a default schema based on database type, then delegates to loadDatabase.- Parameters:
d- the target database to load intoantlrTasks- queue for managing ANTLR parsing tasks- Returns:
- the loaded database with parsed SQL objects
- Throws:
InterruptedException- if parsing is interrupted
-
loadDatabase
public AbstractDatabase loadDatabase(AbstractDatabase intoDb, Queue<AntlrTask<?>> antlrTasks) throws InterruptedException Loads SQL dump into the specified database using ANTLR parsing. Selects appropriate parser listener based on database type and override configuration. Supports PostgreSQL, Microsoft SQL Server, and ClickHouse databases.- Parameters:
intoDb- the target database to load parsed objects intoantlrTasks- queue for managing ANTLR parsing tasks- Returns:
- the database with loaded SQL objects
- Throws:
InterruptedException- if parsing is interrupted
-