private EnvCreate ( |
||
handle | ||
fileName | String | |
flags | int | |
mode | int | |
parameters | ||
리턴 | int |
/// <summary> /// Creates a new Database /// </summary> /// <remarks> /// This method wraps the native ups_env_create function. /// <br /> /// A Database Environment is a collection of Databases, which are all /// stored in one physical file (or in-memory). Per default, up to 16 /// Databases can be stored in one file (<see /// cref="UpsConst.UPS_PARAM_MAX_DATABASES" /> /// on how to store even more Databases). /// <br /> /// Each Database is identified by a positive 16bit value (except /// 0 and values at or above 0xf000). /// Databases in an Environment can be created with /// <see cref="Environment.CreateDatabase(short)" /> or opened with /// <see cref="Environment.OpenDatabase(short)" />. /// </remarks> /// /// <param name="fileName">The file name of the Environment file. If /// the file already exists, it is overwritten. Can be null if you /// create an In-Memory Environment.</param> /// <param name="flags">Optional flags for this operation, combined /// with bitwise OR. Possible flags are: /// <list type="bullet"> /// <item><see cref="UpsConst.UPS_ENABLE_FSYNC" /> /// Immediately write modified pages to the disk. This /// slows down all Database operations, but may save the /// Database integrity in case of a system crash.</item><br /> /// <item><see cref="UpsConst.UPS_IN_MEMORY" /> /// Creates an In-Memory Environment. No file will be created, /// and the Databases are lost after the Environment /// is closed. The <paramref name="fileName" /> parameter can /// be null. Do <b>NOT</b> use in combination with /// a cache size other than 0.</item><br /> /// <item><see cref="UpsConst.UPS_DISABLE_MMAP" /> /// Do not use memory mapped files for I/O. By default, /// upscaledb checks if it can use mmap, since mmap is faster /// than read/write. For performance reasons, this flag should /// not be used.</item><br /> /// <item><see cref="UpsConst.UPS_ENABLE_TRANSACTIONS" /> /// Enables Transactions for this Database.</item><br /> /// </list> /// </param> /// <param name="mode">File access rights for the new file. This is /// the <i>mode</i> parameter for creat(2). Ignored on /// Microsoft Windows.</param> /// <param name="parameters">An array of <see cref="Parameter" /> /// structures. The following parameters are available:<br /> /// <list type="bullet"> /// <item><see cref="UpsConst.UPS_PARAM_CACHESIZE" /> /// The size of the Database cache, in bytes. The default size /// is defined in <i>src/config.h</i> as UPS_DEFAULT_CACHESIZE /// - usually 2 MB.</item><br /> /// <item><see cref="UpsConst.UPS_PARAM_PAGESIZE" /> /// The size of a file page, in bytes. It is recommended not /// to change the default size. The default size depends on /// hardware and operating system. Page sizes must be 1024 or a /// multiple of 2048.</item><br /> /// <item><see cref="UpsConst.UPS_PARAM_MAX_DATABASES" /> /// The number of maximum Databases in this Environment; /// default: 16.</item> /// </list> /// </param> /// <exception cref="DatabaseException"> /// <list type="bullet"> /// <item><see cref="UpsConst.UPS_INV_PARAMETER"/> /// if an invalid combination of flags was specified</item> /// <item><see cref="UpsConst.UPS_INV_PARAMETER"/> /// if the value for UPS_PARAM_MAX_DATABASES is too /// high (either decrease it or increase the page size)</item> /// <item><see cref="UpsConst.UPS_IO_ERROR"/> /// if the file could not be opened or reading/writing failed</item> /// <item><see cref="UpsConst.UPS_OUT_OF_MEMORY"/> /// if memory could not be allocated</item> /// <item><see cref="UpsConst.UPS_INV_PAGESIZE"/> /// if the page size is not a multiple of 1024</item> /// <item><see cref="UpsConst.UPS_INV_KEYSIZE"/> /// if the key size is too large (at least 4 keys must /// fit in a page)</item> /// <item><see cref="UpsConst.UPS_WOULD_BLOCK"/> /// if another process has locked the file</item> /// </list> /// </exception> public void Create(String fileName, int flags, int mode, Parameter[] parameters) { int st; handle = new IntPtr(0); if (parameters != null) { parameters = AppendNullParameter(parameters); } lock (this) { st = NativeMethods.EnvCreate(out handle, fileName, flags, mode, parameters); } if (st != 0) { throw new DatabaseException(st); } }