Ejemplo n.º 1
0
        public BPlusTree()
        {
            var indexFile = "index.dat";
            var metadataFile = "metadata.dat";
            var dataFile = "data.dat";

            //if (File.Exists(indexFile))
            //    File.Delete(indexFile);
            //if (File.Exists(metadataFile))
            //    File.Delete(metadataFile);
            //if (File.Exists(dataFile))
            //    File.Delete(dataFile);

            //indexStream = new MemoryStream();
            //var dataStream = new MemoryStream();

            var metadataStream = new FileStream(metadataFile, FileMode.OpenOrCreate);
            indexStream = new FileStream(indexFile, FileMode.OpenOrCreate);
            //indexStream = new FileStream(indexFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 4096,
            //    FileOptions.WriteThrough | FileOptions.RandomAccess);

            //var mmf = MemoryMappedFile.CreateFromFile(indexFile, FileMode.Open, "index", 0, MemoryMappedFileAccess.ReadWrite);
            //indexStream = mmf.CreateViewStream();

            var dataStream = new FileStream(dataFile, FileMode.OpenOrCreate);

            var appendBpTree = new BPlusTree<int>(metadataStream, indexStream,
                dataStream, 128, 0, 0, serializer);
            tree = new String_BPlusTree<int>(appendBpTree);
        }
Ejemplo n.º 2
0
        public BPlusTree_WriteOnly()
        {
            var indexFile    = "index.dat";
            var metadataFile = "metadata.dat";
            var dataFile     = "data.dat";

            if (File.Exists(indexFile))
            {
                File.Delete(indexFile);
            }
            if (File.Exists(metadataFile))
            {
                File.Delete(metadataFile);
            }
            if (File.Exists(dataFile))
            {
                File.Delete(dataFile);
            }

            //indexStream = new MemoryStream();
            //var dataStream = new MemoryStream();

            metadataStream = new FileStream(metadataFile, FileMode.OpenOrCreate);
            indexStream    = new FileStream(indexFile, FileMode.OpenOrCreate);
            //indexStream = new FileStream(indexFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 4096,
            //    FileOptions.WriteThrough | FileOptions.RandomAccess);

            //var mmf = MemoryMappedFile.CreateFromFile(indexFile, FileMode.Open, "index", 0, MemoryMappedFileAccess.ReadWrite);
            //indexStream = mmf.CreateViewStream();

            dataStream = new FileStream(dataFile, FileMode.OpenOrCreate);

            var appendBpTree = new BPlusTree <int>(metadataStream, indexStream,
                                                   dataStream, 128, 0, 0, serializer);

            tree = new String_BPlusTree <int>(appendBpTree);
        }
Ejemplo n.º 3
0
        public BPlusTree_Azure()
        {
            var container_Name = "bplustree";
            var indexFile = "index.dat";
            var metadataFile = "metadata.dat";
            var dataFile = "data.dat";

            //if (File.Exists(indexFile))
            //    File.Delete(indexFile);
            //if (File.Exists(metadataFile))
            //    File.Delete(metadataFile);
            //if (File.Exists(dataFile))
            //    File.Delete(dataFile);

            long maxValue = uint.MaxValue - uint.MaxValue % 512;

            var account = CloudStorageAccount.DevelopmentStorageAccount;

            account = new CloudStorageAccount(new StorageCredentialsAccountAndKey("valeriob", "2SzgTAaG11U0M1gQ19SNus/vv1f0efwYOwZHL1w9YhTKEYsU1ul+s/ke92DOE1wIeCKYz5CuaowtDceUvZW2Rw=="),true);
            var blobClient =  account.CreateCloudBlobClient();

            var container = blobClient.GetContainerReference(container_Name);
            container.CreateIfNotExist();

            var indexBlob = container.GetPageBlobReference(indexFile);
            indexBlob.DeleteIfExists();
            indexBlob.Create(maxValue);
            var indexStream = new Aligned_PageBlobStream(indexBlob);

            var metadataBlob = container.GetPageBlobReference(metadataFile);
            metadataBlob.DeleteIfExists();
            metadataBlob.Create(maxValue);
            var metadataStream = new Aligned_PageBlobStream(metadataBlob);

            var dataBlob = container.GetPageBlobReference(dataFile);
            dataBlob.DeleteIfExists();
            dataBlob.Create(maxValue);
            var dataStream = new Aligned_PageBlobStream(dataBlob);

            var appendBpTree = new BPlusTree<int>(metadataStream, indexStream, dataStream, 128, 512, 0 , serializer);
            tree = new String_BPlusTree<int>(appendBpTree);
        }