// Generated by CoffeeScript 1.8.0
(function() {
  var ByteBuffer, Increment, ProtoBuf, builder, proto,
    __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  ProtoBuf = require("protobufjs");

  ByteBuffer = require('bytebuffer');

  ProtoBuf.convertFieldsToCamelCase = true;

  builder = ProtoBuf.loadProtoFile("" + __dirname + "/../proto/Client.proto");

  proto = builder.build();

  module.exports = Increment = (function() {
    function Increment(row, ts) {
      this.row = row;
      this.ts = ts;
      this.getRow = __bind(this.getRow, this);
      this.getFields = __bind(this.getFields, this);
      this.add = __bind(this.add, this);
      this.familyMap = {};
    }

    Increment.prototype.add = function(cf, qualifier, value, timestamp) {
      var b, _base;
      if (timestamp == null) {
        timestamp = ByteBuffer.Long.MAX_VALUE;
      }
      b = new ByteBuffer(8);
      b.writeLong(ByteBuffer.Long.fromString("" + value));
      if ((_base = this.familyMap)[cf] == null) {
        _base[cf] = [];
      }
      return this.familyMap[cf].push({
        qualifier: qualifier,
        value: b.toBuffer(),
        timestamp: timestamp
      });
    };

    Increment.prototype.getFields = function() {
      var cf, o, qualifierValue, _ref;
      o = {
        row: this.row,
        mutateType: 'INCREMENT',
        columnValue: []
      };
      _ref = this.familyMap;
      for (cf in _ref) {
        qualifierValue = _ref[cf];
        o.columnValue.push({
          family: cf,
          qualifierValue: qualifierValue
        });
      }
      return o;
    };

    Increment.prototype.getRow = function() {
      return this.row;
    };

    return Increment;

  })();

}).call(this);
