Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit fe666ed1b4e75baee39754fd8eaf4eee7c52b77f @argv0 argv0 committed Jul 22, 2010
Showing with 11,485 additions and 0 deletions.
  1. +5 −0 .hgignore
  2. +28 −0 Makefile
  3. +77 −0 ebin/riak_kv.app
  4. 0 include/.empty_for_hg
  5. +39 −0 include/riak_kv_vnode.hrl
  6. 0 priv/.empty_for_hg
  7. +109 −0 priv/mapred_builtins.js
  8. BIN rebar
  9. +18 −0 rebar.config
  10. +32 −0 src/raw_link_walker.erl
  11. +215 −0 src/riak.erl
  12. +485 −0 src/riak_client.erl
  13. +115 −0 src/riak_kv_app.erl
  14. +63 −0 src/riak_kv_backend.erl
  15. +205 −0 src/riak_kv_backup.erl
  16. +214 −0 src/riak_kv_bitcask_backend.erl
  17. +496 −0 src/riak_kv_cache_backend.erl
  18. +83 −0 src/riak_kv_console.erl
  19. +66 −0 src/riak_kv_delete.erl
  20. +156 −0 src/riak_kv_dets_backend.erl
  21. +161 −0 src/riak_kv_ets_backend.erl
  22. +264 −0 src/riak_kv_fs_backend.erl
  23. +193 −0 src/riak_kv_gb_trees_backend.erl
  24. +319 −0 src/riak_kv_get_fsm.erl
  25. +146 −0 src/riak_kv_js_manager.erl
  26. +44 −0 src/riak_kv_js_sup.erl
  27. +249 −0 src/riak_kv_js_vm.erl
  28. +194 −0 src/riak_kv_keys_fsm.erl
  29. +220 −0 src/riak_kv_legacy_vnode.erl
  30. +153 −0 src/riak_kv_map_executor.erl
  31. +150 −0 src/riak_kv_map_localphase.erl
  32. +101 −0 src/riak_kv_map_phase.erl
  33. +263 −0 src/riak_kv_mapred_json.erl
  34. +159 −0 src/riak_kv_mapred_query.erl
  35. +80 −0 src/riak_kv_mapred_term.erl
  36. +241 −0 src/riak_kv_mapreduce.erl
  37. +286 −0 src/riak_kv_multi_backend.erl
  38. +58 −0 src/riak_kv_pb_listener.erl
  39. +374 −0 src/riak_kv_pb_socket.erl
  40. +44 −0 src/riak_kv_pb_socket_sup.erl
  41. +59 −0 src/riak_kv_phase_proto.erl
  42. +378 −0 src/riak_kv_put_fsm.erl
  43. +104 −0 src/riak_kv_reduce_phase.erl
  44. +418 −0 src/riak_kv_stat.erl
  45. +81 −0 src/riak_kv_sup.erl
  46. +66 −0 src/riak_kv_test_util.erl
  47. +157 −0 src/riak_kv_util.erl
  48. +619 −0 src/riak_kv_vnode.erl
  49. +66 −0 src/riak_kv_web.erl
  50. +436 −0 src/riak_kv_wm_link_walker.erl
  51. +178 −0 src/riak_kv_wm_mapred.erl
  52. +40 −0 src/riak_kv_wm_ping.erl
  53. +1,231 −0 src/riak_kv_wm_raw.erl
  54. +55 −0 src/riak_kv_wm_raw.hrl
  55. +92 −0 src/riak_kv_wm_stats.erl
  56. +619 −0 src/riak_object.erl
  57. +157 −0 test/backend_eqc.erl
  58. +475 −0 test/get_fsm_qc.erl
  59. +149 −0 test/get_fsm_qc_vnode_master.erl
@@ -0,0 +1,5 @@
+syntax regex
+.*~
+^ebin/.*.beam
+include/riak_core_pb.hrl
+^.eunit
@@ -0,0 +1,28 @@
+
+
+.PHONY: deps
+
+all: deps compile
+
+compile:
+ ./rebar compile
+
+deps:
+ ./rebar get-deps
+
+clean:
+ ./rebar clean
+
+distclean: clean
+ ./rebar delete-deps
+
+eunit:
+ ./rebar skip_deps=true eunit
+
+docs:
+ ./rebar skip_deps=true doc
+
+dialyzer: compile
+ @dialyzer -Wno_return -c apps/riak_kv/ebin
+
+
@@ -0,0 +1,77 @@
+%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 et
+{application, riak_kv,
+ [
+ {description, "Riak Key/Value Store"},
+ {vsn, "0.12.0"},
+ {modules, [
+ raw_link_walker,
+ riak,
+ riak_client,
+ riak_kv_app,
+ riak_kv_backup,
+ riak_kv_backend,
+ riak_kv_bitcask_backend,
+ riak_kv_cache_backend,
+ riak_kv_console,
+ riak_kv_delete,
+ riak_kv_dets_backend,
+ riak_kv_ets_backend,
+ riak_kv_fs_backend,
+ riak_kv_gb_trees_backend,
+ riak_kv_get_fsm,
+ riak_kv_js_manager,
+ riak_kv_js_sup,
+ riak_kv_js_vm,
+ riak_kv_keys_fsm,
+ riak_kv_legacy_vnode,
+ riak_kv_map_executor,
+ riak_kv_map_localphase,
+ riak_kv_map_phase,
+ riak_kv_mapred_json,
+ riak_kv_mapred_query,
+ riak_kv_mapred_term,
+ riak_kv_mapreduce,
+ riak_kv_multi_backend,
+ riak_kv_pb_listener,
+ riak_kv_pb_socket,
+ riak_kv_pb_socket_sup,
+ riak_kv_phase_proto,
+ riak_kv_put_fsm,
+ riak_kv_reduce_phase,
+ riak_kv_stat,
+ riak_kv_sup,
+ riak_kv_test_util,
+ riak_kv_util,
+ riak_kv_vnode,
+ riak_kv_web,
+ riak_kv_wm_link_walker,
+ riak_kv_wm_mapred,
+ riak_kv_wm_ping,
+ riak_kv_wm_raw,
+ riak_kv_wm_stats,
+ riak_object
+ ]},
+ {applications, [
+ kernel,
+ stdlib,
+ sasl,
+ crypto,
+ riak_core,
+ luke,
+ erlang_js,
+ bitcask,
+ mochiweb,
+ webmachine,
+ os_mon
+ ]},
+ {registered, []},
+ {mod, {riak_kv_app, []}},
+ {env, [
+ %% Endpoint for system stats HTTP provider
+ {stats_urlpath, "stats"},
+
+ %% Secondary code paths
+ {add_paths, []}
+ ]}
+ ]}.
No changes.
@@ -0,0 +1,39 @@
+-include_lib("riak_core/include/riak_core_vnode.hrl").
+
+-record(riak_kv_put_req_v1, {
+ bkey :: {binary(),binary()},
+ object :: term(),
+ req_id :: non_neg_integer(),
+ start_time :: non_neg_integer(),
+ options :: list()}).
+
+-record(riak_kv_get_req_v1, {
+ bkey :: {binary(), binary()},
+ req_id :: non_neg_integer()}).
+
+-record(riak_kv_listkeys_req_v1, {
+ bucket :: binary(),
+ req_id :: non_neg_integer()}).
+
+-record(riak_kv_delete_req_v1, {
+ bkey :: {binary(), binary()},
+ req_id :: non_neg_integer()}).
+
+-record(riak_kv_map_req_v1, {
+ bkey :: {binary(), binary()},
+ qterm :: term(),
+ keydata :: term()}).
+
+-record(riak_kv_vclock_req_v1, {
+ bkeys = [] :: [{binary(), binary()}]
+ }).
+
+-define(KV_PUT_REQ, #riak_kv_put_req_v1).
+-define(KV_GET_REQ, #riak_kv_get_req_v1).
+-define(KV_LISTKEYS_REQ, #riak_kv_listkeys_req_v1).
+-define(KV_DELETE_REQ, #riak_kv_delete_req_v1).
+-define(KV_MAP_REQ, #riak_kv_map_req_v1).
+-define(KV_VCLOCK_REQ, #riak_kv_vclock_req_v1).
+
+
+
No changes.
@@ -0,0 +1,109 @@
+/** Helper functions start **/
+
+var RiakHelper = function() {
+ return {
+ numericSorter: function(first, second) {
+ return first - second;
+ }
+ };
+}();
+
+/** Helper functions end **/
+
+var Riak = function() {
+
+ return {
+ getClassName: function(obj) {
+ if (obj && obj.constructor && obj.constructor.toString) {
+ var arr = obj.constructor.toString().match(/function\s*(\w+)/);
+ if (arr && arr.length == 2) {
+ return arr[1];
+ }
+ }
+ return undefined;
+ },
+ filterNotFound: function(values) {
+ return values.filter(function(value, index, data) {
+ if (typeof value === 'object') {
+ return value['not_found'] === undefined;
+ }
+ else {
+ return true;
+ } });
+ },
+ mapValues: function(value, keyData, arg) {
+ if (value["not_found"]) {
+ return [value];
+ }
+ var data = value["values"][0]["data"];
+ if (Riak.getClassName(data) !== "Array") {
+ return [data];
+ }
+ else {
+ return data;
+ }},
+ mapValuesJson: function(value, keyData, arg) {
+ if (value["not_found"]) {
+ return [value];
+ }
+ var newValues = Riak.mapValues(value, keyData, arg);
+ return newValues.map(function(nv) { return JSON.parse(nv); });
+ },
+ mapByFields: function(value, keyData, fields) {
+ if(!value.not_found) {
+ var object = Riak.mapValuesJson(value)[0];
+ for(field in fields) {
+ if(object[field] != fields[field]) {
+ return [];
+ }
+ }
+ return [object];
+ }
+ else {
+ return [];
+ }
+ },
+ reduceSum: function(values, arg) {
+ values = Riak.filterNotFound(values);
+ if (values.length > 0) {
+ return [values.reduce(function(prev, curr, index, array) { return prev + curr; } )];
+ }
+ else {
+ return [0];
+ }},
+ reduceMin: function(values, arg) {
+ values.sort();
+ return [values[0]];
+ },
+ reduceMax: function(values, arg) {
+ values.sort().reverse();
+ return [values[0]];
+ },
+ reduceSort: function(value, arg) {
+ try {
+ var c = eval(arg);
+ return value.sort(c);
+ }
+ catch (e) {
+ return value.sort();
+ }
+ },
+ reduceNumericSort: function(value, arg) {
+ value.sort(RiakHelper.numericSorter);
+ return value;
+ },
+ reduceLimit: function(value, arg) {
+ return value.slice(0, arg - 1);
+ },
+ reduceSlice: function(value, arg) {
+ var start = arg[0];
+ var end = arg[1];
+ if (end > value.length) {
+ return value;
+ }
+ else {
+ return value.slice(start, end);
+ }
+ }
+ };
+}();
BIN rebar
Binary file not shown.
@@ -0,0 +1,18 @@
+{require_otp_vsn, "R13B04|R14"}.
+{cover_enabled, true}.
+{erl_opts, [debug_info, fail_on_warning]}.
+
+{deps, [
+ {riak_core, "0.12.0", {hg, "http://bitbucket.org/basho/riak_core",
+ "tip"}},
+ {riakc, "0.2.0", {hg, "http://bitbucket.org/basho/riak-erlang-client",
+ "tip"}},
+ {luke, "\.*", {hg, "http://bitbucket.org/basho/luke",
+ "tip"}},
+ {erlang_js, "0\.4", {hg, "http://bitbucket.org/basho/erlang_js",
+ "erlang_js-0.4"}},
+ {bitcask, "1.0.2", {hg, "http://bitbucket.org/basho/bitcask",
+ "bitcask-1.0.2"}},
+ {ebloom, "1.0.1", {hg, "http://bitbucket.org/basho/ebloom",
+ "ebloom-1.0.1"}}
+ ]}.
@@ -0,0 +1,32 @@
+%% This file is provided to you under the Apache License,
+%% Version 2.0 (the "License"); you may not use this file
+%% except in compliance with the License. You may obtain
+%% a copy of the License at
+
+%% http://www.apache.org/licenses/LICENSE-2.0
+
+%% Unless required by applicable law or agreed to in writing,
+%% software distributed under the License is distributed on an
+%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%% KIND, either express or implied. See the License for the
+%% specific language governing permissions and limitations
+%% under the License.
+
+%% Copyright (c) 2007-2010 Basho Technologies, Inc. All Rights Reserved.
+
+-module(raw_link_walker).
+
+-export([mapreduce_linkfun/3]).
+
+%%
+%% NOTICE
+%%
+%% This module is STRICTLY a pass-thru for backward compatibility. DO NOT
+%% add/modify this code!
+%%
+%% We use the explicit syntax for invoking riak_kv_wm_link_walker to ensure
+%% that code loading works appropriately.
+%%
+
+mapreduce_linkfun(Object, Term, Bucket) ->
+ riak_kv_wm_link_walker:mapreduce_linkfun(Object, Term, Bucket).
Oops, something went wrong.

0 comments on commit fe666ed

Please sign in to comment.