Beispiel #1
0
        /// <summary>
        /// Create a PartitionedTable metadata file from a list of partitions.
        /// </summary>
        /// <param name="metadataFile">Pathname for file containing the metadata.</param>
        /// <returns>The URI to use to read this metadata file.</returns>
        public string CreateMetadataFile(UNCPathname metadataFile)
        {
            // compute the prefix of the first partition
            string prefix = partitions.First().Prefix;

            Utilities.EnsureDirectoryExistsForFile(metadataFile.ToString());
            StreamWriter sw = new StreamWriter(metadataFile.ToString());

            sw.WriteLine(prefix);
            sw.WriteLine(this.partitions.Count);
            foreach (var p in this.partitions)
            {
                sw.WriteLine(p.ToShortString());
            }
            sw.Close();

            return(Uri.UriSchemeFile + @"://" + metadataFile);
        }
Beispiel #2
0
        /// <summary>
        /// Read the metadata from a partitioned file.
        /// </summary>
        /// <param name="metadataFile">Metadata file to read.</param>
        public PartitionedFileMetadata(UNCPathname metadataFile)
        {
            StreamReader sr            = new StreamReader(metadataFile.ToString());
            string       defaultPrefix = sr.ReadLine();
            string       str           = sr.ReadLine();

            if (string.IsNullOrEmpty(str))
            {
                throw new InvalidDataException("Expected a partitioned count, found none");
            }
            int partitionCount = int.Parse(str);

            partitions = new List <Partition>(partitionCount);

            for (int i = 0; i < partitionCount; i++)
            {
                this.Add(new Partition(sr.ReadLine(), defaultPrefix));
            }
        }
        /// <summary>
        /// Read the metadata from a partitioned file.
        /// </summary>
        /// <param name="metadataFile">Metadata file to read.</param>
        public PartitionedFileMetadata(UNCPathname metadataFile)
        {
            StreamReader sr = new StreamReader(metadataFile.ToString());
            string defaultPrefix = sr.ReadLine();
            string str = sr.ReadLine();
            if (string.IsNullOrEmpty(str))
                throw new InvalidDataException("Expected a partitioned count, found none");
            int partitionCount = int.Parse(str);
            partitions = new List<Partition>(partitionCount);

            for (int i = 0; i < partitionCount; i++)
                this.Add(new Partition(sr.ReadLine(), defaultPrefix));
        }
        /// <summary>
        /// Create a PartitionedTable metadata file from a list of partitions.
        /// </summary>
        /// <param name="metadataFile">Pathname for file containing the metadata.</param>
        /// <returns>The URI to use to read this metadata file.</returns>
        public string CreateMetadataFile(UNCPathname metadataFile)
        {
            // compute the prefix of the first partition
            string prefix = partitions.First().Prefix;

            Utilities.EnsureDirectoryExistsForFile(metadataFile.ToString());
            StreamWriter sw = new StreamWriter(metadataFile.ToString());
            sw.WriteLine(prefix);
            sw.WriteLine(this.partitions.Count);
            foreach (var p in this.partitions)
                sw.WriteLine(p.ToShortString());
            sw.Close();

            return Uri.UriSchemeFile + @"://" + metadataFile;
        }