Exemple #1
0
        private void btn_Load_Click(object sender, EventArgs e)
        {
            DynHash <Property> dh = new DynHash <Property>(0, 0, dirPath.Text + "/block_test.bin", new DHObjectReader(dirPath.Text + "/properties_test.bin"));

            dh.Load(dirPath.Text + "/export_test.txt", new Property());
            Console.WriteLine(dh.ToString());
        }
Exemple #2
0
        public RealtyManager(DatabaseInterface dbInterface)
        {
            DbInterface = dbInterface;

            var byNameFile = new FilePaths
            {
                FileBlockData =
                    "../../../SystemCore/data/ByNameAndReg/blocks.txt",
                FileOverflowFile =
                    "../../../SystemCore/data/ByNameAndReg/overflow.txt",
                FileTreeData =
                    "../../../SystemCore/data/ByNameAndReg/configuration.txt"
            };

            DhRealtyByNameAndRegNumber = new DynHash <RealtyByCadAndRegNumber>(byNameFile, DefaultBlockFactor, DefaultOverflowBlockFactor);
            var byId = new FilePaths
            {
                FileBlockData    = "../../../SystemCore/data/ById/blocks.txt",
                FileOverflowFile = "../../../SystemCore/data/ById/overflow.txt",
                FileTreeData     = "../../../SystemCore/data/ById/configuration.txt"
            };

            DhRealtyById = new DynHash <RealtyById>(byId, DefaultBlockFactor, DefaultOverflowBlockFactor);

            var rafBlockFile = "../../../SystemCore/data/Raf/blocks.txt";
            var rafConfFile  = "../../../SystemCore/data/Raf/configuration.txt";

            RafRealties = new RandomAccessFile <Realty>(rafBlockFile, rafConfFile, DefaultBlockFactor);
        }
Exemple #3
0
        private void btn_Test_Click(object sender, EventArgs e)
        {
            string FilePath = dirPath.Text;

            DynHash <Property> dh = new DynHash <Property>(Int32.Parse(trieDepth.Text), Int32.Parse(blockSize.Text), FilePath + "/block_test.bin", new DHObjectReader(FilePath + "/properties_test.bin"));

            dh.Destruct();
            Random       ids     = new Random(100);
            int          ca      = Int32.Parse(caCount.Text);
            int          prop    = Int32.Parse(propCount.Text);
            List <Int32> idArray = new List <Int32>(ca + prop);
            int          id      = 0;

            for (int i = 1; i <= ca; i++)
            {
                for (int j = 1; j <= prop; j++)
                {
                    id = ids.Next(ca * prop);
                    if (dh.Add(new Property()
                    {
                        ID = id,
                        RN = j,
                        CadastralArea = "CA " + i,
                        Description = "Nejaky text " + i + " " + j
                    }
                               ))
                    {
                        idArray.Add(id);
                    }
                }
            }
            bool notGood = false;

            foreach (int i in idArray)
            {
                if (dh.Find(new Property(i)) == null)
                {
                    notGood = true;
                    break;
                }
            }
            if (notGood)
            {
                MessageBox.Show("There is a problem");
            }
            else
            {
                MessageBox.Show("Its all good");
            }

            dh.Save(FilePath + "/export_test.txt");

            this.Dispose();
        }
        public RandomOperationsTester()
        {
            var filePaths = new FilePaths()
            {
                FileBlockData    = "C:/Users/janik/source/repos/US_SemestralnaPraca2/StructureTester/testData/bloky.txt",
                FileTreeData     = "C:/Users/janik/source/repos/US_SemestralnaPraca2/StructureTester/testData/conf.txt",
                FileOverflowFile = "C:/Users/janik/source/repos/US_SemestralnaPraca2/StructureTester/testData/preplnovaci.txt"
            };

            TestDynHash     = new DynHash <TestRecord>(filePaths, 10, 30);
            InsertedRecords = new List <TestRecord>();
        }
        public TesterForRealtyClass()
        {
            var filePaths = new FilePaths()
            {
                FileBlockData    = "C:/Users/janik/source/repos/US_SemestralnaPraca2/StructureTester/testData/bloky.txt",
                FileTreeData     = "C:/Users/janik/source/repos/US_SemestralnaPraca2/StructureTester/testData/conf.txt",
                FileOverflowFile = "C:/Users/janik/source/repos/US_SemestralnaPraca2/StructureTester/testData/preplnovaci.txt"
            };

            TestDynHash     = new DynHash <RealtyByCadAndRegNumber>(filePaths, 10, 30);
            InsertedRecords = new List <RealtyByCadAndRegNumber>();
        }
Exemple #6
0
        public BlocksView(DynHash <Property> p_Id, DynHash <PropertyByCadastral> p_Ca)
        {
            InitializeComponent();

            this.prop   = p_Id;
            this.propCA = p_Ca;

            DataTable tableID = new DataTable();
            DataTable tableCA = new DataTable();

            tableID.Columns.AddRange(this.GetColumns());
            tableCA.Columns.AddRange(this.GetColumns());

            p_Id.GetBlocks((block, address, linked) => tableID.Rows.Add(GetRow(block, address, linked, tableID)));
            p_Ca.GetBlocks((block, address, linked) => tableCA.Rows.Add(GetRow(block, address, linked, tableCA)));

            this.dg_ID.DataSource = tableID;
            this.dg_CA.DataSource = tableCA;

            this.ShowDialog();
        }
Exemple #7
0
        static void Main(string[] args)
        {
            var j = new FilePaths()
            {
                FileTreeData     = "C:/Users/janik/source/repos/US_SemestralnaPraca2/DynamicHash/data/data.txt",
                FileBlockData    = "C:/Users/janik/source/repos/US_SemestralnaPraca2/SystemCore/data/data.txt",
                FileOverflowFile = "C:/Users/janik/source/repos/US_SemestralnaPraca2/SystemCore/data/overflowFile.txt"
            };



            //var raf = new RafTester();
            //raf.DoRafTesting();
            //return;

            //var rTest = new TesterForRealtyClass();
            //rTest.DoDhTesting();
            //return;

            var t = new RandomOperationsTester();

            t.DoDhTesting();
            return;


            var dh = new DynHash <TestRecord>(j, 2, 4);

            while (true)
            {
                Console.WriteLine("__________________________________________");
                Console.WriteLine("Write number to insert new value");
                Console.WriteLine("I-insert / D-delete / F-find value, E-exit, S-save, L-load");
                var line = Console.ReadLine();


                var operation = line[0];
                var sValue    = line.Substring(1);

                switch (Char.ToLower(operation))
                {
                case 'i':
                {
                    dh.Add(new TestRecord(Int32.Parse(sValue)));
                    break;
                }

                case 'd':
                {
                    if (dh.TryRemove(new TestRecord(Int32.Parse(sValue)), out var removed))
                    {
                        Console.WriteLine($"Removed: {removed.Number}");
                    }

                    break;
                }

                case 'e':
                {
                    return;
                }

                case 'l':
                {
                    dh.LoadTreeData();
                    Console.WriteLine("Loaded");
                    break;
                }

                case 's':
                {
                    dh.SaveTreeData();
                    Console.WriteLine("Saved");
                    break;
                }

                case 'f':
                {
                    Console.WriteLine(dh.TryFind(new TestRecord(Int32.Parse(sValue)), out var r));
                    break;
                }

                default:
                {
                    break;
                }
                }
                //dh.Root.Print();
                var free = "";
                //foreach (var dhFreeBlock in dh._freeBlocks)
                //{
                //   free += dhFreeBlock + ", ";
                //}

                //Console.WriteLine("Free blocks: " + free);
                //Console.WriteLine("Max file index: " + dh._blockFile.MaxFileIndex);
            }
        }