public void WriteRow(PlainBufferRow row)
        {
            WriteTag(PlainBufferConsts.TAG_ROW_PK);
            foreach (PlainBufferCell cell in row.GetPrimaryKey())
            {
                WriteCell(cell);
            }

            if (row.GetCells().Count > 0)
            {
                WriteTag(PlainBufferConsts.TAG_ROW_DATA);
                foreach (PlainBufferCell cell in row.GetCells())
                {
                    WriteCell(cell);
                }
            }
            if (row.HasDeleteMarker())
            {
                WriteTag(PlainBufferConsts.TAG_DELETE_ROW_MARKER);
            }

            if (row.HasExtension())
            {
                WriteExtension(row.GetExtension());
            }

            WriteTag(PlainBufferConsts.TAG_ROW_CHECKSUM);
            output.WriteRawByte(row.GetChecksum());
        }
예제 #2
0
        public static int ComputePlainBufferRow(PlainBufferRow row)
        {
            int size = 0;

            size += 1; // TAG_ROW_PK
            foreach (PlainBufferCell cell in row.GetPrimaryKey())
            {
                size += ComputePlainBufferCell(cell);
            }
            if (row.GetCells().Count > 0)
            {
                size += 1; // TAG_ROW_DATA
                foreach (PlainBufferCell cell in row.GetCells())
                {
                    size += ComputePlainBufferCell(cell);
                }
            }
            if (row.HasDeleteMarker())
            {
                size += 1; // TAG_DELETE_MARKER
            }
            if (row.HasExtension())
            {
                size += ComputePlainBufferExtension(row.GetExtension());
            }
            size += 2; // TAG_ROW_CHECKSUM + checksum
            return(size);
        }
예제 #3
0
        public static IRow ToRow(PlainBufferRow plainBufferRow)
        {
            if (plainBufferRow.HasDeleteMarker())
            {
                throw new IOException("Row could not has delete marker: " + plainBufferRow);
            }

            if (plainBufferRow.GetPrimaryKey() == null)
            {
                throw new IOException("Row has no primary key: " + plainBufferRow);
            }

            List <Column> columns = new List <Column>(plainBufferRow.GetCells().Count);

            foreach (PlainBufferCell cell in plainBufferRow.GetCells())
            {
                columns.Add(ToColumn(cell));
            }

            return(new Row(ToPrimaryKey(plainBufferRow.GetPrimaryKey()), columns));
        }
        public static byte GetChecksum(byte crc, PlainBufferRow row)
        {
            foreach (PlainBufferCell cell in row.GetPrimaryKey())
            {
                crc = crc8(crc, cell.GetChecksum());
            }

            foreach (PlainBufferCell cell in row.GetCells())
            {
                crc = crc8(crc, cell.GetChecksum());
            }

            byte del = 0;

            if (row.HasDeleteMarker())
            {
                del = (byte)0x1;
            }
            crc = crc8(crc, del);

            return(crc);
        }