Package dev.frostlake.demo
Class AbstractDemo
java.lang.Object
dev.frostlake.demo.AbstractDemo
- Direct Known Subclasses:
DMLOperationsDemo,EngineDemo,LateralJoinDemo,MergeOperationsDemo,PrimaryKeyDemo,QueryOperatorsDemo,StagesDemo,StreamsAndTasksDemo,WarehousesDemo
Abstract base class for demo applications
Provides common functionality for engine management, output formatting, and database operations
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DatabaseEngineThe engine the demo runs against; created bysetup(), released byshutdown(). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidexecute()Execute the demo with proper setup and cleanupprotected abstract StringGet the demo title to display at the startprotected intGet maximum number of rows to display in result sets Subclasses can override to show more or fewer rowsprotected intgetRowCount(String tableName) Get the row count from a tableprotected voidprintQuery(String sql) Execute a query and print its resultsprotected voidprintResultSet(ResultSet result) Print a result set with formatted output Subclasses can override for custom formattingprotected voidprintResultSet(ResultSet result, int columnWidth) Print a result set with specified column widthprotected voidprintSectionHeader(String title) Print a section header with box formattingprotected voidPrint a horizontal line separatorprotected voidprintSubsection(String title) Print a subsection headerprotected voidprintSuccess(String message) Print an info line with a checkmarkprotected voidprintTable(String tableName) Query a table and print its contentsprotected voidprintTitle(String title) Print demo title with formattingprotected abstract voidrunDemo()Main entry point - subclasses should implement this to define their demo logicprotected voidsetup()Initialize the Frostlake engineprotected voidsetupDatabase(String databaseName) Setup a database - create if doesn't exist and use itprotected voidshutdown()Shutdown the engine and release resources
-
Field Details
-
engine
The engine the demo runs against; created bysetup(), released byshutdown().
-
-
Constructor Details
-
AbstractDemo
public AbstractDemo()
-
-
Method Details
-
runDemo
Main entry point - subclasses should implement this to define their demo logic -
getDemoTitle
Get the demo title to display at the start- Returns:
- the title
execute()prints before running the demo
-
execute
public final void execute()Execute the demo with proper setup and cleanup -
setup
protected void setup()Initialize the Frostlake engine -
shutdown
protected void shutdown()Shutdown the engine and release resources -
setupDatabase
Setup a database - create if doesn't exist and use it- Parameters:
databaseName- the database to create (if missing) and make current, with schema PUBLIC
-
printTitle
Print demo title with formatting- Parameters:
title- the text framed between===markers
-
printSectionHeader
Print a section header with box formatting- Parameters:
title- the heading centered inside the box border
-
printSubsection
Print a subsection header- Parameters:
title- the heading framed between---markers
-
printSuccess
Print an info line with a checkmark- Parameters:
message- the text printed after the checkmark
-
printTable
Query a table and print its contents- Parameters:
tableName- the table whose full contents are selected and printed
-
printQuery
Execute a query and print its results- Parameters:
sql- the query to run against the engine
-
printResultSet
Print a result set with formatted output Subclasses can override for custom formatting- Parameters:
result- the result set to print, at the default 20-character column width
-
printResultSet
Print a result set with specified column width- Parameters:
result- the result set to print, capped atgetMaxDisplayRows()rowscolumnWidth- width of each printed column; longer values are truncated with an ellipsis
-
getMaxDisplayRows
protected int getMaxDisplayRows()Get maximum number of rows to display in result sets Subclasses can override to show more or fewer rows- Returns:
- the row display cap, 100 unless overridden
-
getRowCount
Get the row count from a table- Parameters:
tableName- the table to count- Returns:
- how many rows a
SELECT *over the table yields
-
printSeparator
protected void printSeparator()Print a horizontal line separator
-