Package com.netrics.likeit
Class NetricsTableCursor
- java.lang.Object
-
- com.netrics.likeit.NetricsTableCursor
-
- All Implemented Interfaces:
java.io.Serializable
public class NetricsTableCursor extends java.lang.Object implements java.io.Serializable
This class is used to scan the records in a table. A cursor allows you to scan through all records in a table, in batches of a specified size.If the table is updated in any way after a scan with a cursor is started the results become unpredictable. The scan might skip records, or return the same record multiple times.
As long as no records are added or deleted, the ordering of records is stable: two cursors on the same table will return the records in the same order, and cursors remain valid across a checkpoint/restore.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NetricsTableCursor(java.lang.String table_name, int batch_size)
Create an initialized cursor, setting all options.NetricsTableCursor(java.lang.String table_name, java.lang.String[] child_tables, int batch_size)
Create an initialized cursor for compound records, setting all options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
atEOT()
Determine if a cursor is at the end-of-table position.int
getBatchSize()
Retrieve the batch size for this cursor.java.lang.String[]
getChildTables()
Get the list of child tables for compound records.java.lang.String
getPosition()
Obtains the current cursor position.int
getSkipCount()
Gets the number of records to skip before the next batch is retrieved.java.lang.String
getTableName()
Retrieve the table name for this cursor.void
setBatchSize(int batch_size)
Set the batch size for this cursor.void
setChildTables(java.lang.String[] child_tables)
Set the list of child tables.void
setChildTables(java.util.List<java.lang.String> child_tables)
Set the list of child tables.void
setPosition(java.lang.String pos)
Reset the position of a cursor.void
setSkipCount(int count)
Sets the number of records to skip before the next batch is retrieved.
-
-
-
Constructor Detail
-
NetricsTableCursor
public NetricsTableCursor(java.lang.String table_name, int batch_size)
Create an initialized cursor, setting all options. This creates a cursor for scanning the records of a table.- Parameters:
table_name
- name of the table this cursor is on.batch_size
- number of records to be returned at a time. If <= 0 the default batch size of 1 is used.
-
NetricsTableCursor
public NetricsTableCursor(java.lang.String table_name, java.lang.String[] child_tables, int batch_size)
Create an initialized cursor for compound records, setting all options. This creates a cursor for scanning the records of a table. It sets the set of child tables to be retrieved in a compound record scan.- Parameters:
table_name
- name of the table this cursor is on.child_tables
- names of all child tables to be included in a returned compound record. All tables listed must be children of table_name but validation is not performed until a scan is started. This may be null, in which case all child tables of table_name will be used in a compound record scan.batch_size
- number of records to be returned at a time. If <= 0 the default batch size of 1 is used.
-
-
Method Detail
-
getBatchSize
public int getBatchSize()
Retrieve the batch size for this cursor.- Returns:
- the batch size for this cursor.
-
setBatchSize
public void setBatchSize(int batch_size)
Set the batch size for this cursor.- Parameters:
batch_size
- Set the number of records to be returned at a time. If <= 0 the default batch size of 1 is used.
-
getTableName
public java.lang.String getTableName()
Retrieve the table name for this cursor.- Returns:
- the table name for this cursor.
-
setChildTables
public void setChildTables(java.lang.String[] child_tables)
Set the list of child tables.- Parameters:
child_tables
- names of all child tables to be included in a returned compound record. All tables listed must be children of the main table for this cursor but validation is not performed until a scan is started. This may be null, in which case all child tables of table_name are used in a compound record scan.
-
setChildTables
public void setChildTables(java.util.List<java.lang.String> child_tables)
Set the list of child tables.- Parameters:
child_tables
- names of all child tables to be included in a returned compound record. All tables listed must be children of the main table for this cursor but validation is not performed until a scan is started. This may be null, in which case all child tables of table_name are used in a compound record scan.
-
getChildTables
public java.lang.String[] getChildTables()
Get the list of child tables for compound records.- Returns:
- the list of child tables for compound records, or null if none set.
-
atEOT
public boolean atEOT()
Determine if a cursor is at the end-of-table position.- Returns:
- true if this cursor is at the end-of-table position.
-
setPosition
public void setPosition(java.lang.String pos)
Reset the position of a cursor.This resets the position of a cursor so that it will start reading records at a given position. Note that any table update operation, including a checkpoint/restore operation, can invalidate a saved position value. The results become unpredictable.
This does not affect the skip count.
- Parameters:
pos
- a position value returned by a previous call to getPosition. If null, the cursor is set to the start of the table.
-
getPosition
public java.lang.String getPosition()
Obtains the current cursor position. This position may be used to later set the cursor position using setPosition.- Returns:
- the cursor position as an encoded, opaque string value.
-
setSkipCount
public void setSkipCount(int count)
Sets the number of records to skip before the next batch is retrieved. Skip count is reset to zero when a batch is retrieved.- Parameters:
count
- Number of records to skip. Values less than zero are treated as zero.
-
getSkipCount
public int getSkipCount()
Gets the number of records to skip before the next batch is retrieved. Skip count is reset to zero when a batch is retrieved.- Returns:
- the number of records to skip.
-
-