Adds a qualified entry to the index. Returns true if space still available, false otherwise.
(keyIdx int, key []byte)
| 64 | // Adds a qualified entry to the index. Returns true if space |
| 65 | // still available, false otherwise. |
| 66 | func (s *segmentKeysIndex) add(keyIdx int, key []byte) bool { |
| 67 | if s.numKeys >= s.numIndexableKeys { |
| 68 | // All keys that can be indexed already have been, |
| 69 | // return false indicating that there's no room for |
| 70 | // anymore. |
| 71 | return false |
| 72 | } |
| 73 | |
| 74 | if len(key) > (len(s.data) - s.numKeyBytes) { |
| 75 | // No room for any more keys. |
| 76 | return false |
| 77 | } |
| 78 | |
| 79 | if keyIdx%(s.hop) != 0 { |
| 80 | // Key does not satisfy the hop condition. |
| 81 | return true |
| 82 | } |
| 83 | |
| 84 | s.offsets[s.numKeys] = uint32(s.numKeyBytes) |
| 85 | copy(s.data[s.numKeyBytes:], key) |
| 86 | s.numKeys++ |
| 87 | s.numKeyBytes += len(key) |
| 88 | |
| 89 | return true |
| 90 | } |
| 91 | |
| 92 | // Fetches the range of offsets between which the key exists, |
| 93 | // if present at all. The returned leftPos and rightPos can |
no outgoing calls