public Map timebaseStreamToClickhouseTable()

in java/clickhouse-connector/src/main/java/com/epam/deltix/timebase/connector/clickhouse/algos/SchemaProcessor.java [83:117]


    public Map<String, TableDeclaration> timebaseStreamToClickhouseTable() {
        RecordClassSet tbSchema = schemaOptions.getTbSchema();
        Map<String, String> mapping = schemaOptions.getMapping();

        RecordClassDescriptor[] allDescriptors = Arrays.stream(tbSchema.getClassDescriptors())
                .filter(rcd -> rcd instanceof RecordClassDescriptor && !((RecordClassDescriptor)rcd).isAbstract())
                .map(classDescriptor -> (RecordClassDescriptor) classDescriptor)
                .toArray(RecordClassDescriptor[]::new);

        for (RecordClassDescriptor descriptor : allDescriptors) {
            columnDeclarations.put(descriptor.getName(), getColumnDeclarations(descriptor));
        }
        Map<String, TableDeclaration> tableDeclarations = new HashMap<>(mapping.size());

        for (Map.Entry<String, String> entry : mapping.entrySet()) {
            ClickhouseTableIdentity tableIdentity = ClickhouseTableIdentity.of(clickhouseProperties.getDatabase(), normalizeStreamNameToClickhouseNotation(entry.getValue()));
            if (entry.getKey().equals(ALL_TYPES)) {
                List<ColumnDeclaration> columnDeclarations = getColumnDeclarations(tbSchema.getContentClasses())
                        .stream()
                        .map(c -> (ColumnDeclaration)c)
                        .collect(Collectors.toList());
                tableDeclarations.put(entry.getKey(), new TableDeclaration(tableIdentity, columnDeclarations));
            } else if (columnDeclarations.containsKey(entry.getKey())){
                List<ColumnDeclaration> columnDeclarations = this.columnDeclarations.get(entry.getKey())
                        .stream()
                        .map(c -> (ColumnDeclaration)c)
                        .collect(Collectors.toList());
                tableDeclarations.put(entry.getKey(), new TableDeclaration(tableIdentity, columnDeclarations));
            } else {
                throw new IllegalArgumentException("Invalidate mapping");
            }
        }

        return tableDeclarations;
    }