Deveel.Data.Store.ObjectStore.Open C# (CSharp) Метод

Open() публичный Метод

public Open ( long offset ) : void
offset long
Результат void
        public void Open(long offset)
        {
            // Get the header area
            IArea headerArea = store.GetArea(offset);
            headerArea.Position = 0;

            // Read the magic
            int magic = headerArea.ReadInt4();
            int version = headerArea.ReadInt4();
            if (magic != Magic)
                throw new IOException("The magic value for this Object Store is not correct.");
            if (version != 1)
                throw new IOException("The version number for this Object Store is not correct.");

            long fixedListOffset = headerArea.ReadInt8();
            fixedList.Open(fixedListOffset);

            // Set the delete chain
            firstDeleteChainRecord = fixedList.ReadDeleteHead();
        }

Usage Example

        private void InitObjectStore()
        {
            // Does the file already exist?
            bool blobStoreExists = StoreSystem.StoreExists(ObjectStoreName);
            // If the blob store doesn't exist and we are read_only, we can't do
            // anything further so simply return.
            if (!blobStoreExists && IsReadOnly) {
                return;
            }

            // The blob store,
            if (blobStoreExists) {
                lobStore = StoreSystem.OpenStore(ObjectStoreName);
            } else {
                lobStore = StoreSystem.CreateStore(ObjectStoreName);
            }

            try {
                lobStore.Lock();

                // TODO: have multiple BLOB stores
                LargeObjectStore = new ObjectStore(0, lobStore);

                // Get the 64 byte fixed area
                var fixedArea = lobStore.GetArea(-1, false);
                // If the blob store didn't exist then we need to create it here,
                if (!blobStoreExists) {
                    long headerP = LargeObjectStore.Create();
                    fixedArea.WriteInt8(headerP);
                    fixedArea.Flush();
                } else {
                    // Otherwise we need to initialize the blob store
                    long headerP = fixedArea.ReadInt8();
                    LargeObjectStore.Open(headerP);
                }
            } finally {
                lobStore.Unlock();
            }
        }