1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/*
* 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.drill.exec.record.metadata;
import java.util.List;
import java.util.Map;
import org.apache.drill.exec.record.MaterializedField;
/**
* Metadata description of the schema of a row or a map.
* In Drill, both rows and maps are
* tuples: both are an ordered collection of values, defined by a
* schema. Each tuple has a schema that defines the column ordering
* for indexed access. Each tuple also provides methods to get column
* accessors by name or index.
* <p>
* Models the physical schema of a row set showing the logical hierarchy of fields
* with map fields as first-class fields. Map members appear as children
* under the map, much as they appear in the physical value-vector
* implementation.
* <ul>
* <li>Provides fast lookup by name or index.</li>
* <li>Provides a nested schema, in this same form, for maps.</li>
* </ul>
* This form is useful when performing semantic analysis and when
* working with vectors.
* <p>
* In the future, this structure will also gather metadata useful
* for vector processing such as expected widths and so on.
*/
public interface TupleMetadata extends Iterable<ColumnMetadata> {
/**
* Add a new column to the schema.
*
* @param field materialized field
* @return the index of the new column
*/
ColumnMetadata add(MaterializedField field);
int addColumn(ColumnMetadata column);
int size();
boolean isEmpty();
int index(String name);
ColumnMetadata metadata(int index);
ColumnMetadata metadata(String name);
MaterializedField column(int index);
MaterializedField column(String name);
boolean isEquivalent(TupleMetadata other);
ColumnMetadata parent();
/**
* Return the schema as a list of <tt>MaterializedField</tt> objects
* which can be used to create other schemas. Not valid for a
* flattened schema.
*
* @return a list of the top-level fields. Maps contain their child
* fields
*/
List<MaterializedField> toFieldList();
/**
* Returns schema as list of <tt>ColumnMetadata</tt> objects
* which can be used to create JSON schema object.
*
* @return a list of metadata for each column
*/
List<ColumnMetadata> toMetadataList();
/**
* Full name of the column. Note: this name cannot be used to look up
* the column because of ambiguity. The name "a.b.c" may mean a single
* column with that name, or may mean maps "a", and "b" with column "c",
* etc.
*
* @return full, dotted, column name
*/
String fullName(ColumnMetadata column);
String fullName(int index);
/**
* Sets schema properties if not null.
*
* @param properties schema properties
*/
void setProperties(Map<String, String> properties);
Map<String, String> properties();
}
|