<div dir="ltr"><img width="0" height="0" class="mailtrack-img" alt="" style="display:flex" src="https://mailtrack.io/trace/mail/24a827598484e7b8856b6856147f4127113cc1f7.png?u=1223976"><div>Concordo que a chamada da query é muito grande,</div><div>você viu como ficaram os campos na tabela tempo_permanencia_models depois do insert : tipo e tamanho?</div><div><br></div><div><br></div><div>Juan</div><div><br></div><div>Error in odbcQuery(channel, query, rows_at_time) : <div><div>  'Calloc' could not allocate memory (214748364800 of 1 bytes)</div><br><br><br><div style="display:inline">
            <div class="mt-signature" style="padding-right:5px;color:initial">
                <a href="https://mailtrack.io/" class="mt-signature-logo" style="text-decoration:none" target="_blank">
                    <img src="https://s3-eu-west-1.amazonaws.com/mailtrack-crx/icon-signature.png" height="14">
                </a>
                <span style="color:rgb(153,153,153)">Enviado com </span>
                <a href="https://mailtrack.io/install?source=signature&lang=pt&referral=sotojcr@gmail.com&idSignature=24" class="mt-install" target="_blank">Mailtrack</a>
                
            </div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">Em 1 de agosto de 2017 12:00,  <span dir="ltr"><<a href="mailto:r-br-request@listas.c3sl.ufpr.br" target="_blank">r-br-request@listas.c3sl.ufpr.br</a>></span> escreveu:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Enviar submissões para a lista de discussão R-br para<br>
        <a href="mailto:r-br@listas.c3sl.ufpr.br">r-br@listas.c3sl.ufpr.br</a><br>
<br>
Para se cadastrar ou descadastrar via WWW, visite o endereço<br>
        <a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" rel="noreferrer" target="_blank">https://listas.inf.ufpr.br/<wbr>cgi-bin/mailman/listinfo/r-br</a><br>
ou, via email, envie uma mensagem com a palavra 'help' no assunto ou<br>
corpo da mensagem para<br>
        <a href="mailto:r-br-request@listas.c3sl.ufpr.br">r-br-request@listas.c3sl.ufpr.<wbr>br</a><br>
<br>
Você poderá entrar em contato com a pessoa que gerencia a lista pelo<br>
endereço<br>
        <a href="mailto:r-br-owner@listas.c3sl.ufpr.br">r-br-owner@listas.c3sl.ufpr.br</a><br>
<br>
Quando responder, por favor edite sua linha Assunto assim ela será<br>
mais específica que "Re: Contents of R-br digest..."<br>
<br>Tópicos de Hoje:<br>
<br>
   1. Re: Erro de memória importando objeto pequeno de SQL<br>
      (Cesar Rabak)<br>
   2. Re: Erro de memória importando objeto pequeno de SQL<br>
      (Zhu Sha Zang)<br>
<br><br>---------- Mensagem encaminhada ----------<br>From: Cesar Rabak <<a href="mailto:cesar.rabak@gmail.com">cesar.rabak@gmail.com</a>><br>To: Pedro Emmanuel Alvarenga Americano do Brasil <<a href="mailto:emmanuel.brasil@gmail.com">emmanuel.brasil@gmail.com</a>><br>Cc: "a lista Brasileira oficial de discussão do programa R." <<a href="mailto:r-br@listas.c3sl.ufpr.br">r-br@listas.c3sl.ufpr.br</a>><br>Bcc: <br>Date: Mon, 31 Jul 2017 14:53:52 -0300<br>Subject: Re: [R-br] Erro de memória importando objeto pequeno de SQL<br><div dir="ltr">Correto Pedro!<div><br></div><div>Contudo, não entendo porque. . .</div><div><br></div><div>Minha forma de atacar esse problema seria mandar os dados para o BD por outra maneira (que ñ via R) e tentar conectar apenas para puxar os dados: aí a gente vê se é na criação do BD via R que ele deixa em aberto um tamanho default muito grande ou se é a chamada que por alguma coincidência cria um default exigindo tanta memória (embora nos OSs modernos isso não deveria gerar problema porque existem os gerenciadores de memória virtual).</div><div><br></div><div>HTH</div><div>--</div><div>Cesar Rabak</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-07-31 10:32 GMT-03:00 Pedro Emmanuel Alvarenga Americano do Brasil <span dir="ltr"><<a href="mailto:emmanuel.brasil@gmail.com" target="_blank">emmanuel.brasil@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:arial black,sans-serif;font-size:small;color:#073763">Cesar,</div><div style="font-family:arial black,sans-serif;font-size:small;color:#073763"><br></div><div style="font-family:arial black,sans-serif;font-size:small;color:#073763">A função RODBC::sqlQuery não tem exemplo, mas já usei diversas vezes com outros scripts e funciona. Esse problema está acontecendo somente no exemplo dessa conexão em específico. Então estou entendendo a partir de agora que  alguma configuração da conexão está pedindo pra reservar memória mais do que o a máquina possui. </div></div><div class="gmail_extra"><span class="m_1230040948764472124HOEnZb"><font color="#888888"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><font face="'courier new', monospace" style="background-color:rgb(255,255,255)" color="#000066">Pedro Brasil</font></div></div></div></div></div></div></font></span><div><div class="m_1230040948764472124h5">
<br><div class="gmail_quote">Em 29 de julho de 2017 20:45, Cesar Rabak <span dir="ltr"><<a href="mailto:cesar.rabak@gmail.com" target="_blank">cesar.rabak@gmail.com</a>></span> escreveu:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Pedro,<div><br></div><div>Calloc é uma chamada "primitiva" para o R, uma função da biblioteca C e é uma função feita para "alocar" (reservar) memória e zerá-la.</div><div><br></div><div>O estranho, para mim, é a tentativa do aplicativo de reservar <b>tanta</b> memória assim na chamada da função do R.</div><div><br></div><div>Essa função sqlQuery() pode ser testada fazendo:</div><div><br></div><div>> example(sqlQuery)</div><div><br></div><div>?</div><div><br></div><div>Se o exemplo do próprio pacote funcionar, aí teremos que fazer uma busca para ver de onde vem esse comportamento.</div><div><br></div><div>HTH</div><div>--</div><div>Cesar Rabak</div><div><br></div><div><br></div><div><br></div></div><div class="m_1230040948764472124m_1601941344025199055HOEnZb"><div class="m_1230040948764472124m_1601941344025199055h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-07-28 17:12 GMT-03:00 Pedro Emmanuel Alvarenga Americano do Brasil <span dir="ltr"><<a href="mailto:emmanuel.brasil@gmail.com" target="_blank">emmanuel.brasil@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:arial black,sans-serif;font-size:small;color:#073763">Ei Cesar,</div><div style="font-family:arial black,sans-serif;font-size:small;color:#073763"><br></div><div style="font-family:arial black,sans-serif;font-size:small;color:#073763">Eu tenho pouco familiaridade com SQL, e o amigo da TI que tem e faz manutenção do servidor diz que o erro é na minha estação com R. Eu acho que não, mas não tenho certeza porque eu não sei ao certo o que quer dizer esse erro. O que seria essa "Calloc"? É uma coisa natural do R?</div><div style="font-family:arial black,sans-serif;font-size:small;color:#073763"><br></div><div style="font-family:arial black,sans-serif;font-size:small;color:#073763">Abraço,</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><font face="'courier new', monospace" style="background-color:rgb(255,255,255)" color="#000066">Pedro Brasil</font></div></div></div></div></div></div><div><div class="m_1230040948764472124m_1601941344025199055m_-5566544572137748566h5">
<br><div class="gmail_quote">Em 28 de julho de 2017 16:59, Cesar Rabak <span dir="ltr"><<a href="mailto:cesar.rabak@gmail.com" target="_blank">cesar.rabak@gmail.com</a>></span> escreveu:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Pedro,<div><br></div><div>Mesmo sem poder fazer uma tentativa, me parece que o erro é estranho demais para não ser notado: a chamada à primitiva da ling. C "calloc" está pedindo 200 Gbytes, que falha e me parece algo grande demais para um "default" da chamada a sqlQuery().</div><div><br></div><div>HTH</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_1230040948764472124m_1601941344025199055m_-5566544572137748566m_-2957336891499193865h5">2017-07-28 9:42 GMT-03:00 Pedro Emmanuel Alvarenga Americano do Brasil via R-br <span dir="ltr"><<a href="mailto:r-br@listas.c3sl.ufpr.br" target="_blank">r-br@listas.c3sl.ufpr.br</a>></span>:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_1230040948764472124m_1601941344025199055m_-5566544572137748566m_-2957336891499193865h5"><div dir="ltr"><div style="font-family:"arial black",sans-serif;font-size:small;color:rgb(7,55,99)">Amigos de R,</div><div style="font-family:"arial black",sans-serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:"arial black",sans-serif;font-size:small;color:rgb(7,55,99)">Estou envolvido numa tarefa que importo um banco SQL de um servidor, faço uma modelagem, salvo o modelo no SQL através de uma seriliazação, e depois carrego esse modelo do SQL para fazer previsões em novos dados. </div><div style="font-family:"arial black",sans-serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:"arial black",sans-serif;font-size:small;color:rgb(7,55,99)">Estou seguindo um exemplo disponível nessa página:</div><div><font color="#073763" face="arial black, sans-serif"><a href="https://docs.microsoft.com/pt-br/sql/advanced-analytics/tutorials/walkthrough-deploy-and-use-the-model" target="_blank">https://docs.microsoft.com/pt-<wbr>br/sql/advanced-analytics/tuto<wbr>rials/walkthrough-deploy-and-u<wbr>se-the-model</a></font><br></div><div><font color="#073763" face="arial black, sans-serif"><br></font></div><div><font color="#073763" face="arial black, sans-serif">Sei que esse exemplo não é reproduzível porque depende da conexão com o servidor e credenciais que não posso divulgar. Mas se alguem já passou por esse problema poderia pelo menos indicar aonde está o problema que não estou sabendo identificar? Acho que muito provavelmente seria uma configuração do SQL no servidor... </font></div><div><font color="#073763" face="arial black, sans-serif"><br></font></div><div><font color="#073763" face="arial black, sans-serif"><div>library(RODBC) </div><div><br></div><div># define database connection string</div><div>dbconn <- 'Driver={SQL Server};Server=BLABLABLA;Datab<wbr>ase=BLABLABLA;Trusted_Connecti<wbr>on=yes;' </div><div><br></div><div># define a connection</div><div>conn <- odbcDriverConnect(connection = dbconn) </div></font></div><div><font color="#073763" face="arial black, sans-serif"><br></font></div><div><font color="#073763" face="arial black, sans-serif"># Estou fazendo o exemplo com o objeto LETTERS só pra ter certeza que é um objeto pequeno e que não deveria ser um problema de memória do R.</font></div><div><span style="color:rgb(7,55,99);font-family:"arial black",sans-serif">> LETTERS</span><br></div><div><font color="#073763" face="arial black, sans-serif"><div> [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X"</div><div>[25] "Y" "Z"</div><div>> teste_pequeno <- serialize(LETTERS, connection = NULL)</div><div>> teste_pequeno <- paste(teste_pequeno, collapse = "")</div><div><br></div><div># o EXEC PersistModel faz </div><div># insert into [tempo_permanencia_models] (model, [description]) values (convert(varbinary(max),@m,2), @description)</div><div># insere o modelo e uma descricao</div><div><br></div><div>> p <- paste("EXEC PersistModel @m='", teste_pequeno,"', @description = 'Teste de serialização objeto pequeno'", sep = "")</div><div>> sqlQuery(conn, p)</div><div>character(0)</div><div>> rm(teste_pequeno)</div><div>> p <- "SELECT model FROM [tempo_permanencia_models] WHERE id_model = 1022"</div><div>> mod.teste.peq <- sqlQuery(conn, p)</div><div>Error in odbcQuery(channel, query, rows_at_time) : </div><div>  'Calloc' could not allocate memory (214748364800 of 1 bytes)</div><div>> p <- paste0("SELECT id_model, description FROM [tempo_permanencia_models] WHERE id_model = 1022")<br></div><div>> sqlQuery(conn, p) #</div><div>   id_model                                              description</div><div>1      1022                     Teste de serialização objeto pequeno<br></div><div><br></div><div>Reparem que o objeto está salvo no servidor. Foi salvo a partir do R, mas não retorna para o R por conta do erro de memoria. Eu não estou sabendo nem por onde começar.</div></font></div><div style="font-family:"arial black",sans-serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:"arial black",sans-serif;font-size:small;color:rgb(7,55,99)">Que a força esteja sempre com vocês e abraço forte. </div><span class="m_1230040948764472124m_1601941344025199055m_-5566544572137748566m_-2957336891499193865m_-5822651748509058777HOEnZb"><font color="#888888"><div style="font-family:"arial black",sans-serif;font-size:small;color:rgb(7,55,99)"><br></div><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><font face="'courier new', monospace" style="background-color:rgb(255,255,255)" color="#000066">Pedro Brasil</font></div></div></div></div></div></div>
</font></span></div>
<br></div></div>______________________________<wbr>_________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" rel="noreferrer" target="_blank">https://listas.inf.ufpr.br/cgi<wbr>-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" rel="noreferrer" target="_blank">http://www.leg.ufpr.br/r-br-g<wbr>uia</a>) e forneça código mínimo reproduzível.<br></blockquote></div><br></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>
<br><br>---------- Mensagem encaminhada ----------<br>From: Zhu Sha Zang <<a href="mailto:zhushazang@gmail.com">zhushazang@gmail.com</a>><br>To: <a href="mailto:r-br@listas.c3sl.ufpr.br">r-br@listas.c3sl.ufpr.br</a><br>Cc: <br>Bcc: <br>Date: Mon, 31 Jul 2017 18:52:05 -0400<br>Subject: Re: [R-br] Erro de memória importando objeto pequeno de SQL<br>
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p>Parece que RODBC está "deprecated", tente usar o pacote
      RSQLServer.</p>
    <p><br>
    </p>
    <p>Atenciosamente<br>
    </p>
    <br>
    <div class="m_5307173174013770253moz-cite-prefix">On 07/31/2017 01:53 PM, Cesar Rabak via
      R-br wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Correto Pedro!
        <div><br>
        </div>
        <div>Contudo, não entendo porque. . .</div>
        <div><br>
        </div>
        <div>Minha forma de atacar esse problema seria mandar os dados
          para o BD por outra maneira (que ñ via R) e tentar conectar
          apenas para puxar os dados: aí a gente vê se é na criação do
          BD via R que ele deixa em aberto um tamanho default muito
          grande ou se é a chamada que por alguma coincidência cria um
          default exigindo tanta memória (embora nos OSs modernos isso
          não deveria gerar problema porque existem os gerenciadores de
          memória virtual).</div>
        <div><br>
        </div>
        <div>HTH</div>
        <div>--</div>
        <div>Cesar Rabak</div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">2017-07-31 10:32 GMT-03:00 Pedro
          Emmanuel Alvarenga Americano do Brasil <span dir="ltr"><<a href="mailto:emmanuel.brasil@gmail.com" target="_blank">emmanuel.brasil@gmail.com</a>></span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">
              <div style="font-family:arial black,sans-serif;font-size:small;color:#073763">Cesar,</div>
              <div style="font-family:arial black,sans-serif;font-size:small;color:#073763"><br>
              </div>
              <div style="font-family:arial black,sans-serif;font-size:small;color:#073763">A função
                RODBC::sqlQuery não tem exemplo, mas já usei diversas
                vezes com outros scripts e funciona. Esse problema está
                acontecendo somente no exemplo dessa conexão em
                específico. Então estou entendendo a partir de agora que
                 alguma configuração da conexão está pedindo pra
                reservar memória mais do que o a máquina possui. </div>
            </div>
            <div class="gmail_extra"><span class="m_5307173174013770253HOEnZb"><font color="#888888"><br clear="all">
                  <div>
                    <div class="gmail_signature" data-smartmail="gmail_signature">
                      <div dir="ltr">
                        <div>
                          <div dir="ltr">
                            <div dir="ltr"><font style="background-color:rgb(255,255,255)" face="'courier new', monospace" color="#000066">Pedro Brasil</font></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </font></span>
              <div>
                <div class="m_5307173174013770253h5">
                  <br>
                  <div class="gmail_quote">Em 29 de julho de 2017 20:45,
                    Cesar Rabak <span dir="ltr"><<a href="mailto:cesar.rabak@gmail.com" target="_blank">cesar.rabak@gmail.com</a>></span>
                    escreveu:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                      <div dir="ltr">Pedro,
                        <div><br>
                        </div>
                        <div>Calloc é uma chamada "primitiva" para o R,
                          uma função da biblioteca C e é uma função
                          feita para "alocar" (reservar) memória e
                          zerá-la.</div>
                        <div><br>
                        </div>
                        <div>O estranho, para mim, é a tentativa do
                          aplicativo de reservar <b>tanta</b> memória
                          assim na chamada da função do R.</div>
                        <div><br>
                        </div>
                        <div>Essa função sqlQuery() pode ser testada
                          fazendo:</div>
                        <div><br>
                        </div>
                        <div>> example(sqlQuery)</div>
                        <div><br>
                        </div>
                        <div>?</div>
                        <div><br>
                        </div>
                        <div>Se o exemplo do próprio pacote funcionar,
                          aí teremos que fazer uma busca para ver de
                          onde vem esse comportamento.</div>
                        <div><br>
                        </div>
                        <div>HTH</div>
                        <div>--</div>
                        <div>Cesar Rabak</div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                      </div>
                      <div class="m_5307173174013770253m_1601941344025199055HOEnZb">
                        <div class="m_5307173174013770253m_1601941344025199055h5">
                          <div class="gmail_extra"><br>
                            <div class="gmail_quote">2017-07-28 17:12
                              GMT-03:00 Pedro Emmanuel Alvarenga
                              Americano do Brasil <span dir="ltr"><<a href="mailto:emmanuel.brasil@gmail.com" target="_blank">emmanuel.brasil@gmail.com</a>></span>:<br>
                              <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                                <div dir="ltr">
                                  <div style="font-family:arial black,sans-serif;font-size:small;color:#073763">Ei
                                    Cesar,</div>
                                  <div style="font-family:arial black,sans-serif;font-size:small;color:#073763"><br>
                                  </div>
                                  <div style="font-family:arial black,sans-serif;font-size:small;color:#073763">Eu
                                    tenho pouco familiaridade com SQL, e
                                    o amigo da TI que tem e faz
                                    manutenção do servidor diz que o
                                    erro é na minha estação com R. Eu
                                    acho que não, mas não tenho certeza
                                    porque eu não sei ao certo o que
                                    quer dizer esse erro. O que seria
                                    essa "Calloc"? É uma coisa natural
                                    do R?</div>
                                  <div style="font-family:arial black,sans-serif;font-size:small;color:#073763"><br>
                                  </div>
                                  <div style="font-family:arial black,sans-serif;font-size:small;color:#073763">Abraço,</div>
                                </div>
                                <div class="gmail_extra"><br clear="all">
                                  <div>
                                    <div class="gmail_signature" data-smartmail="gmail_signature">
                                      <div dir="ltr">
                                        <div>
                                          <div dir="ltr">
                                            <div dir="ltr"><font style="background-color:rgb(255,255,255)" face="'courier new',
                                                monospace" color="#000066">Pedro
                                                Brasil</font></div>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                  <div>
                                    <div class="m_5307173174013770253m_1601941344025199055m_-5566544572137748566h5">
                                      <br>
                                      <div class="gmail_quote">Em 28 de
                                        julho de 2017 16:59, Cesar Rabak
                                        <span dir="ltr"><<a href="mailto:cesar.rabak@gmail.com" target="_blank">cesar.rabak@gmail.com</a>></span>
                                        escreveu:<br>
                                        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                                          <div dir="ltr">Pedro,
                                            <div><br>
                                            </div>
                                            <div>Mesmo sem poder fazer
                                              uma tentativa, me parece
                                              que o erro é estranho
                                              demais para não ser
                                              notado: a chamada à
                                              primitiva da ling. C
                                              "calloc" está pedindo 200
                                              Gbytes, que falha e me
                                              parece algo grande demais
                                              para um "default" da
                                              chamada a sqlQuery().</div>
                                            <div><br>
                                            </div>
                                            <div>HTH</div>
                                            <div><br>
                                            </div>
                                          </div>
                                          <div class="gmail_extra"><br>
                                            <div class="gmail_quote">
                                              <div>
                                                <div class="m_5307173174013770253m_1601941344025199055m_-5566544572137748566m_-2957336891499193865h5">2017-07-28
                                                  9:42 GMT-03:00 Pedro
                                                  Emmanuel Alvarenga
                                                  Americano do Brasil
                                                  via R-br <span dir="ltr"><<a href="mailto:r-br@listas.c3sl.ufpr.br" target="_blank">r-br@listas.c3sl.ufpr.br</a>></span>:<br>
                                                </div>
                                              </div>
                                              <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                                                <div>
                                                  <div class="m_5307173174013770253m_1601941344025199055m_-5566544572137748566m_-2957336891499193865h5">
                                                    <div dir="ltr">
                                                      <div>Amigos
                                                        de R,</div>
                                                      <div><br>
                                                      </div>
                                                      <div>Estou
                                                        envolvido numa
                                                        tarefa que
                                                        importo um banco
                                                        SQL de um
                                                        servidor, faço
                                                        uma modelagem,
                                                        salvo o modelo
                                                        no SQL através
                                                        de uma
                                                        seriliazação, e
                                                        depois carrego
                                                        esse modelo do
                                                        SQL para fazer
                                                        previsões em
                                                        novos dados. </div>
                                                      <div><br>
                                                      </div>
                                                      <div>Estou
                                                        seguindo um
                                                        exemplo
                                                        disponível nessa
                                                        página:</div>
                                                      <div><font face="arial
                                                          black,
                                                          sans-serif" color="#073763"><a href="https://docs.microsoft.com/pt-br/sql/advanced-analytics/tutorials/walkthrough-deploy-and-use-the-model" target="_blank">https://docs.microsoft.com/pt-<wbr>br/sql/advanced-analytics/tuto<wbr>rials/walkthrough-deploy-and-u<wbr>se-the-model</a></font><br>
                                                      </div>
                                                      <div><font face="arial
                                                          black,
                                                          sans-serif" color="#073763"><br>
                                                        </font></div>
                                                      <div><font face="arial
                                                          black,
                                                          sans-serif" color="#073763">Sei
                                                          que esse
                                                          exemplo não é
                                                          reproduzível
                                                          porque depende
                                                          da conexão com
                                                          o servidor e
                                                          credenciais
                                                          que não posso
                                                          divulgar. Mas
                                                          se alguem já
                                                          passou por
                                                          esse problema
                                                          poderia pelo
                                                          menos indicar
                                                          aonde está o
                                                          problema que
                                                          não estou
                                                          sabendo
                                                          identificar?
                                                          Acho que muito
                                                          provavelmente
                                                          seria uma
                                                          configuração
                                                          do SQL no
                                                          servidor... </font></div>
                                                      <div><font face="arial
                                                          black,
                                                          sans-serif" color="#073763"><br>
                                                        </font></div>
                                                      <div><font face="arial
                                                          black,
                                                          sans-serif" color="#073763">
                                                          <div>library(RODBC) </div>
                                                          <div><br>
                                                          </div>
                                                          <div>#
                                                          define
                                                          database
                                                          connection
                                                          string</div>
                                                          <div>dbconn
                                                          <-
                                                          'Driver={SQL
                                                          Server};Server=BLABLABLA;Datab<wbr>ase=BLABLABLA;Trusted_Connecti<wbr>on=yes;' </div>
                                                          <div><br>
                                                          </div>
                                                          <div>#
                                                          define a
                                                          connection</div>
                                                          <div>conn
                                                          <-
                                                          odbcDriverConnect(connection
                                                          = dbconn) </div>
                                                        </font></div>
                                                      <div><font face="arial
                                                          black,
                                                          sans-serif" color="#073763"><br>
                                                        </font></div>
                                                      <div><font face="arial
                                                          black,
                                                          sans-serif" color="#073763">#
                                                          Estou fazendo
                                                          o exemplo com
                                                          o objeto
                                                          LETTERS só pra
                                                          ter certeza
                                                          que é um
                                                          objeto pequeno
                                                          e que não
                                                          deveria ser um
                                                          problema de
                                                          memória do R.</font></div>
                                                      <div><span>>
                                                          LETTERS</span><br>
                                                      </div>
                                                      <div><font face="arial
                                                          black,
                                                          sans-serif" color="#073763">
                                                          <div> [1]
                                                          "A" "B" "C"
                                                          "D" "E" "F"
                                                          "G" "H" "I"
                                                          "J" "K" "L"
                                                          "M" "N" "O"
                                                          "P" "Q" "R"
                                                          "S" "T" "U"
                                                          "V" "W" "X"</div>
                                                          <div>[25]
                                                          "Y" "Z"</div>
                                                          <div>>
                                                          teste_pequeno
                                                          <-
                                                          serialize(LETTERS,
                                                          connection =
                                                          NULL)</div>
                                                          <div>>
                                                          teste_pequeno
                                                          <-
                                                          paste(teste_pequeno,
                                                          collapse = "")</div>
                                                          <div><br>
                                                          </div>
                                                          <div>#
                                                          o EXEC
                                                          PersistModel
                                                          faz </div>
                                                          <div>#
                                                          insert into
                                                          [tempo_permanencia_models]
                                                          (model,
                                                          [description])
                                                          values
                                                          (convert(varbinary(max),@m,2),
                                                          @description)</div>
                                                          <div>#
                                                          insere o
                                                          modelo e uma
                                                          descricao</div>
                                                          <div><br>
                                                          </div>
                                                          <div>>
                                                          p <-
                                                          paste("EXEC
                                                          PersistModel
                                                          @m='",
                                                          teste_pequeno,"',
                                                          @description =
                                                          'Teste de
                                                          serialização
                                                          objeto
                                                          pequeno'", sep
                                                          = "")</div>
                                                          <div>>
                                                          sqlQuery(conn,
                                                          p)</div>
                                                          <div>character(0)</div>
                                                          <div>>
rm(teste_pequeno)</div>
                                                          <div>>
                                                          p <-
                                                          "SELECT model
                                                          FROM
                                                          [tempo_permanencia_models]
                                                          WHERE id_model
                                                          = 1022"</div>
                                                          <div>>
                                                          mod.teste.peq
                                                          <-
                                                          sqlQuery(conn,
                                                          p)</div>
                                                          <div>Error
                                                          in
                                                          odbcQuery(channel,
                                                          query,
                                                          rows_at_time)
                                                          : </div>
                                                          <div> 
                                                          'Calloc' could
                                                          not allocate
                                                          memory
                                                          (214748364800
                                                          of 1 bytes)</div>
                                                          <div>>
                                                          p <-
                                                          paste0("SELECT
                                                          id_model,
                                                          description
                                                          FROM
                                                          [tempo_permanencia_models]
                                                          WHERE id_model
                                                          = 1022")<br>
                                                          </div>
                                                          <div>>
                                                          sqlQuery(conn,
                                                          p) #</div>
                                                          <div> 
                                                           id_model    
                                                                       
                                                                       
                                                                     
                                                           description</div>
                                                          <div>1
                                                               1022    
                                                                       
                                                            Teste de
                                                          serialização
                                                          objeto pequeno<br>
                                                          </div>
                                                          <div><br>
                                                          </div>
                                                          <div>Reparem
                                                          que o objeto
                                                          está salvo no
                                                          servidor. Foi
                                                          salvo a partir
                                                          do R, mas não
                                                          retorna para o
                                                          R por conta do
                                                          erro de
                                                          memoria. Eu
                                                          não estou
                                                          sabendo nem
                                                          por onde
                                                          começar.</div>
                                                        </font></div>
                                                      <div><br>
                                                      </div>
                                                      <div>Que
                                                        a força esteja
                                                        sempre com vocês
                                                        e abraço forte. </div>
                                                      <span class="m_5307173174013770253m_1601941344025199055m_-5566544572137748566m_-2957336891499193865m_-5822651748509058777HOEnZb"><font color="#888888">
                                                          <div><br>
                                                          </div>
                                                          <div>
                                                          <div class="gmail_signature">
                                                          <div dir="ltr">
                                                          <div>
                                                          <div dir="ltr">
                                                          <div dir="ltr"><font style="background-color:rgb(255,255,255)" face="'courier new',
                                                          monospace" color="#000066">Pedro
                                                          Brasil</font></div>
                                                          </div>
                                                          </div>
                                                          </div>
                                                          </div>
                                                          </div>
                                                        </font></span></div>
                                                    <br>
                                                  </div>
                                                </div>
______________________________<wbr>_________________<br>
                                                R-br mailing list<br>
                                                <a href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a><br>
                                                <a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" rel="noreferrer" target="_blank">https://listas.inf.ufpr.br/cgi<wbr>-bin/mailman/listinfo/r-br</a><br>
                                                Leia o guia de postagem
                                                (<a href="http://www.leg.ufpr.br/r-br-guia" rel="noreferrer" target="_blank">http://www.leg.ufpr.br/r-br-g<wbr>uia</a>)
                                                e forneça código mínimo
                                                reproduzível.<br>
                                              </blockquote>
                                            </div>
                                            <br>
                                          </div>
                                        </blockquote>
                                      </div>
                                      <br>
                                    </div>
                                  </div>
                                </div>
                              </blockquote>
                            </div>
                            <br>
                          </div>
                        </div>
                      </div>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="m_5307173174013770253mimeAttachmentHeader"></fieldset>
      <br>
      <pre>______________________________<wbr>_________________
R-br mailing list
<a class="m_5307173174013770253moz-txt-link-abbreviated" href="mailto:R-br@listas.c3sl.ufpr.br" target="_blank">R-br@listas.c3sl.ufpr.br</a>
<a class="m_5307173174013770253moz-txt-link-freetext" href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" target="_blank">https://listas.inf.ufpr.br/<wbr>cgi-bin/mailman/listinfo/r-br</a>
Leia o guia de postagem (<a class="m_5307173174013770253moz-txt-link-freetext" href="http://www.leg.ufpr.br/r-br-guia" target="_blank">http://www.leg.ufpr.br/r-br-<wbr>guia</a>) e forne�a c�digo m�nimo reproduz�vel.</pre>
    </blockquote>
    <br>
  </div>

<br>______________________________<wbr>_________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" rel="noreferrer" target="_blank">https://listas.inf.ufpr.br/<wbr>cgi-bin/mailman/listinfo/r-br</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>
</div></div>