ByteBuffer state = null;
if (flags.contains(Flag.HAS_MORE_PAGES))
state = CBUtil.readValue(body);
if (flags.contains(Flag.NO_METADATA))
return new Metadata(columnCount, null, state);
boolean globalTablesSpec = flags.contains(Flag.GLOBAL_TABLES_SPEC);
String globalKsName = null;
String globalCfName = null;
if (globalTablesSpec) {
globalKsName = CBUtil.readString(body);
globalCfName = CBUtil.readString(body);
}
// metadata (names/types)
ColumnDefinitions.Definition[] defs = new ColumnDefinitions.Definition[columnCount];
for (int i = 0; i < columnCount; i++) {
String ksName = globalTablesSpec ? globalKsName : CBUtil.readString(body);
String cfName = globalTablesSpec ? globalCfName : CBUtil.readString(body);
String name = CBUtil.readString(body);
DataType type = DataType.decode(body);
defs[i] = new ColumnDefinitions.Definition(ksName, cfName, name, type);
}
return new Metadata(columnCount, new ColumnDefinitions(defs), state);
}