Merge pull request #346 from harshavardhana/pr_out_rename_parms_as_params_for_brevity_and_misc_cleanup

master
Harshavardhana 10 years ago
commit 80892c5c9b
  1. 6
      pkg/encoding/erasure/cauchy_test.go
  2. 4
      pkg/encoding/erasure/erasure_decode.go
  3. 12
      pkg/encoding/erasure/erasure_encode.go
  4. 2
      pkg/encoding/erasure/vandermonde_test.go

@ -29,8 +29,12 @@ var _ = Suite(&MySuite{})
func Test(t *testing.T) { TestingT(t) }
const (
k = 10
m = 5
)
func (s *MySuite) TestCauchyDecode(c *C) {
const k, m = 10, 5
ep, _ := ParseEncoderParams(k, m, Cauchy)
data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")

@ -37,8 +37,8 @@ func (e *Encoder) Decode(chunks [][]byte, length int) ([]byte, error) {
var decode_index *C.uint32_t
var source, target **C.uint8_t
k := e.parms.K
m := e.parms.M
k := e.params.K
m := e.params.M
n := k + m
if len(chunks) != int(n) {
return nil, errors.New(fmt.Sprintf("chunks length must be %d", n))

@ -51,7 +51,7 @@ type EncoderParams struct {
// Encoder is an object used to encode and decode data.
type Encoder struct {
parms *EncoderParams
params *EncoderParams
encode_matrix,
encode_tbls,
decode_matrix,
@ -104,7 +104,7 @@ func NewEncoder(ep *EncoderParams) *Encoder {
&encode_tbls)
return &Encoder{
parms: ep,
params: ep,
encode_matrix: encode_matrix,
encode_tbls: encode_tbls,
decode_matrix: nil,
@ -134,11 +134,11 @@ func GetEncodedChunkLen(inputLen int, k uint8) (outputChunkLen int) {
// length of the original object.
func (e *Encoder) Encode(input []byte) ([][]byte, error) {
inputLen := len(input)
k := C.int(e.parms.K)
m := C.int(e.parms.M)
k := C.int(e.params.K)
m := C.int(e.params.M)
n := k + m
chunkLen := GetEncodedChunkLen(inputLen, e.parms.K)
chunkLen := GetEncodedChunkLen(inputLen, e.params.K)
encodedDataLen := chunkLen * int(k)
paddedDataLen := int(encodedDataLen) - inputLen
@ -148,7 +148,7 @@ func (e *Encoder) Encode(input []byte) ([][]byte, error) {
input = append(input, s...)
}
encodedParityLen := chunkLen * int(e.parms.M)
encodedParityLen := chunkLen * int(e.params.M)
c := make([]byte, encodedParityLen)
input = append(input, c...)

@ -23,7 +23,7 @@ import (
)
func (s *MySuite) TestVanderMondeDecode(c *C) {
ep, _ := ParseEncoderParams(10, 5, Vandermonde)
ep, _ := ParseEncoderParams(k, m, Vandermonde)
data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")

Loading…
Cancel
Save