erlang

Random bad_object_header mnesia/dets error

♀尐吖头ヾ 提交于 2019-12-11 04:22:23
问题 I am having a very weird error with mnesia. I have about 10 tables that mnesia is recording, and usually it works fine. However, in a certain place in my code, whenever I try to read from a particular table (trying to read from other tables is fine) I get a DETS error. I reduced my code to {atomic, ok} = mnesia:transaction(fun() -> [Entry] = mnesia:read(table_name, Key), ok end) I have a try / catch block around the transaction, and the error I get is this: error:{badmatch, {aborted, {

where is code beam file?

为君一笑 提交于 2019-12-11 04:11:48
问题 I have printed all code loaded as follows, why {lager_default_tracer,[]}, where beam file? (lager_test_1@macbook.local)10> io:format("~p",[code:all_loaded()]). [{io,"/usr/local/lib/erlang/lib/stdlib-2.3/ebin/io.beam"}, {erl_distribution,"/usr/local/lib/erlang/lib/kernel-3.1/ebin/erl_distribution.beam"}, {edlin,"/usr/local/lib/erlang/lib/stdlib-2.3/ebin/edlin.beam"}, {beam_clean,"/usr/local/lib/erlang/lib/compiler-5.0.3/ebin/beam_clean.beam"}, {v3_core,"/usr/local/lib/erlang/lib/compiler-5.0.3

Erlang - How To Return Count/Number Of Elements

元气小坏坏 提交于 2019-12-11 04:09:05
问题 This is my very first Erlang project. Basically, I have to write a function that takes a list of integers as a parameter & returns the number of integers from the list that are less than 1. What I have so far is a function that just returns how many integers in the list. I am not sure where/if I'm supposed to put a if statement and counter to only return how many integers are less than 1. -export([num/1]). num([]) -> 0 ; num(L) -> num(L,0). num([],Len) -> Len; num([_|T],Len) -> num(T,Len+1).

is OTP needed if my state does not change?

妖精的绣舞 提交于 2019-12-11 04:06:38
问题 I have an erlang project whose state is entirely read only, and composed of ets tables and a compiled module. It takes a few seconds to build the tables when the code starts. What is the best way to package this so it can be used by other applications? Some other things to consider: There are no data contention issues or changing state, so it seems as if there is no need for a gen_server. I like being able to call application:start/1 and have things "just work". Some process should own the

How to deserialize an string-serialized Erlang term into a JInterface object in Java?

家住魔仙堡 提交于 2019-12-11 03:37:11
问题 My interface system provides a result from the Erlang world sending a string reppresentation of an erlang term, such as a list of tuples: [ {"key1" , ["AAA", "BBB"] } , {"key2" , ["CCC", "DDD"] } ] Once I receive this string in Java, I want to parse it (deserialize) using the OTP library ( com.ericsson.otp.OtpErlangList, etc). I do not want to connect directly to Erlang OTP or use Json or Xml in my situation ( trying to handle it as native as possible, if possible ). When I convert the string

Cover report from Common Test when using rebar

懵懂的女人 提交于 2019-12-11 03:28:31
问题 I have an Erlang application that uses Rebar, and has tests written using Common Test. I'd like to see the test coverage report for these tests, so I included the following line in my rebar.config file: {cover_enabled, true}. However, the "Coverage log" link in the Common Test report just leads to a page that says "Cover tool is not used". How can I get it to use the cover tool and give me a cover report when running the tests? 回答1: The cover_enabled setting in rebar.config is necessary but

Globally registered process is not registered

强颜欢笑 提交于 2019-12-11 03:14:40
问题 I'm using spawn (node, module, function, Args) global:register_name(name, pid) To register a process on a different node globally. Here's the code Pid = spawn(mi, loop, [X]), io:format("Glavni PID: ~w~n", [Pid]), register(glavni, Pid), Pid1 = spawn (prvi@Molly, mi, loop_prvi, []), io:format("Prvi PID: ~w~n", [Pid1]), global:register_name (prvi, Pid1), When I run the code, it doesn't throw any error but when I try whereis(process) I get undefined on a node that spawned it. Here's what process'

Erlang MapReduce on Riak database giving exception

别等时光非礼了梦想. 提交于 2019-12-11 03:14:23
问题 I am going through the tutorials of riak and Erlang, I have stored data in riak by the riak-erlang-client and i did the following: 1> {ok,Pid} = riakc_pb_socket:start_link("127.0.0.1", 8087). {ok,<0.34.0>} 2> Val1 = [1,2,3]. [1,2,3] 3> MyBucket = <<"numbers">>. <<"numbers">> 4> Obj1 = riakc_obj:new(MyBucket,<<"ott">>,Val1). 5> riakc_pb_socket:put(Pid,Obj1). ok 6> {ok, Fetched} = riakc_pb_socket:get(Pid,MyBucket,<<"ott">>). {ok,{riakc_obj,<<"numbers">>,<<"ott">>, <<107,206,97,96,96,96,204,96

How to list all the bucket types in riak?

扶醉桌前 提交于 2019-12-11 03:09:21
问题 Using Riak Client(erlang), I can list all the buckets of the default bucket type. But how can I list all the bucket types? Or If I can't do this by the client, how can I find out about this? 回答1: For v2.1.4, riak-admin bucket-type list is what you are looking for. Other sub-commands for riak-admin bucket-type (taken from the riak docs at an earlier revision) include: Command Action Form create create or modify a bucket type create <type> <json> before activation activate activate a bucket

Extracting multiple row corresponding to a value in mnesia

混江龙づ霸主 提交于 2019-12-11 03:07:51
问题 Situation is:- i have mnesia tuples like {"Groupid(Primary key)","groupname","grouptype","creatorid","adminid","Member_list"}. Member_list="memberone@xyz,membertwo@xyz,memberthree@xyz".Now i want to extract all those rows in which membertwo@xyz exists.How to apply guard while selecting from mnesisa for this??Any pointers Now after going through the approach given by sherif following error is appearing in function checktable1:getRecords/1 (checktable1.erl, line 201) 37> checktable1:getRecords(