public long ReadKeyRecordOffsetSlow(int key, PartitionTxData tx) { var sd = tx.SymbolData[_fileID]; if (!sd.KeyBlockCreated) { CopyKeyBlock(tx); } long keyBlockOffset = sd.KeyBlockOffset; CheckKeyBlockOffset(keyBlockOffset); // -1 used for null values. long keyOffset = keyBlockOffset + KEY_BLOCK_HEADER_SIZE + (key + 1) * KEY_RECORD_ENTRY_SIZE; if (keyOffset >= keyBlockOffset + sd.KeyBlockSize) { int newKeyBlockSize = (int)(keyOffset - keyBlockOffset) + KEY_RECORD_ENTRY_SIZE; int zerosToWrite = newKeyBlockSize - sd.KeyBlockSize; while (zerosToWrite > 0) { int sizeBytes = Math.Min(EMPTY_BUFFER_SIZE, zerosToWrite); _kData.WriteBytes(keyBlockOffset + sd.KeyBlockSize, EMPTY_BUFFER, 0, sizeBytes); zerosToWrite -= sizeBytes; } sd.KeyBlockSize = newKeyBlockSize; } return(keyOffset); }
public void SetValue(long rowID, byte[] bitArray, PartitionTxData tx) { var offset = rowID * _sizeBytes + ISSET_HEADER_LENGTH; _storage.WriteBytes(offset, bitArray, 0, _sizeBytes); tx.AppendOffset[_fileID] = offset + _sizeBytes; }
private unsafe void WriteInt32Array(int[] array, ref long offset) { if (array != null) { WriteUInt16((UInt16)array.Length, ref offset); var len = array.Length * sizeof(int); fixed(int *arrayPointer = array) { _data.WriteBytes(offset, (byte *)arrayPointer, len); } offset += len; } else { WriteUInt16(0, ref offset); } }
public void SetBytes(long rowID, byte[] value, PartitionTxData tx) { var offset = rowID * MetadataConstants.STRING_INDEX_FILE_RECORD_SIZE; if (value != null) { var writeOffset = tx.AppendOffset[_data.FileID]; _index.WriteInt64(offset, writeOffset); var size = value.Length; WriteLength(writeOffset, size); _data.WriteBytes(writeOffset + HEADER_SIZE, value, 0, size); tx.AppendOffset[_data.FileID] = writeOffset + HEADER_SIZE + size; } else { _index.WriteInt64(offset, MetadataConstants.INDEX_NULL_DATA_VALUE); } }