java/core/src/test/org/apache/orc/impl/TestSchemaEvolution.java
@Test
  public void testConvergentEvolution() {
    TypeDescription fileType = TypeDescription
        .fromString("struct<a:struct<a:int,b:string>,c:struct<a:int>>");
    TypeDescription readerType = TypeDescription.fromString(
        "struct<a:struct<a:int,b:string>,c:struct<a:int,b:string>>");
    boolean[] included = includeAll(readerType);
    options.tolerateMissingSchema(false);
    SchemaEvolution transition =
        new SchemaEvolution(fileType, readerType, options.include(included));

    // c -> c
    TypeDescription reader = readerType.getChildren().get(1);
    TypeDescription mapped = transition.getFileType(reader);
    TypeDescription original = fileType.getChildren().get(1);
    assertSame(original, mapped);

    // c.a -> c.a
    TypeDescription readerchild = reader.getChildren().get(0);
    mapped = transition.getFileType(readerchild);
    original = original.getChildren().get(0);
    assertSame(original, mapped);

    // c.b -> null
    readerchild = reader.getChildren().get(1);
    mapped = transition.getFileType(readerchild);
    original = null;
    assertSame(original, mapped);
  }
/**
   * Two structs can be equal but in different locations. They can converge to this.
   */
Two structs can be equal but in different locations. They can converge to this.
Two structs can be equal but in different locations . They can converge to this .
@Test
  public void testConvergentEvolution() {
    TypeDescription fileType = TypeDescription
        .fromString("struct<a:struct<a:int,b:string>,c:struct<a:int>>");
    TypeDescription readerType = TypeDescription.fromString(
        "struct<a:struct<a:int,b:string>,c:struct<a:int,b:string>>");
    boolean[] included = includeAll(readerType);
    options.tolerateMissingSchema(false);
    SchemaEvolution transition =
        new SchemaEvolution(fileType, readerType, options.include(included));
    TypeDescription reader = readerType.getChildren().get(1);
    TypeDescription mapped = transition.getFileType(reader);
    TypeDescription original = fileType.getChildren().get(1);
    assertSame(original, mapped);
    TypeDescription readerchild = reader.getChildren().get(0);
    mapped = transition.getFileType(readerchild);
    original = original.getChildren().get(0);
    assertSame(original, mapped);
    readerchild = reader.getChildren().get(1);
    mapped = transition.getFileType(readerchild);
    original = null;
    assertSame(original, mapped);
  }
@ Test public void testConvergentEvolution ( ) { TypeDescription fileType = TypeDescription . fromString ( "struct<a:struct<a:int,b:string>,c:struct<a:int>>" ) ; TypeDescription readerType = TypeDescription . fromString ( "struct<a:struct<a:int,b:string>,c:struct<a:int,b:string>>" ) ; boolean [ ] included = includeAll ( readerType ) ; options . tolerateMissingSchema ( false ) ; SchemaEvolution transition = new SchemaEvolution ( fileType , readerType , options . include ( included ) ) ; TypeDescription reader = readerType . getChildren ( ) . get ( 1 ) ; TypeDescription mapped = transition . getFileType ( reader ) ; TypeDescription original = fileType . getChildren ( ) . get ( 1 ) ; assertSame ( original , mapped ) ; TypeDescription readerchild = reader . getChildren ( ) . get ( 0 ) ; mapped = transition . getFileType ( readerchild ) ; original = original . getChildren ( ) . get ( 0 ) ; assertSame ( original , mapped ) ; readerchild = reader . getChildren ( ) . get ( 1 ) ; mapped = transition . getFileType ( readerchild ) ; original = null ; assertSame ( original , mapped ) ; }
Two structs can be equal but in different locations.
Two structs can be equal but in different locations .
// c -> c // c.a -> c.a // c.b -> null