* Create a TableRecord instance from the specified index record
*/
public Table createTableRecord(final char[] record) {
final String str = new String(record);
final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
final Table table = new Table();
// Extract the index version information from the record
int indexVersion = getIndexVersion(record);
// The tokens are the standard header values
int tokenIndex = 0;
setRecordHeaderValues(table, tokens.get(tokenIndex++), tokens.get(tokenIndex++),
tokens.get(tokenIndex++), tokens.get(tokenIndex++),
tokens.get(tokenIndex++), tokens.get(tokenIndex++));
// The next token is the cardinality
table.setCardinality( Integer.parseInt(tokens.get(tokenIndex++)) );
// The next token is the tableType
table.setTableType(Table.Type.values()[Integer.parseInt(tokens.get(tokenIndex++))]);
// The next token are the supports flags
char[] supportFlags = (tokens.get(tokenIndex++)).toCharArray();
table.setVirtual(getBooleanValue(supportFlags[0]));
table.setSystem(getBooleanValue(supportFlags[1]));
table.setSupportsUpdate(getBooleanValue(supportFlags[2]));
if(includeMaterializationFlag(indexVersion)) {
table.setMaterialized(getBooleanValue(supportFlags[3]));
}
// The next token are the UUIDs for the column references (no longer stored on the record)
tokenIndex++;
// The next token is the UUID of the primary key
String id = getObjectValue(tokens.get(tokenIndex++));
if (id != null) {
KeyRecord pk = new KeyRecord(KeyRecord.Type.Primary);
pk.setUUID(id);
table.setPrimaryKey(pk);
}
tokenIndex+=4; //skip reading uuids for associated records
if(includeMaterializationFlag(indexVersion)) {
// The next token are the UUIDs for the materialized table ID
Table matTable = new Table();
matTable.setUUID(tokens.get(tokenIndex++));
table.setMaterializedTable(matTable);
// The next token are the UUID for the materialized stage table ID
matTable = new Table();
matTable.setUUID(tokens.get(tokenIndex++));
table.setMaterializedStageTable(matTable);
}
// The next tokens are footer values
setRecordFooterValues(table, tokens, tokenIndex);