public BinaryDocValuesWriter(FieldInfo fieldInfo, Counter iwBytesUsed)
 {
     this.FieldInfo = fieldInfo;
     this.Bytes = new PagedBytes(BLOCK_BITS);
     this.BytesOut = Bytes.DataOutput;
     this.Lengths = new AppendingDeltaPackedLongBuffer(PackedInts.COMPACT);
     this.IwBytesUsed = iwBytesUsed;
     this.DocsWithField = new FixedBitSet(64);
     this.BytesUsed = DocsWithFieldBytesUsed();
     iwBytesUsed.AddAndGet(BytesUsed);
 }
Beispiel #2
0
        /// <summary>
        /// Encode an exception to an output stream </summary>
        /// <param name="output"> Data output </param>
        /// <param name="exception"> Exception to encode </param>
        /// <exception cref="IOException"> On IO error </exception>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public static void encodeException(DataOutput output, FriendlyException exception) throws IOException
        public static void encodeException(DataOutput output, FriendlyException exception)
        {
            IList <System.Exception> causes = new List <System.Exception>();

            System.Exception next = exception.InnerException;

            while (next != null)
            {
                causes.Add(next);
                next = next.InnerException;
            }

            for (int i = causes.Count - 1; i >= 0; i--)
            {
                System.Exception cause = causes[i];
                output.writeBoolean(true);

                string message;

                if (cause is DecodedException)
                {
                    output.writeUTF(((DecodedException)cause).className);
                    message = ((DecodedException)cause).originalMessage;
                }
                else
                {
                    //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                    output.writeUTF(cause.GetType().FullName);
                    message = cause.Message;
                }

                output.writeBoolean(!string.ReferenceEquals(message, null));
                if (!string.ReferenceEquals(message, null))
                {
                    output.writeUTF(message);
                }

                encodeStackTrace(output, cause);
            }

            output.writeBoolean(false);
            output.writeUTF(exception.Message);
            output.writeInt((int)exception.severity);


            encodeStackTrace(output, exception);
        }
Beispiel #3
0
        public override void EncodeTerm(long[] longs, DataOutput output, FieldInfo fi, BlockTermState state, bool absolute)
        {
            SepTermState state_ = (SepTermState)state;

            if (absolute)
            {
                lastSkipFP    = 0;
                lastPayloadFP = 0;
                lastState     = state_;
            }
            lastState.DocIndex.CopyFrom(state_.DocIndex, false);
            lastState.DocIndex.Write(output, absolute);
            if (indexOptions != IndexOptions.DOCS_ONLY)
            {
                lastState.FreqIndex.CopyFrom(state_.FreqIndex, false);
                lastState.FreqIndex.Write(output, absolute);
                if (indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
                {
                    lastState.PosIndex.CopyFrom(state_.PosIndex, false);
                    lastState.PosIndex.Write(output, absolute);
                    if (storePayloads)
                    {
                        if (absolute)
                        {
                            output.WriteVInt64(state_.PayloadFP);
                        }
                        else
                        {
                            output.WriteVInt64(state_.PayloadFP - lastPayloadFP);
                        }
                        lastPayloadFP = state_.PayloadFP;
                    }
                }
            }
            if (state_.SkipFP != -1)
            {
                if (absolute)
                {
                    output.WriteVInt64(state_.SkipFP);
                }
                else
                {
                    output.WriteVInt64(state_.SkipFP - lastSkipFP);
                }
                lastSkipFP = state_.SkipFP;
            }
        }
        private void CreateReportViewer()
        {
            frmRpt = new frm_Report();

            #region Подготовить данные для вывода в отчет

            // Исходные данные в отчет 
            DataInput_HB _DataInput_HB = new DataInput_HB(HB);
            List<cReportList> RepListInputHB = new List<cReportList>();
            foreach (HeatBalance.Class.Param par in _allParamsInput)
            {
                if (par.IsReport)
                {
                    if (_DataInput_HB.GetType().GetProperty(par.PropertyName).GetValue(_DataInput_HB, null) != null)
                    {
                        double d = Math.Round(Convert.ToDouble(
                            _DataInput_HB.GetType().GetProperty(par.PropertyName).GetValue(
                            _DataInput_HB, null)), 3);
                        RepListInputHB.Add(new HeatBalance.Class.cReportList(par.Description, d.ToString()));
                    }
                }
            }
            frmRpt.cReportInputBindingSource.DataSource = RepListInputHB;
            // Результаты расчета в отчет 
            DataOutput _dataOutput = new DataOutput(HB);
            List<cReportList> RepListOutput = new List<cReportList>();
            foreach (HeatBalance.Class.Param par in _allParamsOutput)
            {
                if (par.IsReport)
                {
                    double d = Math.Round(Convert.ToDouble(
                        _dataOutput.GetType().GetProperty(par.PropertyName).GetValue(_dataOutput, null)), 3);
                    RepListOutput.Add(new HeatBalance.Class.cReportList(par.Description, d.ToString()));
                }
            }
            #endregion

            #region Указать отчету источники данных                
            frmRpt.cReportInputBindingSource.DataSource = RepListInputHB;
            frmRpt.cReportOutputBindingSource.DataSource = RepListOutput;
            #endregion

            #region Показать окно отчета на весь экран
            frmRpt.WindowState = FormWindowState.Maximized;
            frmRpt.ShowDialog(this);
            #endregion
        }
Beispiel #5
0
        private static void WriteState(
            DataOutput output,
            CountMinSketchState state)
        {
            var hashes = state.Hashes;
            output.WriteInt(hashes.Depth);
            output.WriteInt(hashes.Width);

            var table = hashes.Table;
            output.WriteInt(table.Length);
            foreach (var row in table) {
                output.WriteInt(row.Length);
                foreach (var col in row) {
                    output.WriteLong(col);
                }
            }

            var hash = hashes.Hash;
            output.WriteInt(hash.Length);
            foreach (var aHash in hash) {
                output.WriteLong(aHash);
            }

            output.WriteLong(hashes.Total);

            var topk = state.Topk;
            output.WriteBoolean(topk != null);
            if (topk != null) {
                output.WriteInt(topk.TopKMax);
                var topMap = topk.Topk;
                output.WriteInt(topMap.Count);
                foreach (var entry in topMap) {
                    output.WriteLong(entry.Key);
                    if (entry.Value is ByteBuffer byteBuffer) {
                        output.WriteInt(1);
                        WriteBytes(output, byteBuffer);
                    }
                    else {
                        var q = (Deque<ByteBuffer>) entry.Value;
                        output.WriteInt(q.Count);
                        foreach (var buf in q) {
                            WriteBytes(output, buf);
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public void ToData(DataOutput output)
        {
            output.WriteDouble(double_field);
            output.WriteFloat(float_field);
            output.WriteInt64(long_field);
            output.WriteInt32(int_field);
            output.WriteInt16(short_field);
            output.WriteUTF(string_field);
            int itemCount = string_vector.Count;

            output.WriteInt32(itemCount);
            for (int idx = 0; idx < itemCount; idx++)
            {
                string s = (string)string_vector[idx];
                output.WriteUTF(s);
            }
        }
Beispiel #7
0
 public override void writeTagContents(DataOutput dataoutput)
 {
     if (tagList.size() > 0)
     {
         tagType = ((NBTBase)tagList.get(0)).getType();
     }
     else
     {
         tagType = 1;
     }
     dataoutput.writeByte(tagType);
     dataoutput.writeInt(tagList.size());
     for (int i = 0; i < tagList.size(); i++)
     {
         ((NBTBase)tagList.get(i)).writeTagContents(dataoutput);
     }
 }
Beispiel #8
0
 public override void WriteFinalOutput(object output, DataOutput @out)
 {
     if (!(output is IList))
     {
         @out.WriteVInt32(1);
         outputs.Write((T)output, @out);
     }
     else
     {
         IList outputList = (IList)output;
         @out.WriteVInt32(outputList.Count);
         foreach (var eachOutput in outputList)
         {
             outputs.Write((T)eachOutput, @out);
         }
     }
 }
Beispiel #9
0
 public override void Write(object output, DataOutput @out)
 {
     if (Debugging.AssertsEnabled)
     {
         Debugging.Assert(Valid(output, true));
     }
     if (output is Int64 output2)
     {
         @out.WriteVInt64(output2 << 1);
     }
     else
     {
         TwoInt64s output3 = (TwoInt64s)output;
         @out.WriteVInt64((output3.First << 1) | 1);
         @out.WriteVInt64(output3.Second);
     }
 }
 /// <summary>
 /// Serialize a
 /// <see cref="INodeSymlink"/>
 /// node
 /// </summary>
 /// <param name="node">The node to write</param>
 /// <param name="out">
 /// The
 /// <see cref="System.IO.DataOutput"/>
 /// where the fields are written
 /// </param>
 /// <exception cref="System.IO.IOException"/>
 private static void WriteINodeSymlink(INodeSymlink node, DataOutput @out)
 {
     WriteLocalName(node, @out);
     @out.WriteLong(node.GetId());
     @out.WriteShort(0);
     // replication
     @out.WriteLong(0);
     // modification time
     @out.WriteLong(0);
     // access time
     @out.WriteLong(0);
     // preferred block size
     @out.WriteInt(-2);
     // # of blocks
     Text.WriteString(@out, node.GetSymlinkString());
     WritePermissionStatus(node, @out);
 }
Beispiel #11
0
 public override void writeTagContents(DataOutput dataoutput)
 {
     if (tagList.size() > 0)
     {
         tagType = ((NBTBase) tagList.get(0)).getType();
     }
     else
     {
         tagType = 1;
     }
     dataoutput.writeByte(tagType);
     dataoutput.writeInt(tagList.size());
     for (int i = 0; i < tagList.size(); i++)
     {
         ((NBTBase) tagList.get(i)).writeTagContents(dataoutput);
     }
 }
Beispiel #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void writeFinalOutput(Object output, org.apache.lucene.store.DataOutput out) throws java.io.IOException
        public override void writeFinalOutput(object output, DataOutput @out)
        {
            if (!(output is IList))
            {
                @out.writeVInt(1);
                outputs.write((T)output, @out);
            }
            else
            {
                IList <T> outputList = (IList <T>)output;
                @out.writeVInt(outputList.Count);
                foreach (T eachOutput in outputList)
                {
                    outputs.write(eachOutput, @out);
                }
            }
        }
Beispiel #13
0
 public void ToData(DataOutput output)
 {
     output.WriteInt32(m_id);
     output.WriteUTF(m_pkid);
     output.WriteObject(m_position1);
     output.WriteObject(m_position2);
     output.WriteDictionary((System.Collections.IDictionary)m_positions);
     output.WriteUTF(m_type);
     output.WriteUTF(m_status);
     output.WriteObject(m_names);
     output.WriteBytes(m_newVal);
     //output.WriteObject((IGFSerializable)(object)m_creationDate); // VJR: TODO
     //output.WriteObject(CacheableDate.Create(m_creationDate));
     output.WriteDate(m_creationDate);
     output.WriteBytes(m_arrayNull);
     output.WriteBytes(m_arrayZeroSize);
 }
Beispiel #14
0
        static void GetOrderInfoTest()
        {
            var @event = "getorderinfo";

            Console.WriteLine($"{nameof(GetOrderInfoTest)} Start");
            using (var ws = new WebSocket(URL))
            {
                if (URL.StartsWith("wss", StringComparison.OrdinalIgnoreCase))
                {
                    ws.SslConfiguration.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
                }
                ws.OnMessage += (sender, e) => {
                    var output = JsonConvert.DeserializeObject <DataOutput <dynamic> >(e.Data);
                    if (output.Event == @event)
                    {
                        DataOutput <IList <GetOrderInfoOutput> > baseOutput = JsonConvert.DeserializeObject <DataOutput <IList <GetOrderInfoOutput> > >(e.Data);
                        var parameters = baseOutput.Data == null ? string.Empty : JsonConvert.SerializeObject(baseOutput.Data);
                        Console.WriteLine($"Parameters:{parameters} Result:{baseOutput.Result} Code:{baseOutput.ErrorCode} ");
                    }
                    if (output.Event == "login")
                    {
                        Console.WriteLine($"Result:{output.Result} Code:{output.ErrorCode}");
                    }
                };

                GetOrderinfoEvent baseEvent = new GetOrderinfoEvent
                {
                    Event      = @event,
                    Parameters = new Orderinfo
                    {
                        Symbol  = "BTC/VHKD",
                        Sign    = Sign,
                        ApiKey  = ApiKey,
                        OrderId = "EvIJUCwEp0CClKGlM8MRKg"
                    }
                };
                var data = JsonConvert.SerializeObject(baseEvent);
                ws.Connect();
                Login(ws);
                Thread.Sleep(50);
                ws.Send(data);
                Console.ReadLine();
            }
            Console.WriteLine($"{nameof(GetOrderInfoTest)}  End");
        }
Beispiel #15
0
        public DataOutput CreateDataOutput(DataOutputViewModel viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            var output = new DataOutput
            {
                MimeType     = viewModel.SelectedFormat.MimeType,
                Encoding     = viewModel.SelectedFormat.SelectedEncoding,
                Schema       = viewModel.SelectedFormat.SelectedSchema,
                Transmission = TransmissionMode.Value,
                Identifier   = viewModel.Identifier
            };

            return(output);
        }
        private void WriteInternal(
            object[] @object,
            DataOutput output,
            byte[] unitKey,
            EventBeanCollatedWriter writer)
        {
            if (@object == null)
            {
                output.WriteInt(-1);
                return;
            }

            output.WriteInt(@object.Length);
            foreach (object i in @object)
            {
                _componentBinding.Write(i, output, unitKey, writer);
            }
        }
Beispiel #17
0
 public override bool Store(DataOutput output)
 {
     UninterruptableMonitor.Enter(this);
     try
     {
         output.WriteVInt64(count);
         if (this.normalCompletion == null || normalCompletion.FST == null)
         {
             return(false);
         }
         normalCompletion.FST.Save(output);
         return(true);
     }
     finally
     {
         UninterruptableMonitor.Exit(this);
     }
 }
Beispiel #18
0
 public override void Write(object output, DataOutput @out)
 {
     if (Debugging.AssertsEnabled)
     {
         Debugging.Assert(Valid(output, true));
     }
     if (output is long?)
     {
         long?output2 = (long?)output;
         @out.WriteVInt64(output2.GetValueOrDefault() << 1);
     }
     else
     {
         TwoInt64s output3 = (TwoInt64s)output;
         @out.WriteVInt64((output3.First << 1) | 1);
         @out.WriteVInt64(output3.Second);
     }
 }
Beispiel #19
0
        /// <summary>Save snapshots and snapshot quota for a snapshottable directory.</summary>
        /// <param name="current">The directory that the snapshots belongs to.</param>
        /// <param name="out">
        /// The
        /// <see cref="System.IO.DataOutput"/>
        /// to write.
        /// </param>
        /// <exception cref="System.IO.IOException"/>
        public static void SaveSnapshots(INodeDirectory current, DataOutput @out)
        {
            DirectorySnapshottableFeature sf = current.GetDirectorySnapshottableFeature();

            Preconditions.CheckArgument(sf != null);
            // list of snapshots in snapshotsByNames
            ReadOnlyList <Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot> snapshots =
                sf.GetSnapshotList();

            @out.WriteInt(snapshots.Size());
            foreach (Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot s in snapshots)
            {
                // write the snapshot id
                @out.WriteInt(s.GetId());
            }
            // snapshot quota
            @out.WriteInt(sf.GetSnapshotQuota());
        }
Beispiel #20
0
        public void StringExcedesBufferCapacity()
        {
            DataOutput dataOutput = new DataOutput();

            // Chcek that native buffer is unused and get initial capacity.
            Assert.AreEqual(0, dataOutput.BufferLength);
            int bufferSize = dataOutput.GetRemainingBufferLength();

            // New string equal to buffer capacity.
            string s = "".PadRight(bufferSize, 'a');

            dataOutput.WriteUTF(s);

            // Checks native buffer capacity, remaining length should be capacity since wrapper has not flushed to native yet.
            Assert.GreaterOrEqual(dataOutput.GetRemainingBufferLength(), bufferSize + 2, "Buffer should have been resized to account for string + 2 bytes of length");
            // Forces native buffer to be updated and gets length of used buffers.
            Assert.AreEqual(bufferSize + 2, dataOutput.BufferLength, "Buffer length should be string plus 2 bytes for length.");
        }
Beispiel #21
0
 /// <summary>
 /// NOTE: This was saveInts() in Lucene.
 /// </summary>
 private static void SaveInt32s(int[] values, int length, DataOutput @out)
 {
     if (Debugging.AssertsEnabled)
     {
         Debugging.Assert(length > 0);
     }
     if (length == 1)
     {
         @out.WriteVInt32(values[0]);
     }
     else
     {
         bool allEqual = true;
         for (int i = 1; i < length; ++i)
         {
             if (values[i] != values[0])
             {
                 allEqual = false;
                 break;
             }
         }
         if (allEqual)
         {
             @out.WriteVInt32(0);
             @out.WriteVInt32(values[0]);
         }
         else
         {
             long max = 0;
             for (int i = 0; i < length; ++i)
             {
                 max |= (uint)values[i];
             }
             int bitsRequired = PackedInt32s.BitsRequired(max);
             @out.WriteVInt32(bitsRequired);
             PackedInt32s.Writer w = PackedInt32s.GetWriterNoHeader(@out, PackedInt32s.Format.PACKED, length, bitsRequired, 1);
             for (int i = 0; i < length; ++i)
             {
                 w.Add(values[i]);
             }
             w.Finish();
         }
     }
 }
Beispiel #22
0
        public bool CompareTwoPositionObjects(TVal pos1, TVal pos2)
        {
            Position p1 = pos1 as Position;
            Position p2 = pos2 as Position;

            if (p1 == null || p2 == null)
            {
                Util.Log("The object(s) passed are not of Position type");
                return(false);
            }

            DataOutput o1 = m_cache.CreateDataOutput();
            DataOutput o2 = m_cache.CreateDataOutput();

            p1.ToData(o1);
            p2.ToData(o2);

            var len1 = o1.BufferLength;
            var len2 = o2.BufferLength;

            if (len1 != len2)
            {
                return(false);
            }

            byte[] ptr1 = o1.GetBuffer();
            byte[] ptr2 = o2.GetBuffer();

            if (ptr1.Length != ptr2.Length)
            {
                return(false);
            }

            for (int i = ptr1.Length; i < ptr1.Length; i++)
            {
                if (ptr1[i] != ptr2[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #23
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void Write(DataOutput @out)
 {
     @out.WriteLong(totLength);
     @out.WriteInt(lengths.Length);
     foreach (long length in lengths)
     {
         @out.WriteLong(length);
     }
     @out.WriteInt(paths.Length);
     foreach (Path p in paths)
     {
         Text.WriteString(@out, p.ToString());
     }
     @out.WriteInt(startoffset.Length);
     foreach (long length_1 in startoffset)
     {
         @out.WriteLong(length_1);
     }
 }
Beispiel #24
0
 public static void WriteValue(
     object value,
     DataOutput output)
 {
     if (value == null)
     {
         output.WriteByte(NULL_TYPE);
     }
     else if (value is int intValue)
     {
         output.WriteByte(INT_TYPE);
         output.WriteInt(intValue);
     }
     else if (value is double doubleValue)
     {
         output.WriteByte(DOUBLE_TYPE);
         output.WriteDouble(doubleValue);
     }
     else if (value is string stringValue)
     {
         output.WriteByte(STRING_TYPE);
         output.WriteUTF(stringValue);
     }
     else if (value is bool boolValue)
     {
         output.WriteByte(BOOLEAN_TYPE);
         output.WriteBoolean(boolValue);
     }
     else if (value is IDictionary <string, object> dictionary)
     {
         output.WriteByte(OBJECT_TYPE);
         Write(dictionary, output);
     }
     else if (value is object[] objectArray)
     {
         output.WriteByte(ARRAY_TYPE);
         WriteArray(objectArray, output);
     }
     else
     {
         throw new IOException("Unrecognized json object type value of type " + value.GetType() + "'");
     }
 }
Beispiel #25
0
        public void CreateReportViewer()
        {
            frmRpt = new RepForm();

            // Исходные данные в отчет только те, которые отметил пользователь (IsReport=true)
            DataInput          _DataInput   = new DataInput(c);
            List <cReportList> RepListInput = new List <cReportList>();

            foreach (KonverSywul.Class.Param par in _allParamsInput)
            {
                if (par.IsReport)
                {
                    if (_DataInput.GetType().GetProperty(par.PropertyName).GetValue(_DataInput, null) != null)
                    {
                        double d = Math.Round(Convert.ToDouble(
                                                  _DataInput.GetType().GetProperty(par.PropertyName).GetValue(
                                                      _DataInput, null)), 3);
                        RepListInput.Add(new KonverSywul.Class.cReportList(par.Description, d.ToString()));
                    }
                }
            }
            frmRpt.cReportInputBindingSource.DataSource = RepListInput;
            // Результаты расчета в отчет только те, которые отметил пользователь (IsReport=true)
            DataOutput         _DataOutput   = new DataOutput(c);
            List <cReportList> RepListOutput = new List <cReportList>();

            foreach (KonverSywul.Class.Param par in _allParamsOutput)
            {
                if (par.IsReport)
                {
                    double d = Math.Round(Convert.ToDouble(
                                              _DataOutput.GetType().GetProperty(par.PropertyName).GetValue(_DataOutput, null)), 3);
                    RepListOutput.Add(new KonverSywul.Class.cReportList(par.Description, d.ToString()));
                }
            }

            // Указать отчету источники данных
            frmRpt.cReportInputBindingSource.DataSource = RepListInput;
            frmRpt.cParamOutputBindingSource.DataSource = RepListOutput;
            // Показать окно отчета на весь экран
            frmRpt.WindowState = FormWindowState.Maximized;
            frmRpt.ShowDialog(this);
        }
Beispiel #26
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: private static void encodeStackTrace(DataOutput output, Throwable throwable) throws IOException
        private static void encodeStackTrace(DataOutput output, System.Exception throwable)
        {
            StackTraceElement[] trace = throwable.StackTrace;
            output.writeInt(trace.Length);

            foreach (StackTrace element in trace)
            {
                output.writeUTF(element.getClassName());
                output.writeUTF(element.GetFrames().ToString());

                string fileName = element.getFileName();
                output.writeBoolean(!string.ReferenceEquals(fileName, null));
                if (!string.ReferenceEquals(fileName, null))
                {
                    output.writeUTF(fileName);
                }
                output.writeInt(element.getLineNumber());
            }
        }
Beispiel #27
0
            /// <exception cref="System.IO.IOException"/>
            public virtual void WriteINodeReferenceWithCount(INodeReference.WithCount withCount
                                                             , DataOutput @out, bool writeUnderConstruction)
            {
                INode referred      = withCount.GetReferredINode();
                long  id            = withCount.GetId();
                bool  firstReferred = !referenceMap.Contains(id);

                @out.WriteBoolean(firstReferred);
                if (firstReferred)
                {
                    FSImageSerialization.SaveINode2Image(referred, @out, writeUnderConstruction, this
                                                         );
                    referenceMap[id] = withCount;
                }
                else
                {
                    @out.WriteLong(id);
                }
            }
Beispiel #28
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void write(Object _output, org.apache.lucene.store.DataOutput out) throws java.io.IOException
        public override void write(object _output, DataOutput @out)
        {
            Debug.Assert(valid(_output, true));
            if (_output is long?)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Long output = (Long) _output;
                long?output = (long?)_output;
                @out.writeVLong(output << 1);
            }
            else
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final TwoLongs output = (TwoLongs) _output;
                TwoLongs output = (TwoLongs)_output;
                @out.writeVLong((output.first << 1) | 1);
                @out.writeVLong(output.second);
            }
        }
Beispiel #29
0
 /// <summary>
 ///     NOTE: Code-generation-invoked method, method name and parameter order matters
 /// </summary>
 /// <param name="output">output</param>
 /// <param name="unitKey">unit key</param>
 /// <param name="writer">writer</param>
 /// <param name="serdeNullable">binding</param>
 /// <param name="circularBuffer">buffer</param>
 /// <param name="numDataPoints">points</param>
 /// <param name="currentBufferElementPointer">pointer</param>
 /// <param name="sizeBuf">size</param>
 /// <throws>IOException io error</throws>
 public static void Write(
     DataOutput output,
     byte[] unitKey,
     EventBeanCollatedWriter writer,
     DataInputOutputSerdeWCollation<object> serdeNullable,
     object[] circularBuffer,
     long numDataPoints,
     int currentBufferElementPointer,
     int sizeBuf)
 {
     output.WriteBoolean(circularBuffer != null);
     if (circularBuffer != null) {
         output.WriteLong(numDataPoints);
         output.WriteInt(currentBufferElementPointer);
         for (var i = 0; i < sizeBuf; i++) {
             serdeNullable.Write(circularBuffer[i], output, unitKey, writer);
         }
     }
 }
Beispiel #30
0
 public void ToData(DataOutput output)
 {
     output.WriteInt64(m_avg20DaysVol);
     output.WriteUTF(m_bondRating);
     output.WriteDouble(m_convRatio);
     output.WriteUTF(m_country);
     output.WriteDouble(m_delta);
     output.WriteInt64(m_industry);
     output.WriteInt64(m_issuer);
     output.WriteDouble(m_mktValue);
     output.WriteDouble(m_qty);
     output.WriteUTF(m_secId);
     output.WriteUTF(m_secLinks);
     output.WriteUTF(m_secType);
     output.WriteInt32(m_sharesOutstanding);
     output.WriteUTF(m_underlyer);
     output.WriteInt64(m_volatility);
     output.WriteInt32(m_pid);
 }
        private void WriteInternal(
            object[] @object,
            DataOutput output)
        {
            if (@object == null)
            {
                output.WriteInt(-1);
                return;
            }

            output.WriteInt(@object.Length);

            foreach (var obj in @object)
            {
                byte[] data = DIOSerializableObjectSerde.ObjectToByteArr(obj);
                output.WriteInt(data.Length);
                output.Write(data);
            }
        }
Beispiel #32
0
        static void SendOrderTest()
        {
            var @event = "sendorder";

            Console.WriteLine($"{nameof(SendOrderTest)} Start");
            using (var ws = new WebSocket(URL))
            {
                if (URL.StartsWith("wss", StringComparison.OrdinalIgnoreCase))
                {
                    ws.SslConfiguration.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
                }
                ws.OnMessage += (sender, e) => {
                    DataOutput <string> baseOutput = JsonConvert.DeserializeObject <DataOutput <string> >(e.Data);
                    if (baseOutput.Event == @event)
                    {
                        var parameters = baseOutput.Data == null? "": JsonConvert.SerializeObject(baseOutput.Data);
                        Console.WriteLine($"Parameters:{parameters} Result:{baseOutput.Result} Code:{baseOutput.ErrorCode} ");
                    }
                };

                SendOrderEvent baseEvent = new SendOrderEvent
                {
                    Event      = @event,
                    Parameters = new OrderInfo
                    {
                        ApiKey   = ApiKey,
                        Sign     = Sign,
                        Symbol   = "BTC/VHKD",
                        Amount   = 1,
                        IsMarket = false,
                        Price    = (decimal)1,
                        Type     = "buy"
                    }
                };
                var data = JsonConvert.SerializeObject(baseEvent);
                ws.Connect();
                Login(ws);
                Thread.Sleep(50);
                ws.Send(data);
                Console.ReadLine();
            }
            Console.WriteLine($"{nameof(SendOrderTest)} End");
        }
 public override void Write(DataOutput indexOut, bool absolute)
 {
     Debug.Assert(_upto >= 0);
     if (absolute)
     {
         indexOut.WriteVInt(_upto);
         indexOut.WriteVLong(_fp);
     }
     else if (_fp == _lastFp)
     {
         // same block
         Debug.Assert(_upto >= _lastUpto);
         var uptoDelta = _upto - _lastUpto;
         indexOut.WriteVInt(uptoDelta << 1 | 1);
     }
     else
     {
         // new block
         indexOut.WriteVInt(_upto << 1);
         indexOut.WriteVLong(_fp - _lastFp);
     }
     _lastUpto = _upto;
     _lastFp = _fp;
 }
Beispiel #34
0
 public override void writeTagContents(DataOutput dataoutput)
 {
     dataoutput.writeShort(shortValue);
 }
        public override GetOutputResult GetOutput(DataOutput _Output)
        {
            var v = ((MainStationCodeBlock)DataInputs[0].Connected.Owner.Owner).GetOutput(DataInputs[0].Connected);

            var reg = MainStationCompiler.GetRegister(2);
            MemoryStream stream = new MemoryStream();
            byte[] load = CodeInstructions.Load(reg.index, 0xffff);
            byte[] xor = CodeInstructions.Xor(v.Register.index, reg.index, reg.index);
            stream.Write(v.Code, 0, v.Code.Length);
            stream.Write(load, 0, load.Length);
            stream.Write(xor, 0, xor.Length);

            return new GetOutputResult(stream.ToArray(), reg);
        }
 public override object HandleOutput(DataOutput _Output)
 {
     return !(bool)GetInput(DataInputs[0]);
 }
Beispiel #37
0
        private static void EncodeLiterals(sbyte[] bytes, int token, int anchor, int literalLen, DataOutput @out)
        {
            @out.WriteByte((sbyte)token);

            // encode literal length
            if (literalLen >= 0x0F)
            {
                EncodeLen(literalLen - 0x0F, @out);
            }

            // encode literals
            @out.WriteBytes(bytes, anchor, literalLen);
        }
Beispiel #38
0
 private static void EncodeLen(int l, DataOutput @out)
 {
     while (l >= 0xFF)
     {
         @out.WriteByte(unchecked((sbyte)0xFF));
         l -= 0xFF;
     }
     @out.WriteByte((sbyte)l);
 }
Beispiel #39
0
            public override void Compress(byte[] bytes, int off, int len, DataOutput output)
            {
                byte[] resultArray = null;
                using (MemoryStream compressionMemoryStream = new MemoryStream())
                {
                    using (DeflateStream deflateStream = new DeflateStream(compressionMemoryStream, compressionLevel))
                    {
                        deflateStream.Write(bytes, off, len);
                    }
                    resultArray = compressionMemoryStream.ToArray();
                }

                if (resultArray.Length == 0)
                {
                    Debug.Assert(len == 0, len.ToString());
                    output.WriteVInt(0);
                    return;
                }
                else
                {
                    output.WriteVInt(resultArray.Length);
                    output.WriteBytes(resultArray, resultArray.Length);
                }
            }
Beispiel #40
0
        /// <summary>
        /// Compress <code>bytes[off:off+len]</code> into <code>out</code> using
        /// at most 16KB of memory. <code>ht</code> shouldn't be shared across threads
        /// but can safely be reused.
        /// </summary>
        public static void Compress(sbyte[] bytes, int off, int len, DataOutput @out, HashTable ht)
        {
            int @base = off;
            int end = off + len;

            int anchor = off++;

            if (len > LAST_LITERALS + MIN_MATCH)
            {
                int limit = end - LAST_LITERALS;
                int matchLimit = limit - MIN_MATCH;
                ht.Reset(len);
                int hashLog = ht.HashLog;
                PackedInts.Mutable hashTable = ht.hashTable;

                while (off <= limit)
                {
                    // find a match
                    int @ref;
                    while (true)
                    {
                        if (off >= matchLimit)
                        {
                            goto mainBreak;
                        }
                        int v = ReadInt(bytes, off);
                        int h = Hash(v, hashLog);
                        @ref = @base + (int)hashTable.Get(h);
                        Debug.Assert(PackedInts.BitsRequired(off - @base) <= hashTable.BitsPerValue);
                        hashTable.Set(h, off - @base);
                        if (off - @ref < MAX_DISTANCE && ReadInt(bytes, @ref) == v)
                        {
                            break;
                        }
                        ++off;
                    }

                    // compute match length
                    int matchLen = MIN_MATCH + CommonBytes(bytes, @ref + MIN_MATCH, off + MIN_MATCH, limit);

                    EncodeSequence(bytes, anchor, @ref, off, matchLen, @out);
                    off += matchLen;
                    anchor = off;
                mainContinue: ;
                }
            mainBreak: ;
            }

            // last literals
            int literalLen = end - anchor;
            Debug.Assert(literalLen >= LAST_LITERALS || literalLen == len);
            EncodeLastLiterals(bytes, anchor, end - anchor, @out);
        }
 public virtual GetOutputResult GetOutput(DataOutput _Output)
 {
     throw new NotImplementedException();
 }
 public override object HandleOutput(DataOutput _Output)
 {
     float a = (float)GetInput(DataInputs[0]);
     float b = (float)GetInput(DataInputs[1]);
     return a - b;
 }
 public override object HandleOutput(DataOutput _Output)
 {
     if (variables.ContainsKey(name)) return variables[name]; else return 0;
 }
 public override object HandleOutput(DataOutput _Output)
 {
     throw new NotImplementedException();
 }
 public override object HandleOutput(DataOutput _Output)
 {
     return val;
 }
 public override object HandleOutput(DataOutput _Output)
 {
     return Running;
 }
 public override GetOutputResult GetOutput(DataOutput _Output)
 {
     var reg = MainStationCompiler.GetRegister(2);
     return new GetOutputResult(CodeInstructions.Load(reg.index, val), reg);
 }
Beispiel #48
0
 /// <summary>
 /// Writes "location" of current output pointer of primary
 ///  output to different output (out) 
 /// </summary>
 public abstract void Write(DataOutput indexOut, bool absolute);
 public override GetOutputResult GetOutput(DataOutput _Output)
 {
     var reg = MainStationCompiler.GetRegister(2);
     MemoryStream stream = new MemoryStream();
     byte[] code;
     code = CodeInstructions.Load(reg.index, EventID); stream.Write(code, 0, code.Length);
     code = CodeInstructions.EPSend(DeviceID, (byte)(reg.size + 1)); stream.Write(code, 0, code.Length);
     code = CodeInstructions.Mov(0, reg.index, (byte)reg.size); stream.Write(code, 0, code.Length);
     return new GetOutputResult(stream.ToArray(), reg);
 }
            private void SaveAppropriatelySizedBloomFilter(DataOutput bloomOutput,
                FuzzySet bloomFilter, FieldInfo fieldInfo)
            {

                var rightSizedSet = _bfpf._bloomFilterFactory.Downsize(fieldInfo,
                    bloomFilter) ?? bloomFilter;

                rightSizedSet.Serialize(bloomOutput);
            }
 public override void Compress(sbyte[] bytes, int off, int len, DataOutput @out)
 {
     @out.WriteBytes(bytes, off, len);
 }
Beispiel #52
0
        private static void EncodeSequence(sbyte[] bytes, int anchor, int matchRef, int matchOff, int matchLen, DataOutput @out)
        {
            int literalLen = matchOff - anchor;
            Debug.Assert(matchLen >= 4);
            // encode token
            int token = (Math.Min(literalLen, 0x0F) << 4) | Math.Min(matchLen - 4, 0x0F);
            EncodeLiterals(bytes, token, anchor, literalLen, @out);

            // encode match dec
            int matchDec = matchOff - matchRef;
            Debug.Assert(matchDec > 0 && matchDec < 1 << 16);
            @out.WriteByte((sbyte)matchDec);
            @out.WriteByte((sbyte)((int)((uint)matchDec >> 8)));

            // encode match len
            if (matchLen >= MIN_MATCH + 0x0F)
            {
                EncodeLen(matchLen - 0x0F - MIN_MATCH, @out);
            }
        }
Beispiel #53
0
 public override void Compress(byte[] bytes, int off, int len, DataOutput @out)
 {
     LZ4.CompressHC(bytes, off, len, @out, Ht);
 }
 public override void EncodeTerm(long[] longs, DataOutput @out, FieldInfo fieldInfo, BlockTermState _state, bool absolute)
 {
     IntBlockTermState state = (IntBlockTermState)_state;
     if (absolute)
     {
         LastState = EmptyState;
     }
     longs[0] = state.DocStartFP - LastState.DocStartFP;
     if (FieldHasPositions)
     {
         longs[1] = state.PosStartFP - LastState.PosStartFP;
         if (FieldHasPayloads || FieldHasOffsets)
         {
             longs[2] = state.PayStartFP - LastState.PayStartFP;
         }
     }
     if (state.SingletonDocID != -1)
     {
         @out.WriteVInt(state.SingletonDocID);
     }
     if (FieldHasPositions)
     {
         if (state.LastPosBlockOffset != -1)
         {
             @out.WriteVLong(state.LastPosBlockOffset);
         }
     }
     if (state.SkipOffset != -1)
     {
         @out.WriteVLong(state.SkipOffset);
     }
     LastState = state;
 }
Beispiel #55
0
 /// <summary>
 /// Writes all of our bytes to the target <seealso cref="DataOutput"/>. </summary>
 public virtual void WriteTo(DataOutput @out)
 {
     foreach (byte[] block in Blocks)
     {
         @out.WriteBytes(block, 0, block.Length);
     }
 }
Beispiel #56
0
        /// <summary>
        /// Compress <code>bytes[off:off+len]</code> into <code>out</code>. Compared to
        /// <seealso cref="LZ4#compress(byte[], int, int, DataOutput, HashTable)"/>, this method
        /// is slower and uses more memory (~ 256KB per thread) but should provide
        /// better compression ratios (especially on large inputs) because it chooses
        /// the best match among up to 256 candidates and then performs trade-offs to
        /// fix overlapping matches. <code>ht</code> shouldn't be shared across threads
        /// but can safely be reused.
        /// </summary>
        public static void CompressHC(sbyte[] src, int srcOff, int srcLen, DataOutput @out, HCHashTable ht)
        {
            int srcEnd = srcOff + srcLen;
            int matchLimit = srcEnd - LAST_LITERALS;
            int mfLimit = matchLimit - MIN_MATCH;

            int sOff = srcOff;
            int anchor = sOff++;

            ht.Reset(srcOff);
            Match match0 = new Match();
            Match match1 = new Match();
            Match match2 = new Match();
            Match match3 = new Match();

            while (sOff <= mfLimit)
            {
                if (!ht.InsertAndFindBestMatch(src, sOff, matchLimit, match1))
                {
                    ++sOff;
                    continue;
                }

                // saved, in case we would skip too much
                CopyTo(match1, match0);

                while (true)
                {
                    Debug.Assert(match1.Start >= anchor);
                    if (match1.End() >= mfLimit || !ht.InsertAndFindWiderMatch(src, match1.End() - 2, match1.Start + 1, matchLimit, match1.Len, match2))
                    {
                        // no better match
                        EncodeSequence(src, anchor, match1.@ref, match1.Start, match1.Len, @out);
                        anchor = sOff = match1.End();
                        goto mainContinue;
                    }

                    if (match0.Start < match1.Start)
                    {
                        if (match2.Start < match1.Start + match0.Len) // empirical
                        {
                            CopyTo(match0, match1);
                        }
                    }
                    Debug.Assert(match2.Start > match1.Start);

                    if (match2.Start - match1.Start < 3) // First Match too small : removed
                    {
                        CopyTo(match2, match1);
                        goto search2Continue;
                    }

                    while (true)
                    {
                        if (match2.Start - match1.Start < OPTIMAL_ML)
                        {
                            int newMatchLen = match1.Len;
                            if (newMatchLen > OPTIMAL_ML)
                            {
                                newMatchLen = OPTIMAL_ML;
                            }
                            if (match1.Start + newMatchLen > match2.End() - MIN_MATCH)
                            {
                                newMatchLen = match2.Start - match1.Start + match2.Len - MIN_MATCH;
                            }
                            int correction = newMatchLen - (match2.Start - match1.Start);
                            if (correction > 0)
                            {
                                match2.Fix(correction);
                            }
                        }

                        if (match2.Start + match2.Len >= mfLimit || !ht.InsertAndFindWiderMatch(src, match2.End() - 3, match2.Start, matchLimit, match2.Len, match3))
                        {
                            // no better match -> 2 sequences to encode
                            if (match2.Start < match1.End())
                            {
                                match1.Len = match2.Start - match1.Start;
                            }
                            // encode seq 1
                            EncodeSequence(src, anchor, match1.@ref, match1.Start, match1.Len, @out);
                            anchor = sOff = match1.End();
                            // encode seq 2
                            EncodeSequence(src, anchor, match2.@ref, match2.Start, match2.Len, @out);
                            anchor = sOff = match2.End();
                            goto mainContinue;
                        }

                        if (match3.Start < match1.End() + 3) // Not enough space for match 2 : remove it
                        {
                            if (match3.Start >= match1.End()) // // can write Seq1 immediately ==> Seq2 is removed, so Seq3 becomes Seq1
                            {
                                if (match2.Start < match1.End())
                                {
                                    int correction = match1.End() - match2.Start;
                                    match2.Fix(correction);
                                    if (match2.Len < MIN_MATCH)
                                    {
                                        CopyTo(match3, match2);
                                    }
                                }

                                EncodeSequence(src, anchor, match1.@ref, match1.Start, match1.Len, @out);
                                anchor = sOff = match1.End();

                                CopyTo(match3, match1);
                                CopyTo(match2, match0);

                                goto search2Continue;
                            }

                            CopyTo(match3, match2);
                            goto search3Continue;
                        }

                        // OK, now we have 3 ascending matches; let's write at least the first one
                        if (match2.Start < match1.End())
                        {
                            if (match2.Start - match1.Start < 0x0F)
                            {
                                if (match1.Len > OPTIMAL_ML)
                                {
                                    match1.Len = OPTIMAL_ML;
                                }
                                if (match1.End() > match2.End() - MIN_MATCH)
                                {
                                    match1.Len = match2.End() - match1.Start - MIN_MATCH;
                                }
                                int correction = match1.End() - match2.Start;
                                match2.Fix(correction);
                            }
                            else
                            {
                                match1.Len = match2.Start - match1.Start;
                            }
                        }

                        EncodeSequence(src, anchor, match1.@ref, match1.Start, match1.Len, @out);
                        anchor = sOff = match1.End();

                        CopyTo(match2, match1);
                        CopyTo(match3, match2);

                        goto search3Continue;
                    search3Continue: ;
                    }
                search3Break: ;

                search2Continue: ;
                }
            search2Break: ;

            mainContinue: ;
            }
        mainBreak:

            EncodeLastLiterals(src, anchor, srcEnd - anchor, @out);
        }
Beispiel #57
0
 public override void writeTagContents(DataOutput dataoutput)
 {
     dataoutput.writeDouble(doubleValue);
 }
Beispiel #58
0
        public void write(DataOutput @out)
        {
            //serialize path, offset, length using FileSplit
            base.write(@out);

            int flags = (_hasBase ? OrcSplit.BASE_FLAG : 0) |
                (_isOriginal ? OrcSplit.ORIGINAL_FLAG : 0) |
                (_hasFooter ? OrcSplit.FOOTER_FLAG : 0);
            @out.writeByte(flags);
            @out.writeInt(deltas.Count);
            foreach (AcidInputFormat.DeltaMetaData delta in deltas)
            {
                delta.write(@out);
            }
            if (_hasFooter)
            {
                // serialize FileMetaInfo fields
                Text.writeString(@out, fileMetaInfo.compressionType);
                WritableUtils.writeVInt(@out, fileMetaInfo.bufferSize);
                WritableUtils.writeVInt(@out, fileMetaInfo.metadataSize);

                // serialize FileMetaInfo field footer
                ByteBuffer footerBuff = fileMetaInfo.footerBuffer;
                footerBuff.reset();

                // write length of buffer
                WritableUtils.writeVInt(@out, footerBuff.limit() - footerBuff.position());
                @out.write(footerBuff.array(), footerBuff.position(),
                    footerBuff.limit() - footerBuff.position());
                WritableUtils.writeVInt(@out, fileMetaInfo.writerVersion.getId());
            }
        }
Beispiel #59
0
 private static void EncodeLastLiterals(sbyte[] bytes, int anchor, int literalLen, DataOutput @out)
 {
     int token = Math.Min(literalLen, 0x0F) << 4;
     EncodeLiterals(bytes, token, anchor, literalLen, @out);
 }
Beispiel #60
0
 public override void writeTagContents(DataOutput dataoutput)
 {
 }