org.hsqldb.scriptio
Class ScriptWriterBase

java.lang.Object
  extended byorg.hsqldb.scriptio.ScriptWriterBase
Direct Known Subclasses:
ScriptWriterText

public abstract class ScriptWriterBase
extends Object

Handles all logging to file operations. A log consists of three blocks:

DDL BLOCK: definition of DB objects, users and rights at startup time
DATA BLOCK: all data for MEMORY tables at startup time
LOG BLOCK: SQL statements logged since startup or the last CHECKPOINT
The implementation of this class and its subclasses support the formats used for writing the data. In versions up to 1.7.2, this data is written to the *.script file for the database. Since 1.7.2 the data can also be written as binray in order to speed up shutdown and startup.

In 1.7.2, two separate files are used, one for the DDL + DATA BLOCK and the other for the LOG BLOCK.

A related use for this class is for saving a current snapshot of the database data to a user-defined file. This happens in the SHUTDOWN COMPACT process or done as a result of the SCRIPT command. In this case, the DATA block contains the CACHED table data as well.

DatabaseScriptReader and its subclasses read back the data at startup time.

Since:
1.7.2
Version:
1.7.2
Author:
fredt@users

Field Summary
static String[] LIST_SCRIPT_FORMATS
           
static int SCRIPT_BINARY_172
           
static int SCRIPT_TEXT_170
           
static int SCRIPT_ZIPPED_BINARY_172
           
 
Method Summary
 void close()
           
protected  void finishStream()
          This is not really useful in the current usage but may be if this class is used in a different way.
protected abstract  void initBuffers()
           
static ScriptWriterBase newScriptWriter(Database db, String file, boolean includeCachedData, boolean newFile, int scriptType)
           
protected  void openFile()
          File is opened in append mode although in current usage the file never pre-exists
 void setWriteDelay(int delay)
          Not used in current implementation.
 long size()
           
 void sync()
          Called externally in write delay intervals.
 void writeAll()
           
protected abstract  void writeDataTerm()
           
protected  void writeDDL()
           
protected  void writeExistingData()
           
protected abstract  void writeSessionId(int sid)
           
protected  void writeSingleColumnResult(Result r)
           
protected  void writeTableInit(Table t)
           
protected  void writeTableTerm(Table t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIST_SCRIPT_FORMATS

public static String[] LIST_SCRIPT_FORMATS

SCRIPT_TEXT_170

public static final int SCRIPT_TEXT_170
See Also:
Constant Field Values

SCRIPT_BINARY_172

public static final int SCRIPT_BINARY_172
See Also:
Constant Field Values

SCRIPT_ZIPPED_BINARY_172

public static final int SCRIPT_ZIPPED_BINARY_172
See Also:
Constant Field Values
Method Detail

newScriptWriter

public static ScriptWriterBase newScriptWriter(Database db,
                                               String file,
                                               boolean includeCachedData,
                                               boolean newFile,
                                               int scriptType)
                                        throws HsqlException
Throws:
HsqlException

initBuffers

protected abstract void initBuffers()

setWriteDelay

public void setWriteDelay(int delay)
Not used in current implementation.


sync

public void sync()
Called externally in write delay intervals.


close

public void close()
           throws HsqlException
Throws:
HsqlException

size

public long size()

writeAll

public void writeAll()
              throws HsqlException
Throws:
HsqlException

openFile

protected void openFile()
                 throws HsqlException
File is opened in append mode although in current usage the file never pre-exists

Throws:
HsqlException

finishStream

protected void finishStream()
                     throws IOException
This is not really useful in the current usage but may be if this class is used in a different way.

Throws:
IOException

writeDDL

protected void writeDDL()
                 throws IOException,
                        HsqlException
Throws:
IOException
HsqlException

writeExistingData

protected void writeExistingData()
                          throws HsqlException,
                                 IOException
Throws:
HsqlException
IOException

writeTableInit

protected void writeTableInit(Table t)
                       throws HsqlException,
                              IOException
Throws:
HsqlException
IOException

writeTableTerm

protected void writeTableTerm(Table t)
                       throws HsqlException,
                              IOException
Throws:
HsqlException
IOException

writeSingleColumnResult

protected void writeSingleColumnResult(Result r)
                                throws HsqlException,
                                       IOException
Throws:
HsqlException
IOException

writeDataTerm

protected abstract void writeDataTerm()
                               throws IOException
Throws:
IOException

writeSessionId

protected abstract void writeSessionId(int sid)
                                throws IOException
Throws:
IOException


Copyright © 2001 - 2004 HSQL Development Group. All Rights Reserved.