in java/core/src/main/java/com/aliyun/openservices/tablestore/agent/memory/MemoryStoreImpl.java [782:829]
public void initTable() {
// Create Session table
List<Pair<String, MetaType>> sessionDefinedColumns = new ArrayList<>(sessionSecondaryIndexMeta);
if (sessionSecondaryIndexMeta.stream().noneMatch(s -> Session.SESSION_UPDATE_TIME.equals(s.getKey()))) {
sessionDefinedColumns.add(Pair.of(Session.SESSION_UPDATE_TIME, MetaType.INTEGER));
} else {
throw Exceptions.illegalArgument("sessionSecondaryIndexMeta can't contains 'update_time'");
}
TablestoreHelper.createTableIfNotExist(
client,
sessionTableName,
Arrays.asList(Pair.of(Session.SESSION_USER_ID, MetaType.STRING), Pair.of(Session.SESSION_SESSION_ID, MetaType.STRING)),
sessionDefinedColumns
);
// Create Session secondary index
List<String> definedColumnNames = sessionSecondaryIndexMeta.stream().map(Pair::getKey).collect(Collectors.toList());
TablestoreHelper.createSecondaryIndexIfNotExist(
client,
sessionTableName,
sessionSecondaryIndexName,
Arrays.asList(Session.SESSION_USER_ID, Session.SESSION_UPDATE_TIME, Session.SESSION_SESSION_ID),
definedColumnNames,
IndexType.IT_LOCAL_INDEX
);
// Create Message table
TablestoreHelper.createTableIfNotExist(
client,
messageTableName,
Arrays.asList(
Pair.of(Message.MESSAGE_SESSION_ID, MetaType.STRING),
Pair.of(Message.MESSAGE_CREATE_TIME, MetaType.INTEGER),
Pair.of(Message.MESSAGE_MESSAGE_ID, MetaType.STRING)
),
Collections.emptyList()
);
// Create secondary index for Message table
TablestoreHelper.createSecondaryIndexIfNotExist(
client,
messageTableName,
messageSecondaryIndexName,
Arrays.asList(Message.MESSAGE_SESSION_ID, Message.MESSAGE_MESSAGE_ID, Message.MESSAGE_CREATE_TIME),
Collections.emptyList(),
IndexType.IT_LOCAL_INDEX
);
}