joinCount<JK extends SdbKey, JV extends SdbValue> method
Future<int>
joinCount<JK extends SdbKey, JV extends SdbValue>(
- SdbClient client, {
- required SdbJoinTarget<
JK, JV> target, - SdbFindOptions<
SK> ? options, - SdbJoinFindOptions? joinOptions,
The number of rows joinIterate would hand out.
Without distinct nor inner, and joining on a store (at most one
match per record), every record of the source gives one row, so this is
the record count. Otherwise rows are added or dropped in a way only a
scan can tell, so the join is run, reading as little as it can (neither
side is handed out).
Implementation
Future<int> joinCount<JK extends SdbKey, JV extends SdbValue>(
SdbClient client, {
required SdbJoinTarget<JK, JV> target,
SdbFindOptions<SK>? options,
SdbJoinFindOptions? joinOptions,
}) async {
var joinOpts = sdbJoinFindOptionsOrDefault(joinOptions);
if (!joinOpts.distinct &&
!joinOpts.inner &&
target.index == null &&
options?.offset == null &&
options?.limit == null) {
return countRecords(client, options);
}
var rowCount = 0;
await _joinRun<JK, JV>(
client,
target: target,
mode: null,
options: options,
joinOptions: joinOptions,
emit: SdbJoinEmit.none,
onEmit: (row) {
rowCount++;
return true;
},
);
return rowCount;
}