Remove Gob from report package - no longer used

This commit is contained in:
Bryan Boreham
2017-04-25 12:26:15 +00:00
parent 36ff5ab71a
commit b49ee2ae95
6 changed files with 0 additions and 152 deletions

View File

@@ -2,7 +2,6 @@ package report
import (
"bytes"
"encoding/gob"
"fmt"
"reflect"
"sort"
@@ -137,14 +136,6 @@ func (c Counters) DeepEqual(d Counters) bool {
return equal
}
func (c Counters) toIntermediate() map[string]int {
intermediate := map[string]int{}
c.ForEach(func(key string, val int) {
intermediate[key] = val
})
return intermediate
}
func (c Counters) fromIntermediate(in map[string]int) Counters {
out := ps.NewMap()
for k, v := range in {
@@ -182,20 +173,3 @@ func (Counters) MarshalJSON() ([]byte, error) {
func (*Counters) UnmarshalJSON(b []byte) error {
panic("UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead")
}
// GobEncode implements gob.Marshaller
func (c Counters) GobEncode() ([]byte, error) {
buf := bytes.Buffer{}
err := gob.NewEncoder(&buf).Encode(c.toIntermediate())
return buf.Bytes(), err
}
// GobDecode implements gob.Unmarshaller
func (c *Counters) GobDecode(input []byte) error {
in := map[string]int{}
if err := gob.NewDecoder(bytes.NewBuffer(input)).Decode(&in); err != nil {
return err
}
*c = Counters{}.fromIntermediate(in)
return nil
}

View File

@@ -101,18 +101,6 @@ func TestCountersEncoding(t *testing.T) {
Add("foo", 1).
Add("bar", 2)
{
gobs, err := want.GobEncode()
if err != nil {
t.Fatal(err)
}
have := EmptyCounters
have.GobDecode(gobs)
if !reflect.DeepEqual(want, have) {
t.Error(test.Diff(want, have))
}
}
{
for _, h := range []codec.Handle{

View File

@@ -2,7 +2,6 @@ package report
import (
"bytes"
"encoding/gob"
"fmt"
"reflect"
"sort"
@@ -148,24 +147,6 @@ func (c EdgeMetadatas) DeepEqual(d EdgeMetadatas) bool {
return equal
}
func (c EdgeMetadatas) toIntermediate() map[string]EdgeMetadata {
intermediate := map[string]EdgeMetadata{}
if c.psMap != nil {
c.psMap.ForEach(func(key string, val interface{}) {
intermediate[key] = val.(EdgeMetadata)
})
}
return intermediate
}
func (c EdgeMetadatas) fromIntermediate(in map[string]EdgeMetadata) EdgeMetadatas {
out := ps.NewMap()
for k, v := range in {
out = out.Set(k, v)
}
return EdgeMetadatas{out}
}
// CodecEncodeSelf implements codec.Selfer
func (c *EdgeMetadatas) CodecEncodeSelf(encoder *codec.Encoder) {
mapWrite(c.psMap, encoder, func(encoder *codec.Encoder, val interface{}) {
@@ -196,23 +177,6 @@ func (*EdgeMetadatas) UnmarshalJSON(b []byte) error {
panic("UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead")
}
// GobEncode implements gob.Marshaller
func (c EdgeMetadatas) GobEncode() ([]byte, error) {
buf := bytes.Buffer{}
err := gob.NewEncoder(&buf).Encode(c.toIntermediate())
return buf.Bytes(), err
}
// GobDecode implements gob.Unmarshaller
func (c *EdgeMetadatas) GobDecode(input []byte) error {
in := map[string]EdgeMetadata{}
if err := gob.NewDecoder(bytes.NewBuffer(input)).Decode(&in); err != nil {
return err
}
*c = EdgeMetadatas{}.fromIntermediate(in)
return nil
}
// EdgeMetadata describes a superset of the metadata that probes can possibly
// collect about a directed edge between two nodes in any topology.
type EdgeMetadata struct {

View File

@@ -214,18 +214,6 @@ func TestEdgeMetadatasEncoding(t *testing.T) {
EgressPacketCount: newu64(3),
})
{
gobs, err := want.GobEncode()
if err != nil {
t.Fatal(err)
}
have := EmptyEdgeMetadatas
have.GobDecode(gobs)
if !reflect.DeepEqual(want, have) {
t.Error(test.Diff(want, have))
}
}
{
for _, h := range []codec.Handle{
codec.Handle(&codec.MsgpackHandle{}),
@@ -247,18 +235,6 @@ func TestEdgeMetadatasEncoding(t *testing.T) {
func TestEdgeMetadatasEncodingNil(t *testing.T) {
want := EdgeMetadatas{}
{
gobs, err := want.GobEncode()
if err != nil {
t.Fatal(err)
}
have := EmptyEdgeMetadatas
have.GobDecode(gobs)
if have.psMap == nil {
t.Error("needed to get back a non-nil psMap for EdgeMetadata")
}
}
{
for _, h := range []codec.Handle{

View File

@@ -2,7 +2,6 @@ package report
import (
"bytes"
"encoding/gob"
"fmt"
"sort"
@@ -206,20 +205,3 @@ func (NodeSet) MarshalJSON() ([]byte, error) {
func (*NodeSet) UnmarshalJSON(b []byte) error {
panic("UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead")
}
// GobEncode implements gob.Marshaller
func (n NodeSet) GobEncode() ([]byte, error) {
buf := bytes.Buffer{}
err := gob.NewEncoder(&buf).Encode(n.toIntermediate())
return buf.Bytes(), err
}
// GobDecode implements gob.Unmarshaller
func (n *NodeSet) GobDecode(input []byte) error {
in := []Node{}
if err := gob.NewDecoder(bytes.NewBuffer(input)).Decode(&in); err != nil {
return err
}
*n = NodeSet{}.fromIntermediate(in)
return nil
}

View File

@@ -2,7 +2,6 @@ package report
import (
"bytes"
"encoding/gob"
"fmt"
"reflect"
"sort"
@@ -148,24 +147,6 @@ func (s Sets) DeepEqual(t Sets) bool {
return equal
}
func (s Sets) toIntermediate() map[string]StringSet {
intermediate := map[string]StringSet{}
if s.psMap != nil {
s.psMap.ForEach(func(key string, val interface{}) {
intermediate[key] = val.(StringSet)
})
}
return intermediate
}
func (s Sets) fromIntermediate(in map[string]StringSet) Sets {
out := ps.NewMap()
for k, v := range in {
out = out.Set(k, v)
}
return Sets{out}
}
// CodecEncodeSelf implements codec.Selfer
func (s *Sets) CodecEncodeSelf(encoder *codec.Encoder) {
mapWrite(s.psMap, encoder, func(encoder *codec.Encoder, val interface{}) {
@@ -194,20 +175,3 @@ func (Sets) MarshalJSON() ([]byte, error) {
func (*Sets) UnmarshalJSON(b []byte) error {
panic("UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead")
}
// GobEncode implements gob.Marshaller
func (s Sets) GobEncode() ([]byte, error) {
buf := bytes.Buffer{}
err := gob.NewEncoder(&buf).Encode(s.toIntermediate())
return buf.Bytes(), err
}
// GobDecode implements gob.Unmarshaller
func (s *Sets) GobDecode(input []byte) error {
in := map[string]StringSet{}
if err := gob.NewDecoder(bytes.NewBuffer(input)).Decode(&in); err != nil {
return err
}
*s = Sets{}.fromIntermediate(in)
return nil
}