Esempio n. 1
0
func (w *writer) InsertTtl(cf string, row *Row, ttl int) Writer {
	t := now()
	if len(row.SuperColumns) > 0 {
		for _, scol := range row.SuperColumns {
			tm := w.addWriter(cf, row.Key)
			sc := cassandra.NewSuperColumn()
			sc.Name = scol.Name
			sc.Columns = thrift.NewTList(thrift.STRUCT, 1)

			for _, col := range scol.Columns {
				c := cassandra.NewColumn()
				c.Name = col.Name
				c.Value = col.Value
				if ttl > 0 {
					c.Ttl = int32(ttl)
				} else {
					c.Ttl = col.Ttl
				}
				if col.Timestamp > 0 {
					c.Timestamp = col.Timestamp
				} else {
					c.Timestamp = t
				}

				sc.Columns.Push(c)
			}

			cs := cassandra.NewColumnOrSuperColumn()
			cs.SuperColumn = sc
			tm.ColumnOrSupercolumn = cs
		}
	} else if len(row.Columns) > 0 {
		for _, col := range row.Columns {
			tm := w.addWriter(cf, row.Key)
			c := cassandra.NewColumn()
			c.Name = col.Name
			c.Value = col.Value
			if ttl > 0 {
				c.Ttl = int32(ttl)
			} else {
				c.Ttl = col.Ttl
			}
			if col.Timestamp > 0 {
				c.Timestamp = col.Timestamp
			} else {
				c.Timestamp = t
			}
			cs := cassandra.NewColumnOrSuperColumn()
			cs.Column = c
			tm.ColumnOrSupercolumn = cs
		}
	}

	return w
}
Esempio n. 2
0
func (w *writer) DeltaCounters(cf string, row *Row) Writer {
	for _, col := range row.Columns {
		tm := w.addWriter(cf, row.Key)
		c := cassandra.NewCounterColumn()
		c.Name = col.Name
		Unmarshal(col.Value, LongType, &c.Value)
		cs := cassandra.NewColumnOrSuperColumn()
		cs.CounterColumn = c
		tm.ColumnOrSupercolumn = cs
	}
	return w
}
Esempio n. 3
0
func (w *writer) InsertTtl(cf string, row *Row, ttl int) Writer {
	t := now()
	for _, col := range row.Columns {
		tm := w.addWriter(cf, row.Key)
		c := cassandra.NewColumn()
		c.Name = col.Name
		c.Value = col.Value
		if ttl > 0 {
			c.Ttl = int32(ttl)
		} else {
			c.Ttl = c.Ttl
		}
		if col.Timestamp > 0 {
			c.Timestamp = col.Timestamp
		} else {
			c.Timestamp = t
		}
		cs := cassandra.NewColumnOrSuperColumn()
		cs.Column = c
		tm.ColumnOrSupercolumn = cs
	}
	return w
}