openFile function

RecordBatchFileReader openFile(
  1. Uint8List bytes, {
  2. IpcLimits limits = const IpcLimits(),
})

Opens an in-memory Arrow IPC file (ARROW1 magic plus footer), like PyArrow's ipc.open_file.

The footer, schema and all dictionary batches are decoded immediately; record batches are decoded on demand by RecordBatchFileReader.getBatch.

Implementation

RecordBatchFileReader openFile(
  Uint8List bytes, {
  IpcLimits limits = const IpcLimits(),
}) => _ipcGuard(() {
  final (footer, dataLength) = _ipcReadFooter(bytes, limits);
  final data = Uint8List.sublistView(bytes, 0, dataLength);
  final schemaTable = footer.table(1);
  if (schemaTable == null) {
    throw const FormatException('IPC file footer has no schema');
  }
  final state = _IpcReadState(_ipcReadSchema(schemaTable, limits), limits);
  final budget = _IpcValueBudget(limits.maxValues);
  for (final block in _ipcBlocks(footer, 2, limits.maxDictionaries)) {
    final message = _ipcReadBlock(data, block, limits);
    if (message.headerType != _ipcHeaderDictionaryBatch) {
      throw const FormatException('Dictionary block has wrong message type');
    }
    state.acceptDictionary(message, budget, allowReplacement: false);
  }
  return RecordBatchFileReader._(
    state,
    data,
    _ipcBlocks(footer, 3, limits.maxBatches),
    budget.used,
  );
});