MCPcopy Create free account
hub / github.com/apple/foundationdb / getRange

Method getRange

fdbserver/KeyValueStoreSQLite.actor.cpp:1168–1243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1166 return Optional<Value>();
1167 }
1168 RangeResult getRange(KeyRangeRef keys, int rowLimit, int byteLimit) {
1169 RangeResult result;
1170 int accumulatedBytes = 0;
1171 ASSERT(byteLimit > 0);
1172 if (rowLimit == 0) {
1173 return result;
1174 }
1175
1176 if (db.fragment_values) {
1177 if (rowLimit > 0) {
1178 int r = moveTo(keys.begin);
1179 if (r < 0)
1180 moveNext();
1181
1182 DefragmentingReader i(*this, result.arena(), true);
1183 Optional<KeyRef> nextKey = i.peek();
1184 while (nextKey.present() && nextKey.get() < keys.end && rowLimit != 0 && accumulatedBytes < byteLimit) {
1185 Optional<KeyValueRef> kv = i.getNext();
1186 result.push_back(result.arena(), kv.get());
1187 --rowLimit;
1188 accumulatedBytes += sizeof(KeyValueRef) + kv.get().expectedSize();
1189 nextKey = i.peek();
1190 }
1191 } else {
1192 int r = moveTo(keys.end);
1193 if (r >= 0)
1194 movePrevious();
1195 DefragmentingReader i(*this, result.arena(), false);
1196 Optional<KeyRef> nextKey = i.peek();
1197 while (nextKey.present() && nextKey.get() >= keys.begin && rowLimit != 0 &&
1198 accumulatedBytes < byteLimit) {
1199 Optional<KeyValueRef> kv = i.getNext();
1200 result.push_back(result.arena(), kv.get());
1201 ++rowLimit;
1202 accumulatedBytes += sizeof(KeyValueRef) + kv.get().expectedSize();
1203 nextKey = i.peek();
1204 }
1205 }
1206 } else {
1207 if (rowLimit > 0) {
1208 int r = moveTo(keys.begin);
1209 if (r < 0)
1210 moveNext();
1211 while (this->valid && rowLimit != 0 && accumulatedBytes < byteLimit) {
1212 KeyValueRef kv = decodeKV(getEncodedRow(result.arena()));
1213 if (kv.key >= keys.end)
1214 break;
1215 --rowLimit;
1216 accumulatedBytes += sizeof(KeyValueRef) + kv.expectedSize();
1217 result.push_back(result.arena(), kv);
1218 moveNext();
1219 }
1220 } else {
1221 int r = moveTo(keys.end);
1222 if (r >= 0)
1223 movePrevious();
1224 while (this->valid && rowLimit != 0 && accumulatedBytes < byteLimit) {
1225 KeyValueRef kv = decodeKV(getEncodedRow(result.arena()));

Callers

nothing calls this directly

Calls 10

moveToFunction · 0.85
moveNextFunction · 0.85
decodeKVFunction · 0.85
getMethod · 0.65
peekMethod · 0.45
presentMethod · 0.45
getNextMethod · 0.45
push_backMethod · 0.45
expectedSizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected