Documentation
¶
Index ¶
- func ComplexBulkAvroWriter(writer io.Writer, writeTime time.Time, request <-chan *Complex) <-chan error
- func SimpleBulkAvroWriter(writer io.Writer, writeTime time.Time, request <-chan *Simple) <-chan error
- type Complex
- type ComplexCrops
- type ComplexOriginalSize
- type ComplexURL
- type ComplexURLMeta
- type Simple
- type SimpleContributors
- type SimpleSomeDateObj
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComplexBulkAvroWriter ¶ added in v0.14.0
func ComplexBulkAvroWriter(writer io.Writer, writeTime time.Time, request <-chan *Complex) <-chan error
ComplexBulkAvroWriter will begin a go routine writing an Avro Container File to the writer and add each item from the request channel. If an error is encountered it will be sent on the returned error channel. The given writeTime will be used for all data items written by this function. When the returned request channel is closed this function will finalize the Container File and exit. The returned error channel will be closed just before the go routine exits. Note: That though a nil item will be written as delete it will also be written without an ID or other identifying field and so this is of limited value. In general deletes should be done using WriteAvroDeletedCF.
Example ¶
input := []*Complex{{}, {}, {}} inputChan := make(chan *Complex) devnull, _ := os.Open("/dev/null") defer devnull.Close() errChan := ComplexBulkAvroWriter(devnull, time.Now(), inputChan) for _, item := range input { select { case err := <-errChan: fmt.Print(err) return case inputChan <- item: } } // Check for any final errors, the errorChan should be closed when the BulkWriter is finished processing for err := range errChan { if err != nil { fmt.Print(err) return } }
Output:
func SimpleBulkAvroWriter ¶ added in v0.14.0
func SimpleBulkAvroWriter(writer io.Writer, writeTime time.Time, request <-chan *Simple) <-chan error
SimpleBulkAvroWriter will begin a go routine writing an Avro Container File to the writer and add each item from the request channel. If an error is encountered it will be sent on the returned error channel. The given writeTime will be used for all data items written by this function. When the returned request channel is closed this function will finalize the Container File and exit. The returned error channel will be closed just before the go routine exits. Note: That though a nil item will be written as delete it will also be written without an ID or other identifying field and so this is of limited value. In general deletes should be done using WriteAvroDeletedCF.
Example ¶
input := []*Simple{{}, {}, {}} inputChan := make(chan *Simple) devnull, _ := os.Open("/dev/null") defer devnull.Close() errChan := SimpleBulkAvroWriter(devnull, time.Now(), inputChan) for _, item := range input { select { case err := <-errChan: fmt.Print(err) return case inputChan <- item: } } // Check for any final errors, the errorChan should be closed when the BulkWriter is finished processing for err := range errChan { if err != nil { fmt.Print(err) return } }
Output:
Types ¶
type Complex ¶
type Complex struct { Simple Caption string `json:"caption"` Credit string `json:"credit"` // The available cropped images Crops []ComplexCrops `json:"crops"` Cutline string `json:"cutline,omitempty"` DatePhotoTaken time.Time `json:"datePhotoTaken"` Orientation string `json:"orientation"` OriginalSize ComplexOriginalSize `json:"originalSize"` // a type Type string `json:"type"` // Universal Resource Locator URL ComplexURL `json:"URL"` }
func (*Complex) WriteAvroCF ¶ added in v0.14.0
WriteAvroCF writes an Avro Containter File to the given io.Writer using snappy compression for the data. The time is used as the AvroWriteTime, if the time is the Zero value then the current time is used. NOTE: If the type has a field in an embedded struct with the same name as a field not in the embedded struct the value will be pulled from the field not in the embedded struct.
type ComplexCrops ¶
type ComplexOriginalSize ¶
type ComplexURL ¶
type ComplexURL struct { // The full Canonical URL Absolute string `json:"absolute"` Meta *ComplexURLMeta `json:"meta,omitempty"` Publish string `json:"publish"` }
type ComplexURLMeta ¶
type Simple ¶
type Simple struct { Contributors []*SimpleContributors `json:"contributors,omitempty"` Height int64 `json:"height,omitempty"` SomeDateObj *SimpleSomeDateObj `json:"someDateObj,omitempty"` Type string `json:"type"` Visible bool `json:"visible,omitempty"` Width float64 `json:"width,omitempty"` }
func (*Simple) WriteAvroCF ¶ added in v0.14.0
WriteAvroCF writes an Avro Containter File to the given io.Writer using snappy compression for the data. The time is used as the AvroWriteTime, if the time is the Zero value then the current time is used. NOTE: If the type has a field in an embedded struct with the same name as a field not in the embedded struct the value will be pulled from the field not in the embedded struct.