Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importing file contents #24

Closed
moos3 opened this issue Jun 15, 2011 · 0 comments
Closed

importing file contents #24

moos3 opened this issue Jun 15, 2011 · 0 comments

Comments

@moos3
Copy link

moos3 commented Jun 15, 2011

/Users/moose/.rvm/gems/ruby-1.8.7-p334/gems/rubberband-0.0.12/lib/elasticsearch/transport/base_protocol.rb:159:in `handle_error': (400) {"error":"MapperParsingException[Failed to parse [content]]; nested: JsonParseException[Invalid UTF-8 start byte 0xb4\n at [Source: [B@1ca24fe7; line: 1, column: 1622]]; ","status":400} (ElasticSearch::RequestError)

I'm trying to import a svn repo into elastic search. Its hanging up on files contents and i can't figure out how or why?

client = ElasticSearch.new('127.0.0.1:9200', :index => 'code', :type => repo)
@files.each do |f|
  puts "Adding " + f.name.green + " to index code in type " + repo
  #puts f.to_json
  client.index(f.to_json)
end
{"repo":"include","name":"c128aobject.php","size":12406,"commitLog":null,"branch":null,"checksum":"d2e9998311ed2bf159d34336a32917ec","content":"<?php\n/*\nBarcode Render Class for PHP using the GD graphics library\nCopyright (C) 2001  Karim Mribti\n\n   Version  0.0.7a  2001-04-01\n\nThis library is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 2.1 of the License, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this library; if not, write to the Free Software\nFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n\nCopy of GNU Lesser General Public License at: http://www.gnu.org/copyleft/lesser.txt\n\nSource code home page: http://www.mribti.com/barcode/\nContact author at: barcode@mribti.com\n*/\n\n  /*\n    Render for Code 128-A\n      Code 128-A is a continuous, multilevel and include all upper case alphanumeric characters and ASCII control characters .\n  */\n\n\n  class C128AObject extends BarcodeObject {\n   var $mCharSet, $mChars;\n   function C128AObject($Width, $Height, $Style, $Value)\n   {\n     $this->BarcodeObject($Width, $Height, $Style);\n     $this->mValue   = $Value;\n     $this->mChars   = \" !\\\"#$%&'()*+?-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_\";\n     $this->mCharSet = array\n      (\n              \"212222\",   /*   00 */\n              \"222122\",   /*   01 */\n              \"222221\",   /*   02 */\n              \"121223\",   /*   03 */\n              \"121322\",   /*   04 */\n              \"131222\",   /*   05 */\n              \"122213\",   /*   06 */\n              \"122312\",   /*   07 */\n              \"132212\",   /*   08 */\n              \"221213\",   /*   09 */\n              \"221312\",   /*   10 */\n              \"231212\",   /*   11 */\n              \"112232\",   /*   12 */\n              \"122132\",   /*   13 */\n              \"122231\",   /*   14 */\n              \"113222\",   /*   15 */\n              \"123122\",   /*   16 */\n              \"123221\",   /*   17 */\n              \"223211\",   /*   18 */\n              \"221132\",   /*   19 */\n              \"221231\",   /*   20 */\n              \"213212\",   /*   21 */\n              \"223112\",   /*   22 */\n              \"312131\",   /*   23 */\n              \"311222\",   /*   24 */\n              \"321122\",   /*   25 */\n              \"321221\",   /*   26 */\n              \"312212\",   /*   27 */\n              \"322112\",   /*   28 */\n              \"322211\",   /*   29 */\n              \"212123\",   /*   30 */\n              \"212321\",   /*   31 */\n              \"232121\",   /*   32 */\n              \"111323\",   /*   33 */\n              \"131123\",   /*   34 */\n              \"131321\",   /*   35 */\n              \"112313\",   /*   36 */\n              \"132113\",   /*   37 */\n              \"132311\",   /*   38 */\n              \"211313\",   /*   39 */\n              \"231113\",   /*   40 */\n              \"231311\",   /*   41 */\n              \"112133\",   /*   42 */\n              \"112331\",   /*   43 */\n              \"132131\",   /*   44 */\n              \"113123\",   /*   45 */\n              \"113321\",   /*   46 */\n              \"133121\",   /*   47 */\n              \"313121\",   /*   48 */\n              \"211331\",   /*   49 */\n              \"231131\",   /*   50 */\n              \"213113\",   /*   51 */\n              \"213311\",   /*   52 */\n              \"213131\",   /*   53 */\n              \"311123\",   /*   54 */\n              \"311321\",   /*   55 */\n              \"331121\",   /*   56 */\n              \"312113\",   /*   57 */\n              \"312311\",   /*   58 */\n              \"332111\",   /*   59 */\n              \"314111\",   /*   60 */\n              \"221411\",   /*   61 */\n              \"431111\",   /*   62 */\n              \"111224\",   /*   63 */\n              \"111422\",   /*   64 */\n              \"121124\",   /*   65 */\n              \"121421\",   /*   66 */\n              \"141122\",   /*   67 */\n              \"141221\",   /*   68 */\n              \"112214\",   /*   69 */\n              \"112412\",   /*   70 */\n              \"122114\",   /*   71 */\n              \"122411\",   /*   72 */\n              \"142112\",   /*   73 */\n              \"142211\",   /*   74 */\n              \"241211\",   /*   75 */\n              \"221114\",   /*   76 */\n              \"413111\",   /*   77 */\n              \"241112\",   /*   78 */\n              \"134111\",   /*   79 */\n              \"111242\",   /*   80 */\n              \"121142\",   /*   81 */\n              \"121241\",   /*   82 */\n              \"114212\",   /*   83 */\n              \"124112\",   /*   84 */\n              \"124211\",   /*   85 */\n              \"411212\",   /*   86 */\n              \"421112\",   /*   87 */\n              \"421211\",   /*   88 */\n              \"212141\",   /*   89 */\n              \"214121\",   /*   90 */\n              \"412121\",   /*   91 */\n              \"111143\",   /*   92 */\n              \"111341\",   /*   93 */\n              \"131141\",   /*   94 */\n              \"114113\",   /*   95 */\n              \"114311\",   /*   96 */\n              \"411113\",   /*   97 */\n              \"411311\",   /*   98 */\n              \"113141\",   /*   99 */\n              \"114131\",   /*  100 */\n              \"311141\",   /*  101 */\n              \"411131\"    /*  102 */\n    );\n   }\n\n   function GetCharIndex ($char) {\n     for ($i=0;$i<64;$i++) {\n       if ($this->mChars[$i] == $char)\n         return $i;\n     }\n     return -1;\n   }\n\n   function GetBarSize ($xres, $char) {\n     switch ($char)\n     {\n      case '1':\n                $cVal = BCD_C128_BAR_1;\n                break;\n      case '2':\n                $cVal = BCD_C128_BAR_2;\n                break;\n      case '3':\n                $cVal = BCD_C128_BAR_3;\n                break;\n      case '4':\n                $cVal = BCD_C128_BAR_4;\n                break;\n      default:\n                $cVal = 0;\n     }\n     return  $cVal * $xres;\n   }\n\n\n   function GetSize($xres) {\n     $len = strlen($this->mValue);\n\n     if ($len == 0)  {\n       $this->mError = \"Null value\";\n       error_log(\"GetRealSize: null barcode value\");\n       return false;\n     }\n     $ret = 0;\n     for ($i=0;$i<$len;$i++) {\n       if (($id = $this->GetCharIndex($this->mValue[$i])) == -1) {\n            $this->mError = \"C128A not include the char '\".$this->mValue[$i].\"'\";\n            return false;\n       } else {\n                 $cset = $this->mCharSet[$id];\n                 $ret += $this->GetBarSize($xres, $cset[0]);\n                 $ret += $this->GetBarSize($xres, $cset[1]);\n                 $ret += $this->GetBarSize($xres, $cset[2]);\n                 $ret += $this->GetBarSize($xres, $cset[3]);\n                 $ret += $this->GetBarSize($xres, $cset[4]);\n                 $ret += $this->GetBarSize($xres, $cset[5]);\n       }\n     }\n\n     /* length of Check character */\n     $cset = $this->GetCheckCharValue();\n     for ($i=0;$i<6;$i++) {\n       $CheckSize += $this->GetBarSize($cset[$i], $xres);\n     }\n     $StartSize = 2*BCD_C128_BAR_2*$xres + 3*BCD_C128_BAR_1*$xres + BCD_C128_BAR_4*$xres;\n      $StopSize  = 2*BCD_C128_BAR_2*$xres + 3*BCD_C128_BAR_1*$xres + 2*BCD_C128_BAR_3*$xres;\n     return $StartSize + $ret + $CheckSize + $StopSize;\n   }\n\n   function GetCheckCharValue()\n   {\n     $len = strlen($this->mValue);\n     $sum = 103; // 'A' type;\n     for ($i=0;$i<$len;$i++) {\n      $sum +=  $this->GetCharIndex($this->mValue[$i]) * ($i+1);\n     }\n     $check  = $sum % 103;\n     return $this->mCharSet[$check];\n   }\n\n   function DrawStart($DrawPos, $yPos, $ySize, $xres)\n   {  /* Start code is '211412' */\n      $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('2', $xres) , $ySize);\n      $DrawPos += $this->GetBarSize('2', $xres);\n      $DrawPos += $this->GetBarSize('1', $xres);\n      $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('1', $xres) , $ySize);\n      $DrawPos += $this->GetBarSize('1', $xres);\n      $DrawPos += $this->GetBarSize('4', $xres);\n      $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('1', $xres) , $ySize);\n      $DrawPos += $this->GetBarSize('1', $xres);\n      $DrawPos += $this->GetBarSize('2', $xres);\n      return $DrawPos;\n   }\n\n   function DrawStop($DrawPos, $yPos, $ySize, $xres)\n   {  /* Stop code is '2331112' */\n      $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('2', $xres) , $ySize);\n      $DrawPos += $this->GetBarSize('2', $xres);\n      $DrawPos += $this->GetBarSize('3', $xres);\n      $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('3', $xres) , $ySize);\n      $DrawPos += $this->GetBarSize('3', $xres);\n      $DrawPos += $this->GetBarSize('1', $xres);\n      $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('1', $xres) , $ySize);\n      $DrawPos += $this->GetBarSize('1', $xres);\n      $DrawPos += $this->GetBarSize('1', $xres);\n      $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('2', $xres) , $ySize);\n      $DrawPos += $this->GetBarSize('2', $xres);\n      return $DrawPos;\n   }\n\n   function DrawCheckChar($DrawPos, $yPos, $ySize, $xres)\n   {\n     $cset = $this->GetCheckCharValue();\n     $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[0], $xres) , $ySize);\n     $DrawPos += $this->GetBarSize($cset[0], $xres);\n     $DrawPos += $this->GetBarSize($cset[1], $xres);\n     $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[2], $xres) , $ySize);\n     $DrawPos += $this->GetBarSize($cset[2], $xres);\n     $DrawPos += $this->GetBarSize($cset[3], $xres);\n     $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[4], $xres) , $ySize);\n     $DrawPos += $this->GetBarSize($cset[4], $xres);\n     $DrawPos += $this->GetBarSize($cset[5], $xres);\n     return $DrawPos;\n   }\n\n   function DrawObject ($xres)\n   {\n     $len = strlen($this->mValue);\n     if (($size = $this->GetSize($xres))==0) {\n         error_log(\"GetSize: failed\");\n        return false;\n     }\n\n     if ($this->mStyle & BCS_ALIGN_CENTER) $sPos = (integer)(($this->mWidth - $size ) / 2);\n     else if ($this->mStyle & BCS_ALIGN_RIGHT) $sPos = $this->mWidth - $size;\n           else $sPos = 0;\n\n     /* Total height of bar code -Bars only- */\n     if ($this->mStyle & BCS_DRAW_TEXT) $ysize = $this->mHeight - BCD_DEFAULT_MAR_Y1 - BCD_DEFAULT_MAR_Y2 - $this->GetFontHeight($this->mFont);\n     else $ysize = $this->mHeight - BCD_DEFAULT_MAR_Y1 - BCD_DEFAULT_MAR_Y2;\n\n     /* Draw text */\n     if ($this->mStyle & BCS_DRAW_TEXT) {\n            if ($this->mStyle & BCS_STRETCH_TEXT) {\n            for ($i=0;$i<$len;$i++) {\n                       $this->DrawChar($this->mFont, $sPos+(2*BCD_C128_BAR_2*$xres + 3*BCD_C128_BAR_1*$xres + BCD_C128_BAR_4*$xres)+($size/$len)*$i,\n                           $ysize + BCD_DEFAULT_MAR_Y1 + BCD_DEFAULT_TEXT_OFFSET, $this->mValue[$i]);\n                }\n         } else {/* Center */\n               $text_width = $this->GetFontWidth($this->mFont) * strlen($this->mValue);\n             $this->DrawText($this->mFont, $sPos+(($size-$text_width)/2)+(2*BCD_C128_BAR_2*$xres + 3*BCD_C128_BAR_1*$xres + BCD_C128_BAR_4*$xres),\n                               $ysize + BCD_DEFAULT_MAR_Y1 + BCD_DEFAULT_TEXT_OFFSET, $this->mValue);\n          }\n     }\n\n     $cPos = 0;\n     $DrawPos = $this->DrawStart($sPos, BCD_DEFAULT_MAR_Y1 , $ysize, $xres);\n     do {\n        $c     = $this->GetCharIndex($this->mValue[$cPos]);\n        $cset  = $this->mCharSet[$c];\n        $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[0], $xres) , $ysize);\n        $DrawPos += $this->GetBarSize($cset[0], $xres);\n        $DrawPos += $this->GetBarSize($cset[1], $xres);\n        $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[2], $xres) , $ysize);\n        $DrawPos += $this->GetBarSize($cset[2], $xres);\n        $DrawPos += $this->GetBarSize($cset[3], $xres);\n        $this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[4], $xres) , $ysize);\n        $DrawPos += $this->GetBarSize($cset[4], $xres);\n        $DrawPos += $this->GetBarSize($cset[5], $xres);\n        $cPos++;\n      } while ($cPos<$len);\n      $DrawPos = $this->DrawCheckChar($DrawPos, BCD_DEFAULT_MAR_Y1 , $ysize, $xres);\n      $DrawPos =  $this->DrawStop($DrawPos, BCD_DEFAULT_MAR_Y1 , $ysize, $xres);\n      return true;\n     }\n  }\n?>","path":null}
@grantr grantr closed this as completed Jun 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants