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)); }
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}\".")); } }
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); }
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); })); }
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); }
internal static RelationException DataHeaderCannotHaveDupes(IRelationHeader header, IReadOnlyList <string> dataHeader, int dupeIndex) => From(header, $"Attribute \"{dataHeader[dupeIndex]}\" at index {dupeIndex} is already specified.");
internal static RelationException DataHeaderCannotBeNull(IRelationHeader header, int emptyIndex) => From(header, $"Attribute name at index {emptyIndex} cannot be null.");
internal static RelationException NoDataAvailableCallRead(IRelationHeader header) => From(header, $"No data available. Call Read() to start reading data.");
internal static RelationException NoDataAvailable(IRelationHeader header) => From(header, $"No data available.");
internal static RelationException IndexOutOfRange(IRelationHeader header, int index) => From(header, $"Index {index} is out of range.");
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}).")); }
public bool Equals(IRelationHeader other) => Equality.CombineAll(this.Attributes, other?.Attributes);
public RelationCacheKey(MetadataIdentity source, IRelationHeader header) { this.Source = source ?? throw new ArgumentNullException(nameof(source)); this.Header = header ?? throw new ArgumentNullException(nameof(header)); }
public Relation(IField source, IRelationHeader header) { this.Source = source ?? throw new ArgumentNullException(nameof(source)); this.Header = header ?? throw new ArgumentNullException(nameof(header)); }