You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2015/05/23 00:41:10 UTC

[1/2] cassandra git commit: cqlsh: Improve default float precision behavior

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.2 490053820 -> 321f5e82f


cqlsh: Improve default float precision behavior

Patch by Stefania Alborghetti; reviewed by Tyler Hobbs for
CASSANDRA-9224


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7f855d11
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7f855d11
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7f855d11

Branch: refs/heads/cassandra-2.2
Commit: 7f855d113bef60808dd55735e70ec86646582de1
Parents: 744db70
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Fri May 22 17:38:46 2015 -0500
Committer: Tyler Hobbs <ty...@gmail.com>
Committed: Fri May 22 17:38:46 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                  | 1 +
 pylib/cqlshlib/formatting.py | 8 ++++++++
 2 files changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7f855d11/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index ca12522..a4430c0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.6
+ * (cqlsh) Better float precision by default (CASSANDRA-9224)
  * Improve estimated row count (CASSANDRA-9107)
  * Optimize range tombstone memory footprint (CASSANDRA-8603)
  * Use configured gcgs in anticompaction (CASSANDRA-9397)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7f855d11/pylib/cqlshlib/formatting.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/formatting.py b/pylib/cqlshlib/formatting.py
index e9d22fd..2a99e23 100644
--- a/pylib/cqlshlib/formatting.py
+++ b/pylib/cqlshlib/formatting.py
@@ -14,6 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import sys
 import re
 import time
 import calendar
@@ -144,6 +145,13 @@ def format_floating_point_type(val, colormap, float_precision, **_):
     elif math.isinf(val):
         bval = 'Infinity'
     else:
+        exponent = int(math.log10(abs(val))) if abs(val) > sys.float_info.epsilon else -sys.maxint -1
+        if -4 <= exponent < float_precision:
+            # when this is true %g will not use scientific notation,
+            # increasing precision should not change this decision
+            # so we increase the precision to take into account the
+            # digits to the left of the decimal point
+            float_precision = float_precision + exponent + 1
         bval = '%.*g' % (float_precision, val)
     return colorme(bval, colormap, 'float')
 


[2/2] cassandra git commit: Merge branch 'cassandra-2.1' into cassandra-2.2

Posted by ty...@apache.org.
Merge branch 'cassandra-2.1' into cassandra-2.2

Conflicts:
	CHANGES.txt
	pylib/cqlshlib/formatting.py


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/321f5e82
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/321f5e82
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/321f5e82

Branch: refs/heads/cassandra-2.2
Commit: 321f5e82f3083927d642416f1f51e54476225437
Parents: 4900538 7f855d1
Author: Tyler Hobbs <ty...@gmail.com>
Authored: Fri May 22 17:40:58 2015 -0500
Committer: Tyler Hobbs <ty...@gmail.com>
Committed: Fri May 22 17:40:58 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                  | 1 +
 pylib/cqlshlib/formatting.py | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/321f5e82/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index ca87385,a4430c0..d4a8150
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,10 -1,5 +1,11 @@@
 -2.1.6
 +2.2
 + * Extend Transactional API to sstable lifecycle management (CASSANDRA-8568)
 + * (cqlsh) Add support for native protocol 4 (CASSANDRA-9399)
 + * Ensure that UDF and UDAs are keyspace-isolated (CASSANDRA-9409)
 + * Revert CASSANDRA-7807 (tracing completion client notifications) (CASSANDRA-9429)
 + * Add ability to stop compaction by ID (CASSANDRA-7207)
 +Merged from 2.1:
+  * (cqlsh) Better float precision by default (CASSANDRA-9224)
   * Improve estimated row count (CASSANDRA-9107)
   * Optimize range tombstone memory footprint (CASSANDRA-8603)
   * Use configured gcgs in anticompaction (CASSANDRA-9397)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/321f5e82/pylib/cqlshlib/formatting.py
----------------------------------------------------------------------
diff --cc pylib/cqlshlib/formatting.py
index 2310fa9,2a99e23..c0c3163
--- a/pylib/cqlshlib/formatting.py
+++ b/pylib/cqlshlib/formatting.py
@@@ -14,11 -14,11 +14,11 @@@
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
 -import sys
 -import re
 -import time
  import calendar
  import math
 +import re
- import time
 +import sys
++import time
  from collections import defaultdict
  from . import wcwidth
  from .displaying import colorme, FormattedValue, DEFAULT_VALUE_COLORS