computePrimaryKeyValueSize: function()

in lib/protocol/plian_buffer_builder.js [5:25]


    computePrimaryKeyValueSize: function (value) {
        var size = 1;  // # TAG_CELL_VALUE
        size += TableStore.plainBufferConsts.LITTLE_ENDIAN_32_SIZE + 1; // length + type

        if ((value === TableStore.INF_MIN) || (value === TableStore.INF_MAX) || (value === TableStore.PK_AUTO_INCR)) {
            size += 1;
            return size;
        }
        if (value instanceof Int64buf.Int64LE) {
            size += 8;
        } else if (typeof (value) === 'string') {
            size += TableStore.plainBufferConsts.LITTLE_ENDIAN_32_SIZE;
            size += TableStore.util.string.byteLength(value);
        } else if (value instanceof Buffer) {
            size += TableStore.plainBufferConsts.LITTLE_ENDIAN_32_SIZE;
            size += value.length;
        } else {
            throw new Error("Unsupported primary key type:" + typeof (value));
        }
        return size;
    },