public Maybe <TableRow> GetRow(NID[] nodePath, int rowIndex) { var hnHeader = heapOnNodeReader.GetHeapOnNodeHeader(nodePath); var userRootHeapItem = heapOnNodeReader.GetHeapItem(nodePath, hnHeader.UserRoot); var tcInfo = TCINFO.OfValue(userRootHeapItem); var cebStartingOffset = tcInfo.GroupsOffsets[2]; var rowLength = tcInfo.GroupsOffsets[3]; var rowMatrixHnid = HNID.OfValue(tcInfo.RowMatrix); if (rowMatrixHnid.IsZero) { return(Maybe <TableRow> .NoValue()); } if (rowMatrixHnid.IsHID) { var heapItem = heapOnNodeReader.GetHeapItem(nodePath, rowMatrixHnid.HID); var encodedRows = heapItem.Slice(rowLength); var rowValues = rowValuesExtractor.Extract(encodedRows[rowIndex], tcInfo.ColumnDescriptors, cebStartingOffset); return(Maybe <TableRow> .OfValue(new TableRow(rowValues))); } else { var numberOfRowsPerBlock = (8 * 1024 - 16) / rowLength; var blockIndex = rowIndex / numberOfRowsPerBlock; var childNodePath = new List <NID>(nodePath) { rowMatrixHnid.NID }; var dataBlock = dataTreeReader.Read(childNodePath.ToArray(), blockIndex)[0]; var encodedRows = dataBlock.Slice(rowLength); var rowValues = rowValuesExtractor.Extract(encodedRows[rowIndex], tcInfo.ColumnDescriptors, cebStartingOffset); return(Maybe <TableRow> .OfValue(new TableRow(rowValues))); } }
public PropertyValue Read(NID[] nodePath, PropertyType propertyType, BinaryData propertyValue) { if (propertyType.IsFixedLength()) { var size = propertyType.GetFixedLengthTypeSize(); if (size <= 4) { return(new PropertyValue(propertyValue)); } var hnid = HNID.OfValue(propertyValue); var heapItem = heapOnNodeReader.GetHeapItem(nodePath, hnid.HID); return(new PropertyValue(heapItem)); } if (propertyType.IsMultiValueFixedLength() || propertyType.IsVariableLength() || propertyType.IsMultiValueVariableLength()) { var hnid = HNID.OfValue(propertyValue); var value = GetHNIDBinaryData(nodePath, hnid); if (value.HasNoValue) { return(PropertyValue.Empty); } return(new PropertyValue(value.Value)); } if (propertyType.Value == Constants.PtypObject) { var hnid = HNID.OfValue(propertyValue); var heapItem = heapOnNodeReader.GetHeapItem(nodePath, hnid.HID); return(new PropertyValue(heapItem)); } return(PropertyValue.Empty); }