private long ReadVLong(SolrBinaryStream stream) { var b = Convert.ToByte(stream.ReadByte()); long i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = Convert.ToByte(stream.ReadByte()); i |= (long)(b & 0x7F) << shift; } return(i); }
private int ReadVInt(SolrBinaryStream stream) { var b = Convert.ToByte(stream.ReadByte()); int i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = Convert.ToByte(stream.ReadByte()); i |= (b & 0x7F) << shift; } return(i); }
public object ReadJavaBin(Stream stream) { var solrStream = new SolrBinaryStream(stream); var version = solrStream.ReadByte(); if (version != VERSION) { throw new Exception("Invalid version (expected " + VERSION + ", but " + version + ") or the data in not in 'javabin' format"); } return ReadVal(solrStream); }
public object ReadJavaBin(Stream stream) { var solrStream = new SolrBinaryStream(stream); var version = solrStream.ReadByte(); if (version != VERSION) { throw new Exception("Invalid version (expected " + VERSION + ", but " + version + ") or the data in not in 'javabin' format"); } return(ReadVal(solrStream)); }
public object ReadVal(SolrBinaryStream stream) { tagByte = Convert.ToByte(stream.ReadByte()); //Reduced bitshifting to required minimum (each case is static, instead of bitshifted switch (tagByte >> 5) { case 1: //STR >> 5: return(ReadString(stream)); case 2: //SINT >> 5: return(ReadSmallInt(stream)); case 3: //SLONG >> 5: return(ReadSmallLong(stream)); case 4: //ARR >> 5: return(ReadArray(stream)); case 5: //ORDERED_MAP >> 5: return(ReadOrderedMap(stream)); case 6: //NAMED_LST >> 5: return(ReadNamedList(stream)); case 7: //EXTERN_STRING >> 5: return(ReadExternString(stream)); } switch (tagByte) { case NULL: return(null); case DATE: var timestamp = stream.ReadLong(); if (timestamp < -62135596800000) { return(DateTime.MinValue); } DateTime date; try { date = utcDateTime.AddMilliseconds(timestamp).ToLocalTime(); } catch { date = DateTime.MinValue; } return(date); case INT: return(stream.ReadInt()); case BOOL_TRUE: return(true); case BOOL_FALSE: return(false); case FLOAT: return(stream.ReadFloat()); case DOUBLE: return(stream.ReadDouble()); case LONG: return(stream.ReadLong()); case BYTE: return(stream.ReadByte()); case SHORT: return(stream.ReadShort()); case MAP: return(ReadMap(stream)); case SOLRDOC: return(ReadSolrDocument(stream)); case SOLRDOCLST: return(ReadSolrDocumentList(stream)); case BYTEARR: return(ReadByteArray(stream)); case ITERATOR: return(ReadIterator(stream)); case END: return(END_OBJ); case SOLRINPUTDOC: return(ReadSolrInputDocument(stream)); case ENUM_FIELD_VALUE: return(ReadEnumFieldValue(stream)); case MAP_ENTRY: return(ReadMapEntry(stream)); } throw new Exception("Unknown type " + tagByte); }
public object ReadVal(SolrBinaryStream stream) { tagByte = Convert.ToByte(stream.ReadByte()); //Reduced bitshifting to required minimum (each case is static, instead of bitshifted switch (tagByte >> 5) { case 1: //STR >> 5: return ReadString(stream); case 2: //SINT >> 5: return ReadSmallInt(stream); case 3: //SLONG >> 5: return ReadSmallLong(stream); case 4: //ARR >> 5: return ReadArray(stream); case 5: //ORDERED_MAP >> 5: return ReadOrderedMap(stream); case 6: //NAMED_LST >> 5: return ReadNamedList(stream); case 7: //EXTERN_STRING >> 5: return ReadExternString(stream); } switch (tagByte) { case NULL: return null; case DATE: var timestamp = stream.ReadLong(); if (timestamp < -62135596800000) return DateTime.MinValue; DateTime date; try { date = utcDateTime.AddMilliseconds(timestamp).ToLocalTime(); } catch { date = DateTime.MinValue; } return date; case INT: return stream.ReadInt(); case BOOL_TRUE: return true; case BOOL_FALSE: return false; case FLOAT: return stream.ReadFloat(); case DOUBLE: return stream.ReadDouble(); case LONG: return stream.ReadLong(); case BYTE: return stream.ReadByte(); case SHORT: return stream.ReadShort(); case MAP: return ReadMap(stream); case SOLRDOC: return ReadSolrDocument(stream); case SOLRDOCLST: return ReadSolrDocumentList(stream); case BYTEARR: return ReadByteArray(stream); case ITERATOR: return ReadIterator(stream); case END: return END_OBJ; case SOLRINPUTDOC: return ReadSolrInputDocument(stream); case ENUM_FIELD_VALUE: return ReadEnumFieldValue(stream); case MAP_ENTRY: return ReadMapEntry(stream); } throw new Exception("Unknown type " + tagByte); }
private long ReadVLong(SolrBinaryStream stream) { var b = Convert.ToByte(stream.ReadByte()); long i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = Convert.ToByte(stream.ReadByte()); i |= (long)(b & 0x7F) << shift; } return i; }
private int ReadVInt(SolrBinaryStream stream) { var b = Convert.ToByte(stream.ReadByte()); int i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = Convert.ToByte(stream.ReadByte()); i |= (b & 0x7F) << shift; } return i; }