Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang print entire data structure

Following the instructions on page 41 of a little riak book, I’m trying to dump out the ring structure using these commands:

{ok,Ring} = riak_core_ring_manager:get_my_ring().
riak_core_ring:chash(Ring).

It works, but the data gets elided. The first 24 entries get printed correctly, but the rest just gets replaced with ellipses …; see below.

How do I print the full ring structure?

# riak attach
Attempting to restart script through sudo -H -u riak
Attaching to /tmp/riak/erlang.pipe.1 (^D to exit)
{ok,Ring} = riak_core_ring_manager:get_my_ring().
{ok,{chstate_v2,'riak@riak1',
        [{'riak@riak1',{693,63553468079}},
         {'riak@riak2',{228,63553468008}},
         {'riak@riak3',{131,63553468075}}],
        {128,
         [{0,'riak@riak1'},
          {11417981541647679048466287755595961091061972992,
           'riak@riak2'},
          {22835963083295358096932575511191922182123945984,
           'riak@riak3'},
          {34253944624943037145398863266787883273185918976,
           'riak@riak1'},
          {45671926166590716193865151022383844364247891968,
           'riak@riak2'},
          {57089907708238395242331438777979805455309864960,
           'riak@riak3'},
          {68507889249886074290797726533575766546371837952,
           'riak@riak1'},
          {79925870791533753339264014289171727637433810944,
           'riak@riak2'},
          {91343852333181432387730302044767688728495783936,
           'riak@riak3'},
          {102761833874829111436196589800363649819557756928,
           'riak@riak1'},
          {114179815416476790484662877555959610910619729920,
           'riak@riak2'},
          {125597796958124469533129165311555572001681702912,
           'riak@riak3'},
          {137015778499772148581595453067151533092743675904,
           'riak@riak1'},
          {148433760041419827630061740822747494183805648896,
           'riak@riak2'},
          {159851741583067506678528028578343455274867621888,
           'riak@riak3'},
          {171269723124715185726994316333939416365929594880,
           'riak@riak1'},
          {182687704666362864775460604089535377456991567872,
           'riak@riak2'},
          {194105686208010543823926891845131338548053540864,
           'riak@riak3'},
          {205523667749658222872393179600727299639115513856,
           'riak@riak1'},
          {216941649291305901920859467356323260730177486848,...},
          {...}|...]},
 % snip %
(riak@riak1)4> riak_core_ring:chash(Ring).
{128,
 [{0,'riak@riak1'},
  {11417981541647679048466287755595961091061972992,
   'riak@riak2'},
  {22835963083295358096932575511191922182123945984,
   'riak@riak3'},
  {34253944624943037145398863266787883273185918976,
   'riak@riak1'},
  {45671926166590716193865151022383844364247891968,
   'riak@riak2'},
  {57089907708238395242331438777979805455309864960,
   'riak@riak3'},
  {68507889249886074290797726533575766546371837952,
   'riak@riak1'},
  {79925870791533753339264014289171727637433810944,
   'riak@riak2'},
  {91343852333181432387730302044767688728495783936,
   'riak@riak3'},
  {102761833874829111436196589800363649819557756928,
   'riak@riak1'},
  {114179815416476790484662877555959610910619729920,
   'riak@riak2'},
  {125597796958124469533129165311555572001681702912,
   'riak@riak3'},
  {137015778499772148581595453067151533092743675904,
   'riak@riak1'},
  {148433760041419827630061740822747494183805648896,
   'riak@riak2'},
  {159851741583067506678528028578343455274867621888,
   'riak@riak3'},
  {171269723124715185726994316333939416365929594880,
   'riak@riak1'},
  {182687704666362864775460604089535377456991567872,
   'riak@riak2'},
  {194105686208010543823926891845131338548053540864,
   'riak@riak3'},
  {205523667749658222872393179600727299639115513856,
   'riak@riak1'},
  {216941649291305901920859467356323260730177486848,
   'riak@riak2'},
  {228359630832953580969325755111919221821239459840,
   'riak@riak3'},
  {239777612374601260017792042867515182912301432832,
   'riak@riak1'},
  {251195593916248939066258330623111144003363405824,
   'riak@riak2'},
  {262613575457896618114724618378707105094425378816,
   'riak@riak3'},
  {274031556999544297163190906134303066185487351808,
   'riak@riak1'},
  {285449538541191976211657193889899027276549324800,...},
  {...}|...]}
(riak@riak1)5>
like image 642
andrewdotn Avatar asked May 21 '14 21:05

andrewdotn


2 Answers

If you're in the shell, you can use rp(Term) to print arbitrary terms without truncation.

like image 195
kjw0188 Avatar answered Oct 24 '22 10:10

kjw0188


It's a console pretty printer which truncates output. All you need is to print the value using plain io:format("~p~n", [Ring])..

like image 42
Dmitry Belyaev Avatar answered Oct 24 '22 09:10

Dmitry Belyaev