Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add More Examples #50

Open
vfrank66 opened this issue May 25, 2019 · 0 comments
Open

Add More Examples #50

vfrank66 opened this issue May 25, 2019 · 0 comments

Comments

@vfrank66
Copy link

vfrank66 commented May 25, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant