Skip to content

Commit 767321e

Browse files
committed
Merge pull request #21 from pakozm/devel
Version 0.4.0
2 parents a835af6 + d26308d commit 767321e

File tree

9 files changed

+30
-18
lines changed

9 files changed

+30
-18
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "external/luamongo"]
2+
path = external/luamongo
3+
url = https://github.com/moai/luamongo.git

.travis.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ services:
33
env: LUA_PATH="./?/init.lua;./?.lua"
44
before_install:
55
- sudo apt-get update -qq
6-
- sudo apt-get install -y screen lua5.2 liblua5.2-dev libboost-filesystem-dev libboost-filesystem-dev libboost-thread-dev libssl-dev
7-
- wget https://github.com/mongodb/mongo-cxx-driver/archive/legacy-0.9.0.tar.gz
8-
- tar zxvf legacy-0.9.0.tar.gz
9-
- cd mongo-cxx-driver-legacy-0.9.0 && sudo scons --prefix=/usr install-mongoclient && cd -
10-
- wget https://github.com/moai/luamongo/archive/v0.4.3.tar.gz
11-
- tar zxvf v0.4.3.tar.gz
12-
- cd luamongo-0.4.3 && make && sudo mkdir -p /usr/lib/lua/5.2 && sudo cp mongo.so /usr/lib/lua/5.2 && cd -
6+
- sudo apt-get install -y mongodb mongodb-server screen lua5.2 liblua5.2-dev libboost-filesystem-dev libboost-filesystem-dev libboost-thread-dev libboost-regex-dev libssl-dev
7+
- git submodule update --init --recursive
8+
- cd external/luamongo/external/mongo-cxx-driver/ && sudo scons --sharedclient=yes --prefix=/usr install && cd -
9+
- cd external/luamongo/ && make && sudo mkdir -p /usr/lib/lua/5.2 && sudo cp mongo.so /usr/lib/lua/5.2 && cd -
1310
- ssh-keygen -b 2048 -f /home/travis/.ssh/id_rsa -t rsa -q -N ""
1411
- ssh-keyscan -t rsa localhost > ~/.ssh/known_hosts
1512
- ssh-keyscan -t rsa $(hostname) >> ~/.ssh/known_hosts
1613
- cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
14+
before_script:
15+
- sleep 15
1716
language: lua
1817
script: ./test.sh

external/luamongo

Submodule luamongo added at 0e4e7ab

mapreduce/cnn.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,15 @@ function cnn:gridfs()
4444
return gridfs
4545
end
4646

47+
-- this weak table allow to index gridfs objects using weak grid_file_builder
48+
-- keys
49+
local gridfs_instances = setmetatable({}, { __mode="k" })
50+
4751
function cnn:grid_file_builder()
48-
return mongo.GridFileBuilder.New(self:connect(), self.gridfs_dbname)
52+
local gridfs = self:gridfs()
53+
local grid_file_builder = mongo.GridFileBuilder.New(gridfs)
54+
gridfs_instances[grid_file_builder] = gridfs
55+
return grid_file_builder
4956
end
5057

5158
function cnn:get_dbname()

mapreduce/examples/APRIL-ANN/common.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ util.omp_set_num_threads(1)
2323

2424
local serialize_to_gridfs = function(gridfs, filename, obj)
2525
gridfs:remove_file(filename)
26-
local builder = mongo.GridFileBuilder.New(db, dbname)
26+
local builder = mongo.GridFileBuilder.New(gridfs)
2727
builder:append(util.serialize(obj))
2828
builder:build(filename)
2929
end
3030

3131
local deserialize_from_gridfs = function(gridfs, filename)
32-
local file = assert( gridfs:find_file(filename) )
32+
local file = assert( gridfs:find_file_by_name(filename) )
3333
local str_tbl = {}
3434
for i=1,file:num_chunks() do
3535
local chunk = file:chunk(i-1)

mapreduce/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ local tuple = require "mapreduce.tuple"
2323
local persistent_table = require "mapreduce.persistent_table"
2424

2525
local mapreduce = {
26-
_VERSION = "0.3.7",
26+
_VERSION = "0.4.0",
2727
_NAME = "mapreduce",
2828
worker = worker,
2929
server = server,

mapreduce/server.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ local function server_drop_collections(self)
333333
local dbname = self.cnn:get_dbname()
334334
-- drop all the collections
335335
for _,name in ipairs(db:get_collections(dbname)) do
336-
db:drop_collection(name)
336+
if name ~= "system_indexes" then
337+
db:drop_collection(dbname .. "." .. name)
338+
end
337339
end
338340
local gridfs = self.cnn:gridfs()
339341
local list = gridfs:list()

mapreduce/utils.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
local mongo = require "mongo"
2020
local heap = require "mapreduce.heap"
2121

22-
assert(mongo._VERSION == "0.4" or tonumber(mongo._VERSION > 0.4))
22+
assert(mongo._VERSION == "0.5" or tonumber(mongo._VERSION) > 0.5)
2323

2424
local utils = {
2525
_VERSION = "0.3",
@@ -131,7 +131,7 @@ end
131131
-- and last chunks where the line is contained, and the first and last position
132132
-- inside the corresponding chunks
133133
local function gridfs_lines_iterator(gridfs, filename)
134-
local gridfile = gridfs:find_file(filename)
134+
local gridfile = assert( gridfs:find_file_by_name(filename) )
135135
local size = #gridfile
136136
local current_chunk = 0
137137
local current_pos = 1

test.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if [[ $? -ne 0 ]]; then
66
exit 1
77
fi
88
for storage in gridfs shared sshfs; do
9-
## COMBINER + ASSOCIATIVE COMMUTATIVE IDEMPOTENT REDUCER
9+
echo COMBINER + ASSOCIATIVE COMMUTATIVE IDEMPOTENT REDUCER
1010
screen -d -m ./execute_example_worker.sh
1111
diff <(./execute_example_server.sh $storage | awk '{ print $1,$2 }' | sort) \
1212
<(cat mapreduce/server.lua \
@@ -17,7 +17,7 @@ for storage in gridfs shared sshfs; do
1717
echo "ERROR"
1818
exit 1
1919
fi
20-
## NO COMBINER + ASSOCIATIVE COMMUTATIVE IDEMPOTENT REDUCER
20+
echo NO COMBINER + ASSOCIATIVE COMMUTATIVE IDEMPOTENT REDUCER
2121
screen -d -m ./execute_example_worker.sh
2222
diff <(lua execute_server.lua localhost wordcount \
2323
mapreduce.examples.WordCount.taskfn \
@@ -34,7 +34,7 @@ for storage in gridfs shared sshfs; do
3434
echo "ERROR"
3535
exit 1
3636
fi
37-
## NO COMBINER + GENERAL REDUCER
37+
echo NO COMBINER + GENERAL REDUCER
3838
screen -d -m ./execute_example_worker.sh
3939
diff <(lua execute_server.lua localhost wordcount \
4040
mapreduce.examples.WordCount.taskfn \
@@ -51,7 +51,7 @@ for storage in gridfs shared sshfs; do
5151
echo "ERROR"
5252
exit 1
5353
fi
54-
## INIT SCRIPT
54+
echo INIT SCRIPT
5555
screen -d -m ./execute_example_worker.sh
5656
diff <(lua execute_server.lua localhost wordcount \
5757
mapreduce.examples.WordCount \

0 commit comments

Comments
 (0)