use of org.apache.parquet.schema.Type.Repetition in project parquet-mr by apache.
the class MetadataUtils method showDetails.
private static void showDetails(PrettyPrintWriter out, GroupType type, int depth, MessageType container, List<String> cpath) {
String name = Strings.repeat(".", depth) + type.getName();
Repetition rep = type.getRepetition();
int fcount = type.getFieldCount();
out.format("%s: %s F:%d%n", name, rep, fcount);
cpath.add(type.getName());
for (Type ftype : type.getFields()) {
showDetails(out, ftype, depth + 1, container, cpath);
}
cpath.remove(cpath.size() - 1);
}
use of org.apache.parquet.schema.Type.Repetition in project parquet-mr by apache.
the class MetadataUtils method showDetails.
private static void showDetails(PrettyPrintWriter out, PrimitiveType type, int depth, MessageType container, List<String> cpath) {
String name = Strings.repeat(".", depth) + type.getName();
OriginalType otype = type.getOriginalType();
Repetition rep = type.getRepetition();
PrimitiveTypeName ptype = type.getPrimitiveTypeName();
out.format("%s: %s %s", name, rep, ptype);
if (otype != null)
out.format(" O:%s", otype);
if (container != null) {
cpath.add(type.getName());
String[] paths = cpath.toArray(new String[cpath.size()]);
cpath.remove(cpath.size() - 1);
ColumnDescriptor desc = container.getColumnDescription(paths);
int defl = desc.getMaxDefinitionLevel();
int repl = desc.getMaxRepetitionLevel();
out.format(" R:%d D:%d", repl, defl);
}
out.println();
}
use of org.apache.parquet.schema.Type.Repetition in project parquet-mr by apache.
the class MessageTypeParser method addType.
private static void addType(String t, Tokenizer st, Types.GroupBuilder builder) {
Repetition repetition = asRepetition(t, st);
// Read type.
String type = st.nextToken();
if ("group".equalsIgnoreCase(type)) {
addGroupType(st, repetition, builder);
} else {
addPrimitiveType(st, asPrimitive(type, st), repetition, builder);
}
}
use of org.apache.parquet.schema.Type.Repetition in project parquet-mr by apache.
the class TestTypeBuilders method testPrimitiveTypeConstruction.
@Test
public void testPrimitiveTypeConstruction() {
PrimitiveTypeName[] types = new PrimitiveTypeName[] { BOOLEAN, INT32, INT64, INT96, FLOAT, DOUBLE, BINARY };
for (PrimitiveTypeName type : types) {
String name = type.toString() + "_";
for (Type.Repetition repetition : Type.Repetition.values()) {
PrimitiveType expected = new PrimitiveType(repetition, type, name);
PrimitiveType built = Types.primitive(type, repetition).named(name);
Assert.assertEquals(expected, built);
switch(repetition) {
case REQUIRED:
built = Types.required(type).named(name);
break;
case OPTIONAL:
built = Types.optional(type).named(name);
break;
case REPEATED:
built = Types.repeated(type).named(name);
break;
}
Assert.assertEquals(expected, built);
}
}
}
use of org.apache.parquet.schema.Type.Repetition in project parquet-mr by apache.
the class TestTypeBuilders method testGroupTypeConstruction.
@Test
public void testGroupTypeConstruction() {
PrimitiveType f1 = Types.required(BINARY).as(UTF8).named("f1");
PrimitiveType f2 = Types.required(INT32).named("f2");
PrimitiveType f3 = Types.optional(INT32).named("f3");
String name = "group";
for (Type.Repetition repetition : Type.Repetition.values()) {
GroupType expected = new GroupType(repetition, name, f1, new GroupType(repetition, "g1", f2, f3));
GroupType built = Types.buildGroup(repetition).addField(f1).group(repetition).addFields(f2, f3).named("g1").named(name);
Assert.assertEquals(expected, built);
switch(repetition) {
case REQUIRED:
built = Types.requiredGroup().addField(f1).requiredGroup().addFields(f2, f3).named("g1").named(name);
break;
case OPTIONAL:
built = Types.optionalGroup().addField(f1).optionalGroup().addFields(f2, f3).named("g1").named(name);
break;
case REPEATED:
built = Types.repeatedGroup().addField(f1).repeatedGroup().addFields(f2, f3).named("g1").named(name);
break;
}
Assert.assertEquals(expected, built);
}
}
Aggregations