Skip to content

Commit

Permalink
Also allow 'long' type for 'timestamp' args
Browse files Browse the repository at this point in the history
Fixes issue #23.
  • Loading branch information
wbolster committed May 22, 2013
1 parent 7ad4ee8 commit e5419f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion happybase/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from collections import defaultdict
import logging
from numbers import Integral

from .hbase.ttypes import BatchMutation, Mutation

Expand All @@ -19,7 +20,7 @@ class Batch(object):
def __init__(self, table, timestamp=None, batch_size=None,
transaction=False):
"""Initialise a new Batch instance."""
if not (timestamp is None or isinstance(timestamp, int)):
if not (timestamp is None or isinstance(timestamp, Integral)):
raise TypeError("'timestamp' must be an integer or None")

if batch_size is not None:
Expand Down
7 changes: 4 additions & 3 deletions happybase/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import logging
from numbers import Integral
from operator import attrgetter
from struct import Struct

Expand Down Expand Up @@ -104,7 +105,7 @@ def row(self, row, columns=None, timestamp=None, include_timestamp=False):
rows = self.connection.client.getRowWithColumns(
self.name, row, columns)
else:
if not isinstance(timestamp, int):
if not isinstance(timestamp, Integral):
raise TypeError("'timestamp' must be an integer")
rows = self.connection.client.getRowWithColumnsTs(
self.name, row, columns, timestamp)
Expand Down Expand Up @@ -144,7 +145,7 @@ def rows(self, rows, columns=None, timestamp=None,
results = self.connection.client.getRowsWithColumns(
self.name, rows, columns)
else:
if not isinstance(timestamp, int):
if not isinstance(timestamp, Integral):
raise TypeError("'timestamp' must be an integer")

# Work-around a bug in the HBase Thrift server where the
Expand Down Expand Up @@ -192,7 +193,7 @@ def cells(self, row, column, versions=None, timestamp=None,
cells = self.connection.client.getVer(
self.name, row, column, versions)
else:
if not isinstance(timestamp, int):
if not isinstance(timestamp, Integral):
raise TypeError("'timestamp' must be an integer")
cells = self.connection.client.getVerTs(
self.name, row, column, timestamp, versions)
Expand Down
1 change: 1 addition & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def test_families():
def test_put():
table.put('r1', {'cf1:c1': 'v1', 'cf1:c2': 'v2', 'cf2:c3': 'v3'})
table.put('r1', {'cf1:c4': 'v2'}, timestamp=2345678)
table.put('r1', {'cf1:c4': 'v2'}, timestamp=1369168852994L)


def test_atomic_counters():
Expand Down

0 comments on commit e5419f8

Please sign in to comment.