@@ -85,28 +85,32 @@ func (i Item) GetFieldUint64(name string) (uint64, error) {
8585}
8686
8787// For internal use only - DO NOT USE!
88- func (i Item ) GetShard () (map [uint64 ]* ItemChunk , * ItemCurrentChunkMetadata , error ) {
88+ func (i Item ) GetShard () (map [int ]* ItemChunk , * ItemCurrentChunkMetadata , error ) {
8989 const streamDataPrefix = "__data_stream["
9090 const streamMetadataPrefix = "__data_stream_metadata["
9191 const offsetPrefix = "__data_stream[0000]["
9292
9393 currentChunkMetadata := ItemCurrentChunkMetadata {}
94- chunkMap := make (map [uint64 ]* ItemChunk )
94+ chunkMap := make (map [int ]* ItemChunk )
9595
9696 for k , v := range i {
9797 if strings .HasPrefix (k , streamDataPrefix ) {
98- chunkID , ok := strconv .ParseUint (k [len (streamDataPrefix ):][:4 ], 16 , 64 )
98+ chunkID64 , ok := strconv .ParseUint (k [len (streamDataPrefix ):][:4 ], 16 , 64 )
9999 if ok != nil {
100100 return nil , nil , v3ioerrors .ErrInvalidTypeConversion
101101 }
102+ chunkID := int (chunkID64 )
103+
102104 offset , ok := strconv .ParseUint (k [len (offsetPrefix ):][:16 ], 16 , 64 )
103105 if ok != nil {
104106 return nil , nil , v3ioerrors .ErrInvalidTypeConversion
105107 }
106- data , ok2 := v .([]byte )
107- if ! ok2 {
108+
109+ data , castingSuccess := v .([]byte )
110+ if ! castingSuccess {
108111 return nil , nil , v3ioerrors .ErrInvalidTypeConversion
109112 }
113+
110114 streamData := ItemChunkData {Offset : offset , Data : & data }
111115 if _ , ok := chunkMap [chunkID ]; ! ok {
112116 chunkMap [chunkID ] = & ItemChunk {}
@@ -115,21 +119,24 @@ func (i Item) GetShard() (map[uint64]*ItemChunk, *ItemCurrentChunkMetadata, erro
115119 }
116120
117121 if strings .HasPrefix (k , streamMetadataPrefix ) {
118- chunkID , ok := strconv .ParseUint (k [len (streamMetadataPrefix ):][:4 ], 16 , 64 )
122+ chunkID64 , ok := strconv .ParseUint (k [len (streamMetadataPrefix ):][:4 ], 16 , 64 )
119123 if ok != nil {
120124 return nil , nil , v3ioerrors .ErrInvalidTypeConversion
121125 }
126+ chunkID := int (chunkID64 )
122127
123- metadata , ok2 := v .([]byte )
124- if ! ok2 {
128+ metadata , castingSuccess := v .([]byte )
129+ if ! castingSuccess {
125130 return nil , nil , v3ioerrors .ErrInvalidTypeConversion
126131 }
132+
127133 buf := bytes .NewBuffer (metadata [8 :64 ])
128134 chunkMetaData := ItemChunkMetadata {}
129135 err := binary .Read (buf , binary .LittleEndian , & chunkMetaData )
130136 if err != nil {
131137 return nil , nil , err
132138 }
139+
133140 if _ , ok := chunkMap [chunkID ]; ! ok {
134141 chunkMap [chunkID ] = & ItemChunk {}
135142 }
0 commit comments