Merge branch 'cassandra-3.5' into trunk

This commit is contained in:
Sylvain Lebresne 2016-03-08 10:26:08 +01:00
commit acde508159
5 changed files with 826 additions and 422 deletions

View File

@ -13,6 +13,7 @@ Merged from 2.2:
* Only log yaml config once, at startup (CASSANDRA-11217)
* Reference leak with parallel repairs on the same table (CASSANDRA-11215)
Merged from 2.1:
* COPY FROM on large datasets: fix progress report and debug performance (CASSANDRA-11053)
* InvalidateKeys should have a weak ref to key cache (CASSANDRA-11176)

View File

@ -480,7 +480,7 @@ COPY_COMMON_OPTIONS = ['DELIMITER', 'QUOTE', 'ESCAPE', 'HEADER', 'NULL', 'DATETI
'MAXATTEMPTS', 'REPORTFREQUENCY', 'DECIMALSEP', 'THOUSANDSSEP', 'BOOLSTYLE',
'NUMPROCESSES', 'CONFIGFILE', 'RATEFILE']
COPY_FROM_OPTIONS = ['CHUNKSIZE', 'INGESTRATE', 'MAXBATCHSIZE', 'MINBATCHSIZE', 'MAXROWS',
'SKIPROWS', 'SKIPCOLS', 'MAXPARSEERRORS', 'MAXINSERTERRORS', 'ERRFILE', 'TTL']
'SKIPROWS', 'SKIPCOLS', 'MAXPARSEERRORS', 'MAXINSERTERRORS', 'ERRFILE', 'PREPAREDSTATEMENTS', 'TTL']
COPY_TO_OPTIONS = ['ENCODING', 'PAGESIZE', 'PAGETIMEOUT', 'BEGINTOKEN', 'ENDTOKEN', 'MAXOUTPUTSIZE', 'MAXREQUESTS']
@ -607,7 +607,24 @@ def insert_driver_hooks():
def extend_cql_deserialization():
# The python driver returns BLOBs as string, but we expect them as bytearrays
"""
The python driver returns BLOBs as string, but we expect them as bytearrays
the implementation of cassandra.cqltypes.BytesType.deserialize.
The deserializers package exists only when the driver has been compiled with cython extensions and
cassandra.deserializers.DesBytesType replaces cassandra.cqltypes.BytesType.deserialize.
DesBytesTypeByteArray is a fast deserializer that converts blobs into bytearrays but it was
only introduced recently (3.1.0). If it is available we use it, otherwise we remove
cassandra.deserializers.DesBytesType so that we fall back onto cassandra.cqltypes.BytesType.deserialize
just like in the case where no cython extensions are present.
"""
if hasattr(cassandra, 'deserializers'):
if hasattr(cassandra.deserializers, 'DesBytesTypeByteArray'):
cassandra.deserializers.DesBytesType = cassandra.deserializers.DesBytesTypeByteArray
else:
del cassandra.deserializers.DesBytesType
cassandra.cqltypes.BytesType.deserialize = staticmethod(lambda byts, protocol_version: bytearray(byts))
class DateOverFlowWarning(RuntimeWarning):
@ -624,6 +641,9 @@ def extend_cql_deserialization():
cassandra.cqltypes.DateType.deserialize = staticmethod(deserialize_date_fallback_int)
if hasattr(cassandra, 'deserializers'):
del cassandra.deserializers.DesDateType
# Return cassandra.cqltypes.EMPTY instead of None for empty values
cassandra.cqltypes.CassandraType.support_empty_values = True
@ -1856,9 +1876,9 @@ class Shell(cmd.Cmd):
Available COPY FROM options and defaults:
CHUNKSIZE=1000 - the size of chunks passed to worker processes
CHUNKSIZE=5000 - the size of chunks passed to worker processes
INGESTRATE=100000 - an approximate ingest rate in rows per second
MINBATCHSIZE=2 - the minimum size of an import batch
MINBATCHSIZE=10 - the minimum size of an import batch
MAXBATCHSIZE=20 - the maximum size of an import batch
MAXROWS=-1 - the maximum number of rows, -1 means no maximum
SKIPROWS=0 - the number of rows to skip
@ -1867,6 +1887,11 @@ class Shell(cmd.Cmd):
MAXINSERTERRORS=-1 - the maximum global number of insert errors, -1 means no maximum
ERRFILE='' - a file where to store all rows that could not be imported, by default this is
import_ks_table.err where <ks> is your keyspace and <table> is your table name.
PREPAREDSTATEMENTS=True - whether to use prepared statements when importing, by default True. Set this to
False if you don't mind shifting data parsing to the cluster. The cluster will also
have to compile every batch statement. For large and oversized clusters
this will result in a faster import but for smaller clusters it may generate
timeouts.
TTL=3600 - the time to live in seconds, by default data will not expire
Available COPY TO options and defaults:

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,12 @@ from itertools import izip
from datetime import timedelta, tzinfo
from StringIO import StringIO
try:
from line_profiler import LineProfiler
HAS_LINE_PROFILER = True
except ImportError:
HAS_LINE_PROFILER = False
ZERO = timedelta(0)
@ -126,18 +132,35 @@ def get_file_encoding_bomsize(filename):
else:
file_encoding, size = "utf-8", 0
return (file_encoding, size)
return file_encoding, size
def profile_on():
def profile_on(fcn_names=None):
if fcn_names and HAS_LINE_PROFILER:
pr = LineProfiler()
for fcn_name in fcn_names:
pr.add_function(fcn_name)
pr.enable()
return pr
pr = cProfile.Profile()
pr.enable()
return pr
def profile_off(pr):
def profile_off(pr, file_name):
pr.disable()
s = StringIO()
ps = pstats.Stats(pr, stream=s).sort_stats('cumulative')
ps.print_stats()
print s.getvalue()
if HAS_LINE_PROFILER and isinstance(pr, LineProfiler):
pr.print_stats(s)
else:
ps = pstats.Stats(pr, stream=s).sort_stats('cumulative')
ps.print_stats()
ret = s.getvalue()
if file_name:
with open(file_name, 'w') as f:
print "Writing to %s\n" % (f.name, )
f.write(ret)
return ret

View File

@ -16,9 +16,11 @@
# limitations under the License.
from distutils.core import setup
from Cython.Build import cythonize
setup(
name="cassandra-pylib",
description="Cassandra Python Libraries",
packages=["cqlshlib"],
ext_modules=cythonize("cqlshlib/copyutil.py"),
)