/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.shardingsphere.core.metadata.table;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;

/**
 * Table metadata.
 *
 * @author panjuan
 */
@Getter
@EqualsAndHashCode
@ToString
public final class TableMetaData {
    
    private final Map<String, ColumnMetaData> columns;
    
    private final Set<String> logicIndexes;
    
    public TableMetaData(final Collection<ColumnMetaData> columnMetaDataList, final Set<String> logicIndexes) {
        columns = getColumns(columnMetaDataList);
        this.logicIndexes = new CopyOnWriteArraySet<>(logicIndexes);
    }
    
    private Map<String, ColumnMetaData> getColumns(final Collection<ColumnMetaData> columnMetaDataList) {
        final Map<String, ColumnMetaData> columns;
        columns = new ConcurrentHashMap<>(columnMetaDataList.size(), 1);
        for (ColumnMetaData each : columnMetaDataList) {
            columns.put(each.getColumnName(), each);
        }
        return columns;
    }
}

@@ -978,16 +978,26 @@
 va.util.
+LinkedHash
 Map;%0Aimp
@@ -1010,19 +1010,19 @@
 va.util.
-Set
+Map
 ;%0Aimport
@@ -1036,36 +1036,11 @@
 til.
-concurrent.ConcurrentHashMap
+Set
 ;%0Aim
@@ -1087,16 +1087,70 @@
 aySet;%0A%0A
+import static java.util.Collections.synchronizedMap;%0A%0A
 /**%0A * T
@@ -1732,22 +1732,16 @@
         
-final 
 Map%3CStri
@@ -1771,42 +1771,21 @@
 umns
-;%0A        columns = new Concurrent
+ = new Linked
 Hash
@@ -1956,23 +1956,40 @@
  return 
+synchronizedMap(
 columns
+)
 ;%0A    %7D%0A

USE synchronizedMap