Esempio n. 1
0
        /// <summary>
        /// Creates the new bucket.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="location">The location.</param>
        /// <param name="maxDocumentSize">Size of the max document.</param>
        /// <param name="maxDocumentCountPerFile">The max document count per file.</param>
        /// <returns>DataBucket.</returns>
        public static DataBucket CreateNewBucket(string name, string location, int maxDocumentSize, int maxDocumentCountPerFile)
        {
            var bucket = new DataBucket
            {
                Name                    = name,
                Location                = Path.Combine(location, name),
                MaxDocumentSize         = maxDocumentSize,
                MaxDocumentCountPerFile = maxDocumentCountPerFile
            };

            if (!Directory.Exists(bucket.Location))
            {
                Directory.CreateDirectory(bucket.Location);
            }

            bucket.CreateNewMapFile();
            bucket.KeyTree = KeyTree.CreateNew(Path.Combine(bucket.Location, bucket.Name + "-KeyTree.key"));
            File.WriteAllText(Path.Combine(location, name + ".bucket"), bucket.ToString());

            return(bucket);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the new bucket.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="location">The location.</param>
        /// <param name="maxDocumentSize">Size of the max document.</param>
        /// <param name="maxDocumentCountPerFile">The max document count per file.</param>
        /// <returns>DataBucket.</returns>
        public static DataBucket CreateNewBucket(string name, string location, int maxDocumentSize, int maxDocumentCountPerFile)
        {
            var bucket = new DataBucket
                             {
                                 Name = name,
                                 Location = Path.Combine(location,name),
                                 MaxDocumentSize = maxDocumentSize,
                                 MaxDocumentCountPerFile = maxDocumentCountPerFile
                             };

            if (!Directory.Exists(bucket.Location))
                Directory.CreateDirectory(bucket.Location);

            bucket.CreateNewMapFile();
            bucket.KeyTree = KeyTree.CreateNew(Path.Combine(bucket.Location, bucket.Name + "-KeyTree.key"));
            File.WriteAllText(Path.Combine(location,name + ".bucket"),bucket.ToString());

            return bucket;
        }