Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update kafka direct python docs on how to get the offset ranges for a…
… KafkaRDD
  • Loading branch information
ontarionick committed Oct 27, 2015
commit acb202a1a2e28b28df16c6e5269c65c2da9dddc3
15 changes: 14 additions & 1 deletion docs/streaming-kafka-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,20 @@ Next, we discuss how to use this approach in your streaming application.
);
</div>
<div data-lang="python" markdown="1">
Not supported yet
offsetRanges = []

def storeOffsetRanges(rdd):
del offsetRanges[:]
offsetRanges.extend(rdd.offsetRanges())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant we simply use offsetRanges = rdd.offsetRanges()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that and couldn't get it working - seems to be related to a new object being created instead of updating the old one.

However, if I add global offsetRanges before, that seems to work fine. I'll push that change out.

return rdd

def printOffsetRanges(rdd):
for o in offsetRanges:
print "%s %s %s %s" % (o.topic, o.partition, o.fromOffset, o.untilOffset)

directKafkaStream\
.transform(storeOffsetRanges)\
.foreachRDD(printOffsetRanges)
</div>
</div>

Expand Down