public PlainBufferCell ReadCell() { if (!CheckLastTagWas(PlainBufferConsts.TAG_CELL)) { throw new IOException("Expect TAG_CELL but it was " + PlainBufferConsts.PrintTag(GetLastTag())); } PlainBufferCell cell = new PlainBufferCell(); ReadTag(); if (GetLastTag() == PlainBufferConsts.TAG_CELL_NAME) { cell.SetCellName(ReadUTFString(ReadUInt32())); ReadTag(); } if (GetLastTag() == PlainBufferConsts.TAG_CELL_VALUE) { cell.SetCellValue(ReadCellValue()); } if (GetLastTag() == PlainBufferConsts.TAG_CELL_TYPE) { cell.SetCellType(this.inputStream.ReadRawByte()); ReadTag(); } if (GetLastTag() == PlainBufferConsts.TAG_CELL_TIMESTAMP) { long timestamp = (long)ReadInt64(); if (timestamp < 0) { throw new IOException("The timestamp is negative."); } cell.SetCellTimestamp(timestamp); ReadTag(); // consume next tag as all read function should consume next tag } if (GetLastTag() == PlainBufferConsts.TAG_CELL_CHECKSUM) { byte checksum = this.inputStream.ReadRawByte(); ReadTag(); if (cell.GetChecksum() != checksum) { throw new IOException("Checksum is mismatch. Cell: " + cell + ". Checksum: " + checksum + ". PlainBuffer: " + this.inputStream); } } else { throw new IOException("Expect TAG_CELL_CHECKSUM but it was " + PlainBufferConsts.PrintTag(GetLastTag())); } return(cell); }
public static PlainBufferCell ToPlainBufferCell(Column column, bool ignoreValue, bool ignoreTs, bool setType, byte type) { PlainBufferCell cell = new PlainBufferCell(); cell.SetCellName(column.Name); if (!ignoreValue) { cell.SetCellValue(column.Value); } if (!ignoreTs) { if (column.Timestamp.HasValue) { cell.SetCellTimestamp(column.Timestamp.Value); } } if (setType) { cell.SetCellType(type); } return(cell); }