Skip to content

Add More Examples  #50

Description

@vfrank66

I used this orc reader for a project I was working and I wanted to offer an example I needed which helped me. I had nested orc structures I wanted to convert to json. If would like a PR I would be happy to submit to the README.md

// Example 2

   r, err := Open("./examples/demo-12-zlib.orc")
    if err != nil {
        log.Fatal(err)
    }
    defer r.Close()

    rootColumns := r.Schema().Columns()
    count := len(rootColumns)
    values := make([]interface{}, count)

    // Create a new Cursor reading the provided columns.
    c := r.Select(rootColumns...)


    returnData := make(map[string]interface{})
    // Iterate over each stripe in the file.
    for c.Stripes() {
        
        // Iterate over each row in the stripe.
        for c.Next() {
              
            // Retrieve a slice of interface values for the current row.
            log.Println(c.Row())
            
            currentRow := c.Row()
	    for i, _ := range values {
		masterData[rootColumns[i]] = currentRow[i]
	    }
			
	    slicer, _ := json.Marshal(returnData)
	    fmt.Println(string(slicer))
        }
       
    }

    if err := c.Err(); err != nil {
        log.Fatal(err)
    }

This is taken from https://github.com/vfrank66/aws-s3-orc-to-kinesis.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions