Beispiel #1
0
func (def ListOfStringDef) New() ListOfString {
	l := make([]types.Value, len(def))
	for i, d := range def {
		l[i] = types.NewString(d)
	}
	return ListOfString{types.NewTypedList(__typeForListOfString, l...), &ref.Ref{}}
}
Beispiel #2
0
func (def ListOfRefOfFloat32Def) New() ListOfRefOfFloat32 {
	l := make([]types.Value, len(def))
	for i, d := range def {
		l[i] = NewRefOfFloat32(d)
	}
	return ListOfRefOfFloat32{types.NewTypedList(__typeForListOfRefOfFloat32, l...), &ref.Ref{}}
}
func (def ListOfUint8Def) New() ListOfUint8 {
	l := make([]types.Value, len(def))
	for i, d := range def {
		l[i] = types.Uint8(d)
	}
	return ListOfUint8{types.NewTypedList(__typeForListOfUint8, l...), &ref.Ref{}}
}
Beispiel #4
0
func (def ListOfRefOfMapOfStringToValueDef) New() ListOfRefOfMapOfStringToValue {
	l := make([]types.Value, len(def))
	for i, d := range def {
		l[i] = NewRefOfMapOfStringToValue(d)
	}
	return ListOfRefOfMapOfStringToValue{types.NewTypedList(__typeForListOfRefOfMapOfStringToValue, l...), &ref.Ref{}}
}
func (def ListOfDDef) New() ListOfD {
	l := make([]types.Value, len(def))
	for i, d := range def {
		l[i] = d.New()
	}
	return ListOfD{types.NewTypedList(__typeForListOfD, l...), &ref.Ref{}}
}
Beispiel #6
0
func NewListOfString() ListOfString {
	return ListOfString{types.NewTypedList(__typeForListOfString), &ref.Ref{}}
}
Beispiel #7
0
func NewListOfRefOfFloat32() ListOfRefOfFloat32 {
	return ListOfRefOfFloat32{types.NewTypedList(__typeForListOfRefOfFloat32), &ref.Ref{}}
}
func NewListOfUint8() ListOfUint8 {
	return ListOfUint8{types.NewTypedList(__typeForListOfUint8), &ref.Ref{}}
}
Beispiel #9
0
// FIXME: run with pipe
func (s *testSuite) TestCSVExporter() {
	storeName := "store"
	setName := "csv"
	header := []string{"a", "b", "c"}
	payload := [][]string{
		[]string{"5", "7", "100"},
		[]string{"4", "10", "255"},
		[]string{"512", "12", "55"},
	}
	structName := "SomeStruct"

	// Setup data store
	cs := chunks.NewLevelDBStore(s.LdbDir, storeName, 1, false)
	ds := dataset.NewDataset(datas.NewDataStore(cs), setName)

	// Build Struct fields based on header
	f := make([]types.Field, 0, len(header))
	for _, key := range header {
		f = append(f, types.Field{
			Name: key,
			T:    types.MakePrimitiveType(types.StringKind),
		})
	}

	typeDef := types.MakeStructType(structName, f, types.Choices{})
	pkg := types.NewPackage([]types.Type{typeDef}, []ref.Ref{})
	pkgRef := types.RegisterPackage(&pkg)
	typeRef := types.MakeType(pkgRef, 0)
	structFields := typeDef.Desc.(types.StructDesc).Fields

	// Build data rows
	structs := make([]types.Value, len(payload))
	for i, row := range payload {
		fields := make(map[string]types.Value)
		for j, v := range row {
			fields[structFields[j].Name] = types.NewString(v)
		}
		structs[i] = types.NewStruct(typeRef, typeDef, fields)
	}

	listType := types.MakeCompoundType(types.ListKind, typeRef)
	ds.Commit(types.NewTypedList(listType, structs...))
	ds.Store().Close()

	// Run exporter
	out := s.Run(main, []string{"-store", storeName, "-ds", setName})

	// Verify output
	csvReader := csv.NewReader(strings.NewReader(out))

	row, err := csvReader.Read()
	d.Chk.NoError(err)
	s.Equal(header, row)

	for i := 0; i < len(payload); i++ {
		row, err := csvReader.Read()
		d.Chk.NoError(err)
		s.Equal(payload[i], row)
	}

	row, err = csvReader.Read()
	s.Equal(io.EOF, err)
}
func NewListOfD() ListOfD {
	return ListOfD{types.NewTypedList(__typeForListOfD), &ref.Ref{}}
}
Beispiel #11
0
func NewListOfStruct() ListOfStruct {
	return ListOfStruct{types.NewTypedList(__typeForListOfStruct), &ref.Ref{}}
}
Beispiel #12
0
func NewListOfBlob() ListOfBlob {
	return ListOfBlob{types.NewTypedList(__typeForListOfBlob), &ref.Ref{}}
}
Beispiel #13
0
func NewListOfRefOfMapOfStringToValue() ListOfRefOfMapOfStringToValue {
	return ListOfRefOfMapOfStringToValue{types.NewTypedList(__typeForListOfRefOfMapOfStringToValue), &ref.Ref{}}
}
Beispiel #14
0
func NewListOfPitch() ListOfPitch {
	return ListOfPitch{types.NewTypedList(__typeForListOfPitch), &ref.Ref{}}
}
Beispiel #15
0
func NewListOfRefOfAlbum() ListOfRefOfAlbum {
	return ListOfRefOfAlbum{types.NewTypedList(__typeForListOfRefOfAlbum), &ref.Ref{}}
}
Beispiel #16
0
func NewListOfTree() ListOfTree {
	return ListOfTree{types.NewTypedList(__typeForListOfTree), &ref.Ref{}}
}