Exemplo n.º 1
0
 private void WriteLong(long value, SolrBinaryStream stream)
 {
     if (((ulong)value & 0xff00000000000000L) == 0)
     {
         int b = SLONG | ((int)value & 0x0f);
         if (value >= 0x0f)
         {
             b |= 0x10;
             stream.Write(b);
             WriteVLong(value >> 4, stream);
         }
         else
         {
             stream.Write(b);
         }
     }
     else
     {
         stream.Write(LONG);
         stream.WriteLong(value);
     }
 }
Exemplo n.º 2
0
 private bool WritePrimitive(object value, SolrBinaryStream stream)
 {
     if (value == null)
     {
         stream.Write(NULL);
         return true;
     }
     if (value is string)
     {
         WriteString((string)value, stream);
         return true;
     }
     if (value is int)
     {
         WriteInt((int)value, stream);
         return true;
     }
     if (value is long)
     {
         WriteLong((long)value, stream);
         return true;
     }
     if (value is float)
     {
         WriteFloat((float)value, stream);
         return true;
     }
     if (value is double)
     {
         stream.Write(DOUBLE);
         stream.WriteDouble((double)value);
         return true;
     }
     if (value is byte)
     {
         stream.Write(BYTE);
         stream.Write((byte)value);
         return true;
     }
     if (value is short)
     {
         stream.Write(SHORT);
         stream.WriteShort((short)value);
         return true;
     }
     if (value is DateTime)
     {
         stream.Write(DATE);
         stream.WriteLong((long)((DateTime)value).ToUniversalTime().Subtract(utcDateTime).TotalMilliseconds);
         return true;
     }
     if (value is bool)
     {
         if ((bool)value) stream.Write(BOOL_TRUE);
         else stream.Write(BOOL_FALSE);
         return true;
     }
     if (value is byte[])
     {
         var buf = (byte[])value;
         WriteByteArray(buf, 0, buf.Length, stream);
         return true;
     }
     if (value == END_OBJ)
     {
         WriteTag(END, stream);
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 private bool WritePrimitive(object value, SolrBinaryStream stream)
 {
     if (value == null)
     {
         stream.Write(NULL);
         return(true);
     }
     if (value is string)
     {
         WriteString((string)value, stream);
         return(true);
     }
     if (value is int)
     {
         WriteInt((int)value, stream);
         return(true);
     }
     if (value is long)
     {
         WriteLong((long)value, stream);
         return(true);
     }
     if (value is float)
     {
         WriteFloat((float)value, stream);
         return(true);
     }
     if (value is double)
     {
         stream.Write(DOUBLE);
         stream.WriteDouble((double)value);
         return(true);
     }
     if (value is byte)
     {
         stream.Write(BYTE);
         stream.Write((byte)value);
         return(true);
     }
     if (value is short)
     {
         stream.Write(SHORT);
         stream.WriteShort((short)value);
         return(true);
     }
     if (value is DateTime)
     {
         stream.Write(DATE);
         stream.WriteLong((long)((DateTime)value).ToUniversalTime().Subtract(utcDateTime).TotalMilliseconds);
         return(true);
     }
     if (value is bool)
     {
         if ((bool)value)
         {
             stream.Write(BOOL_TRUE);
         }
         else
         {
             stream.Write(BOOL_FALSE);
         }
         return(true);
     }
     if (value is byte[])
     {
         var buf = (byte[])value;
         WriteByteArray(buf, 0, buf.Length, stream);
         return(true);
     }
     if (value == END_OBJ)
     {
         WriteTag(END, stream);
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
 private void WriteLong(long value, SolrBinaryStream stream)
 {
     if (((ulong)value & 0xff00000000000000L) == 0)
     {
         int b = SLONG | ((int)value & 0x0f);
         if (value >= 0x0f)
         {
             b |= 0x10;
             stream.Write(b);
             WriteVLong(value >> 4, stream);
         }
         else
             stream.Write(b);
     }
     else
     {
         stream.Write(LONG);
         stream.WriteLong(value);
     }
 }