All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.flink.lakesoul.metadata.DatabaseSchemaedTables Maven / Gradle / Ivy

There is a newer version: 2.5.1-flink-1.17
Show newest version
// SPDX-FileCopyrightText: 2023 LakeSoul Contributors
//
// SPDX-License-Identifier: Apache-2.0

package org.apache.flink.lakesoul.metadata;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class DatabaseSchemaedTables {
    private final String DBName;
    HashMap tables = new HashMap<>(20);

    public DatabaseSchemaedTables(String DBName) {
        this.DBName = DBName;
    }

    public Table addTable(String tableName) {
        if (!tables.containsKey(tableName)) {
            Table tb = new Table(tableName);
            tables.put(tableName, tb);
        }
        return tables.get(tableName);
    }

    class Table {
        String TName;
        List cols = new ArrayList<>(50);
        List PKs = new ArrayList<>(10);

        public Table(String TName) {
            this.TName = TName;
        }

        public void addColumn(String colName, String colType) {
            cols.add(new Column(colName, colType));
        }

        public void addPrimaryKey(String key, int index) {
            if (key != null) {
                PKs.add(new PK(key, index));
            }
        }
    }

    class Column {
        String colName;
        String type;

        public Column(String colName, String type) {
            this.colName = colName;
            this.type = type;
        }
    }

    class PK implements Comparable {
        String colName;
        int pos;

        public PK(String colName, int pos) {
            this.colName = colName;
            this.pos = pos;
        }

        @Override
        public int compareTo(PK o) {
            return this.pos - o.pos;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy