readPrimaryKeyValue: function()

in lib/protocol/plain_buffer_coded_stream.js [26:60]


    readPrimaryKeyValue: function (cellCheckSum) {
        if (!this.checkLastTagWas(TableStore.plainBufferConsts.TAG_CELL_VALUE)) {
            throw new Error('Expect TAG_CELL_VALUE but it was' + this.getLastTag());
        }
        this.inputStream.readRawLittleEndian32();
        var columnType = this.inputStream.readRawByte();

        var pkVal = undefined;
        if (columnType === TableStore.plainBufferConsts.VT_INTEGER) {
            var int64 = this.inputStream.readInt64();
            cellCheckSum = TableStore.plainBufferCrc8.crcInt8(cellCheckSum, TableStore.plainBufferConsts.VT_INTEGER);
            cellCheckSum = TableStore.plainBufferCrc8.crcInt64Buf(cellCheckSum, int64.toBuffer());
            this.readTag();
            pkVal = int64;
        } else if (columnType === TableStore.plainBufferConsts.VT_STRING) {
            var value_size = this.inputStream.readInt32();
            var string_value = this.inputStream.readUtfString(value_size);
            cellCheckSum = TableStore.plainBufferCrc8.crcInt8(cellCheckSum, TableStore.plainBufferConsts.VT_STRING);
            cellCheckSum = TableStore.plainBufferCrc8.crcInt32(cellCheckSum, value_size);
            cellCheckSum = TableStore.plainBufferCrc8.crcString(cellCheckSum, string_value);
            this.readTag();
            pkVal = string_value;
        } else if (columnType === TableStore.plainBufferConsts.VT_BLOB) {
            var value_size = this.inputStream.readInt32();
            var binary_value = this.inputStream.readBytes(value_size);
            cellCheckSum = TableStore.plainBufferCrc8.crcInt8(cellCheckSum, TableStore.plainBufferConsts.VT_BLOB);
            cellCheckSum = TableStore.plainBufferCrc8.crcInt32(cellCheckSum, value_size);
            cellCheckSum = TableStore.plainBufferCrc8.crcString(cellCheckSum, binary_value);
            this.readTag();
            pkVal = binary_value;
        } else {
            throw new Error('Unsupported primary key type' + columnType);
        }
        return { pkVal: pkVal, cellCheckSum: cellCheckSum };
    },