MCPcopy Create free account
hub / github.com/documentdb/documentdb / extension_rumgettuple_core

Function extension_rumgettuple_core

pg_documentdb/src/index_am/rum.c:1306–1365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1304
1305
1306bool
1307extension_rumgettuple_core(IndexScanDesc scan, ScanDirection direction,
1308 IndexAmRoutine *coreRoutine)
1309{
1310 if (IsCompositeOpClass(scan->indexRelation))
1311 {
1312 DocumentDBRumIndexState *outerScanState =
1313 (DocumentDBRumIndexState *) scan->opaque;
1314
1315 /* The caller will always pass ForwardScanDirection
1316 * since PG always uses ForwardScanDirection in cases where we do
1317 * amcanorderbyop. For the inner scan, we would need to pass the
1318 * scanDirection as determined in amrescan from the index state.
1319 */
1320 if (unlikely(direction != ForwardScanDirection))
1321 {
1322 ereport(ERROR, (errmsg("rumgettuple only supports forward scans")));
1323 }
1324
1325 /* Push this to the inner scan */
1326 outerScanState->innerScan->kill_prior_tuple = scan->kill_prior_tuple;
1327 if (outerScanState->indexArrayState == NULL)
1328 {
1329 /* No arrays, or we don't support dedup - just return the basics */
1330 return GetOneTupleCore(outerScanState, scan, outerScanState->scanDirection,
1331 coreRoutine);
1332 }
1333 else
1334 {
1335 bool result = GetOneTupleCore(outerScanState, scan,
1336 outerScanState->scanDirection, coreRoutine);
1337 while (result)
1338 {
1339 /* if we could add it to the bitmap, return */
1340 if (IndexArrayStateFuncs->addItem(outerScanState->indexArrayState,
1341 &scan->xs_heaptid))
1342 {
1343 return true;
1344 }
1345 else
1346 {
1347 outerScanState->numDuplicates++;
1348 }
1349
1350 /* else, get the next tuple
1351 * Ensure that we reset kill_prior_tuple since this is the duplicate path.
1352 */
1353 outerScanState->innerScan->kill_prior_tuple = false;
1354 result = GetOneTupleCore(outerScanState, scan,
1355 outerScanState->scanDirection, coreRoutine);
1356 }
1357
1358 return result;
1359 }
1360 }
1361 else
1362 {
1363 return coreRoutine->amgettuple(scan, direction);

Callers 2

extension_amgettupleFunction · 0.85

Calls 2

IsCompositeOpClassFunction · 0.85
GetOneTupleCoreFunction · 0.85

Tested by

no test coverage detected