/// <summary> /// Close this session /// </summary> public void Close() { if (IsRootCatalog) { index_check_out = null; index_reference = null; Storage.Close(); state = DEFS.STATE_DEFINED; } else { throw new VXmlException(VXmlException.E0006_CATALOG_INVALID_OP_CODE, "- 'Close'"); } }
/// <summary> /// Delete index (string key) /// </summary> /// <param name="key"></param> /// <param name="id">For non-unique index. 0 - delete a </param> /// <returns></returns> public bool Delete(string index, string key, long id = 0) { VSIndex x = node_space.GetIndex(index); return(x.Delete(key, id)); }
/// <summary> /// Check if node exists (string key) /// </summary> /// <param name="key"></param> /// <param name="partial"></param> /// <returns>true/false</returns> public bool Exists(string index, string key, bool partial = false) { VSIndex x = node_space.GetIndex(index); return(x.Exists(key, partial)); }
/// <summary> /// Get all IDs by full key (single ID if unique index) /// </summary> /// <param name="k"></param> /// <returns></returns> public long[] FindAll(string index, string key, bool partial = false) { VSIndex x = node_space.GetIndex(index); return(x.FindAll(key, partial)); }
/// <summary> /// Add new index (string key) /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <returns></returns> public bool Insert(string index, string key, long value) { VSIndex x = node_space.GetIndex(index); return(x.Insert(key, value)); }
/// <summary> /// Initialize all objects and indexes (re-open, storage is on) /// </summary> private void initialize_storage() { // Initialize Catalog node_space = Storage.GetSpace(DEFX.XML_SPACE_NAME); content_space = Storage.GetSpace(DEFX.XML_CONTENT_SPACE_NAME); if (content_space == null) { content_space = node_space; } // Check for space ownership, set if undefined if (NodeSpace.Owner != DEFX.SYSTEM_OWNER_VSXML) { if (NodeSpace.Owner == DEFS.SYSTEM_OWNER_UNDEFINED) { if (NodeSpace.GetRootID(DEFX.NODE_TYPE_CATALOG) > 0) { Storage.Close(); throw new VXmlException(VXmlException.E0023_NOT_EMPTY_UNDEFINED_SPACE_CODE, ": '" + NodeSpace.Name + "'"); } else { NodeSpace.Owner = DEFX.SYSTEM_OWNER_VSXML; } } else { Storage.Close(); throw new VXmlException(VXmlException.E0022_NOT_VSXML_NODE_SPACE_CODE, ": '" + NodeSpace.Owner + "'"); } } if (content_space.Name != DEFX.SYSTEM_OWNER_VSXML) { if (content_space.Owner != DEFX.SYSTEM_OWNER_VSXML) { if (content_space.Owner == DEFS.SYSTEM_OWNER_UNDEFINED) { if (content_space.GetRootID(DEFX.NODE_TYPE_CONTENT) > 0) { Storage.Close(); throw new VXmlException(VXmlException.E0023_NOT_EMPTY_UNDEFINED_SPACE_CODE, ": '" + content_space.Name + "'"); } else { content_space.Owner = DEFX.SYSTEM_OWNER_VSXML; } } else { Storage.Close(); throw new VXmlException(VXmlException.E0022_NOT_VSXML_NODE_SPACE_CODE, ": '" + content_space.Owner + "'"); } } } // 1.Lookup root catalog node this.OBJ = NodeSpace.GetRootObject(DEFX.NODE_TYPE_CATALOG); if (this.OBJ == null) { // Create root catalog object long sz = DEFX.ROOT_CATALOG_NODE_NAME.Length + 64 + NODE_FIXED_LENGTH; this.OBJ = NodeSpace.Allocate(sz, DEFX.NODE_TYPE_CATALOG, 0, NODE_FIXED_LENGTH); // Create default chunk this.type = DEFX.NODE_TYPE_CATALOG; this.OWNER_ID = this.OBJ.Id; this.FGEN = 0; OBJ.Set(DEFX.F_NAME, DEFX.ROOT_CATALOG_NODE_NAME); } this.type = DEFX.NODE_TYPE_CATALOG; this.root_catalog = this; // INDEXES // Create/Open Checkout index if (node_space.IndexExists(DEFX.INDEX_NAME_CHARGEOUT)) { index_check_out = node_space.GetIndex(DEFX.INDEX_NAME_CHARGEOUT); } else { index_check_out = node_space.CreateIndex(DEFX.INDEX_NAME_CHARGEOUT, true); } // Create/Open Reference index if (node_space.IndexExists(DEFX.INDEX_NAME_REFERENCE)) { index_reference = node_space.GetIndex(DEFX.INDEX_NAME_REFERENCE); } else { index_reference = node_space.CreateIndex(DEFX.INDEX_NAME_REFERENCE, false); } // Create/Open CATALOG index if (node_space.IndexExists(DEFX.INDEX_NAME_CATALOG)) { index_catalog = node_space.GetIndex(DEFX.INDEX_NAME_CATALOG); } else { index_catalog = node_space.CreateIndex(DEFX.INDEX_NAME_CATALOG, false); } // Create/Open DOCUMENT index if (node_space.IndexExists(DEFX.INDEX_NAME_DOCUMENT)) { index_document = node_space.GetIndex(DEFX.INDEX_NAME_DOCUMENT); } else { index_document = node_space.CreateIndex(DEFX.INDEX_NAME_DOCUMENT, false); } state = DEFS.STATE_OPENED; }