Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
//
// This file contains the pre-run code for the ORT WebAssembly module. The code in this file will be injected into the
// final module using Emscripten's `--pre-js` option.
 
/**
 * Mount external data files of a model to an internal map, which will be used during session initialization.
 *
 * @param {string} externalDataFilesPath
 * @param {Uint8Array|Blob} externalDataFilesData
 */
Module["mountExternalData"] = (externalDataFilePath, externalDataFileData) => {
  if (externalDataFilePath.startsWith("./")) {
    externalDataFilePath = externalDataFilePath.substring(2);
  }
  const files = Module.MountedFiles || (Module.MountedFiles = new Map());
  files.set(externalDataFilePath, externalDataFileData);
};
 
/**
 * Unmount external data files of a model.
 */
Module["unmountExternalData"] = () => {
  delete Module.MountedFiles;
  // Release the buffers used by the Blob-backed external data loader
  delete Module.ortExtDataScratch;
  delete Module.ortExtDataChunk;
  delete Module.ortExtDataScratchBusy;
};
 
/**
 * A workaround for SharedArrayBuffer when it is not available in the current context.
 *
 * We need this workaround because Emscripten generates code that assumes `SharedArrayBuffer` is always available and
 * uses SharedArrayBuffer in this way:
 * ```js
 * buffer instanceof SharedArrayBuffer
 * ```
 *
 * This code will throw an error when SharedArrayBuffer is not available. Fortunately, we can use `WebAssembly.Memory`
 * to create an instance of SharedArrayBuffer even when SharedArrayBuffer is not available in `globalThis`.
 *
 * While this workaround allows the WebAssembly module to be loaded, it does not provide multi-threading features when
 * SharedArrayBuffer is not available in `globalThis`. The WebAssembly module will run well in a single thread, when:
 * - Module['numThreads'] is set to 1, and
 * - _OrtInit() is called with numThreads = 1.
 *
 * @suppress {checkVars}
 */
var SharedArrayBuffer =
  globalThis.SharedArrayBuffer ??
  // prettier-ignore
  //
  // the line above is used to force prettier to skip formatting the next statement.
  // this is because prettier will remove the quotes around the property names, but we need to keep them
  // because otherwise closure compiler may rename them and break the code.
  new WebAssembly.Memory({ "initial": 0, "maximum": 0, "shared": true }).buffer.constructor;