readPrimaryKeyColumn: function()

in lib/protocol/plain_buffer_coded_stream.js [130:169]


    readPrimaryKeyColumn: 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 name_size = this.inputStream.readRawLittleEndian32();
        var columnName = this.inputStream.readUtfString(name_size);
        var cellCheckSum = TableStore.plainBufferCrc8.crcString(cellCheckSum, columnName);
        this.readTag();

        if (!this.checkLastTagWas(TableStore.plainBufferConsts.TAG_CELL_VALUE)) {
            throw new Error("Expect TAG_CELL_VALUE but it was " + this.getLastTag());
        }
        var primaryKeyValue, cellCheckSum;
        var result = this.readPrimaryKeyValue(cellCheckSum);
        primaryKeyValue = result.pkVal;
        cellCheckSum = result.cellCheckSum;

        if (this.getLastTag() == TableStore.plainBufferConsts.TAG_CELL_CHECKSUM) {
            var checkSum = this.inputStream.readRawByte();
            if (checkSum != cellCheckSum) {
                throw new Error("Checksum mismatch. expected:" + checkSum + ",actual:" + cellCheckSum);
            }
            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,
            primaryKeyValue: primaryKeyValue,
            rowCheckSum: rowCheckSum
        };
    },