org.jclarion.clarion.util
Class FileState

java.lang.Object
  extended by org.jclarion.clarion.util.FileState

public class FileState
extends java.lang.Object

Model state of JDBC Connection. This same object is used for current state and saved states

Author:
barney

Nested Class Summary
static class FileState.Global
           
static class FileState.Mode
          Read mode/state of the connection NONE - no reading occurring RESET - file/key is positioned but no reading yet FORWARD - we are reading forward BACK - we are reading backwards RESTORED - we have been restored file that was previously - either in Forward or Back mode, but we have not yet fully restored iterator position (iterator restore is lazy) USER - user defined SQL was executed
 
Field Summary
 boolean[] changed
          catalog of buffer columns that have been modified
 int currentLimit
           
 boolean disableBinding
           
 ClarionObject[] fields
           
 FileState.Global global
           
 boolean ignoreChange
          Ignore changes made to parameters as these are being done by internal ClarionFile object
 boolean isBounded
           
 boolean[] isnull
          catalog of buffer columns that have been flagged as null
 boolean keyBinding
          Key binding.
 int limit
          Limits - when scanning very large files say 10,000s of records in a browse, user usually only wants to see the first 20 or so.
 ClarionMemoryChangeListener[] listeners
           
 FileState.Mode mode
           
 int offset
           
 SharedOutputStream position
          Current scan position
 ClarionKey primaryKey
          Primary key and position
 ClarionObject[] primaryKeyFields
           
 boolean quickScan
          Quick scan has a comparable in original clarion.
 ClarionObject quickScanBuffer
           
 boolean quickScanResetActivated
           
 int readCount
           
 java.sql.ResultSet result
           
 org.jclarion.clarion.util.FileState.ResultSetCount resultSetCount
           
 ClarionObject[] scanFields
           
 ClarionKey scanKey
          Current scan key (if any)
 java.lang.StringBuilder select
           
 java.sql.PreparedStatement statement
          Current Result Set/etc
 boolean watchArmed
          is watch armed.
 ClarionObject[] watchBuffer
          Run following SQL before PUT() if expression fails then fail PUT().
 
Constructor Summary
FileState()
           
FileState(FileState.Global global)
           
FileState(FileState base)
           
 
Method Summary
 void closeCursor()
           
 void closeCursor(boolean clearKeyAndPosition)
           
 void closeCursor(boolean clearKeyAndPosition, boolean clearMode)
           
 void free()
           
 int getFieldIndex(ClarionObject o)
           
 void restore(FileState save)
           
 FileState save()
           
 void saveBuffer(SharedOutputStream target)
           
 void setKeyBinding(boolean b)
           
 void setLimit(int limit)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

global

public FileState.Global global

mode

public FileState.Mode mode

fields

public ClarionObject[] fields

changed

public boolean[] changed
catalog of buffer columns that have been modified


isnull

public boolean[] isnull
catalog of buffer columns that have been flagged as null


statement

public java.sql.PreparedStatement statement
Current Result Set/etc


result

public java.sql.ResultSet result

resultSetCount

public org.jclarion.clarion.util.FileState.ResultSetCount resultSetCount

scanKey

public ClarionKey scanKey
Current scan key (if any)


scanFields

public ClarionObject[] scanFields

quickScanBuffer

public ClarionObject quickScanBuffer

primaryKey

public ClarionKey primaryKey
Primary key and position


primaryKeyFields

public ClarionObject[] primaryKeyFields

position

public SharedOutputStream position
Current scan position


ignoreChange

public boolean ignoreChange
Ignore changes made to parameters as these are being done by internal ClarionFile object


watchBuffer

public ClarionObject[] watchBuffer
Run following SQL before PUT() if expression fails then fail PUT(). Post PUT clear expression


watchArmed

public boolean watchArmed
is watch armed. If true On next read - set watch expression


listeners

public ClarionMemoryChangeListener[] listeners

select

public java.lang.StringBuilder select

limit

public int limit
Limits - when scanning very large files say 10,000s of records in a browse, user usually only wants to see the first 20 or so. Isntead of pulling back 10,000s of records per scan across JDBC - limit number of records to pull back. If limit is exhausted, then invisibly reset the scan to get the next block of records


currentLimit

public int currentLimit

readCount

public int readCount

offset

public int offset

keyBinding

public boolean keyBinding
Key binding. When using keys that are composite fields, it is very common that the program wants to 'fix' the first key and only scan second key. For example stock(franchise,partnum) - user may only want to look at parts in a given franchise But way clarion files work is that if I say all parts from franchise 2, partnum '1234' then all franchises above 2 are considered as well. When binding is in effect it works similar to limits. The initial query assumes that only franchise=2 is wanted. But if user executes 'next' statement beyond this then it will invisibly rewrite the query to handle this. This is beneficial in postgres at least because I had trouble getting postgres to optimise the following well franchise>2 OR (franchise=2 and partnum>='1234') Under some circumstances, instead of selecting a index scan starting at (2,'1234') sometimes postgrs would do a index scan at (2,) only - and filter records prior to 1234. For large data sets this can be very inefficient. But when I break it up into two queries i.e. a) franchise=2 and partnum>='1234' b) franchise>2 The system optimises quite well


isBounded

public boolean isBounded

disableBinding

public boolean disableBinding

quickScan

public boolean quickScan
Quick scan has a comparable in original clarion. Browse tables force reset when scrolling through parts instead of continuing to read the already established statement. Clearly this is inefficient. Clarion worked around this with a quickscan setting. What that setting does in clarion is unclear, documentation talks about 'buffering' which I assume is caching etc. For this implementation - quickScan merely intercepts key methods. Specifically: reset() - if resetting a scan that is already occurring in scan position matches the currently cached position - enable quickScan to continue to 'use' the existing scan


quickScanResetActivated

public boolean quickScanResetActivated
Constructor Detail

FileState

public FileState(FileState base)

FileState

public FileState()

FileState

public FileState(FileState.Global global)
Method Detail

closeCursor

public void closeCursor()

closeCursor

public void closeCursor(boolean clearKeyAndPosition)

closeCursor

public void closeCursor(boolean clearKeyAndPosition,
                        boolean clearMode)

free

public void free()

save

public FileState save()

saveBuffer

public void saveBuffer(SharedOutputStream target)

restore

public void restore(FileState save)

setLimit

public void setLimit(int limit)

setKeyBinding

public void setKeyBinding(boolean b)

getFieldIndex

public int getFieldIndex(ClarionObject o)


Copyright © 2010. All Rights Reserved.