Skip to content

Instantly share code, notes, and snippets.

View kellymclaughlin's full-sized avatar
🏠
Working from home

Kelly McLaughlin kellymclaughlin

🏠
Working from home
View GitHub Profile
@kellymclaughlin
kellymclaughlin / README
Created August 11, 2010 05:31
Instructions on adding http digest support to Erlang R13B04.
These are source files to add http digest authentication to erlang's inet-5.3 application. To install do the following:
1. Copy all three source files to /usr/lib/erlang/lib/inets-5.3/src.
2. cd /usr/lib/erlang/lib/inets-5.3/src
3. erlc -W -o ../ebin http_request.erl httpc.erl httpc_request.erl
@kellymclaughlin
kellymclaughlin / README
Created December 2, 2010 23:55
Instructions on adding http digest support to Erlang R14B01 with Inets 5.5.
These are source files to add http digest authentication to erlang's inet-5.5 application. To install do the following:
1. Copy httpc_request.erl and httpc.erl to /usr/lib/erlang/lib/inets-5.5/src/http_client/.
2. Copy http_request.erl to /usr/lib/erlang/lib/inets-5.5/src/http_lib/.
3. cd /usr/lib/erlang/lib/inets-5.5/src
3. sudo erlc -W -o ../ebin http_lib/http_request.erl http_client/httpc.erl http_client/httpc_request.erl

KV Operations

The following list illustrates how the Riak KV operations would be specified using different apis. The first sub-entry for each list member represents how the operation is specified in the existing api. The second sub-entry shows the operation in the new proposed api and the final sub-entry uses a shortened syntax of b for buckets and k for keys.

  1. List Buckets
%% @private
%% @doc Find a minimal set of covering VNodes
find_coverage([], _, _, _, _, Coverage) ->
{ok, lists:sort(Coverage)};
find_coverage(KeySpace, [], _, _, _, Coverage) ->
{insufficient_vnodes_available, KeySpace, lists:sort(Coverage)};
find_coverage(KeySpace, Available, NVal, PartitionCount, Offset, Coverage) ->
Res = next_vnode(KeySpace, NVal, PartitionCount, Offset, Available),
case Res of
{0, _, _} -> % out of vnodes
malformed_index_headers(RD, Ctx) ->
%% Get a list of index_headers...
L1 = extract_index_headers(RD),
%% Remove the prefix...
%% PrefixSize = length(?HEAD_INDEX_PREFIX),
%% F = fun(X) -> element(2, lists:split(PrefixSize, X)) end,
@kellymclaughlin
kellymclaughlin / chash_diff
Created June 9, 2011 15:11
next_index function
diff --git a/src/chash.erl b/src/chash.erl
index ecf0fb2..8aafb20 100644
--- a/src/chash.erl
+++ b/src/chash.erl
@@ -37,7 +37,7 @@
successors/2,successors/3,
predecessors/2,predecessors/3,
contains_name/2,key_of/1,
- merge_rings/2]).
+ merge_rings/2, next_index/2]).
diff --git a/src/riak_index.erl b/src/riak_index.erl
index ca258bc..c94499d 100644
--- a/src/riak_index.erl
+++ b/src/riak_index.erl
@@ -93,18 +93,7 @@ parse_object(RObj) ->
parse_fields(IndexFields) ->
%% Call parse_field on each field, and accumulate in ResultAcc or
%% ErrorAcc, depending on whether the operation was successful.
- Types = field_types(),
- F = fun({Field, Value}, {ResultAcc, ErrorAcc}) ->
@kellymclaughlin
kellymclaughlin / gist:1035827
Created June 20, 2011 15:31
riak_kv_pb_socket:legacy_mapreduce using if statement to reduce nesting
legacy_mapreduce(Req, #state{client=C}=State, Inputs, Query, Timeout) ->
if
is_binary(Inputs)
orelse (is_tuple(Inputs)
andalso is_binary(element(1, Inputs))
andalso is_list(element(2, Inputs))) ->
case C:mapred_bucket_stream(Inputs, Query,
self(), Timeout) of
{stop, Error} ->
send_error("~p", [Error], State);
{"inputs":{
"bucket":"invoices",
"key_filters":[["tokenize", ",", 4],["eq", "key"]]
},
"query":[
{"map":
{
"language":"javascript",
"source": "function(value, key, arg) { return [value.key] }",
"keep": true
@kellymclaughlin
kellymclaughlin / az475-bb-summary.png
Created July 13, 2011 17:45
Notes for Andrew on lager review.
az475-bb-summary.png