Beispiel #1
0
        private void TestCreateDropFile()
        {
            try
            {
                _logger.Message("Testing CreateDropFile");
                Manager.CreateFile(SampleFile, 10, false);
                Manager.CreateFile(SampleFile_BM, 7, true);
                Assert.IsTrue(File.Exists(SampleFile));
                Assert.IsTrue(File.Exists(SampleFile_BM));
                Assert.IsTrue(File.Exists(SampleFile_BM + " - BitMap"));
                Assert.AreEqual(File.ReadAllBytes(SampleFile).Length, Manager.HeaderSize);
                Assert.AreEqual(File.ReadAllBytes(SampleFile_BM).Length, Manager.HeaderSize);
                Assert.AreEqual(File.ReadAllBytes(SampleFile_BM + " - BitMap").Length, Manager.HeaderSize);

                Manager.DropFile(SampleFile);
                Manager.DropFile(SampleFile_BM);
                Manager.DropFile(SampleFile_BM + " - BitMap");
                Assert.IsTrue(!File.Exists(SampleFile));
                Assert.IsTrue(!File.Exists(SampleFile_BM));
                Assert.IsTrue(!File.Exists(SampleFile_BM + " - BitMap"));
            }
            catch (Exception e)
            {
                _logger.Error(e.Message);
            }
        }
Beispiel #2
0
        /**
         * Creates all the folders/files related to a new table
         * IMPORTANT - Presently assumed indexColumns would be empty
         * Index can be added on later using AddIndex
         */

        public void CreateTable(string dbName, string tableName, List <Column> columns)
        {
            String path    = GetFilePath.Table(dbName, tableName);
            String conf    = GetFilePath.TableConf(dbName, tableName);
            String records = GetFilePath.TableRecords(dbName, tableName);

            if (Directory.Exists(path))
            {
                throw new Exception("Table already exists");
            }
            else
            {
                table = new Table(dbName, tableName, columns, new List <Column>());
                storageManager.CreateFolder(path);                       //table folder
                Converter.ObjectToFile(table, conf);                     //schema file of table
                byte[] record = Converter.CharToBytes(new char[table.GetSizeOfRecordArray()]);
                storageManager.CreateFile(records, record.Length, true); //records file of table
            }
        }