-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bo Du
committed
Nov 29, 2018
1 parent
8024f1f
commit c7c47c3
Showing
6 changed files
with
121 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package bool | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/xichen2020/eventdb/encoding/common" | ||
) | ||
|
||
// Encoder encodes bool values. | ||
type Encoder interface { | ||
// Encode a collection of bools. | ||
// Callers should explicitly call `Reset` before | ||
// subsequent call to `Encode`. | ||
Encode(values Iterator) error | ||
// Bytes returns the encoded bytes of the encoder. | ||
Bytes() []byte | ||
// Reset should be called between `Encode` calls. | ||
Reset() | ||
} | ||
|
||
// Decoder decodes bool values. | ||
type Decoder interface { | ||
// Decode the source bytes. | ||
// Callers should explicitly call `Reset` before | ||
// subsequent call to `Decode`. | ||
Decode(src common.Reader) (Iterator, error) | ||
// Reset should be called between `Decode` calls. | ||
Reset() | ||
} | ||
|
||
// Iterator lazily produces bool values decoded from a byte stream. | ||
type Iterator interface { | ||
io.Closer | ||
|
||
// Next returns true if there is another value | ||
// in the data stream. If it returns false, err should be | ||
// checked for errors. | ||
Next() bool | ||
// Current returns the current value in the iteration. | ||
Current() bool | ||
// Err returns any error encountered during iteration. | ||
Err() error | ||
// Reset iteration back to the first item in the collection. | ||
Reset() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package common | ||
|
||
import ( | ||
"io" | ||
) | ||
|
||
// Reader wraps both `io.Reader` and `io.ByteReader` interfaces. | ||
type Reader interface { | ||
io.Reader | ||
io.ByteReader | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package double | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/xichen2020/eventdb/encoding/common" | ||
) | ||
|
||
// Encoder encodes float64 values. | ||
type Encoder interface { | ||
// Encode a collection of float64s. | ||
// Callers should explicitly call `Reset` before | ||
// subsequent call to `Encode`. | ||
Encode(values Iterator) error | ||
// Bytes returns the encoded bytes of the encoder. | ||
Bytes() []byte | ||
// Reset should be called between `Encode` calls. | ||
Reset() | ||
} | ||
|
||
// Decoder decodes float64 values. | ||
type Decoder interface { | ||
// Decode the source bytes. | ||
// Callers should explicitly call `Reset` before | ||
// subsequent call to `Decode`. | ||
Decode(src common.Reader) (Iterator, error) | ||
// Reset should be called between `Decode` calls. | ||
Reset() | ||
} | ||
|
||
// Iterator lazily produces float64 values decoded from a byte stream. | ||
type Iterator interface { | ||
io.Closer | ||
|
||
// Next returns true if there is another value | ||
// in the data stream. If it returns false, err should be | ||
// checked for errors. | ||
Next() bool | ||
// Current returns the current value in the iteration. | ||
Current() float64 | ||
// Err returns any error encountered during iteration. | ||
Err() error | ||
// Reset iteration back to the first item in the collection. | ||
Reset() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.