public void WriteCell(PlainBufferCell cell)
        {
            WriteTag(PlainBufferConsts.TAG_CELL);

            if (cell.HasCellName())
            {
                WriteCellName(cell.GetNameRawData());
            }

            if (cell.HasCellValue())
            {
                var columnValue = cell.IsPk() ? cell.GetPkCellValue() : cell.GetCellValue();
                WriteCellValue(columnValue);
            }

            if (cell.HasCellType())
            {
                WriteTag(PlainBufferConsts.TAG_CELL_TYPE);
                output.WriteRawByte(cell.GetCellType());
            }

            if (cell.HasCellTimestamp())
            {
                WriteTag(PlainBufferConsts.TAG_CELL_TIMESTAMP);
                output.WriteRawLittleEndian64(cell.GetCellTimestamp());
            }

            WriteTag(PlainBufferConsts.TAG_CELL_CHECKSUM);
            output.WriteRawByte(cell.GetChecksum());
        }
        public static byte GetChecksum(byte crc, PlainBufferCell cell)
        {
            if (cell.HasCellName())
            {
                crc = crc8(crc, cell.GetNameRawData());
            }

            if (cell.HasCellValue())
            {
                if (cell.IsPk())
                {
                    crc = cell.GetPkCellValue().GetChecksum(crc);
                }
                else
                {
                    crc = cell.GetCellValue().GetChecksum(crc);
                }
            }

            if (cell.HasCellTimestamp())
            {
                crc = crc8(crc, cell.GetCellTimestamp());
            }

            if (cell.HasCellType())
            {
                crc = crc8(crc, cell.GetCellType());
            }

            return(crc);
        }
Esempio n. 3
0
        public static Column ToColumn(PlainBufferCell cell)
        {
            if (!cell.HasCellName() || !cell.HasCellValue())
            {
                throw new IOException("The cell has no name or value: " + cell);
            }

            if (cell.HasCellType() && cell.GetCellType() != PlainBufferConsts.INCREMENT)
            {
                throw new IOException("The cell should not has type: " + cell);
            }

            if (cell.HasCellTimestamp())
            {
                return(new Column(cell.GetCellName(), cell.GetCellValue(), cell.GetCellTimestamp()));
            }
            else
            {
                return(new Column(cell.GetCellName(), cell.GetCellValue()));
            }
        }