/// <param name="cellBytes">If property is external, byte[0] means empty data item</param> public void SetPropertyValue(int rowIndex, int columnIndex, byte[] propertyBytes) { TableColumnDescriptor columnDescriptor = m_tcInfo.rgTCOLDESC[columnIndex]; if (columnDescriptor.IsStoredExternally) { byte[] cellBytes = GetInternalCellBytes(rowIndex, columnIndex); HeapOrNodeID heapOrNodeID; if (cellBytes != null) { heapOrNodeID = new HeapOrNodeID(cellBytes); } else { heapOrNodeID = new HeapOrNodeID(HeapID.EmptyHeapID); } HeapOrNodeID newHeapOrNodeID = NodeStorageHelper.StoreExternalProperty(this.File, m_heap, ref m_subnodeBTree, heapOrNodeID, propertyBytes); // we call SetInternalCellBytes even when oldHeapID.Value == newHeapID.Value, // this will make sure the CEB will be updated SetInternalCellBytes(rowIndex, columnIndex, LittleEndianConverter.GetBytes(newHeapOrNodeID.Value)); } else { SetInternalCellBytes(rowIndex, columnIndex, propertyBytes); } }
public void SetExternalProperty(PropertyID propertyID, PropertyTypeName propertyType, byte[] propertyBytes) { PropertyContextRecord record = GetRecordByPropertyID(propertyID); if (record != null) { if (record.wPropType != propertyType) { throw new InvalidPropertyException("Property type mismatch"); } if (record.IsExternal) { HeapOrNodeID newHeapOrNodeID = NodeStorageHelper.StoreExternalProperty(this.File, this.Heap, ref m_subnodeBTree, record.HeapOrNodeID, propertyBytes); if (record.HeapOrNodeID.Value != newHeapOrNodeID.Value) { record.HeapOrNodeID = newHeapOrNodeID; UpdateRecord(record); } } else { // old record is not external but new record is, this should never happen. throw new InvalidPropertyException("Old record should be external but is not"); } } else // old record does not exist { record = new PropertyContextRecord(); record.HeapOrNodeID = NodeStorageHelper.StoreExternalProperty(this.File, this.Heap, ref m_subnodeBTree, propertyBytes); record.wPropId = propertyID; record.wPropType = propertyType; AddRecord(record); } }
private void RemoveExternalProperty(int rowIndex, int columnIndex) { byte[] cellBytes = GetInternalCellBytes(rowIndex, columnIndex); if (cellBytes != null) { HeapOrNodeID heapOrNodeID = new HeapOrNodeID(cellBytes); NodeStorageHelper.RemoveExternalProperty(m_heap, m_subnodeBTree, heapOrNodeID); } }
public byte[] GetExternalRecordData(PropertyContextRecord record) { if (record.IsExternal) { return(NodeStorageHelper.GetExternalPropertyBytes(this.Heap, m_subnodeBTree, record.HeapOrNodeID)); } else { throw new ArgumentException("Not an external record"); } }
public void RemoveProperty(PropertyID propertyID) { PropertyContextRecord oldRecord = GetRecordByPropertyID(propertyID); if (oldRecord != null) { if (oldRecord.IsExternal) { NodeStorageHelper.RemoveExternalProperty(this.Heap, m_subnodeBTree, oldRecord.HeapOrNodeID); } this.RemoveRecord(oldRecord.Key); } }
public byte[] GetPropertyValue(int rowIndex, int columnIndex) { TableColumnDescriptor columnDescriptor = m_tcInfo.rgTCOLDESC[columnIndex]; byte[] cellBytes = GetInternalCellBytes(rowIndex, columnIndex); if (cellBytes == null) { return(null); } else { if (columnDescriptor.IsStoredExternally) { HeapOrNodeID heapOrNodeID = new HeapOrNodeID(cellBytes); return(NodeStorageHelper.GetExternalPropertyBytes(m_heap, m_subnodeBTree, heapOrNodeID)); } else { return(cellBytes); } } }