bulkInsertParallel method

int bulkInsertParallel(
  1. int poolId,
  2. String table,
  3. List<String> columns,
  4. Uint8List dataBuffer,
  5. int parallelism,
)
inherited

Performs a parallel bulk insert operation through poolId.

dataBuffer must be built using BulkInsertBuilder.build(). Returns inserted row count on success, -1 on failure.

Implementation

int bulkInsertParallel(
  int poolId,
  String table,
  List<String> columns,
  Uint8List dataBuffer,
  int parallelism,
) {
  final tablePtr = _sqlCache.acquire(table);
  final colPtrs = malloc<ffi.Pointer<bindings.Utf8>>(columns.length);
  try {
    for (var i = 0; i < columns.length; i++) {
      (colPtrs + i).value = _sqlCache.acquire(columns[i]);
    }
    final rowsInserted = _bulkRowsInsertedPtr();
    return _withByteBuffer(dataBuffer, (dataPtr) {
          final code = _bindings.odbc_bulk_insert_parallel(
            poolId,
            tablePtr,
            colPtrs,
            columns.length,
            dataPtr,
            dataBuffer.length,
            parallelism,
            rowsInserted,
          );
          if (code != 0) return -1;
          return rowsInserted.value;
        }) ??
        -1;
  } finally {
    malloc.free(colPtrs);
  }
}