hs are the high bits to include to avoid needing to reiterate over the buffer in NextMany
(hs uint32, buf []uint32)
| 1225 | |
| 1226 | // hs are the high bits to include to avoid needing to reiterate over the buffer in NextMany |
| 1227 | func (ri *runIterator16) nextMany(hs uint32, buf []uint32) int { |
| 1228 | n := 0 |
| 1229 | |
| 1230 | if !ri.hasNext() { |
| 1231 | return n |
| 1232 | } |
| 1233 | |
| 1234 | // start and end are inclusive |
| 1235 | for n < len(buf) { |
| 1236 | moreVals := 0 |
| 1237 | |
| 1238 | if ri.rc.iv[ri.curIndex].length >= ri.curPosInIndex { |
| 1239 | // add as many as you can from this seq |
| 1240 | moreVals = minOfInt(int(ri.rc.iv[ri.curIndex].length-ri.curPosInIndex)+1, len(buf)-n) |
| 1241 | base := uint32(ri.rc.iv[ri.curIndex].start+ri.curPosInIndex) | hs |
| 1242 | |
| 1243 | // allows BCE |
| 1244 | buf2 := buf[n : n+moreVals] |
| 1245 | i := 0 |
| 1246 | for ; i+3 < len(buf2); i += 4 { |
| 1247 | buf2[i] = base |
| 1248 | buf2[i+1] = base + 1 |
| 1249 | buf2[i+2] = base + 2 |
| 1250 | buf2[i+3] = base + 3 |
| 1251 | base += 4 |
| 1252 | } |
| 1253 | for ; i < len(buf2); i++ { |
| 1254 | buf2[i] = base |
| 1255 | base++ |
| 1256 | } |
| 1257 | |
| 1258 | // update values |
| 1259 | n += moreVals |
| 1260 | } |
| 1261 | |
| 1262 | if moreVals+int(ri.curPosInIndex) > int(ri.rc.iv[ri.curIndex].length) { |
| 1263 | ri.curPosInIndex = 0 |
| 1264 | ri.curIndex++ |
| 1265 | |
| 1266 | if ri.curIndex == len(ri.rc.iv) { |
| 1267 | break |
| 1268 | } |
| 1269 | } else { |
| 1270 | ri.curPosInIndex += uint16(moreVals) // moreVals always fits in uint16 |
| 1271 | } |
| 1272 | } |
| 1273 | |
| 1274 | return n |
| 1275 | } |
| 1276 | |
| 1277 | func (ri *runIterator16) nextMany64(hs uint64, buf []uint64) int { |
| 1278 | n := 0 |