mirror of
https://github.com/jimeh/rbheap.git
synced 2026-02-19 04:46:40 +00:00
Rename HeapItem to HeapEntry
This commit is contained in:
14
heap_dump.go
14
heap_dump.go
@@ -15,9 +15,9 @@ func NewHeapDump(file string) (*HeapDump, error) {
|
||||
|
||||
// HeapDump contains all relevant data for a single heap dump.
|
||||
type HeapDump struct {
|
||||
File string
|
||||
Index []string
|
||||
Items map[string]*HeapItem
|
||||
File string
|
||||
Index []string
|
||||
Entries map[string]*HeapEntry
|
||||
}
|
||||
|
||||
// Process processes the heap dump
|
||||
@@ -29,7 +29,7 @@ func (s *HeapDump) Process() error {
|
||||
return err
|
||||
}
|
||||
|
||||
s.Items = map[string]*HeapItem{}
|
||||
s.Entries = map[string]*HeapEntry{}
|
||||
|
||||
reader := bufio.NewReader(file)
|
||||
for {
|
||||
@@ -56,14 +56,14 @@ func (s *HeapDump) ProcessLine(line []byte) error {
|
||||
|
||||
if len(item.Address) > 0 {
|
||||
index := item.Address + ":" + item.Type
|
||||
s.Items[index] = item
|
||||
s.Entries[index] = item
|
||||
s.Index = append(s.Index, index)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *HeapDump) Parse(itemJSON []byte) (*HeapItem, error) {
|
||||
var i HeapItem
|
||||
func (s *HeapDump) Parse(itemJSON []byte) (*HeapEntry, error) {
|
||||
var i HeapEntry
|
||||
err := json.Unmarshal(itemJSON, &i)
|
||||
|
||||
return &i, err
|
||||
|
||||
9
heap_entry.go
Normal file
9
heap_entry.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
//go:generate easyjson -all heap_entry.go
|
||||
|
||||
// HeapEntry is a parsed heap item object
|
||||
type HeapEntry struct {
|
||||
Address string `json:"address"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
_ easyjson.Marshaler
|
||||
)
|
||||
|
||||
func easyjson1c69144aDecodeGithubComJimehRbheapleak(in *jlexer.Lexer, out *HeapItem) {
|
||||
func easyjson48125c2bDecodeGithubComJimehRbheapleak(in *jlexer.Lexer, out *HeapEntry) {
|
||||
isTopLevel := in.IsStart()
|
||||
if in.IsNull() {
|
||||
if isTopLevel {
|
||||
@@ -50,7 +50,7 @@ func easyjson1c69144aDecodeGithubComJimehRbheapleak(in *jlexer.Lexer, out *HeapI
|
||||
in.Consumed()
|
||||
}
|
||||
}
|
||||
func easyjson1c69144aEncodeGithubComJimehRbheapleak(out *jwriter.Writer, in HeapItem) {
|
||||
func easyjson48125c2bEncodeGithubComJimehRbheapleak(out *jwriter.Writer, in HeapEntry) {
|
||||
out.RawByte('{')
|
||||
first := true
|
||||
_ = first
|
||||
@@ -78,25 +78,25 @@ func easyjson1c69144aEncodeGithubComJimehRbheapleak(out *jwriter.Writer, in Heap
|
||||
}
|
||||
|
||||
// MarshalJSON supports json.Marshaler interface
|
||||
func (v HeapItem) MarshalJSON() ([]byte, error) {
|
||||
func (v HeapEntry) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
easyjson1c69144aEncodeGithubComJimehRbheapleak(&w, v)
|
||||
easyjson48125c2bEncodeGithubComJimehRbheapleak(&w, v)
|
||||
return w.Buffer.BuildBytes(), w.Error
|
||||
}
|
||||
|
||||
// MarshalEasyJSON supports easyjson.Marshaler interface
|
||||
func (v HeapItem) MarshalEasyJSON(w *jwriter.Writer) {
|
||||
easyjson1c69144aEncodeGithubComJimehRbheapleak(w, v)
|
||||
func (v HeapEntry) MarshalEasyJSON(w *jwriter.Writer) {
|
||||
easyjson48125c2bEncodeGithubComJimehRbheapleak(w, v)
|
||||
}
|
||||
|
||||
// UnmarshalJSON supports json.Unmarshaler interface
|
||||
func (v *HeapItem) UnmarshalJSON(data []byte) error {
|
||||
func (v *HeapEntry) UnmarshalJSON(data []byte) error {
|
||||
r := jlexer.Lexer{Data: data}
|
||||
easyjson1c69144aDecodeGithubComJimehRbheapleak(&r, v)
|
||||
easyjson48125c2bDecodeGithubComJimehRbheapleak(&r, v)
|
||||
return r.Error()
|
||||
}
|
||||
|
||||
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
|
||||
func (v *HeapItem) UnmarshalEasyJSON(l *jlexer.Lexer) {
|
||||
easyjson1c69144aDecodeGithubComJimehRbheapleak(l, v)
|
||||
func (v *HeapEntry) UnmarshalEasyJSON(l *jlexer.Lexer) {
|
||||
easyjson48125c2bDecodeGithubComJimehRbheapleak(l, v)
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package main
|
||||
|
||||
//go:generate easyjson -all heap_item.go
|
||||
|
||||
// HeapItem is a parsed heap item object
|
||||
type HeapItem struct {
|
||||
Address string `json:"address"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
Reference in New Issue
Block a user