Example #1
0
func (w *WriteShardRequest) unmarshalPoints() []models.Point {
	points := make([]models.Point, len(w.pb.GetPoints()))
	for i, p := range w.pb.GetPoints() {
		pt, err := models.NewPointFromBytes(p)
		if err != nil {
			// A error here means that one node created a valid point and sent us an
			// unparseable version.  We could log and drop the point and allow
			// anti-entropy to resolve the discrepancy, but this shouldn't ever happen.
			panic(fmt.Sprintf("failed to parse point: `%v`: %v", string(p), err))
		}

		points[i] = pt
	}
	return points
}
Example #2
0
func (w *WriteWALEntry) UnmarshalBinary(b []byte) error {
	var i int

	for i < len(b) {
		length := int(btou32(b[i : i+4]))
		i += 4

		point, err := models.NewPointFromBytes(b[i : i+length])
		if err != nil {
			return err
		}
		i += length
		w.Points = append(w.Points, point)
	}
	return nil
}