Merge pull request #346 from harshavardhana/pr_out_rename_parms_as_params_for_brevity_and_misc_cleanup

This commit is contained in:
Harshavardhana 2015-03-22 20:27:11 -07:00
commit 80892c5c9b
4 changed files with 14 additions and 10 deletions

View file

@ -29,8 +29,12 @@ var _ = Suite(&MySuite{})
func Test(t *testing.T) { TestingT(t) } func Test(t *testing.T) { TestingT(t) }
const (
k = 10
m = 5
)
func (s *MySuite) TestCauchyDecode(c *C) { func (s *MySuite) TestCauchyDecode(c *C) {
const k, m = 10, 5
ep, _ := ParseEncoderParams(k, m, Cauchy) 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.") 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.")

View file

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

View file

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

View file

@ -23,7 +23,7 @@ import (
) )
func (s *MySuite) TestVanderMondeDecode(c *C) { 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.") 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.")