change count to uint64 to fix #109

fix https://github.com/chrislusf/weed-fs/issues/109
This commit is contained in:
chrislusf 2015-04-06 14:17:36 -07:00
parent c37a20178e
commit 3ece066700
8 changed files with 42 additions and 10 deletions

View file

@ -0,0 +1,32 @@
package compress
import (
"github.com/reducedb/encoding/cursor"
"github.com/reducedb/encoding/delta/bp32"
)
// Compress compresses in[]int32 to out[]int32
func Compress32(in []int32) (out []int32, err error) {
out = make([]int32, len(in)*2)
inpos := cursor.New()
outpos := cursor.New()
if err = bp32.New().Compress(in, inpos, len(in), out, outpos); err != nil {
return nil, err
}
return out[:outpos.Get()], nil
}
// Uncompress uncompresses in[]int32 to out[]int32
func Uncompress32(in []int32, buffer []int32) (out []int32, err error) {
out = buffer
inpos := cursor.New()
outpos := cursor.New()
if err = bp32.New().Uncompress(in, inpos, len(in), out, outpos); err != nil {
return nil, err
}
return out[:outpos.Get()], nil
}

View file

@ -15,13 +15,13 @@ type AssignResult struct {
Fid string `json:"fid,omitempty"`
Url string `json:"url,omitempty"`
PublicUrl string `json:"publicUrl,omitempty"`
Count int `json:"count,omitempty"`
Count uint64 `json:"count,omitempty"`
Error string `json:"error,omitempty"`
}
func Assign(server string, count int, replication string, collection string, ttl string) (*AssignResult, error) {
func Assign(server string, count uint64, replication string, collection string, ttl string) (*AssignResult, error) {
values := make(url.Values)
values.Add("count", strconv.Itoa(count))
values.Add("count", strconv.FormatUint(count, 10))
if replication != "" {
values.Add("replication", replication)
}

View file

@ -43,7 +43,7 @@ func SubmitFiles(master string, files []FilePart,
for index, file := range files {
results[index].FileName = file.FileName
}
ret, err := Assign(master, len(files), replication, collection, ttl)
ret, err := Assign(master, uint64(len(files)), replication, collection, ttl)
if err != nil {
for index, _ := range files {
results[index].Error = err.Error()

View file

@ -15,7 +15,7 @@ func NewMemorySequencer() (m *MemorySequencer) {
return
}
func (m *MemorySequencer) NextFileId(count int) (uint64, int) {
func (m *MemorySequencer) NextFileId(count uint64) (uint64, uint64) {
m.sequenceLock.Lock()
defer m.sequenceLock.Unlock()
ret := m.counter

View file

@ -1,7 +1,7 @@
package sequence
type Sequencer interface {
NextFileId(count int) (uint64, int)
NextFileId(count uint64) (uint64, uint64)
SetMax(uint64)
Peek() uint64
}

View file

@ -115,7 +115,7 @@ func (t *Topology) HasWritableVolume(option *VolumeGrowOption) bool {
return vl.GetActiveVolumeCount(option) > 0
}
func (t *Topology) PickForWrite(count int, option *VolumeGrowOption) (string, int, *DataNode, error) {
func (t *Topology) PickForWrite(count uint64, option *VolumeGrowOption) (string, uint64, *DataNode, error) {
vid, count, datanodes, err := t.GetVolumeLayout(option.Collection, option.ReplicaPlacement, option.Ttl).PickForWrite(count, option)
if err != nil || datanodes.Length() == 0 {
return "", 0, nil, errors.New("No writable volumes available!")

View file

@ -87,7 +87,7 @@ func (vl *VolumeLayout) ListVolumeServers() (nodes []*DataNode) {
return
}
func (vl *VolumeLayout) PickForWrite(count int, option *VolumeGrowOption) (*storage.VolumeId, int, *VolumeLocationList, error) {
func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (*storage.VolumeId, uint64, *VolumeLocationList, error) {
len_writers := len(vl.writables)
if len_writers <= 0 {
glog.V(0).Infoln("No more writable volumes!")

View file

@ -69,8 +69,8 @@ func (ms *MasterServer) volumeLookupHandler(w http.ResponseWriter, r *http.Reque
func (ms *MasterServer) dirAssignHandler(w http.ResponseWriter, r *http.Request) {
stats.AssignRequest()
requestedCount, e := strconv.Atoi(r.FormValue("count"))
if e != nil {
requestedCount, e := strconv.ParseUint(r.FormValue("count"), 10, 64)
if e != nil || requestedCount == 0 {
requestedCount = 1
}