Skip to content

Commit

Permalink
del dot import
Browse files Browse the repository at this point in the history
  • Loading branch information
xitongsys committed Nov 15, 2017
1 parent f9192f7 commit 5c17734
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 128 deletions.
26 changes: 13 additions & 13 deletions example/csv_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package main

import (
"fmt"
. "github.com/xitongsys/parquet-go/ParquetHandler"
. "github.com/xitongsys/parquet-go/ParquetType"
. "github.com/xitongsys/parquet-go/Plugin/CSVWriter"
"github.com/xitongsys/parquet-go/ParquetHandler"
"github.com/xitongsys/parquet-go/ParquetType"
"github.com/xitongsys/parquet-go/Plugin/CSVWriter"
"log"
"os"
)
Expand All @@ -14,14 +14,14 @@ type MyFile struct {
File *os.File
}

func (self *MyFile) Create(name string) (ParquetFile, error) {
func (self *MyFile) Create(name string) (ParquetHandler.ParquetFile, error) {
file, err := os.Create(name)
myFile := new(MyFile)
myFile.File = file
return myFile, err

}
func (self *MyFile) Open(name string) (ParquetFile, error) {
func (self *MyFile) Open(name string) (ParquetHandler.ParquetFile, error) {
var (
err error
)
Expand Down Expand Up @@ -52,20 +52,20 @@ func (self *MyFile) Close() {
}

func main() {
md := []MetadataType{
md := []CSVWriter.MetadataType{
{Type: "UTF8", Name: "Name"},
{Type: "INT32", Name: "Age"},
{Type: "INT64", Name: "Id"},
{Type: "FLOAT", Name: "Weight"},
{Type: "BOOLEAN", Name: "Sex"},
}

var f ParquetFile
var f ParquetHandler.ParquetFile
f = &MyFile{}

//write flat
f, _ = f.Create("csv.parquet")
ph := NewCSVWriterHandler()
ph := CSVWriter.NewCSVWriterHandler()
ph.WriteInit(md, f, 10, 30)

num := 10
Expand All @@ -84,11 +84,11 @@ func main() {
ph.WriteString(rec)

data2 := []interface{}{
UTF8("Student Name"),
INT32(20 + i*5),
INT64(i),
FLOAT(50.0 + float32(i)*0.1),
BOOLEAN(i%2 == 0),
ParquetType.UTF8("Student Name"),
ParquetType.INT32(20 + i*5),
ParquetType.INT64(i),
ParquetType.FLOAT(50.0 + float32(i)*0.1),
ParquetType.BOOLEAN(i%2 == 0),
}
ph.Write(data2)
}
Expand Down
34 changes: 17 additions & 17 deletions example/hdfs_flat.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package main

import (
"github.com/colinmarc/hdfs"
. "github.com/xitongsys/parquet-go/ParquetHandler"
. "github.com/xitongsys/parquet-go/ParquetType"
"github.com/xitongsys/parquet-go/ParquetHandler"
"github.com/xitongsys/parquet-go/ParquetType"
"log"
)

type Student struct {
Name UTF8
Age INT32
Id INT64
Weight FLOAT
Sex BOOLEAN
Name ParquetType.UTF8
Age ParquetType.INT32
Id ParquetType.INT64
Weight ParquetType.FLOAT
Sex ParquetType.BOOLEAN
}

type MyFile struct {
Expand All @@ -29,7 +29,7 @@ func (self *MyFile) Init() error {
return err
}

func (self *MyFile) Create(name string) (ParquetFile, error) {
func (self *MyFile) Create(name string) (ParquetHandler.ParquetFile, error) {
file, err := self.Client.Create(name)
myFile := new(MyFile)
myFile.HdfsURL = self.HdfsURL
Expand All @@ -38,7 +38,7 @@ func (self *MyFile) Create(name string) (ParquetFile, error) {
return myFile, err

}
func (self *MyFile) Open(name string) (ParquetFile, error) {
func (self *MyFile) Open(name string) (ParquetHandler.ParquetFile, error) {
var (
err error
)
Expand Down Expand Up @@ -75,7 +75,7 @@ func (self *MyFile) Close() {
}

func main() {
var f ParquetFile
var f ParquetHandler.ParquetFile
myFile := &MyFile{
HdfsURL: "localhost:9000",
}
Expand All @@ -84,17 +84,17 @@ func main() {

//write flat
f, _ = f.Create("/flat.parquet")
ph := NewParquetHandler()
ph := ParquetHandler.NewParquetHandler()
ph.WriteInit(f, new(Student), 2, 30)

num := 10
for i := 0; i < num; i++ {
stu := Student{
Name: UTF8("StudentName"),
Age: INT32(20 + i%5),
Id: INT64(i),
Weight: FLOAT(50.0 + float32(i)*0.1),
Sex: BOOLEAN(i%2 == 0),
Name: ParquetType.UTF8("StudentName"),
Age: ParquetType.INT32(20 + i%5),
Id: ParquetType.INT64(i),
Weight: ParquetType.FLOAT(50.0 + float32(i)*0.1),
Sex: ParquetType.BOOLEAN(i%2 == 0),
}
ph.Write(stu)
}
Expand All @@ -105,7 +105,7 @@ func main() {

///read flat
f, _ = f.Open("/flat.parquet")
ph = NewParquetHandler()
ph = ParquetHandler.NewParquetHandler()
rowGroupNum := ph.ReadInit(f, 10)
for i := 0; i < rowGroupNum; i++ {
stus := make([]Student, 0)
Expand Down
38 changes: 19 additions & 19 deletions example/local_flat.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
package main

import (
. "github.com/xitongsys/parquet-go/ParquetHandler"
. "github.com/xitongsys/parquet-go/ParquetType"
"github.com/xitongsys/parquet-go/ParquetHandler"
"github.com/xitongsys/parquet-go/ParquetType"
"log"
"os"
"time"
)

type Student struct {
Name UTF8
Age INT32
Id INT64
Weight FLOAT
Sex BOOLEAN
Day DATE
Name ParquetType.UTF8
Age ParquetType.INT32
Id ParquetType.INT64
Weight ParquetType.FLOAT
Sex ParquetType.BOOLEAN
Day ParquetType.DATE
}

type MyFile struct {
FilePath string
File *os.File
}

func (self *MyFile) Create(name string) (ParquetFile, error) {
func (self *MyFile) Create(name string) (ParquetHandler.ParquetFile, error) {
file, err := os.Create(name)
myFile := new(MyFile)
myFile.File = file
return myFile, err

}
func (self *MyFile) Open(name string) (ParquetFile, error) {
func (self *MyFile) Open(name string) (ParquetHandler.ParquetFile, error) {
var (
err error
)
Expand Down Expand Up @@ -59,23 +59,23 @@ func (self *MyFile) Close() {
}

func main() {
var f ParquetFile
var f ParquetHandler.ParquetFile
f = &MyFile{}

//write flat
f, _ = f.Create("flat.parquet")
ph := NewParquetHandler()
ph := ParquetHandler.NewParquetHandler()
ph.WriteInit(f, new(Student), 4, 30)

num := 10
for i := 0; i < num; i++ {
stu := Student{
Name: UTF8("StudentName"),
Age: INT32(20 + i%5),
Id: INT64(i),
Weight: FLOAT(50.0 + float32(i)*0.1),
Sex: BOOLEAN(i%2 == 0),
Day: DATE(time.Now().Unix() / 3600 / 24),
Name: ParquetType.UTF8("StudentName"),
Age: ParquetType.INT32(20 + i%5),
Id: ParquetType.INT64(i),
Weight: ParquetType.FLOAT(50.0 + float32(i)*0.1),
Sex: ParquetType.BOOLEAN(i%2 == 0),
Day: ParquetType.DATE(time.Now().Unix() / 3600 / 24),
}
ph.Write(stu)
}
Expand All @@ -87,7 +87,7 @@ func main() {

///read flat
f, _ = f.Open("flat.parquet")
ph = NewParquetHandler()
ph = ParquetHandler.NewParquetHandler()
rowGroupNum := ph.ReadInit(f, 10)
for i := 0; i < rowGroupNum; i++ {
stus := make([]Student, 0)
Expand Down
44 changes: 22 additions & 22 deletions example/local_nested.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"fmt"
. "github.com/xitongsys/parquet-go/ParquetHandler"
. "github.com/xitongsys/parquet-go/ParquetType"
"github.com/xitongsys/parquet-go/ParquetHandler"
"github.com/xitongsys/parquet-go/ParquetType"
"log"
"os"
)
Expand All @@ -13,14 +13,14 @@ type MyFile struct {
File *os.File
}

func (self *MyFile) Create(name string) (ParquetFile, error) {
func (self *MyFile) Create(name string) (ParquetHandler.ParquetFile, error) {
file, err := os.Create(name)
myFile := new(MyFile)
myFile.File = file
return myFile, err

}
func (self *MyFile) Open(name string) (ParquetFile, error) {
func (self *MyFile) Open(name string) (ParquetHandler.ParquetFile, error) {
var (
err error
)
Expand Down Expand Up @@ -50,16 +50,16 @@ func (self *MyFile) Close() {
}

type Student struct {
Name UTF8
Age INT32
Weight *INT32
Classes *map[UTF8][]*Class
Name ParquetType.UTF8
Age ParquetType.INT32
Weight *ParquetType.INT32
Classes *map[ParquetType.UTF8][]*Class
}

type Class struct {
Name UTF8
Id *INT32
Required []UTF8
Name ParquetType.UTF8
Id *ParquetType.INT32
Required []ParquetType.UTF8
}

func (c Class) String() string {
Expand Down Expand Up @@ -92,30 +92,30 @@ func (s Student) String() string {
}

func writeNested() {
math01ID := INT32(1)
math01ID := ParquetType.INT32(1)
math01 := Class{
Name: "Math1",
Id: &math01ID,
Required: make([]UTF8, 0),
Required: make([]ParquetType.UTF8, 0),
}

math02ID := INT32(2)
math02ID := ParquetType.INT32(2)
math02 := Class{
Name: "Math2",
Id: &math02ID,
Required: make([]UTF8, 0),
Required: make([]ParquetType.UTF8, 0),
}
math02.Required = append(math02.Required, "Math01")

physics := Class{
Name: "Physics",
Id: nil,
Required: make([]UTF8, 0),
Required: make([]ParquetType.UTF8, 0),
}
physics.Required = append(physics.Required, "Math01", "Math02")

weight01 := INT32(60)
stu01Class := make(map[UTF8][]*Class)
weight01 := ParquetType.INT32(60)
stu01Class := make(map[ParquetType.UTF8][]*Class)
stu01Class["Science"] = make([]*Class, 0)
stu01Class["Science"] = append(stu01Class["Science"], &math01, &math02)
stu01 := Student{
Expand All @@ -125,7 +125,7 @@ func writeNested() {
Classes: &stu01Class,
}

stu02Class := make(map[UTF8][]*Class)
stu02Class := make(map[ParquetType.UTF8][]*Class)
stu02Class["Science"] = make([]*Class, 0)
stu02Class["Science"] = append(stu02Class["Science"], &physics)
stu02 := Student{
Expand All @@ -138,12 +138,12 @@ func writeNested() {
stus := make([]Student, 0)
stus = append(stus, stu01, stu02)

var f ParquetFile
var f ParquetHandler.ParquetFile
f = &MyFile{}

//write nested
f, _ = f.Create("nested.parquet")
ph := NewParquetHandler()
ph := ParquetHandler.NewParquetHandler()
ph.WriteInit(f, new(Student), 4, 30)
for _, stu := range stus {
ph.Write(stu)
Expand All @@ -155,7 +155,7 @@ func writeNested() {

//read nested
f, _ = f.Open("nested.parquet")
ph = NewParquetHandler()
ph = ParquetHandler.NewParquetHandler()
rowGroupNum := ph.ReadInit(f, 10)
for i := 0; i < rowGroupNum; i++ {
stus := make([]Student, 0)
Expand Down
Loading

0 comments on commit 5c17734

Please sign in to comment.