Exemplo n.º 1
0
def set(key, name, value, timestamp=None, consistency=None):
    """Set a column's value."""
    timestamp = timestamp or timestamp()
    consistency = consistency or cas_types.ConsistencyLevel.ONE
    get_pool(key.keyspace).insert(
        key.key, key.get_path(column=name), value, timestamp,
        consistency)
Exemplo n.º 2
0
def remove(key, column, timestamp=None, consistency=None):
    """Remove a column."""
    timestamp = timestamp or timestamp()
    consistency = consistency or cas_types.ConsistencyLevel.ONE
    get_pool(key.keyspace).remove(key.key,
                                  key.get_path(column=column), timestamp,
                                  consistency)
Exemplo n.º 3
0
    def test_timestamp(self):
        """Test Record.timestamp."""
        tstamp = self.object.timestamp()
        self.assert_(isinstance(tstamp, int))
        tstamp_2 = self.object.timestamp()
        self.assert_(tstamp_2 >= tstamp)

        time.sleep(.01)
        self.assert_(abs(self.object.timestamp() < util.timestamp()))
Exemplo n.º 4
0
 def get_slice(self, *args, **kwargs):
     [_last_cols.pop() for i in range(len(_last_cols))]
     cols = []
     for i in range(random.randrange(1, 15)):
         cols.append(ColumnOrSuperColumn(
                 column=Column(name=uuid.uuid4().hex,
                               value=uuid.uuid4().hex,
                               timestamp=util.timestamp())))
     _last_cols.extend(cols)
     return cols
Exemplo n.º 5
0
def columns(seq, ts=None):
    """Yield Column instances form from seq of (name, value)."""
    ts = util.timestamp() if ts is None else ts
    return (Column(name, value, ts) for (name, value) in seq)
Exemplo n.º 6
0
 def timestamp():
     """Return a GMT UNIX timestamp."""
     return util.timestamp()
Exemplo n.º 7
0
    def setUp(self):
        self.row_data = list(
            lzb.pack(columns(((str(uuid.uuid4()), random.randint(0, 10000)) for x in range(100)), util.timestamp()))
        )

        self.array = Array(lzb.Key("Keyspace", "Colfam", "Rowkey"))
        self.array._slice_iterator = lambda *args, **kwargs: (
            kwargs.get("reverse") and reversed(self.row_data) or iter(self.row_data)
        )

        fake_cas = type("FakeCas", (), {"get_count": lambda *args: len(self.row_data)})
        self.array._get_cas = fake_cas