@Test public void testReassignIds() { Schema schema = TypeUtil.reassignIds( new Schema( Types.NestedField.required(10, "a", Types.LongType.get()), Types.NestedField.required(11, "b", Types.StringType.get()) ), new Schema( Types.NestedField.required(0, "a", Types.LongType.get()))); check(ImmutableMap.of("b", 1, "a", 0), schema); schema = TypeUtil.reassignIds( new Schema( Types.NestedField.required(20, "a", Types.MapType.ofRequired(21, 22, Types.StringType.get(), Types.StructType.of( Types.NestedField.required(25, "b", Types.StringType.get()), Types.NestedField.required(27, "c", Types.StructType.of( Types.NestedField.required(28, "d", Types.FloatType.get()), Types.NestedField.required(29, "e", Types.FloatType.get()) )))))), new Schema( Types.NestedField.required(1, "a", Types.MapType.ofRequired(2, 3, Types.StringType.get(), Types.StructType.of( Types.NestedField.required(4, "b", Types.StringType.get())))))); check(ImmutableMap.of("a.c", 7, "a.c.d", 5, "a.c.e", 6), schema); schema = TypeUtil.reassignIds( new Schema( Types.NestedField.required(9, "e", Types.IntegerType.get()), Types.NestedField.required(10, "a", Types.StructType.of( Types.NestedField.required(11, "b", Types.StructType.of( Types.NestedField.required(12, "c", Types.StructType.of( Types.NestedField.required(13, "d", Types.IntegerType.get())))))))), new Schema( Types.NestedField.required(0, "e", Types.IntegerType.get()))); check(ImmutableMap.of("a.b.c.d", 1, "a.b.c", 2, "a.b", 3, "a", 4, "e", 0), schema); }
ReassignIds(Schema sourceSchema) { this.sourceSchema = sourceSchema; nextId = Collections.max(TypeUtil.indexById(sourceSchema.asStruct()).keySet()) + 1; newField = false; }
ReassignIds extends TypeUtil.CustomOrderSchemaVisitor<Type> { ReassignIds(Schema sourceSchema) { this.sourceSchema = sourceSchema; nextId = Collections.max(TypeUtil.indexById(sourceSchema.asStruct()).keySet()) + 1; newField = false; } }
ReassignIds extends TypeUtil.CustomOrderSchemaVisitor<Type> { ReassignIds(Schema sourceSchema) { this.sourceSchema = sourceSchema; nextId = Collections.max(TypeUtil.indexById(sourceSchema.asStruct()).keySet()) + 1; newField = false; } ReassignIds(Schema sourceSchema); }
ReassignIds extends TypeUtil.CustomOrderSchemaVisitor<Type> { ReassignIds(Schema sourceSchema) { this.sourceSchema = sourceSchema; nextId = Collections.max(TypeUtil.indexById(sourceSchema.asStruct()).keySet()) + 1; newField = false; } ReassignIds(Schema sourceSchema); @Override Type schema(Schema schema, Supplier<Type> future); @Override Type struct(Types.StructType struct, Iterable<Type> fieldTypes); @Override Type field(Types.NestedField field, Supplier<Type> future); @Override Type list(Types.ListType list, Supplier<Type> elementTypeFuture); @Override Type map(Types.MapType map, Supplier<Type> keyTypeFuture, Supplier<Type> valueTypeFuture); @Override Type primitive(Type.PrimitiveType primitive); }
ReassignIds extends TypeUtil.CustomOrderSchemaVisitor<Type> { ReassignIds(Schema sourceSchema) { this.sourceSchema = sourceSchema; nextId = Collections.max(TypeUtil.indexById(sourceSchema.asStruct()).keySet()) + 1; newField = false; } ReassignIds(Schema sourceSchema); @Override Type schema(Schema schema, Supplier<Type> future); @Override Type struct(Types.StructType struct, Iterable<Type> fieldTypes); @Override Type field(Types.NestedField field, Supplier<Type> future); @Override Type list(Types.ListType list, Supplier<Type> elementTypeFuture); @Override Type map(Types.MapType map, Supplier<Type> keyTypeFuture, Supplier<Type> valueTypeFuture); @Override Type primitive(Type.PrimitiveType primitive);  }