コード例 #1
0
        public static RelationException From(IRelationHeader header, string message = null, Exception innerException = null)
        {
            string attributeList = string.Join(", ", header.Attributes.Select(a => $"\"{a.Identity.Name}\""));
            string fullMessage   = $"Error in relation {header.Schema}({attributeList}).";

            if (message != null || innerException != null)
            {
                fullMessage += $" {message ?? innerException.Message}";
            }

            return(new RelationException(fullMessage, innerException));
        }
コード例 #2
0
        internal static RelationException Unreachable(MetadataIdentity source, IRelationHeader header, IList <IRelationMetadata> attributes)
        {
            string attributeNames = string.Join(", ", attributes.Select(a => $"\"{a.Identity.Name}\""));

            if (attributes.Count == 1)
            {
                return(From(header, $"Attribute {attributeNames} is unreachable from source \"{source.Name}\"."));
            }
            else
            {
                return(From(header, $"Attributes {attributeNames} are unreachable from source \"{source.Name}\"."));
            }
        }
コード例 #3
0
        public BufferTree Parse(MetadataIdentity source, IRelationHeader header)
        {
            NodeTree   nodeTree = NodeParser.Parse(source, header);
            BufferTree tree     = new BufferTree()
            {
                Notation = new DotNotation(),
                Header   = header,
            };

            this.CreateSource(nodeTree.Source, tree);

            return(tree);
        }
コード例 #4
0
        private static BufferWriter GetWriter(MetadataIdentity source, IRelationHeader header)
        {
            RelationCacheKey key = new RelationCacheKey(source, header);

            return(cache.GetOrAdd(key, _ =>
            {
                BufferParser parser = new BufferParser();
                BufferTree tree = parser.Parse(source, header);
                RelationCompiler compiler = new RelationCompiler();

                return compiler.Compile(tree);
            }));
        }
コード例 #5
0
        public static NodeTree Parse(MetadataIdentity source, IRelationHeader header)
        {
            NodeTree tree = new NodeTree();

            IRelationMetadata sourceMetadata = GetMetadata(source);

            tree.Source = AddSourceNode(tree, sourceMetadata);

            for (int i = 0; i < header.Degree; i++)
            {
                AddNode(tree, header.Attributes[i], index: i);
            }

            if (tree.Unreachable.Any())
            {
                throw RelationException.Unreachable(source, header, tree.Unreachable);
            }

            return(tree);
        }
コード例 #6
0
 internal static RelationException DataHeaderCannotHaveDupes(IRelationHeader header, IReadOnlyList <string> dataHeader, int dupeIndex)
 => From(header, $"Attribute \"{dataHeader[dupeIndex]}\" at index {dupeIndex} is already specified.");
コード例 #7
0
 internal static RelationException DataHeaderCannotBeNull(IRelationHeader header, int emptyIndex)
 => From(header, $"Attribute name at index {emptyIndex} cannot be null.");
コード例 #8
0
 internal static RelationException NoDataAvailableCallRead(IRelationHeader header)
 => From(header, $"No data available. Call Read() to start reading data.");
コード例 #9
0
 internal static RelationException NoDataAvailable(IRelationHeader header)
 => From(header, $"No data available.");
コード例 #10
0
 internal static RelationException IndexOutOfRange(IRelationHeader header, int index)
 => From(header, $"Index {index} is out of range.");
コード例 #11
0
        internal static RelationException InvalidDataReaderHeader(IRelationHeader header, IEnumerable <string> dataHeader)
        {
            string headerString = string.Join(", ", dataHeader.Select(a => $"\"{a}\""));

            return(From(header, $"Degree does not match IDataReader({headerString})."));
        }
コード例 #12
0
 public bool Equals(IRelationHeader other) => Equality.CombineAll(this.Attributes, other?.Attributes);
コード例 #13
0
 public RelationCacheKey(MetadataIdentity source, IRelationHeader header)
 {
     this.Source = source ?? throw new ArgumentNullException(nameof(source));
     this.Header = header ?? throw new ArgumentNullException(nameof(header));
 }
コード例 #14
0
 public Relation(IField source, IRelationHeader header)
 {
     this.Source = source ?? throw new ArgumentNullException(nameof(source));
     this.Header = header ?? throw new ArgumentNullException(nameof(header));
 }