Git Product home page Git Product logo

Comments (8)

Pryz avatar Pryz commented on August 10, 2024 1

Hi @seaguest,

Looking at the snippet you shared it doesn't look like you are using segmentio/parquet-go.

Using the following :

package main

import (
        "os"

        "log"

        segmentparquet "github.com/segmentio/parquet-go"
)

func write() {
        f, err := os.OpenFile("outputs.parquet", os.O_APPEND|os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm)
        if err != nil {
                log.Println(err)
                return
        }
        defer f.Close()

        writer := segmentparquet.NewWriter(f)

        type record struct {
                Format   string `parquet:"format,snappy"`
                DataType int32  `parquet:"data_type,snappy"`
                Country  string `parquet:"country,snappy"`
        }

        num := 1000
        for i := 0; i < num; i++ {
                stu := record{
                        Format:   "Test",
                        DataType: 1,
                        Country:  "IN",
                }

                writer.Write(stu) // here argument can only be []byte
        }
        // Closing the writer is necessary to flush buffers and write the file footer.
        if err := writer.Close(); err != nil {
                log.Println(err)
        }

}

func main() {
        write()
}

ends up creating a file of 1060 bytes so about 1KB.

from parquet-go.

seaguest avatar seaguest commented on August 10, 2024

I tried to use

	type record struct {
		Format   string `parquet:"format,snappy"`
		DataType int32  `parquet:"data_type,snappy"`
		Country  string `parquet:"country,snappy"`
	}

but the output file is still very large, about 34M,while with other 2 libraries, they are only 1KB

from parquet-go.

seaguest avatar seaguest commented on August 10, 2024

@Pryz

Indeed it works now.
But I am curious why should we put snappy annotation for each field, usually we won't have different compression type for different fields in one struct.

I saw other library has an option like this

	pw.CompressionType = parquet2.CompressionCodec_GZIP

why this library doesn't have such an option?

from parquet-go.

kevinburkesegment avatar kevinburkesegment commented on August 10, 2024

usually we won't have different compression type for different fields in one struct.

We're planning to use different compression types for different fields in one struct (tracing data), which is why we thought that choice was a good fit.

from parquet-go.

kevinburkesegment avatar kevinburkesegment commented on August 10, 2024

I'm going to close this - thanks for the issue report and glad you got it working!

from parquet-go.

seaguest avatar seaguest commented on August 10, 2024

are you planning to provide an option of compression type for all fields in the future?
If we have hundreds of fields, it would be a disaster to add "snappy" for each, and that is meaningless in case we need only one compression type.

thanks for your quick reply~

from parquet-go.

himanshpal avatar himanshpal commented on August 10, 2024

+1 on this. It would be great to provide an alternative way to pass compression config while initialising an writer.

from parquet-go.

Pryz avatar Pryz commented on August 10, 2024

Created #124 as a follow up

from parquet-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.