private bool TryGetLinkMessageFromLinkInfoMessage(LinkInfoMessage linkInfoMessage, string name, [NotNullWhen(returnValue: true)] out LinkMessage?linkMessage) { linkMessage = null; var fractalHeap = linkInfoMessage.FractalHeap; var btree2NameIndex = linkInfoMessage.BTree2NameIndex; var nameHash = H5Checksum.JenkinsLookup3(name); var candidate = default(LinkMessage); var success = btree2NameIndex.TryFindRecord(out var record, record => { #warning Better to implement comparison code in record (here: BTree2Record05) itself? if (nameHash < record.NameHash) { return(-1); } else if (nameHash > record.NameHash) { return(1); } else { #warning duplicate2 using var localReader = new H5BinaryReader(new MemoryStream(record.HeapId)); var heapId = FractalHeapId.Construct(this.Context, localReader, fractalHeap); candidate = heapId.Read(reader => new LinkMessage(reader, this.Context.Superblock)); // https://stackoverflow.com/questions/35257814/consistent-string-sorting-between-c-sharp-and-c // https://stackoverflow.com/questions/492799/difference-between-invariantculture-and-ordinal-string-comparison return(string.CompareOrdinal(name, candidate.LinkName)); } }); if (success) { if (candidate == null) { throw new Exception("This should never happen. Just to satisfy the compiler."); } linkMessage = candidate; return(true); } return(false); }
private bool TryGetAttributeMessageFromAttributeInfoMessage(AttributeInfoMessage attributeInfoMessage, string name, [NotNullWhen(returnValue: true)] out AttributeMessage?attributeMessage) { attributeMessage = null; var fractalHeap = attributeInfoMessage.FractalHeap; var btree2NameIndex = attributeInfoMessage.BTree2NameIndex; var nameHash = ChecksumUtils.JenkinsLookup3(name); var candidate = default(AttributeMessage); var success = btree2NameIndex.TryFindRecord(out var record, record => { // H5Abtree2.c (H5A__dense_btree2_name_compare, H5A__dense_fh_name_cmp) if (nameHash < record.NameHash) { return(-1); } else if (nameHash > record.NameHash) { return(1); } else { #warning duplicate using var localReader = new H5BinaryReader(new MemoryStream(record.HeapId)); var heapId = FractalHeapId.Construct(this.Context, localReader, fractalHeap); candidate = heapId.Read(reader => new AttributeMessage(reader, this.Context.Superblock)); // https://stackoverflow.com/questions/35257814/consistent-string-sorting-between-c-sharp-and-c // https://stackoverflow.com/questions/492799/difference-between-invariantculture-and-ordinal-string-comparison return(string.CompareOrdinal(name, candidate.Name)); } }); if (success) { if (candidate is null) { throw new Exception("This should never happen. Just to satisfy the compiler."); } attributeMessage = candidate; return(true); } return(false); }
private IEnumerable <AttributeMessage> EnumerateAttributeMessagesFromAttributeInfoMessage(AttributeInfoMessage attributeInfoMessage) { var btree2NameIndex = attributeInfoMessage.BTree2NameIndex; var records = btree2NameIndex .EnumerateRecords() .ToList(); var fractalHeap = attributeInfoMessage.FractalHeap; // local cache: indirectly accessed, non-filtered List <BTree2Record01>?record01Cache = null; foreach (var record in records) { #warning duplicate1 using var localReader = new H5BinaryReader(new MemoryStream(record.HeapId)); var heapId = FractalHeapId.Construct(this.Context, localReader, fractalHeap); var message = heapId.Read(reader => new AttributeMessage(reader, this.Context.Superblock), ref record01Cache); yield return(message); } }
private IEnumerable <LinkMessage> EnumerateLinkMessagesFromLinkInfoMessage(LinkInfoMessage infoMessage) { var fractalHeap = infoMessage.FractalHeap; var btree2NameIndex = infoMessage.BTree2NameIndex; var records = btree2NameIndex .EnumerateRecords() .ToList(); // local cache: indirectly accessed, non-filtered List <BTree2Record01>?record01Cache = null; foreach (var record in records) { using var localReader = new H5BinaryReader(new MemoryStream(record.HeapId)); var heapId = FractalHeapId.Construct(this.Context, localReader, fractalHeap); yield return(heapId.Read(reader => { var message = new LinkMessage(reader, this.Context.Superblock); return message; }, ref record01Cache)); } }