readColumnValue: function()

in lib/protocol/plain_buffer_coded_stream.js [62:111]


    readColumnValue: function (cellCheckSum) {
        if (!this.checkLastTagWas(TableStore.plainBufferConsts.TAG_CELL_VALUE)) {
            throw new Error('Expect TAG_CELL_VALUE but it was' + this.getLastTag());
        }
        var columnVal = undefined;
        this.inputStream.readRawLittleEndian32();
        var columnType = this.inputStream.readRawByte();
        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();
            columnVal = 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();
            columnVal = 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();
            columnVal = binary_value;
        } else if (columnType == TableStore.plainBufferConsts.VT_BOOLEAN) {
            var bool_value = this.inputStream.readBoolean();
            var cellCheckSum = TableStore.plainBufferCrc8.crcInt8(cellCheckSum, TableStore.plainBufferConsts.VT_BOOLEAN);
            var bool_int8 = bool_value == true;
            cellCheckSum = TableStore.plainBufferCrc8.crcInt8(cellCheckSum, bool_int8);
            this.readTag();
            columnVal = bool_value;
        } else if (columnType == TableStore.plainBufferConsts.VT_DOUBLE) {
            var result = this.inputStream.readDoubleAndInt64();
            var int64 = result.int64LE;
            var doubleVal = result.doubleVal;
            cellCheckSum = TableStore.plainBufferCrc8.crcInt8(cellCheckSum, TableStore.plainBufferConsts.VT_DOUBLE);
            cellCheckSum = TableStore.plainBufferCrc8.crcInt64Buf(cellCheckSum, int64.toBuffer());
            this.readTag();

            columnVal = doubleVal;
        } else {
            throw new Error("Unsupported column type: " + columnType);
        }
        return { columnVal: columnVal, cellCheckSum: cellCheckSum };
    },