project method

List<Object?> project(
  1. VxsSchema schema,
  2. List<int> fieldIds
)

Reads several fields in a single scan, in fieldIds order.

Strings come back as StringView (zero-copy), bytes and lists as Bytes, numbers as int/double/bool. Missing fields are null. This avoids the O(fields x requested) cost of calling the individual getters.

Implementation

List<Object?> project(VxsSchema schema, List<int> fieldIds) {
  final out = List<Object?>.filled(fieldIds.length, null);
  if (fieldIds.isEmpty) return out;
  final cursor = this.cursor();
  while (cursor.next()) {
    final index = fieldIds.indexOf(cursor.fieldId);
    if (index < 0) continue;
    final field = schema.fieldById(cursor.fieldId);
    if (field == null || field.type.wireType != cursor.wireType) continue;
    out[index] = _valueOf(field.type, cursor);
  }
  return out;
}