Exemplo n.º 1
0
        public static long ReadVLong(FastInputStream stream)
        {
            byte b = (byte)stream.ReadByte();
            long i = b & 0x7F;

            for (int shift = 7; (b & 0x80) != 0; shift += 7)
            {
                b  = (byte)stream.ReadByte();
                i |= (long)(b & 0x7F) << shift;
            }
            return(i);
        }
Exemplo n.º 2
0
        /**
         * The counterpart for {@link #writeVInt(int, FastOutputStream)}
         *
         * @ If there is a low-level I/O error.
         */
        public static int ReadVInt(FastInputStream stream)
        {
            byte b = (byte)stream.ReadByte();
            int  i = b & 0x7F;

            for (int shift = 7; (b & 0x80) != 0; shift += 7)
            {
                b  = (byte)stream.ReadByte();
                i |= (b & 0x7F) << shift;
            }
            return(i);
        }
Exemplo n.º 3
0
        public Object Unmarshal(Stream inputStream)
        {
            FastInputStream dis = new FastInputStream(inputStream);

            version = (byte)dis.ReadByte();
            if (version != VERSION)
            {
                throw new ApplicationException("Invalid version (expected " + VERSION +
                                               ", but " + version + ") or the data in not in 'javabin' format");
            }
            return(ReadVal(dis));
        }
Exemplo n.º 4
0
 public static long ReadVLong(FastInputStream stream)
 {
     byte b = (byte)stream.ReadByte();
     long i = b & 0x7F;
     for (int shift = 7; (b & 0x80) != 0; shift += 7)
     {
         b = (byte)stream.ReadByte();
         i |= (long)(b & 0x7F) << shift;
     }
     return i;
 }
Exemplo n.º 5
0
 /**
  * The counterpart for {@link #writeVInt(int, FastOutputStream)}
  *
  * @ If there is a low-level I/O error.
  */
 public static int ReadVInt(FastInputStream stream)
 {
     byte b = (byte)stream.ReadByte();
     int i = b & 0x7F;
     for (int shift = 7; (b & 0x80) != 0; shift += 7)
     {
         b = (byte)stream.ReadByte();
         i |= (b & 0x7F) << shift;
     }
     return i;
 }
Exemplo n.º 6
0
 public Object Unmarshal(Stream inputStream)
 {
     FastInputStream dis = new FastInputStream(inputStream);
     version = (byte)dis.ReadByte();
     if (version != VERSION)
     {
         throw new ApplicationException("Invalid version (expected " + VERSION +
             ", but " + version + ") or the data in not in 'javabin' format");
     }
     return ReadVal(dis);
 }
Exemplo n.º 7
0
        public Object ReadVal(FastInputStream dis)
        {
            tagByte = (byte)dis.ReadByte();

            // if ((tagByte & 0xe0) == 0) {
            // if top 3 bits are clear, this is a normal tag

            // OK, try type + size in single byte
            switch (tagByte >> 5)
            {
                case STR >> 5:
                    return ReadStr(dis);
                case SINT >> 5:
                    return ReadSmallInt(dis);
                case SLONG >> 5:
                    return ReadSmallLong(dis);
                case ARR >> 5:
                    return ReadArray(dis);
                case ORDERED_MAP >> 5:
                    return ReadOrderedMap(dis);
                case NAMED_LST >> 5:
                    return ReadNamedList(dis);
                case EXTERN_STRING >> 5:
                    return ReadExternString(dis);
            }

            switch (tagByte)
            {
                case NULL:
                    return null;
                case DATE:
                    try
                    {
                        return dis.ReadLong().ConvertToDateTime();
                    }
                    catch
                    {
                        return null;
                    }
                case INT:
                    return dis.ReadInt();
                case BOOL_TRUE:
                    return true;
                case BOOL_FALSE:
                    return false;
                case FLOAT:
                    return dis.ReadFloat();
                case DOUBLE:
                    return dis.ReadDouble();
                case LONG:
                    return dis.ReadLong();
                case BYTE:
                    return dis.ReadByte();
                case SHORT:
                    return dis.ReadShort();
                case MAP:
                    return ReadMap(dis);
                case SOLRDOC:
                    return ReadSolrDocument(dis);
                case SOLRDOCLST:
                    return ReadSolrDocumentList(dis);
                case BYTEARR:
                    return ReadByteArray(dis);
                case ITERATOR:
                    return ReadIterator(dis);
                case END:
                    return END_OBJ;
                case SOLRINPUTDOC:
                    return ReadSolrInputDocument(dis);
            }

            throw new ApplicationException("Unknown type " + tagByte);
        }
Exemplo n.º 8
0
        public Object ReadVal(FastInputStream dis)
        {
            tagByte = (byte)dis.ReadByte();

            // if ((tagByte & 0xe0) == 0) {
            // if top 3 bits are clear, this is a normal tag

            // OK, try type + size in single byte
            switch (tagByte >> 5)
            {
            case STR >> 5:
                return(ReadStr(dis));

            case SINT >> 5:
                return(ReadSmallInt(dis));

            case SLONG >> 5:
                return(ReadSmallLong(dis));

            case ARR >> 5:
                return(ReadArray(dis));

            case ORDERED_MAP >> 5:
                return(ReadOrderedMap(dis));

            case NAMED_LST >> 5:
                return(ReadNamedList(dis));

            case EXTERN_STRING >> 5:
                return(ReadExternString(dis));
            }

            switch (tagByte)
            {
            case NULL:
                return(null);

            case DATE:
                try
                {
                    return(dis.ReadLong().ConvertToDateTime());
                }
                catch
                {
                    return(null);
                }

            case INT:
                return(dis.ReadInt());

            case BOOL_TRUE:
                return(true);

            case BOOL_FALSE:
                return(false);

            case FLOAT:
                return(dis.ReadFloat());

            case DOUBLE:
                return(dis.ReadDouble());

            case LONG:
                return(dis.ReadLong());

            case BYTE:
                return(dis.ReadByte());

            case SHORT:
                return(dis.ReadShort());

            case MAP:
                return(ReadMap(dis));

            case SOLRDOC:
                return(ReadSolrDocument(dis));

            case SOLRDOCLST:
                return(ReadSolrDocumentList(dis));

            case BYTEARR:
                return(ReadByteArray(dis));

            case ITERATOR:
                return(ReadIterator(dis));

            case END:
                return(END_OBJ);

            case SOLRINPUTDOC:
                return(ReadSolrInputDocument(dis));
            }

            throw new ApplicationException("Unknown type " + tagByte);
        }