コード例 #1
0
ファイル: writer.go プロジェクト: pokebyte/gossie
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
}
コード例 #2
0
ファイル: writer.go プロジェクト: carloscm/gossie
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
}