Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added implementation of Cascade and trivial tasks for building/cleanu…

…p; bug fixes
  • Loading branch information...
commit 77a798df185c227025e08ad98515c6109225801f 1 parent 6071464
@mrwalker mrwalker authored
View
4 HACKING
@@ -2,7 +2,7 @@ Some hacking info on cascading.jruby
* cascading.jruby can be packaged as a gem. To do so, you must generate the necessary packaging files:
- jruby -S rake gem
+ ant build; jruby -S rake gem
will produce the gem in the pkg/ dub-directory.
After that, just cd this directory and:
@@ -15,4 +15,4 @@ After that, just cd this directory and:
* The high level commands for creating new pipes are defined in cascading/helpers.rb.
* The fil cascading/cascading.rb defines global helper methods for cascading like tap creation, fields
-creation, etc.
+creation, etc.
View
4 Rakefile
@@ -28,6 +28,10 @@ task :run do
require "samples/#{ARGS[0]}"
end
+desc 'Remove gem and Java build files'
+task :clean => ['ant:clean', 'gem:clean'] do
+ puts 'Build files removed'
+end
PROJ.name = 'cascading.jruby'
PROJ.authors = 'Grégoire Marabout'
View
4 lib/cascading/assembly.rb
@@ -150,7 +150,7 @@ def copy(node, *args)
# A pipe that does nothing.
def pass(node, *args)
operation = Java::CascadingOperation::Identity.new
- node.make_pipe(Java::CascadingPipe::Each, all_fields, operation)
+ node.make_pipe(Java::CascadingPipe::Each, node.tail_pipe, Cascading.fields(all_fields), operation)
end
def assert(node, *args)
@@ -193,4 +193,4 @@ def to_s
end
-end
+end
View
4 lib/cascading/base.rb
@@ -49,6 +49,8 @@ def method_missing(name, *args, &block)
@children << child
end
return child
+ else
+ super(name, *args, &block)
end
end
@@ -95,4 +97,4 @@ def registered
end
-end
+end
View
36 lib/cascading/cascade.rb
@@ -10,28 +10,42 @@ module Cascading
class CascadeFactory
def flow(node, *args, &block)
+ name = args[0]
if block.nil?
return Cascading::Flow.get(name)
else
- return Cascading::Flow.new(name)
+ return Cascading::Flow.new(name, &block)
end
end
end
- class Cascade
- def make
- super
- connector = Java::CascadingCascade::CascadeConnector.new
- flow_instances = @flows.map do |flow|
- flow.make
- end
- cascade = connector.connect(flow_instances.to_java(Java::CascadingFlow::Flow))
+ class Cascade < Cascading::Node
+ attr_accessor :flows
+
+ def initialize(name, parent=nil, &block)
+ @flows = []
+ super(name, parent, &block)
+ end
+
+ def flow(name, *args, &block)
+ # Call method_missing to send to factory and side-effect @children
+ @flows << method_missing(:flow, *args, &block)
end
def complete
- cascade = make
+ parameters = make_flows(@flows)
+ cascade = Java::CascadingCascade::CascadeConnector.new().connect(parameters)
cascade.complete
end
+
+ private
+
+ def make_flows(flows)
+ flow_instances = flows.map do |flow|
+ flow.connect
+ end
+ flow_instances.to_java(Java::CascadingFlow::Flow)
+ end
end
-end
+end
View
10 lib/cascading/flow.rb
@@ -53,9 +53,13 @@ def source(*args)
end
end
- def complete
+ def connect
parameters = build_connect_parameter()
- flow = Java::CascadingFlow::FlowConnector.new().connect(*parameters)
+ Java::CascadingFlow::FlowConnector.new().connect(*parameters)
+ end
+
+ def complete
+ flow = connect
flow.complete
end
@@ -93,4 +97,4 @@ def make_pipes
end
-end
+end
View
5 tasks/gem.rake
@@ -189,6 +189,11 @@ namespace :gem do
task :cleanup do
sh "#{SUDO} #{GEM} cleanup #{PROJ.gem._spec.name}"
end
+
+ desc 'Remove gem build files'
+ task :clean do
+ `rm -rf pkg`
+ end
end # namespace :gem
Please sign in to comment.
Something went wrong with that request. Please try again.