コード例 #1
0
ファイル: Directory.cs プロジェクト: yuexiaoyun/cloudb
        public Key AddItem(string name)
        {
            ++directoryVersion;

            StringDictionary pset = new StringDictionary(GetDataFile(propertySetKey));

            // Assert the item isn't already stored,
            if (pset.GetValue <long>(name, -1) != -1)
            {
                throw new ApplicationException("Item already exists: " + name);
            }

            // Generate a unique identifier for the name,
            long id = GenerateId();

            pset.SetValue(name, id);
            SortedIndex iset = new SortedIndex(GetDataFile(indexSetKey));

            iset.Insert(name, id, collator);

            Key itemKey = GetItemKey(id);

            IDataFile df = GetDataFile(itemKey);

            try {
                BinaryWriter dout = new BinaryWriter(new DataFileStream(df), Encoding.Unicode);
                dout.Write(name);
            } catch (IOException e) {
                throw new ApplicationException(e.Message);
            }

            return(itemKey);
        }
コード例 #2
0
ファイル: DbTable.cs プロジェクト: yuexiaoyun/cloudb
 private void AddRowToIndexSet(long rowid)
 {
     // Get the set of columns that are indexed in this table,
     string[] indexedCols = IndexedColumns;
     foreach (String col in indexedCols)
     {
         // Resolve the column name to an id, turn it into a OrderedList64Bit,
         // and insert the row in the correct location in the index,
         long        columnid = GetColumnId(col);
         IDataFile   df       = GetDataFile(GetIndexIdKey(columnid));
         SortedIndex index    = new SortedIndex(df);
         IIndexedObjectComparer <string> indexComparer = GetIndexComparerFor(col, columnid);
         index.Insert(GetValue(rowid, columnid), rowid, indexComparer);
     }
 }
コード例 #3
0
ファイル: DbTable.cs プロジェクト: yuexiaoyun/cloudb
        private void BuildIndex(long columnid, IIndexedObjectComparer <string> indexComparer)
        {
            // Get the index object
            IDataFile df = GetDataFile(GetIndexIdKey(columnid));
            // Get the index and clear it,
            SortedIndex index = new SortedIndex(df);

            index.Clear();

            // For each row in this table,
            foreach (DbRow row in this)
            {
                // Get the column value and the rowid
                string columnValue = row.GetValue(columnid);
                long   rowid       = row.RowId;
                // Add it into the index,
                index.Insert(columnValue, rowid, indexComparer);
            }
            // Done.
        }