openOrCreate static method

Future<PagedTable> openOrCreate(
  1. String basePath, {
  2. required List<PagedColumn> columns,
  3. required String primaryKey,
  4. int pageSize = 4096,
  5. int cacheCapacity = 64,
})

Open an existing table or create one if <basePath>.meta.json is missing. The schema is only consulted when creating.

Implementation

static Future<PagedTable> openOrCreate(
  String basePath, {
  required List<PagedColumn> columns,
  required String primaryKey,
  int pageSize = 4096,
  int cacheCapacity = 64,
}) async {
  final meta = await _readMeta(basePath);
  if (meta != null) {
    final effectivePageSize = meta.pageSize ?? pageSize;
    return _openWith(basePath, meta.columns, meta.pkIndex, meta.indexes,
        pageSize: effectivePageSize, cacheCapacity: cacheCapacity);
  }
  return create(basePath,
      columns: columns,
      primaryKey: primaryKey,
      pageSize: pageSize,
      cacheCapacity: cacheCapacity);
}