readColumn: function()

in lib/protocol/plain_buffer_coded_stream.js [171:222]


    readColumn: function (rowCheckSum) {
        if (!this.checkLastTagWas(TableStore.plainBufferConsts.TAG_CELL)) {
            throw new Error("Expect TAG_CELL but it was " + this.getLastTag());
        }
        this.readTag();

        if (!this.checkLastTagWas(TableStore.plainBufferConsts.TAG_CELL_NAME)) {
            throw new Error("Expect TAG_CELL_NAME but it was " + this.getLastTag());
        }
        var cellCheckSum = 0;
        var columnName = null;
        var columnValue = null;
        var timestamp = null;
        var name_size = this.inputStream.readRawLittleEndian32();
        var columnName = this.inputStream.readUtfString(name_size);
        var cellCheckSum = TableStore.plainBufferCrc8.crcString(cellCheckSum, columnName);
        this.readTag();

        if (this.getLastTag() == TableStore.plainBufferConsts.TAG_CELL_VALUE) {
            var columnVal = this.readColumnValue(cellCheckSum);
            columnValue = columnVal.columnVal;
            cellCheckSum = columnVal.cellCheckSum;
        }
        //# skip CELL_TYPE
        if (this.getLastTag() == TableStore.plainBufferConsts.TAG_CELL_TYPE) {
            cell_type = TableStore.plainBufferCrc8.crcInt8(cellCheckSum, cell_type);
            this.readTag();
        }

        if (this.getLastTag() == TableStore.plainBufferConsts.TAG_CELL_TIMESTAMP) {
            var int64 = this.inputStream.readInt64();
            timestamp = int64;
            cellCheckSum = TableStore.plainBufferCrc8.crcInt64Buf(cellCheckSum, int64.toBuffer());
            this.readTag();
        }
        if (this.getLastTag() == TableStore.plainBufferConsts.TAG_CELL_CHECKSUM) {
            var checkSum = this.inputStream.readRawByte();
            if (checkSum != cellCheckSum) {
                throw new Error("Checksum mismatch.");
            }
            this.readTag();
        } else {
            throw new Error("Expect TAG_CELL_CHECKSUM but it was " + this.getLastTag());
        }
        var rowCheckSum = TableStore.plainBufferCrc8.crcInt8(rowCheckSum, cellCheckSum);
        return {
            columnName: columnName,
            columnValue: columnValue,
            timestamp: timestamp,
            rowCheckSum: rowCheckSum
        };
    },