Deveel.Data.TableStateStore.Create C# (CSharp) Method

Create() public method

public Create ( ) : long
return long
        public long Create()
        {
            lock (this) {
                // Allocate empty visible and deleted tables area
                using (var visTablesArea = Store.CreateArea(12)) {
                    using (var delTablesArea = Store.CreateArea(12)) {
                        visAreaPointer = visTablesArea.Id;
                        delAreaPointer = delTablesArea.Id;

                        // Write empty entries for both of these
                        visTablesArea.WriteInt4(1);
                        visTablesArea.WriteInt8(0);
                        visTablesArea.Flush();
                        delTablesArea.WriteInt4(1);
                        delTablesArea.WriteInt8(0);
                        delTablesArea.Flush();

                        // Now allocate an empty state header
                        using (var headerWriter = Store.CreateArea(32)) {
                            long headerP = headerWriter.Id;
                            headerWriter.WriteInt4(Magic);
                            headerWriter.WriteInt4(0);
                            headerWriter.WriteInt8(0);
                            headerWriter.WriteInt8(visAreaPointer);
                            headerWriter.WriteInt8(delAreaPointer);
                            headerWriter.Flush();

                            headerArea = Store.GetArea(headerP, false);

                            // Reset currentTableId
                            currentTableId = 0;

                            visibleList = new List<TableState>();
                            deleteList = new List<TableState>();

                            // Return pointer to the header area
                            return headerP;
                        }
                    }
                }
            }
        }

Usage Example

        private void MinimalCreate()
        {
            if (Exists())
            {
                throw new IOException("Composite already exists");
            }

            // Lock the store system (generates an IOException if exclusive Lock
            // can not be made).
            if (!IsReadOnly)
            {
                StoreSystem.Lock(StateStoreName);
            }

            // Create/Open the state store
            stateStore = StoreSystem.CreateStore(StateStoreName);
            try {
                stateStore.Lock();

                StateStore = new TableStateStore(stateStore);
                long headP = StateStore.Create();
                // Get the fixed area
                var fixedArea = stateStore.GetArea(-1);
                fixedArea.WriteInt8(headP);
                fixedArea.Flush();
            } finally {
                stateStore.Unlock();
            }

            Setup();

            // Init the conglomerate blob store
            InitObjectStore();

            // Create the system table (but don't initialize)
            CreateSystem();
        }
All Usage Examples Of Deveel.Data.TableStateStore::Create