You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ro...@apache.org on 2016/07/14 21:18:58 UTC
[1/2] incubator-beam git commit: Closes #653
Repository: incubator-beam
Updated Branches:
refs/heads/python-sdk 3b6950689 -> c8cef2cba
Closes #653
Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/c8cef2cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/c8cef2cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/c8cef2cb
Branch: refs/heads/python-sdk
Commit: c8cef2cbac10b2a3be79b7087c96e254ce7aedd3
Parents: 3b69506 afc68bc
Author: Robert Bradshaw <ro...@google.com>
Authored: Thu Jul 14 14:18:43 2016 -0700
Committer: Robert Bradshaw <ro...@google.com>
Committed: Thu Jul 14 14:18:43 2016 -0700
----------------------------------------------------------------------
sdks/python/apache_beam/coders/coders_test_common.py | 4 ++--
.../apache_beam/examples/complete/top_wikipedia_sessions.py | 6 +++---
sdks/python/apache_beam/transforms/timeutil.py | 5 ++---
3 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
[2/2] incubator-beam git commit: Fix min and max timestamp on 32-bit
machines
Posted by ro...@apache.org.
Fix min and max timestamp on 32-bit machines
Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/afc68bc3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/afc68bc3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/afc68bc3
Branch: refs/heads/python-sdk
Commit: afc68bc3aee9cafbe865628a9683bffdd73853ec
Parents: 3b69506
Author: Charles Chen <cc...@google.com>
Authored: Thu Jul 14 00:39:01 2016 -0700
Committer: Robert Bradshaw <ro...@google.com>
Committed: Thu Jul 14 14:18:43 2016 -0700
----------------------------------------------------------------------
sdks/python/apache_beam/coders/coders_test_common.py | 4 ++--
.../apache_beam/examples/complete/top_wikipedia_sessions.py | 6 +++---
sdks/python/apache_beam/transforms/timeutil.py | 5 ++---
3 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/afc68bc3/sdks/python/apache_beam/coders/coders_test_common.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/coders/coders_test_common.py b/sdks/python/apache_beam/coders/coders_test_common.py
index 07436cb..0266fdc 100644
--- a/sdks/python/apache_beam/coders/coders_test_common.py
+++ b/sdks/python/apache_beam/coders/coders_test_common.py
@@ -19,7 +19,6 @@
import logging
import math
-import sys
import unittest
import dill
@@ -121,9 +120,10 @@ class CodersTest(unittest.TestCase):
# Multi-byte encoding starts at 128
self.check_coder(coders.VarIntCoder(), *range(120, 140))
# Large values
+ MAX_64_BIT_INT = 0x7fffffffffffffff
self.check_coder(coders.VarIntCoder(),
*[int(math.pow(-1, k) * math.exp(k))
- for k in range(0, int(math.log(sys.maxint)))])
+ for k in range(0, int(math.log(MAX_64_BIT_INT)))])
def test_float_coder(self):
self.check_coder(coders.FloatCoder(),
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/afc68bc3/sdks/python/apache_beam/examples/complete/top_wikipedia_sessions.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/examples/complete/top_wikipedia_sessions.py b/sdks/python/apache_beam/examples/complete/top_wikipedia_sessions.py
index 55b7857..7337910 100644
--- a/sdks/python/apache_beam/examples/complete/top_wikipedia_sessions.py
+++ b/sdks/python/apache_beam/examples/complete/top_wikipedia_sessions.py
@@ -42,7 +42,6 @@ from __future__ import absolute_import
import argparse
import json
import logging
-import sys
import apache_beam as beam
from apache_beam import combiners
@@ -50,6 +49,7 @@ from apache_beam import window
ONE_HOUR_IN_SECONDS = 3600
THIRTY_DAYS_IN_SECONDS = 30 * 24 * ONE_HOUR_IN_SECONDS
+MAX_TIMESTAMP = 0x7fffffffffffffff
class ExtractUserAndTimestampDoFn(beam.DoFn):
@@ -128,8 +128,8 @@ class ComputeTopSessions(beam.PTransform):
return (pcoll
| beam.ParDo('ExtractUserAndTimestamp',
ExtractUserAndTimestampDoFn())
- | beam.Filter(
- lambda x: abs(hash(x)) <= sys.maxint * self.sampling_threshold)
+ | beam.Filter(lambda x: (abs(hash(x)) <=
+ MAX_TIMESTAMP * self.sampling_threshold))
| ComputeSessions()
| beam.ParDo('SessionsToStrings', SessionsToStringsDoFn())
| TopPerMonth()
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/afc68bc3/sdks/python/apache_beam/transforms/timeutil.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/transforms/timeutil.py b/sdks/python/apache_beam/transforms/timeutil.py
index f72a9e4..4092b60 100644
--- a/sdks/python/apache_beam/transforms/timeutil.py
+++ b/sdks/python/apache_beam/transforms/timeutil.py
@@ -23,7 +23,6 @@ from abc import ABCMeta
from abc import abstractmethod
import datetime
-import sys
class Timestamp(object):
@@ -115,8 +114,8 @@ class Timestamp(object):
return Duration(micros=self.micros % other.micros)
-MIN_TIMESTAMP = Timestamp(micros=-sys.maxint - 1)
-MAX_TIMESTAMP = Timestamp(micros=sys.maxint)
+MIN_TIMESTAMP = Timestamp(micros=-0x7fffffffffffffff - 1)
+MAX_TIMESTAMP = Timestamp(micros=0x7fffffffffffffff)
class Duration(object):