public interface Table
TableAPI.getTable(java.lang.String)
and getChildTable(java.lang.String)
.
Table contains immutable metadata for a table and acts as a factory for
objects used in the TableAPI
interface.
Tables are defined in terms of named fields where each field is defined by
an instance of FieldDef
. A single record in a table is called a
Row
and is uniquely identified by the table's PrimaryKey
.
The primary key is defined upon construction by an ordered list of fields.
Tables also have a shardKey
which is a proper subset of the primary
key. A shard key has the property that all rows in a table that share the
same shard key values are stored in the same partition and can be accessed
transactionally. If not otherwise defined the shard key is the same as the
table's primary key.
A table may be a top-level table, with no parent table, or a child table, which has a parent. A child table shares its parent table's primary key but adds its own fields to its primary key to uniquely identify child table rows. It is not possible to define a shard key on a child table. It inherits its parent table's shard key.
Modifier and Type | Method and Description |
---|---|
boolean |
childTableExists(String name)
Returns true if the named child table exists, false otherwise.
|
Table |
clone()
Clone the table.
|
FieldRange |
createFieldRange(String fieldName)
Creates a
FieldRange object used to specify a value range for use
in a table iteration operation in TableAPI . |
PrimaryKey |
createPrimaryKey()
Creates an empty
PrimaryKey for the table that can only hold
fields that are part of the primary key for the table. |
PrimaryKey |
createPrimaryKey(RecordValue value)
Creates a
PrimaryKey for the table populated with relevant
fields from the RecordValue parameter. |
PrimaryKey |
createPrimaryKeyFromJson(InputStream jsonInput,
boolean exact)
Creates a
PrimaryKey based on JSON input. |
PrimaryKey |
createPrimaryKeyFromJson(String jsonInput,
boolean exact)
Creates a
PrimaryKey based on JSON input. |
ReturnRow |
createReturnRow(ReturnRow.Choice returnChoice)
Creates a ReturnRow object for the ReturnRow parameter in
table put and delete methods in
TableAPI such as
TableAPI.put(oracle.kv.table.Row, oracle.kv.table.ReturnRow, oracle.kv.table.WriteOptions) and TableAPI.delete(oracle.kv.table.PrimaryKey, oracle.kv.table.ReturnRow, oracle.kv.table.WriteOptions) . |
Row |
createRow()
Creates an empty Row for the table that can hold any field value.
|
Row |
createRow(RecordValue value)
Creates a Row for the table populated with relevant fields from the
RecordValue parameter. |
Row |
createRowFromJson(InputStream jsonInput,
boolean exact)
Creates a Row based on JSON input.
|
Row |
createRowFromJson(String jsonInput,
boolean exact)
Creates a Row based on JSON string input.
|
Row |
createRowWithDefaults()
Creates a Row using the default values for all fields.
|
Table |
getChildTable(String name)
Gets the named child table if it exists.
|
Map<String,Table> |
getChildTables()
Gets an unmodifiable view of all child tables of this table.
|
FieldValue |
getDefaultValue(String name)
Creates an instance using the default value for the named field.
|
String |
getDescription()
Returns the table's description if present, otherwise null.
|
FieldDef |
getField(String name)
Returns the named field from the table definition, or null if the field
does not exist.
|
List<String> |
getFields()
Returns an unmodifiable list of the field names of the table in
declaration order which is done during table definition.
|
String |
getFullName()
Returns the table's fully-qualified name which includes its ancestor
tables in a dot (".") separated path.
|
Index |
getIndex(String indexName)
Gets the named index if it exists, null otherwise.
|
Map<String,Index> |
getIndexes()
Returns an unmodifiable map of all of the indexes on this table.
|
String |
getName()
Gets the name of the table.
|
Table |
getParent()
Returns the parent table, or null if this table has no parent.
|
List<String> |
getPrimaryKey()
Returns an unmodifable list of the field names that comprise the primary
key for the table.
|
List<String> |
getShardKey()
Returns an unmodifable list of the shard key fields.
|
int |
getTableVersion()
Returns the current version of the table metadata.
|
Table |
getVersion(int version)
Gets the specified version of the table.
|
boolean |
isNullable(String name)
Returns true if the named field is nullable.
|
int |
numTableVersions()
Returns the number of versions of this table that exist.
|
Table getChildTable(String name)
name
- the table name for the desired tableboolean childTableExists(String name)
name
- the table name for the desired tableMap<String,Table> getChildTables()
Table getParent()
int getTableVersion()
Table getVersion(int version)
The version must be a valid version between 0 and the value of
numTableVersions()
. If the version is 0 the latest
version is used. Actual version numbers begin with 1.
version
- the version to useIllegalArgumentException
- if the requested version number is
negative or out of range of the known versionsint numTableVersions()
By default when a table is accessed its current (latest) version will be
used. It is possible to see an earlier or later version using
getVersion(int)
.
Index getIndex(String indexName)
indexName
- the name of the indexMap<String,Index> getIndexes()
String getName()
String getFullName()
String getDescription()
List<String> getFields()
FieldDef getField(String name)
boolean isNullable(String name)
name
- the name of the fieldIllegalArgumentException
- if the named field does not exist
in the table definitionFieldValue getDefaultValue(String name)
FieldValue
and not a more specific type
because in the case of nullable fields the default will be a null value,
which is a special value that returns true for isNullable(java.lang.String)
.name
- the name of the fieldIllegalArgumentException
- if the named field does not exist
in the table definitionList<String> getPrimaryKey()
List<String> getShardKey()
Row createRow()
Row createRow(RecordValue value)
RecordValue
parameter. Only fields that belong in
this table are added. Other fields are silently ignored.value
- a RecordValue instance containing fields that may or
may not be applicable to this tableRow createRowWithDefaults()
PrimaryKey createPrimaryKey()
PrimaryKey
for the table that can only hold
fields that are part of the primary key for the table. Other fields
will be rejected if an attempt is made to set them on the returned
object.PrimaryKey createPrimaryKey(RecordValue value)
PrimaryKey
for the table populated with relevant
fields from the RecordValue
parameter. Only fields that belong
in this primary key are added. Other fields are silently ignored.value
- a RecordValue
instance containing fields that may
or may not be applicable to this table's primary key. Only fields that
belong in the key are added.ReturnRow createReturnRow(ReturnRow.Choice returnChoice)
TableAPI
such as
TableAPI.put(oracle.kv.table.Row, oracle.kv.table.ReturnRow, oracle.kv.table.WriteOptions)
and TableAPI.delete(oracle.kv.table.PrimaryKey, oracle.kv.table.ReturnRow, oracle.kv.table.WriteOptions)
.returnChoice
- describes the state to returnReturnRow
containing the choice passed in the
parameterRow createRowFromJson(String jsonInput, boolean exact)
exact
parameter is true the input string must contain an exact match to
the table row, including all fields, required or not. It must not
have additional data. If false, only matching fields will be added
and the input may have additional, unrelated data.jsonInput
- a JSON stringexact
- set to true for an exact match. See aboveIllegalArgumentException
- if exact is true and a field is
missing or extra. It will also be thrown if a field type or value is
not correctIllegalArgumentException
- if the input is malformedRow createRowFromJson(InputStream jsonInput, boolean exact)
exact
parameter is true the input string must contain an exact match to
the table row, including all fields, required or not. It must not
have additional data. If false, only matching fields will be added
and the input may have additional, unrelated data.jsonInput
- a JSON stringexact
- set to true for an exact match. See aboveIllegalArgumentException
- if exact is true and a field is
missing or extra. It will also be thrown if a field type or value is
not correctIllegalArgumentException
- if the input is malformedPrimaryKey createPrimaryKeyFromJson(String jsonInput, boolean exact)
PrimaryKey
based on JSON input. If the
exact
parameter is true the input string must contain an exact match to
the primary key, including all fields, required or not. It must not
have additional data. If false, only matching fields will be added
and the input may have additional, unrelated data.jsonInput
- a JSON stringexact
- set to true for an exact match. See aboveIllegalArgumentException
- if exact is true and a field is
missing or extra. It will also be thrown if a field type or value is
not correctIllegalArgumentException
- if the input is malformedPrimaryKey createPrimaryKeyFromJson(InputStream jsonInput, boolean exact)
PrimaryKey
based on JSON input. If the
exact
parameter is true the input string must contain an exact match to
the primary key, including all fields, required or not. It must not
have additional data. If false, only matching fields will be added
and the input may have additional, unrelated data.jsonInput
- a JSON stringexact
- set to true for an exact match. See aboveIllegalArgumentException
- if exact is true and a field is
missing or extra. It will also be thrown if a field type or value is
not correctIllegalArgumentException
- if the input is malformedFieldRange createFieldRange(String fieldName)
FieldRange
object used to specify a value range for use
in a table iteration operation in TableAPI
.fieldName
- the name of the field from the PrimaryKey to use for
the rangeFieldRange
based on the table and fieldIllegalArgumentException
- if the field is not defined in the
table's primary keyTable clone()
Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.