com.continuent.tungsten.replicator.prefetch
Class KeySelect

java.lang.Object
  extended by com.continuent.tungsten.replicator.prefetch.KeySelect

public class KeySelect
extends java.lang.Object

Encapsulates data and statement generation logic for prefetching slices of indexes. This includes holding the key definition as well as the associated values we are selecting from the key.


Constructor Summary
KeySelect(Table table, Key key)
          Create a new instance.
 
Method Summary
 java.lang.String createPrefetchSelect()
          Creates generic prefetch prepared statement text appropriate to the index type including drop-outs for key values.
 java.lang.String generateKey()
          Returns a reasonably efficient key for this select that incorporates both the fully qualified key name as well as select values.
 Key getKey()
           
 long getLastInvocation()
           
 Table getTable()
           
 java.lang.Object getValue(int index)
          Gets a column value by index.
 java.lang.Object getValue(java.lang.String colName)
          Gets a column value by name.
 java.util.List<java.lang.Object> getValues()
           
 boolean hasNulls()
          Returns true if any of the values in the key select is a null.
 void setLastInvocation(long lastInvocation)
           
 void setValue(int index, java.lang.Object value)
          Sets a column value for the select.
 void setValue(java.lang.String colName, java.lang.Object value)
          Sets a column value for the select.
 int size()
          Returns the number of columns in the key.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeySelect

public KeySelect(Table table,
                 Key key)
Create a new instance.

Method Detail

getTable

public Table getTable()

getKey

public Key getKey()

getValues

public java.util.List<java.lang.Object> getValues()

getLastInvocation

public long getLastInvocation()

setLastInvocation

public void setLastInvocation(long lastInvocation)

size

public int size()
Returns the number of columns in the key.


hasNulls

public boolean hasNulls()
Returns true if any of the values in the key select is a null.


setValue

public void setValue(int index,
                     java.lang.Object value)
              throws ReplicatorException
Sets a column value for the select.

Parameters:
index - Column index in key where 1 is the first index
value - Value to set
Throws:
ReplicatorException

getValue

public java.lang.Object getValue(int index)
Gets a column value by index.

Parameters:
index - Column index in key where 1 is the first index

setValue

public void setValue(java.lang.String colName,
                     java.lang.Object value)
              throws ReplicatorException
Sets a column value for the select.

Parameters:
colName - Name of the column in key
value - Value to set
Throws:
ReplicatorException

getValue

public java.lang.Object getValue(java.lang.String colName)
                          throws ReplicatorException
Gets a column value by name.

Parameters:
colName - Name of the column in key
Throws:
ReplicatorException

createPrefetchSelect

public java.lang.String createPrefetchSelect()
Creates generic prefetch prepared statement text appropriate to the index type including drop-outs for key values. For a primary key, we use SELECT * to force reading of the base data, whereas for a secondary index we use SELECT count(*), which reads only index pages.


generateKey

public java.lang.String generateKey()
Returns a reasonably efficient key for this select that incorporates both the fully qualified key name as well as select values. This key can be used for caching information about this particular index prefetch query.


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()