Ejemplo n.º 1
0
        /// <summary>
        /// Pulls bytes from the provided IndexInput. </summary>
        public BytesStore(DataInput @in, long numBytes, int maxBlockSize)
        {
            int blockSize = 2;
            int blockBits = 1;
            while (blockSize < numBytes && blockSize < maxBlockSize)
            {
                blockSize *= 2;
                blockBits++;
            }
            this.blockBits = blockBits;
            this.BlockSize = blockSize;
            this.BlockMask = blockSize - 1;
            long left = numBytes;
            while (left > 0)
            {
                int chunk = (int)Math.Min(blockSize, left);
                byte[] block = new byte[chunk];
                @in.ReadBytes(block, 0, block.Length);
                Blocks.Add(block);
                left -= chunk;
            }

            // So .getPosition still works
            NextWrite = Blocks[Blocks.Count - 1].Length;
        }
Ejemplo n.º 2
0
 public override void Read(DataInput indexIn, bool absolute)
 {
     if (absolute)
     {
         _upto = indexIn.ReadVInt();
         _fp = indexIn.ReadVLong();
     }
     else
     {
         int uptoDelta = indexIn.ReadVInt();
         if ((uptoDelta & 1) == 1)
         {
             // same block
             _upto += (int) ((uint) uptoDelta >> 1);
         }
         else
         {
             // new block
             _upto = (int) ((uint) uptoDelta >> 1);
             _fp += indexIn.ReadVLong();
         }
     }
     // TODO: we can't do this assert because non-causal
     // int encoders can have upto over the buffer size
     //assert upto < maxBlockSize: "upto=" + upto + " max=" + maxBlockSize;
 }
Ejemplo n.º 3
0
 internal Direct64(int packedIntsVersion, DataInput @in, int valueCount)
     : this(valueCount)
 {
     for (int i = 0; i < valueCount; ++i)
     {
         Values[i] = @in.ReadLong();
     }
 }
Ejemplo n.º 4
0
 internal Packed8ThreeBlocks(int packedIntsVersion, DataInput @in, int valueCount)
     : this(valueCount)
 {
     @in.ReadBytes(Blocks, 0, 3 * valueCount);
     // because packed ints have not always been byte-aligned
     int remaining = (int)(PackedInts.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 24) - 3L * valueCount * 1);
     for (int i = 0; i < remaining; ++i)
     {
         @in.ReadByte();
     }
 }
Ejemplo n.º 5
0
 public override void Decompress(DataInput @in, int originalLength, int offset, int length, BytesRef bytes)
 {
     Debug.Assert(offset + length <= originalLength);
     if (bytes.Bytes.Length < originalLength)
     {
         bytes.Bytes = new sbyte[ArrayUtil.Oversize(originalLength, 1)];
     }
     @in.ReadBytes(bytes.Bytes, 0, offset + length);
     bytes.Offset = offset;
     bytes.Length = length;
 }
Ejemplo n.º 6
0
 internal Direct8(int packedIntsVersion, DataInput @in, int valueCount)
     : this(valueCount)
 {
     @in.ReadBytes(Values, 0, valueCount);
     // because packed ints have not always been byte-aligned
     int remaining = (int)(PackedInts.Format.PACKED.ByteCount(packedIntsVersion, valueCount, 8) - 1L * valueCount);
     for (int i = 0; i < remaining; ++i)
     {
         @in.ReadByte();
     }
 }
 // same as DataInput.readVLong but supports negative values
 internal static long ReadVLong(DataInput @in)
 {
     byte b = @in.ReadByte();
     if ((sbyte)b >= 0)
     {
         return b;
     }
     long i = b & 0x7FL;
     b = @in.ReadByte();
     i |= (b & 0x7FL) << 7;
     if ((sbyte)b >= 0)
     {
         return i;
     }
     b = @in.ReadByte();
     i |= (b & 0x7FL) << 14;
     if ((sbyte)b >= 0)
     {
         return i;
     }
     b = @in.ReadByte();
     i |= (b & 0x7FL) << 21;
     if ((sbyte)b >= 0)
     {
         return i;
     }
     b = @in.ReadByte();
     i |= (b & 0x7FL) << 28;
     if ((sbyte)b >= 0)
     {
         return i;
     }
     b = @in.ReadByte();
     i |= (b & 0x7FL) << 35;
     if ((sbyte)b >= 0)
     {
         return i;
     }
     b = @in.ReadByte();
     i |= (b & 0x7FL) << 42;
     if ((sbyte)b >= 0)
     {
         return i;
     }
     b = @in.ReadByte();
     i |= (b & 0x7FL) << 49;
     if ((sbyte)b >= 0)
     {
         return i;
     }
     b = @in.ReadByte();
     i |= (b & 0xFFL) << 56;
     return i;
 }
Ejemplo n.º 8
0
 public override void readTagContents(DataInput datainput)
 {
     tagType = datainput.readByte();
     int i = datainput.readInt();
     tagList = new ArrayList();
     for (int j = 0; j < i; j++)
     {
         NBTBase nbtbase = createTagOfType(tagType);
         nbtbase.readTagContents(datainput);
         tagList.add(nbtbase);
     }
 }
Ejemplo n.º 9
0
 internal PackedReaderIterator(PackedInts.Format format, int packedIntsVersion, int valueCount, int bitsPerValue, DataInput @in, int mem)
     : base(valueCount, bitsPerValue, @in)
 {
     this.Format = format;
     this.PackedIntsVersion = packedIntsVersion;
     BulkOperation = BulkOperation.Of(format, bitsPerValue);
     Iterations_Renamed = Iterations(mem);
     Debug.Assert(valueCount == 0 || Iterations_Renamed > 0);
     NextBlocks = new byte[Iterations_Renamed * BulkOperation.ByteBlockCount()];
     NextValues = new LongsRef(new long[Iterations_Renamed * BulkOperation.ByteValueCount()], 0, 0);
     NextValues.Offset = NextValues.Longs.Length;
     Position = -1;
 }
Ejemplo n.º 10
0
 public MicroInstruction(int address, NextAddress nextAddress, bool enableValue,
     int value, JumpCriterion jumpCriterion, bool clearInterrupt,
     bool affected, AluCmd aluCommand, Source source,
     Destination destination, DataInput dataInput, ReadWrite readWrite)
 {
     this.Address = address;
     this.NextAddress = nextAddress;
     this.EnableValue = enableValue;
     this.Value = value;
     this.JumpCriterion = jumpCriterion;
     this.ClearInterrupt = clearInterrupt;
     this.AffectFlags = affected;
     this.AluCommand = aluCommand;
     this.Source = source;
     this.Destination = destination;
     this.DataInput = dataInput;
     this.ReadWrite = readWrite;
 }
Ejemplo n.º 11
0
        public void readFields(DataInput @in)
        {
            //deserialize path, offset, length using FileSplit
            base.readFields(@in);

            byte flags = @in.readByte();
            _hasFooter = (OrcSplit.FOOTER_FLAG & flags) != 0;
            _isOriginal = (OrcSplit.ORIGINAL_FLAG & flags) != 0;
            _hasBase = (OrcSplit.BASE_FLAG & flags) != 0;

            deltas.Clear();
            int numDeltas = @in.readInt();
            for (int i = 0; i < numDeltas; i++)
            {
                AcidInputFormat.DeltaMetaData dmd = new AcidInputFormat.DeltaMetaData();
                dmd.readFields(@in);
                deltas.Add(dmd);
            }
            if (_hasFooter)
            {
                // deserialize FileMetaInfo fields
                string compressionType = Text.readString(@in);
                int bufferSize = WritableUtils.readVInt(@in);
                int metadataSize = WritableUtils.readVInt(@in);

                // deserialize FileMetaInfo field footer
                int footerBuffSize = WritableUtils.readVInt(@in);
                ByteBuffer footerBuff = ByteBuffer.allocate(footerBuffSize);
                @in.readFully(footerBuff.array(), 0, footerBuffSize);
                OrcFile.WriterVersion writerVersion =
                    ReaderImpl.getWriterVersion(WritableUtils.readVInt(@in));

                fileMetaInfo = new FileMetaInfo(compressionType, bufferSize,
                    metadataSize, footerBuff, writerVersion);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Decompress at least <code>decompressedLen</code> bytes into
        /// <code>dest[dOff:]</code>. Please note that <code>dest</code> must be large
        /// enough to be able to hold <b>all</b> decompressed data (meaning that you
        /// need to know the total decompressed length).
        /// </summary>
        public static int Decompress(DataInput compressed, int decompressedLen, sbyte[] dest, int dOff)
        {
            int destEnd = dest.Length;

            do
            {
                // literals
                int token = compressed.ReadByte() & 0xFF;
                int literalLen = (int)(((uint)token) >> 4);

                if (literalLen != 0)
                {
                    if (literalLen == 0x0F)
                    {
                        byte len;
                        while ((len = compressed.ReadByte()) == 0xFF)
                        {
                            literalLen += 0xFF;
                        }
                        literalLen += len & 0xFF;
                    }
                    compressed.ReadBytes(dest, dOff, literalLen);
                    dOff += literalLen;
                }

                if (dOff >= decompressedLen)
                {
                    break;
                }

                // matchs
                var byte1 = compressed.ReadByte();
                var byte2 = compressed.ReadByte();
                int matchDec = (byte1 & 0xFF) | ((byte2 & 0xFF) << 8);
                Debug.Assert(matchDec > 0);

                int matchLen = token & 0x0F;
                if (matchLen == 0x0F)
                {
                    int len;
                    while ((len = compressed.ReadByte()) == 0xFF)
                    {
                        matchLen += 0xFF;
                    }
                    matchLen += len & 0xFF;
                }
                matchLen += MIN_MATCH;

                // copying a multiple of 8 bytes can make decompression from 5% to 10% faster
                int fastLen = (int)((matchLen + 7) & 0xFFFFFFF8);
                if (matchDec < matchLen || dOff + fastLen > destEnd)
                {
                    // overlap -> naive incremental copy
                    for (int @ref = dOff - matchDec, end = dOff + matchLen; dOff < end; ++@ref, ++dOff)
                    {
                        dest[dOff] = dest[@ref];
                    }
                }
                else
                {
                    // no overlap -> arraycopy
                    Array.Copy(dest, dOff - matchDec, dest, dOff, fastLen);
                    dOff += matchLen;
                }
            } while (dOff < decompressedLen);

            return dOff;
        }
 /// <summary>
 /// Creates an {@code IndexFormatTooOldException}.
 /// </summary>
 ///  <param name="in"> the open file that's too old </param>
 ///  <param name="version"> the version of the file that was too old
 ///
 /// @lucene.internal  </param>
 public IndexFormatTooOldException(DataInput @in, string version)
     : this(@in.ToString(), version)
 {
 }
Ejemplo n.º 14
0
 public override void readTagContents(DataInput datainput)
 {
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Actually decode metadata for next term. </summary>
 /// <seealso cref="PostingsWriterBase.EncodeTerm(long[], Store.DataOutput, FieldInfo, BlockTermState, bool)"/>
 public abstract void DecodeTerm(long[] longs, DataInput @in, FieldInfo fieldInfo, BlockTermState state, bool absolute);
Ejemplo n.º 16
0
 public short?Read(DataInput input)
 {
     return(ReadInternal(input));
 }
Ejemplo n.º 17
0
 public override void CopyBytes(DataInput input, long numBytes)
 {
     @delegate.CopyBytes(input, numBytes);
 }
Ejemplo n.º 18
0
        public override void DecodeTerm(long[] longs, DataInput @in, FieldInfo fieldInfo, BlockTermState _termState, bool absolute)
        {
            StandardTermState termState = (StandardTermState)_termState;
            // if (DEBUG) System.out.println("SPR: nextTerm seg=" + segment + " tbOrd=" + termState.termBlockOrd + " bytesReader.fp=" + termState.bytesReader.getPosition());
            bool isFirstTerm = termState.TermBlockOrd == 0;
            if (absolute)
            {
                termState.FreqOffset = 0;
                termState.ProxOffset = 0;
            }

            termState.FreqOffset += @in.ReadVLong();
            /*
            if (DEBUG) {
              System.out.println("  dF=" + termState.docFreq);
              System.out.println("  freqFP=" + termState.freqOffset);
            }
            */
            Debug.Assert(termState.FreqOffset < FreqIn.Length());

            if (termState.DocFreq >= SkipMinimum)
            {
                termState.SkipOffset = @in.ReadVLong();
                // if (DEBUG) System.out.println("  skipOffset=" + termState.skipOffset + " vs freqIn.length=" + freqIn.length());
                Debug.Assert(termState.FreqOffset + termState.SkipOffset < FreqIn.Length());
            }
            else
            {
                // undefined
            }

            if (fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
            {
                termState.ProxOffset += @in.ReadVLong();
                // if (DEBUG) System.out.println("  proxFP=" + termState.proxOffset);
            }
        }
Ejemplo n.º 19
0
 public override DateTimeOffset?[] ReadValue(
     DataInput input,
     byte[] unitKey)
 {
     return(ReadInternal(input));
 }
Ejemplo n.º 20
0
 public DateTimeOffset?[] Read(DataInput input)
 {
     return(ReadInternal(input));
 }
Ejemplo n.º 21
0
        public override void AddProx(int numProx, DataInput positions, DataInput offsets)
        {
            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert((curField.hasPositions) == (positions != null));
                Debugging.Assert((curField.hasOffsets) == (offsets != null));
            }

            if (curField.hasPositions)
            {
                int posStart = curField.posStart + curField.totalPositions;
                if (posStart + numProx > positionsBuf.Length)
                {
                    positionsBuf = ArrayUtil.Grow(positionsBuf, posStart + numProx);
                }
                int position = 0;
                if (curField.hasPayloads)
                {
                    int payStart = curField.payStart + curField.totalPositions;
                    if (payStart + numProx > payloadLengthsBuf.Length)
                    {
                        payloadLengthsBuf = ArrayUtil.Grow(payloadLengthsBuf, payStart + numProx);
                    }
                    for (int i = 0; i < numProx; ++i)
                    {
                        int code = positions.ReadVInt32();
                        if ((code & 1) != 0)
                        {
                            // this position has a payload
                            int payloadLength = positions.ReadVInt32();
                            payloadLengthsBuf[payStart + i] = payloadLength;
                            payloadBytes.CopyBytes(positions, payloadLength);
                        }
                        else
                        {
                            payloadLengthsBuf[payStart + i] = 0;
                        }
                        position += (int)((uint)code >> 1);
                        positionsBuf[posStart + i] = position;
                    }
                }
                else
                {
                    for (int i = 0; i < numProx; ++i)
                    {
                        position += ((int)((uint)positions.ReadVInt32() >> 1));
                        positionsBuf[posStart + i] = position;
                    }
                }
            }

            if (curField.hasOffsets)
            {
                int offStart = curField.offStart + curField.totalPositions;
                if (offStart + numProx > startOffsetsBuf.Length)
                {
                    int newLength = ArrayUtil.Oversize(offStart + numProx, 4);
                    startOffsetsBuf = Arrays.CopyOf(startOffsetsBuf, newLength);
                    lengthsBuf      = Arrays.CopyOf(lengthsBuf, newLength);
                }
                int lastOffset = 0, startOffset, endOffset;
                for (int i = 0; i < numProx; ++i)
                {
                    startOffset = lastOffset + offsets.ReadVInt32();
                    endOffset   = startOffset + offsets.ReadVInt32();
                    lastOffset  = endOffset;
                    startOffsetsBuf[offStart + i] = startOffset;
                    lengthsBuf[offStart + i]      = endOffset - startOffset;
                }
            }

            curField.totalPositions += numProx;
        }
Ejemplo n.º 22
0
 public override byte?ReadValue(DataInput s, byte[] resourceKey)
 {
     return(ReadInternal(s));
 }
Ejemplo n.º 23
0
 public byte?Read(DataInput input)
 {
     return(ReadInternal(input));
 }
Ejemplo n.º 24
0
        string CreateDataCommandLineArgs(DataInput input)
        {
            // yes to all confirmations, batch for no prompt
            StringBuilder args = new StringBuilder("--yes --batch ");

            if (input.Armor)
            {
                args.Append("-a ");
            }

            if (input.AlwaysTrustPublicKey)
            {
                args.Append("--always-trust ");
            }

            if (!string.IsNullOrWhiteSpace(KeyringFolder))
            {
                args.AppendFormat("--homedir \"{0}\" ", KeyringFolder);
            }
            switch (input.Operation)
            {
            case DataOperation.Decrypt:
                // [d]ecrypt
                args.Append("-d ");
                break;

            case DataOperation.Encrypt:
                // [e]ncrypt for [r]ecipient
                args.AppendFormat("-e -r \"{0}\" ", input.Recipient);
                break;

            case DataOperation.Sign:
                // [s]ign for [u]ser
                args.AppendFormat("-s -u \"{0}\" ", input.Originator);
                break;

            case DataOperation.ClearSign:
                args.AppendFormat("--clearsign -u \"{0}\" ", input.Originator);
                break;

            case DataOperation.SignAndEncrypt:
                args.AppendFormat("-se -r \"{0}\" -u \"{1}\" ", input.Recipient, input.Originator);
                break;
                //case DataOperation.Verify:
                //    args.Append("--verify ");
                //    break;
            }

            if (input.NeedsPassphrase)
            {
                // will enter passphrase via std in
                args.Append("--passphrase-fd 0 ");
            }

            var fileInput = input as FileDataInput;

            if (fileInput != null)
            {
                args.AppendFormat("-o \"{0}\" \"{1}\"", fileInput.OutputFile, fileInput.InputFile);
            }

            var finalArg = args.ToString();

            Debug.WriteLine("gpg args: " + finalArg);

            return(finalArg);
        }
Ejemplo n.º 25
0
 public override short?ReadValue(
     DataInput input,
     byte[] resourceKey)
 {
     return(ReadInternal(input));
 }
Ejemplo n.º 26
0
 public static string ReadUTF(DataInput stream)
 {
     return DecodeUTF(stream.ReadUnsignedShort(), stream);
 }
Ejemplo n.º 27
0
 public override void readTagContents(DataInput datainput)
 {
     shortValue = datainput.readShort();
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Méthode exécutant le traitement demandé dans l'objet de transfert au travers de gestionnaire de thread indépendant
        /// </summary>
        /// <param name="processFunction">Méthode à exécutant la fonction passée en paramètre de l'objet de transfert </param>
        /// <param name="taskData">Objet dfe trasnfert contenant les données à traiter </param>
        /// <param name="totalNbWorker"> Nombre de gestionbnaires de thread à exécuter</param>
        protected void LaunchBgForWork(Action <object, DoWorkEventArgs> processFunction, DataInput taskData, int totalNbWorker)
        {
            BackgroundWorker bw = new BackgroundWorker();

            //// Abonnement ////
            bw.DoWork             += new DoWorkEventHandler(processFunction);
            bw.RunWorkerCompleted += WorkerEndProcess;
            int workerTaskId = CreateWorkerTask(taskData.NodeTaskId);
            Tuple <int, DataInput, int> dataAndMeta = new Tuple <int, DataInput, int>(workerTaskId, taskData, totalNbWorker);

            bw.RunWorkerAsync(dataAndMeta);
        }
Ejemplo n.º 29
0
 public override void Decompress(DataInput @in, int originalLength, int offset, int length, BytesRef bytes)
 {
     Debug.Assert(offset + length <= originalLength);
     // add 7 padding bytes, this is not necessary but can help decompression run faster
     if (bytes.Bytes.Length < originalLength + 7)
     {
         bytes.Bytes = new byte[ArrayUtil.Oversize(originalLength + 7, 1)];
     }
     int decompressedLength = LZ4.Decompress(@in, offset + length, bytes.Bytes, 0);
     if (decompressedLength > originalLength)
     {
         throw new CorruptIndexException("Corrupted: lengths mismatch: " + decompressedLength + " > " + originalLength + " (resource=" + @in + ")");
     }
     bytes.Offset = offset;
     bytes.Length = length;
 }
Ejemplo n.º 30
0
    private void OnGUI()
    {
        GUILayout.Label("Nom de l'objet");
        nameObject = EditorGUILayout.TextArea(nameObject);
        if (nameObject == "")
        {
            nameObject = "J'ai laissé un nom vide , shame on me";
        }

        GUILayout.Label("Vitesse du bandeau (multiplicateur)");
        vitesseBandeauMultipler = Mathf.Max(0.001f,EditorGUILayout.FloatField("", vitesseBandeauMultipler));

        GUILayout.Label("Texte de victoire");
        textVictory = EditorGUILayout.TextArea(textVictory);

        GUILayout.Label("Texte de defaite");
        textDefeat= EditorGUILayout.TextArea(textDefeat);

        GUILayout.Label("Taille de police (Victoire)");
        textSizeVictory = Mathf.Max(10, EditorGUILayout.IntField(textSizeVictory));

        GUILayout.Label("Taille de police (Defaite)");
        textSizeDefeat = Mathf.Max(10, EditorGUILayout.IntField(textSizeDefeat));

        GUILayout.Label("Delai du bandeau (temps en secondes)");
        delaiBandeau = Mathf.Max(0.001f, EditorGUILayout.FloatField("", delaiBandeau));


        GUILayout.Label("Vitesse de transition (multiplicateur) ");
        vitesseInsertion = Mathf.Max(0.001f, EditorGUILayout.FloatField("", vitesseInsertion));

        GUILayout.Label("Quel animation ?");
        anim = (animHero)EditorGUILayout.EnumPopup(anim);

        sprt = (Sprite)EditorGUILayout.ObjectField("Quel sprite de fond ? ", sprt, typeof(Sprite), true);

        GUILayout.Label("IMPORTANT SINON CA MARCHE PAS ");
        model = (GameObject)EditorGUILayout.ObjectField("Modele de base", model, typeof(GameObject), true);

        GUILayout.Label("Code ? (une seule lettre et en majuscule)");
        code = GUILayout.TextField(code);

        GUILayout.Label("Position x ");
        x = EditorGUILayout.FloatField(x);

        GUILayout.Label("Position y");
        y = EditorGUILayout.FloatField(y);

        if (GUILayout.Button("Ajouter la frappe dans la liste actuelle"))
        {
            if (sequence >= sequences.Count)
            {
                sequences.Add(new SequenceInput());
            }

            KeyCode c = KeyCode.A;
            for(int i = 97; i <= 122; i++)
            {
                if (((KeyCode)i).ToString() == code.ToUpper())
                {
                    c = (KeyCode)i;
                }
            }

            DataInput sI = new DataInput(c, new Vector2(x, y));
            sequences[sequence].dI.Add(sI);
        }

        if (GUILayout.Button("Supprimer la derniere frappe de la liste actuelle"))
        {
            if (sequences[sequence].dI.Count > 0)
            {
                sequences[sequence].dI.RemoveAt(sequences[sequence].dI.Count - 1);
            }
        }

        if (GUILayout.Button("Liste de frappe suivante"))
        {
            sequence++;
            if (sequence >= sequences.Count)
            {
                sequences.Add(new SequenceInput());
            }
        }

        if (GUILayout.Button("Liste de frappe precedente"))
        {
            sequence = Mathf.Max(0, sequence - 1);
        }

        EditorGUILayout.LabelField("Index : " + sequence.ToString());
        foreach(SequenceInput sI in sequences)
        {
            foreach(string s in sI.ToStringAlt())
            {
                EditorGUILayout.LabelField(s);
            }
        }

        GUILayout.Label("Sons Optionnels (en prendra un par defaut si aucun n'est choisi)");
        clpFail = (AudioClip)EditorGUILayout.ObjectField("Mauvaise touche ", clpFail, typeof(AudioClip), true);
        clpSuccess = (AudioClip)EditorGUILayout.ObjectField("Bonne touche ", clpSuccess, typeof(AudioClip), true);
        clpSuccessScenette = (AudioClip)EditorGUILayout.ObjectField("Fin scenette positive ", clpSuccessScenette, typeof(AudioClip), true);


        if (GUILayout.Button("Créer"))
        {
            GameObject instance;
            instance = Instantiate(model);
            instance.name = nameObject;
            Scenette scn = instance.GetComponent<Scenette>();
            scn.sequencesToDo = new List<SequenceInput>(sequences);
            scn.speedBandeauMultipler = vitesseBandeauMultipler;
            scn.timeBeforeNext = delaiBandeau;
            scn.mutliplerSpeedEnter = vitesseInsertion;
            scn.failClic = clpFail;
            scn.successClic = clpSuccess;
            scn.successScenette = clpSuccessScenette;
            scn.animPourHero = anim;
            scn.backgroundSprite = sprt;
            scn.textSizeDefeat = textSizeDefeat;
            scn.textSizeVictory = textSizeVictory;
            scn.textVictory = textVictory;
            scn.textDefeat = textDefeat;
            scn.init();

            sequences = new List<SequenceInput>();
        }
    }
Ejemplo n.º 31
0
 /// <summary>
 /// Reset the current reader to wrap a stream of <code>valueCount</code>
 /// values contained in <code>in</code>. The block size remains unchanged.
 /// </summary>
 public void Reset(DataInput @in, long valueCount)
 {
     this.@in = @in;
     Debug.Assert(valueCount >= 0);
     this.ValueCount = valueCount;
     Off = BlockSize;
     Ord_Renamed = 0;
 }
Ejemplo n.º 32
0
 public override object Read(DataInput @in)
 {
     return(outputs.Read(@in));
 }
Ejemplo n.º 33
0
        private int ReadHeader(DataInput input)
        {
            var version = CodecUtil.CheckHeader(input, FixedGapTermsIndexWriter.CODEC_NAME,
                FixedGapTermsIndexWriter.VERSION_START, FixedGapTermsIndexWriter.VERSION_CURRENT);
            
            if (version < FixedGapTermsIndexWriter.VERSION_APPEND_ONLY)
                _dirOffset = input.ReadLong();

            return version;
        }
Ejemplo n.º 34
0
 public override void readTagContents(DataInput datainput)
 {
     floatValue = datainput.readFloat();
 }
Ejemplo n.º 35
0
        /// <summary>
        /// Called by IndexWriter when writing new segments.
        /// <p>
        /// this is an expert API that allows the codec to consume
        /// positions and offsets directly from the indexer.
        /// <p>
        /// The default implementation calls <seealso cref="#addPosition(int, int, int, BytesRef)"/>,
        /// but subclasses can override this if they want to efficiently write
        /// all the positions, then all the offsets, for example.
        /// <p>
        /// NOTE: this API is extremely expert and subject to change or removal!!!
        /// @lucene.internal
        /// </summary>
        // TODO: we should probably nuke this and make a more efficient 4.x format
        // PreFlex-RW could then be slow and buffer (its only used in tests...)
        public virtual void AddProx(int numProx, DataInput positions, DataInput offsets)
        {
            int position = 0;
            int lastOffset = 0;
            BytesRef payload = null;

            for (int i = 0; i < numProx; i++)
            {
                int startOffset;
                int endOffset;
                BytesRef thisPayload;

                if (positions == null)
                {
                    position = -1;
                    thisPayload = null;
                }
                else
                {
                    int code = positions.ReadVInt();
                    position += (int)((uint)code >> 1);
                    if ((code & 1) != 0)
                    {
                        // this position has a payload
                        int payloadLength = positions.ReadVInt();

                        if (payload == null)
                        {
                            payload = new BytesRef();
                            payload.Bytes = new sbyte[payloadLength];
                        }
                        else if (payload.Bytes.Length < payloadLength)
                        {
                            payload.Grow(payloadLength);
                        }

                        positions.ReadBytes(payload.Bytes, 0, payloadLength);
                        payload.Length = payloadLength;
                        thisPayload = payload;
                    }
                    else
                    {
                        thisPayload = null;
                    }
                }

                if (offsets == null)
                {
                    startOffset = endOffset = -1;
                }
                else
                {
                    startOffset = lastOffset + offsets.ReadVInt();
                    endOffset = startOffset + offsets.ReadVInt();
                    lastOffset = endOffset;
                }
                AddPosition(position, startOffset, endOffset, thisPayload);
            }
        }
Ejemplo n.º 36
0
 public void FromData(DataInput input)
 {
     OrderId  = input.ReadInt32();
     Name     = input.ReadUTF();
     Quantity = input.ReadInt16();
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Reads from the stream <code>in</code> a representation of a Unicode  character string encoded in Java modified UTF-8 format; this string of characters  is then returned as a <code>String</code>.
 /// </summary>
 public static string readUTF(DataInput @in)
 {
     return default(string);
 }
Ejemplo n.º 38
0
        internal object ReadAMF3Object(ClassDefinition classDefinition)
        {
            object instance = null;

            if (!string.IsNullOrEmpty(classDefinition.ClassName))
            {
                instance = ObjectFactory.CreateInstance(classDefinition.ClassName);
            }
            else
            {
                instance = new ASObject()
                {
                    Definition = classDefinition
                }
            };
            if (instance == null)
            {
#if !SILVERLIGHT
                if (log.IsWarnEnabled)
                {
                    log.Warn(__Res.GetString(__Res.TypeLoad_ASO, classDefinition.ClassName));
                }
#endif
                instance = new ASObject(classDefinition.ClassName);
            }
            AddAMF3ObjectReference(instance);
            if (classDefinition.IsExternalizable)
            {
                if (instance is IExternalizable)
                {
                    IExternalizable externalizable = instance as IExternalizable;
                    DataInput       dataInput      = new DataInput(this);
                    externalizable.ReadExternal(dataInput);
                }
                else
                {
                    string msg = __Res.GetString(__Res.Externalizable_CastFail, instance.GetType().FullName, classDefinition.ClassName);
                    throw new FluorineException(msg);
                }
            }
            else
            {
                for (int i = 0; i < classDefinition.MemberCount; i++)
                {
                    string key   = classDefinition.Members[i].Name;
                    object value = ReadAMF3Data();
                    SetMember(instance, key, value);
                }
                if (classDefinition.IsDynamic)
                {
                    string key = ReadAMF3String();
                    while (key != null && key != string.Empty)
                    {
                        object value = ReadAMF3Data();
                        SetMember(instance, key, value);
                        key = ReadAMF3String();
                    }
                }
            }
            return(instance);
        }
 /// <summary>
 /// Creates an {@code IndexFormatTooOldException}.
 /// </summary>
 ///  <param name="in"> the open file that's too old </param>
 ///  <param name="version"> the version of the file that was too old </param>
 ///  <param name="minVersion"> the minimum version accepted </param>
 ///  <param name="maxVersion"> the maxium version accepted
 ///
 /// @lucene.internal  </param>
 public IndexFormatTooOldException(DataInput @in, int version, int minVersion, int maxVersion)
     : this(@in.ToString(), version, minVersion, maxVersion)
 {
 }
Ejemplo n.º 40
0
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: @Override public NodeStatisticsMessage decode(java.io.DataInput in, int version) throws java.io.IOException
 public NodeStatisticsMessage decode(DataInput @in, int version)
 {
     return(new NodeStatisticsMessage(@in.readInt(), @in.readInt(), @in.readFloat(), @in.readFloat()));
 }
Ejemplo n.º 41
0
 private static string DecodeUTF(int utfSize, DataInput stream)
 {
     byte[] buffer = new byte[utfSize];
     char[] outb = new char[utfSize];
     stream.ReadFully(buffer, 0, utfSize);
     return ConvertUTF8WithBuf(buffer, outb, 0, utfSize);
 }
Ejemplo n.º 42
0
        /// <summary>
        /// Decompress at least <paramref name="decompressedLen"/> bytes into
        /// <c>dest[dOff]</c>. Please note that <paramref name="dest"/> must be large
        /// enough to be able to hold <b>all</b> decompressed data (meaning that you
        /// need to know the total decompressed length).
        /// </summary>
        public static int Decompress(DataInput compressed, int decompressedLen, byte[] dest, int dOff)
        {
            int destEnd = dest.Length;

            do
            {
                // literals
                int token      = compressed.ReadByte() & 0xFF;
                int literalLen = (int)(((uint)token) >> 4);

                if (literalLen != 0)
                {
                    if (literalLen == 0x0F)
                    {
                        byte len;
                        while ((len = compressed.ReadByte()) == 0xFF)
                        {
                            literalLen += 0xFF;
                        }
                        literalLen += len & 0xFF;
                    }
                    compressed.ReadBytes(dest, dOff, literalLen);
                    dOff += literalLen;
                }

                if (dOff >= decompressedLen)
                {
                    break;
                }

                // matchs
                var byte1    = compressed.ReadByte();
                var byte2    = compressed.ReadByte();
                int matchDec = (byte1 & 0xFF) | ((byte2 & 0xFF) << 8);
                if (Debugging.AssertsEnabled)
                {
                    Debugging.Assert(matchDec > 0);
                }

                int matchLen = token & 0x0F;
                if (matchLen == 0x0F)
                {
                    int len;
                    while ((len = compressed.ReadByte()) == 0xFF)
                    {
                        matchLen += 0xFF;
                    }
                    matchLen += len & 0xFF;
                }
                matchLen += MIN_MATCH;

                // copying a multiple of 8 bytes can make decompression from 5% to 10% faster
                int fastLen = (int)((matchLen + 7) & 0xFFFFFFF8);
                if (matchDec < matchLen || dOff + fastLen > destEnd)
                {
                    // overlap -> naive incremental copy
                    for (int @ref = dOff - matchDec, end = dOff + matchLen; dOff < end; ++@ref, ++dOff)
                    {
                        dest[dOff] = dest[@ref];
                    }
                }
                else
                {
                    // no overlap -> arraycopy
                    Array.Copy(dest, dOff - matchDec, dest, dOff, fastLen);
                    dOff += matchLen;
                }
            } while (dOff < decompressedLen);

            return(dOff);
        }
Ejemplo n.º 43
0
 /// <summary>
 /// Creates an <see cref="IndexFormatTooNewException"/>
 /// <para/>
 /// @lucene.internal
 /// </summary>
 /// <param name="input"> the open file that's too old </param>
 /// <param name="version"> the version of the file that was too old </param>
 /// <param name="minVersion"> the minimum version accepted </param>
 /// <param name="maxVersion"> the maxium version accepted </param>
 public IndexFormatTooNewException(DataInput input, int version, int minVersion, int maxVersion)
     : this(input.ToString(), version, minVersion, maxVersion)
 {
 }
Ejemplo n.º 44
0
 /// <summary>
 /// Decompress bytes that were stored between offsets <code>offset</code> and
 /// <code>offset+length</code> in the original stream from the compressed
 /// stream <code>in</code> to <code>bytes</code>. After returning, the length
 /// of <code>bytes</code> (<code>bytes.length</code>) must be equal to
 /// <code>length</code>. Implementations of this method are free to resize
 /// <code>bytes</code> depending on their needs.
 /// </summary>
 /// <param name="in"> the input that stores the compressed stream </param>
 /// <param name="originalLength"> the length of the original data (before compression) </param>
 /// <param name="offset"> bytes before this offset do not need to be decompressed </param>
 /// <param name="length"> bytes after <code>offset+length</code> do not need to be decompressed </param>
 /// <param name="bytes"> a <seealso cref="BytesRef"/> where to store the decompressed data </param>
 public abstract void Decompress(DataInput @in, int originalLength, int offset, int length, BytesRef bytes);
Ejemplo n.º 45
0
        /// <summary>
        /// Reads from the
        /// stream <code>in</code> a representation
        /// of a Unicode  character string encoded in
        /// <a href="DataInput.html#modified-utf-8">modified UTF-8</a> format;
        /// this string of characters is then returned as a <code>String</code>.
        /// </summary>
        /// <remarks>
        /// Reads from the
        /// stream <code>in</code> a representation
        /// of a Unicode  character string encoded in
        /// <a href="DataInput.html#modified-utf-8">modified UTF-8</a> format;
        /// this string of characters is then returned as a <code>String</code>.
        /// The details of the modified UTF-8 representation
        /// are  exactly the same as for the <code>readUTF</code>
        /// method of <code>DataInput</code>.
        /// </remarks>
        /// <param name="in">a data input stream.</param>
        /// <returns>a Unicode string.</returns>
        /// <exception>
        /// EOFException
        /// if the input stream reaches the end
        /// before all the bytes.
        /// </exception>
        /// <exception>
        /// IOException
        /// the stream has been closed and the contained
        /// input stream does not support reading after close, or
        /// another I/O error occurs.
        /// </exception>
        /// <exception>
        /// UTFDataFormatException
        /// if the bytes do not represent a
        /// valid modified UTF-8 encoding of a Unicode string.
        /// </exception>
        /// <seealso cref="java.io.DataInputStream.readUnsignedShort()">java.io.DataInputStream.readUnsignedShort()
        /// 	</seealso>
        /// <exception cref="System.IO.IOException"></exception>
        public static string readUTF(DataInput @in)
        {
            int utflen = @in.readUnsignedShort();
            byte[] bytearr = null;
            char[] chararr = null;
            if (@in is DataInputStream)
            {
                DataInputStream dis = (DataInputStream)@in;
                if (dis.bytearr.Length < utflen)
                {
                    dis.bytearr = new byte[utflen * 2];
                    dis.chararr = new char[utflen * 2];
                }
                chararr = dis.chararr;
                bytearr = dis.bytearr;
            }
            else
            {
                bytearr = new byte[utflen];
                chararr = new char[utflen];
            }
            int c;
            int char2;
            int char3;
            int count = 0;
            int chararr_count = 0;
            @in.readFully(bytearr, 0, utflen);
            while (count < utflen)
            {
                c = (int)bytearr[count] & unchecked((int)(0xff));
                if (c > 127)
                {
                    break;
                }
                count++;
                chararr[chararr_count++] = (char)c;
            }
            while (count < utflen)
            {
                c = (int)bytearr[count] & unchecked((int)(0xff));
                switch (c >> 4)
                {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    {
                        count++;
                        chararr[chararr_count++] = (char)c;
                        break;
                    }

                    case 12:
                    case 13:
                    {
                        count += 2;
                        if (count > utflen)
                        {
                            throw new java.io.UTFDataFormatException("malformed input: partial character at end"
                                );
                        }
                        char2 = (int)bytearr[count - 1];
                        if ((char2 & unchecked((int)(0xC0))) != unchecked((int)(0x80)))
                        {
                            throw new java.io.UTFDataFormatException("malformed input around byte " + count);
                        }
                        chararr[chararr_count++] = (char)(((c & unchecked((int)(0x1F))) << 6) | (char2 &
                            unchecked((int)(0x3F))));
                        break;
                    }

                    case 14:
                    {
                        count += 3;
                        if (count > utflen)
                        {
                            throw new java.io.UTFDataFormatException("malformed input: partial character at end"
                                );
                        }
                        char2 = (int)bytearr[count - 2];
                        char3 = (int)bytearr[count - 1];
                        if (((char2 & unchecked((int)(0xC0))) != unchecked((int)(0x80))) || ((char3 & unchecked(
                            (int)(0xC0))) != unchecked((int)(0x80))))
                        {
                            throw new java.io.UTFDataFormatException("malformed input around byte " + (count
                                - 1));
                        }
                        chararr[chararr_count++] = (char)(((c & unchecked((int)(0x0F))) << 12) | ((char2
                            & unchecked((int)(0x3F))) << 6) | ((char3 & unchecked((int)(0x3F))) << 0));
                        break;
                    }

                    default:
                    {
                        throw new java.io.UTFDataFormatException("malformed input around byte " + count);
                        break;
                    }
                }
            }
            // The number of chars produced may be less than utflen
            return new string(chararr, 0, chararr_count);
        }
Ejemplo n.º 46
0
        public virtual void TestDataInputOutput2()
        {
            Random random = Random();

            for (int iter = 0; iter < 5 * RANDOM_MULTIPLIER; iter++)
            {
                int        blockBits = TestUtil.NextInt(random, 1, 20);
                int        blockSize = 1 << blockBits;
                PagedBytes p         = new PagedBytes(blockBits);
                DataOutput @out      = p.GetDataOutput();
                int        numBytes  = Random().Next(10000000);

                byte[] answer = new byte[numBytes];
                Random().NextBytes(answer);
                int written = 0;
                while (written < numBytes)
                {
                    if (Random().Next(10) == 7)
                    {
                        @out.WriteByte(answer[written++]);
                    }
                    else
                    {
                        int chunk = Math.Min(Random().Next(1000), numBytes - written);
                        @out.WriteBytes(answer, written, chunk);
                        written += chunk;
                    }
                }

                PagedBytes.Reader reader = p.Freeze(random.NextBoolean());

                DataInput @in = p.GetDataInput();

                byte[] verify = new byte[numBytes];
                int    read   = 0;
                while (read < numBytes)
                {
                    if (Random().Next(10) == 7)
                    {
                        verify[read++] = @in.ReadByte();
                    }
                    else
                    {
                        int chunk = Math.Min(Random().Next(1000), numBytes - read);
                        @in.ReadBytes(verify, read, chunk);
                        read += chunk;
                    }
                }
                Assert.IsTrue(Arrays.Equals(answer, verify));

                BytesRef slice = new BytesRef();
                for (int iter2 = 0; iter2 < 100; iter2++)
                {
                    int pos = random.Next(numBytes - 1);
                    int len = random.Next(Math.Min(blockSize + 1, numBytes - pos));
                    reader.FillSlice(slice, pos, len);
                    for (int byteUpto = 0; byteUpto < len; byteUpto++)
                    {
                        Assert.AreEqual(answer[pos + byteUpto], (byte)slice.Bytes[slice.Offset + byteUpto]);
                    }
                }
            }
        }
Ejemplo n.º 47
0
 public override IGFSerializable FromData(DataInput input)
 {
     assetId = input.ReadInt32();
     value   = input.ReadDouble();
     return(this);
 }
Ejemplo n.º 48
0
 /// <summary>
 /// Decode an output value previously written with
 /// <see cref="Write(T, DataOutput)"/>.
 /// </summary>
 public abstract T Read(DataInput @in);
Ejemplo n.º 49
0
            public override void Decompress(DataInput input, int originalLength, int offset, int length, BytesRef bytes)
            {
                Debug.Assert(offset + length <= originalLength);
                if (length == 0)
                {
                    bytes.Length = 0;
                    return;
                }

                byte[] compressedBytes = new byte[input.ReadVInt()];
                input.ReadBytes(compressedBytes, 0, compressedBytes.Length);
                byte[] decompressedBytes = null;

                using (MemoryStream decompressedStream = new MemoryStream())
                {
                    using (MemoryStream compressedStream = new MemoryStream(compressedBytes))
                    {
                        using (DeflateStream dStream = new DeflateStream(compressedStream, System.IO.Compression.CompressionMode.Decompress))
                        {
                            dStream.CopyTo(decompressedStream);
                        }
                    }
                    decompressedBytes = decompressedStream.ToArray();
                }

                if (decompressedBytes.Length != originalLength)
                {
                    throw new CorruptIndexException("Length mismatch: " + decompressedBytes.Length + " != " + originalLength + " (resource=" + input + ")");
                }

                bytes.Bytes = decompressedBytes;
                bytes.Offset = offset;
                bytes.Length = length;            
            }
Ejemplo n.º 50
0
 public override void readTagContents(DataInput datainput)
 {
     doubleValue = datainput.readDouble();
 }
Ejemplo n.º 51
0
 /// <summary>
 /// Sole constructor. </summary>
 /// <param name="blockSize"> the number of values of a block, must be equal to the
 ///                  block size of the <seealso cref="BlockPackedWriter"/> which has
 ///                  been used to write the stream </param>
 public BlockPackedReaderIterator(DataInput @in, int packedIntsVersion, int blockSize, long valueCount)
 {
     PackedInts.CheckBlockSize(blockSize, AbstractBlockPackedWriter.MIN_BLOCK_SIZE, AbstractBlockPackedWriter.MAX_BLOCK_SIZE);
     this.PackedIntsVersion = packedIntsVersion;
     this.BlockSize = blockSize;
     this.Values = new long[blockSize];
     this.ValuesRef = new LongsRef(this.Values, 0, 0);
     Reset(@in, valueCount);
 }
Ejemplo n.º 52
0
 /**
  * Reads a string encoded in {@link DataInput modified UTF-8} from the
  * {@code DataInput} stream {@code in}.
  *
  * @param in
  *            the input stream to read from.
  * @return the next {@link DataInput MUTF-8} encoded string from the source
  *         stream.
  * @throws IOException
  *             if a problem occurs while reading from this stream.
  * @see DataOutputStream#writeUTF(java.lang.String)
  */
 public static String readUTF(DataInput input)
 {
     // throws IOException {
     return decodeUTF(input.readUnsignedShort(), input);
 }
Ejemplo n.º 53
0
 public virtual void ReadFields(DataInput @in)
 {
 }
Ejemplo n.º 54
0
 public override object Read(DataInput @in)
 {
     //assert false;
     //return null;
     return(NO_OUTPUT);
 }
Ejemplo n.º 55
0
        private static String decodeUTF(int utfSize, DataInput input)
        {
            // throws IOException {
            byte[] buf = new byte[utfSize];
            char[] output = new char[utfSize];
            input.readFully(buf, 0, utfSize);

            return Util.convertUTF8WithBuf(buf, output, 0, utfSize);
        }
Ejemplo n.º 56
0
 /// <summary>
 /// Constructs a <see cref="ByteSequencesReader"/> from the provided <see cref="DataInput"/>. </summary>
 public ByteSequencesReader(DataInput inputStream)
 {
     this.inputStream = inputStream;
 }
Ejemplo n.º 57
0
 public virtual T ReadFinalOutput(DataInput @in)
 {
     return(Read(@in));
 }
Ejemplo n.º 58
0
 public override bool Load(DataInput @out)
 {
     return(false);
 }
Ejemplo n.º 59
0
        public virtual void TestDataInputOutput()
        {
            Random random = Random();

            for (int iter = 0; iter < 5 * RANDOM_MULTIPLIER; iter++)
            {
                BaseDirectoryWrapper dir = NewFSDirectory(CreateTempDir("testOverflow"));
                if (dir is MockDirectoryWrapper)
                {
                    ((MockDirectoryWrapper)dir).Throttling = MockDirectoryWrapper.Throttling_e.NEVER;
                }
                int         blockBits = TestUtil.NextInt(random, 1, 20);
                int         blockSize = 1 << blockBits;
                PagedBytes  p         = new PagedBytes(blockBits);
                IndexOutput @out      = dir.CreateOutput("foo", IOContext.DEFAULT);
                int         numBytes  = TestUtil.NextInt(Random(), 2, 10000000);

                byte[] answer = new byte[numBytes];
                Random().NextBytes(answer);
                int written = 0;
                while (written < numBytes)
                {
                    if (Random().Next(10) == 7)
                    {
                        @out.WriteByte(answer[written++]);
                    }
                    else
                    {
                        int chunk = Math.Min(Random().Next(1000), numBytes - written);
                        @out.WriteBytes(answer, written, chunk);
                        written += chunk;
                    }
                }

                @out.Dispose();
                IndexInput input = dir.OpenInput("foo", IOContext.DEFAULT);
                DataInput  @in   = (DataInput)input.Clone();

                p.Copy(input, input.Length);
                PagedBytes.Reader reader = p.Freeze(random.NextBoolean());

                byte[] verify = new byte[numBytes];
                int    read   = 0;
                while (read < numBytes)
                {
                    if (Random().Next(10) == 7)
                    {
                        verify[read++] = @in.ReadByte();
                    }
                    else
                    {
                        int chunk = Math.Min(Random().Next(1000), numBytes - read);
                        @in.ReadBytes(verify, read, chunk);
                        read += chunk;
                    }
                }
                Assert.IsTrue(Arrays.Equals(answer, verify));

                BytesRef slice = new BytesRef();
                for (int iter2 = 0; iter2 < 100; iter2++)
                {
                    int pos = random.Next(numBytes - 1);
                    int len = random.Next(Math.Min(blockSize + 1, numBytes - pos));
                    reader.FillSlice(slice, pos, len);
                    for (int byteUpto = 0; byteUpto < len; byteUpto++)
                    {
                        Assert.AreEqual(answer[pos + byteUpto], (byte)slice.Bytes[slice.Offset + byteUpto]);
                    }
                }
                input.Dispose();
                dir.Dispose();
            }
        }
Ejemplo n.º 60
0
 /// <summary>
 /// Discard current lookup data and load it from a previously saved copy.
 /// Optional operation. </summary>
 /// <param name="input"> the <seealso cref="DataInput"/> to load the lookup data. </param>
 /// <returns> true if completed successfully, false if unsuccessful or not supported. </returns>
 /// <exception cref="IOException"> when fatal IO error occurs. </exception>
 public abstract bool Load(DataInput input);