GenericTableSchema hwvtepSchema = dbSchema.getTableSchema(Global.class);
Select<GenericTableSchema> selectOperation = op.select(hwvtepSchema);
- selectOperation.setColumns(new ArrayList<>(hwvtepSchema.getColumns()));
+ selectOperation.setColumns(hwvtepSchema.getColumnList());
ArrayList<Operation> operations = new ArrayList<>(2);
operations.add(selectOperation);
final GenericTableSchema hwvtepSchema = dbSchema.getTableSchema(tableClass);
final Select<GenericTableSchema> selectOperation = op.select(hwvtepSchema);
- selectOperation.setColumns(new ArrayList<>(hwvtepSchema.getColumns()));
+ selectOperation.setColumns(hwvtepSchema.getColumnList());
if (existingUUID == null) {
final WhereClauseGetter<?> whereClausule = whereClauseGetters.get(cls);
final Class<? extends TypedBaseTable<?>> tableClass = TABLE_MAP.get(cls);
final GenericTableSchema hwvtepSchema = dbSchema.getTableSchema(tableClass);
final Select<GenericTableSchema> selectOperation = op.select(hwvtepSchema);
- selectOperation.setColumns(new ArrayList<>(hwvtepSchema.getColumns()));
+ selectOperation.setColumns(hwvtepSchema.getColumnList());
final List<OperationResult> results;
try {
private static Select<GenericTableSchema> buildSelectOperationFor(final GenericTableSchema tableSchema) {
Select<GenericTableSchema> selectOpearation = op.select(tableSchema);
- selectOpearation.setColumns(new ArrayList<>(tableSchema.getColumns()));
+ selectOpearation.setColumns(tableSchema.getColumnList());
return selectOpearation;
}
import org.opendaylight.ovsdb.lib.notation.Row;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.lib.operations.Insert;
+import org.opendaylight.yangtools.util.CollectionWrappers;
public abstract class TableSchema<E extends TableSchema<E>> {
private static final AtomicColumnType UUID_COLUMN_TYPE = new AtomicColumnType(UuidBaseType.SINGLETON);
private final String name;
private final ImmutableMap<String, ColumnSchema> columns;
+ private volatile List<String> columnList;
+
protected TableSchema(final String name) {
this(name, ImmutableMap.of());
}
return columns.keySet();
}
+ public List<String> getColumnList() {
+ final List<String> local = columnList;
+ return local != null ? local : populateColumnList();
+ }
+
+ private synchronized List<String> populateColumnList() {
+ List<String> local = columnList;
+ if (local == null) {
+ columnList = local = CollectionWrappers.wrapAsList(columns.keySet());
+ }
+ return local;
+ }
+
public Map<String, ColumnSchema> getColumnSchemas() {
return columns;
}
final GenericTableSchema openVSwitchSchema = dbSchema.getTableSchema(OpenVSwitch.class);
final Select<GenericTableSchema> selectOperation = op.select(openVSwitchSchema);
- selectOperation.setColumns(new ArrayList<>(openVSwitchSchema.getColumns()));
+ selectOperation.setColumns(openVSwitchSchema.getColumnList());
List<Operation> operations = new ArrayList<>();
operations.add(selectOperation);