hailin0 commented on code in PR #261:
URL: 
https://github.com/apache/skywalking-banyandb/pull/261#discussion_r1246012021


##########
pkg/wal/wal.go:
##########
@@ -42,19 +72,642 @@ type Segment interface {
 type WAL interface {
        // Write a logging entity.
        // It will return immediately when the data is written in the buffer,
-       // The returned function will be called when the entity is flushed on 
the persistent storage.
-       Write(seriesID common.SeriesID, timestamp time.Time, data []byte) 
(func(), error)
+       // The callback function will be called when the entity is flushed on 
the persistent storage.
+       Write(seriesID common.SeriesIDV2, timestamp time.Time, data []byte, 
callback func(common.SeriesIDV2, time.Time, []byte, error))
        // Read specified segment by SegmentID.
-       Read(segmentID SegmentID) (*Segment, error)
+       Read(segmentID SegmentID) (Segment, error)
        // ReadAllSegments reads all segments sorted by their creation time in 
ascending order.
-       ReadAllSegments() ([]*Segment, error)
+       ReadAllSegments() ([]Segment, error)
        // Rotate closes the open segment and opens a new one, returning the 
closed segment details.
-       Rotate() (*Segment, error)
+       Rotate() (Segment, error)
        // Delete the specified segment.
        Delete(segmentID SegmentID) error
+       // Close all of segments and stop WAL work.
+       Close() error
+}
+
+// SegmentID identities a segment in a WAL.
+type SegmentID uint64
+
+// Segment allows reading underlying segments that hold WAl entities.
+type Segment interface {
+       GetSegmentID() SegmentID
+       GetLogEntries() []LogEntry
+}
+
+// LogEntry used for attain detail value of WAL entry.
+type LogEntry interface {
+       GetSeriesID() common.SeriesIDV2
+       GetTimestamps() []time.Time
+       GetValues() *list.List
+}
+
+// Log implements the WAL interface.
+type Log struct {
+       buffer           buffer
+       logger           *logger.Logger
+       bytesBuffer      *bytes.Buffer
+       timestampsBuffer *bytes.Buffer
+       segmentIndexMap  map[SegmentID]*segment
+       workSegment      *segment

Review Comment:
   fixed



##########
pkg/wal/wal.go:
##########
@@ -42,19 +72,642 @@ type Segment interface {
 type WAL interface {
        // Write a logging entity.
        // It will return immediately when the data is written in the buffer,
-       // The returned function will be called when the entity is flushed on 
the persistent storage.
-       Write(seriesID common.SeriesID, timestamp time.Time, data []byte) 
(func(), error)
+       // The callback function will be called when the entity is flushed on 
the persistent storage.
+       Write(seriesID common.SeriesIDV2, timestamp time.Time, data []byte, 
callback func(common.SeriesIDV2, time.Time, []byte, error))
        // Read specified segment by SegmentID.
-       Read(segmentID SegmentID) (*Segment, error)
+       Read(segmentID SegmentID) (Segment, error)
        // ReadAllSegments reads all segments sorted by their creation time in 
ascending order.
-       ReadAllSegments() ([]*Segment, error)
+       ReadAllSegments() ([]Segment, error)
        // Rotate closes the open segment and opens a new one, returning the 
closed segment details.
-       Rotate() (*Segment, error)
+       Rotate() (Segment, error)
        // Delete the specified segment.
        Delete(segmentID SegmentID) error
+       // Close all of segments and stop WAL work.
+       Close() error
+}
+
+// SegmentID identities a segment in a WAL.
+type SegmentID uint64
+
+// Segment allows reading underlying segments that hold WAl entities.
+type Segment interface {
+       GetSegmentID() SegmentID
+       GetLogEntries() []LogEntry
+}
+
+// LogEntry used for attain detail value of WAL entry.
+type LogEntry interface {
+       GetSeriesID() common.SeriesIDV2
+       GetTimestamps() []time.Time
+       GetValues() *list.List
+}
+
+// Log implements the WAL interface.
+type Log struct {
+       buffer           buffer
+       logger           *logger.Logger
+       bytesBuffer      *bytes.Buffer
+       timestampsBuffer *bytes.Buffer
+       segmentIndexMap  map[SegmentID]*segment

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to