예제 #1
0
        public WDC3Row(DB2Reader reader, BitReader data, int recordsOffset, int id, int refId, bool isSparse, Dictionary <long, string> stringsTable)
        {
            m_reader        = reader;
            m_data          = data;
            m_recordsOffset = recordsOffset;
            m_refId         = refId;
            m_isSparse      = isSparse;
            m_stringsTable  = stringsTable;

            m_dataOffset = m_data.Offset;

            if (id != -1)
            {
                Id = id;
            }
            else
            {
                int idFieldIndex = reader.IdFieldIndex;

                m_data.Position = reader.ColumnMeta[idFieldIndex].RecordOffset;

                Id = FieldReader.GetFieldValue <int>(0, m_data, reader.Meta[idFieldIndex], reader.ColumnMeta[idFieldIndex], reader.PalletData[idFieldIndex], reader.CommonData[idFieldIndex]);

                m_idRead = true;
            }
        }
예제 #2
0
        private void RenameClassObject(IDataset dsCurrent, int standardID)
        {
            if (dsCurrent == null)
            {
                return;
            }

            Hy.Check.Define.StandardLayer standardLayer = LayerReader.GetLayerByName(dsCurrent.Name, standardID);
            //string strAliasName = Hy.Check.Rule.Helper.LayerReader.GetAliasName(dsCurrent.Name, standardID);
            if (standardLayer != null)// dsCurrent.Name != strAliasName)
            {
                ISchemaLock schemaLock = dsCurrent as ISchemaLock;
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

                IClassSchemaEdit classSchemaEdit = dsCurrent as IClassSchemaEdit;
                if (classSchemaEdit != null)
                {
                    classSchemaEdit.AlterAliasName(standardLayer.AliasName);

                    ITable tCurrent = dsCurrent as ITable;
                    if (tCurrent != null)
                    {
                        List <Hy.Check.Define.StandardField> fields = FieldReader.GetFieldsByLayer(standardLayer.ID);
                        for (int i = 0; i < fields.Count; i++)
                        {
                            if (tCurrent.Fields.FindField(fields[i].Name) > -1)
                            {
                                classSchemaEdit.AlterFieldAliasName(fields[i].Name, fields[i].AliasName);
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
		public void ParseFields_ReturnsExpectedValues(string fieldValue, string standardValue, string expected)
		{
			using (var db = new Db())
			{
				var testFieldId = ID.NewID;

				var template = new DbTemplate("Test Template") { { testFieldId, standardValue } };

				db.Add(template);

				var testItem = ItemManager.CreateItem("Test", db.GetItem(ItemIDs.ContentRoot), template.ID);

				if (expected != null)
				{
					using (new EditContext(testItem))
					{
						testItem[testFieldId] = expected;
					}
				}

				var sut = new FieldReader();

				testItem.Fields.ReadAll();

				var result = sut.ParseFields(testItem, FieldReader.FieldReadType.Versioned).FirstOrDefault(f => f.FieldId == testFieldId.Guid);

				
				if (expected == null) result.Should().BeNull();
				else result.Value.Should().Be(expected);
			}
		}
        public void CheckDateTime()
        {
            MemoryStream buffer        = new MemoryStream();
            IFieldWriter writer        = new FieldWriter(buffer);
            IFieldReader reader        = new FieldReader(buffer);
            var          referenceTime = new DateTime(1973, 6, 25, 8, 30, 12, DateTimeKind.Utc); //UTC to ensure tests are portable

            buffer.Position = 0;
            writer.Write(referenceTime);
            Assert.AreEqual(11, buffer.Position,
                            "Serialized value isn't the expected length.  Position is: {1}, expected {0}.\r\nSerialized Value: {2}",
                            buffer.Position, 11, buffer.ToArray().ToDisplayString());

            writer.Write(referenceTime.AddTicks(1));
            Assert.AreEqual(14, buffer.Position);
            writer.Write(referenceTime.AddMilliseconds(50));
            Assert.AreEqual(19, buffer.Position);
            writer.Write(referenceTime.AddHours(1));
            Assert.AreEqual(27, buffer.Position);
            writer.Write(referenceTime.AddDays(1));
            Assert.AreEqual(35, buffer.Position);
            buffer.Position = 0;
            Assert.AreEqual(referenceTime, reader.ReadDateTime());
            Assert.AreEqual(referenceTime.AddTicks(1), reader.ReadDateTime());
            Assert.AreEqual(referenceTime.AddMilliseconds(50), reader.ReadDateTime());
            Assert.AreEqual(referenceTime.AddHours(1), reader.ReadDateTime());
            Assert.AreEqual(referenceTime.AddDays(1), reader.ReadDateTime());
        }
        public void CheckUInt64Array()
        {
            MemoryStream buffer = new MemoryStream();
            IFieldWriter writer = new FieldWriter(buffer);
            IFieldReader reader = new FieldReader(buffer);

            UInt64[] array1 = new UInt64[] {};
            UInt64[] array2 = new UInt64[] { 1 };
            UInt64[] array3 = new UInt64[] { 0, 0, 0, 0, 0, 0 };
            UInt64[] array4 = new UInt64[] { 0, 1, 2, 3, 4, 5 };
            UInt64[] array5 = new UInt64[] { 0, 1, 1, 2, 2, 2 };
            UInt64[] array6 = new UInt64[] { 0, 1, 1, 2, 2, 2, 3 };
            writer.Write(array1);
            writer.Write(array2);
            writer.Write(array3);
            writer.Write(array4);
            writer.Write(array5);
            writer.Write(array6);
            buffer.Position = 0;
            array1.CompareArray(reader.ReadUInt64Array());
            array2.CompareArray(reader.ReadUInt64Array());
            array3.CompareArray(reader.ReadUInt64Array());
            array4.CompareArray(reader.ReadUInt64Array());
            array5.CompareArray(reader.ReadUInt64Array());
            array6.CompareArray(reader.ReadUInt64Array());
        }
예제 #6
0
        private string ConstructErrorInfo()
        {
            string        strInfo;
            string        strFields = "";
            StandardLayer lyr       = LayerReader.GetLayerByName(m_structInvalidPara.strFtName, this.m_StandarID);

            if (lyr == null)
            {
                return("");
            }
            int lyrID = lyr.ID;

            if (m_structInvalidPara.fieldArray.Count > 0)
            {
                for (int i = 0; i < m_structInvalidPara.fieldArray.Count; i++)
                {
                    string strTFields = FieldReader.GetNameByAliasName(m_structInvalidPara.fieldArray[i], lyrID);
                    strFields = strFields + "|" + strTFields;
                }
            }
            string strCharset;

            strCharset = m_structInvalidPara.charSetArray[0];
            for (int j = 1; j < m_structInvalidPara.charSetArray.Count; j++)
            {
                strCharset += "," + m_structInvalidPara.charSetArray[j];
            }
            strInfo = "字段 " + strFields + " 值中含有不符合要求的字符(" + strCharset + ")中的一个或多个";

            return(strInfo);
        }
예제 #7
0
        public void CheckDateTime()
        {
            MemoryStream buffer        = new MemoryStream();
            IFieldWriter writer        = new FieldWriter(buffer);
            IFieldReader reader        = new FieldReader(buffer);
            DateTime     referenceTime = DateTime.Now; //we convert to UTC during serialization, we want local time.

            buffer.Position = 0;
            writer.Write(referenceTime);
            Assert.AreEqual(12, buffer.Position);
            writer.Write(referenceTime.AddTicks(1));
            Assert.AreEqual(16, buffer.Position);
            writer.Write(referenceTime.AddMilliseconds(50));
            Assert.AreEqual(22, buffer.Position);
            writer.Write(referenceTime.AddHours(1));
            Assert.AreEqual(31, buffer.Position);
            writer.Write(referenceTime.AddDays(1));
            Assert.AreEqual(40, buffer.Position);
            buffer.Position = 0;
            Assert.AreEqual(referenceTime, reader.ReadDateTime());
            Assert.AreEqual(referenceTime.AddTicks(1), reader.ReadDateTime());
            Assert.AreEqual(referenceTime.AddMilliseconds(50), reader.ReadDateTime());
            Assert.AreEqual(referenceTime.AddHours(1), reader.ReadDateTime());
            Assert.AreEqual(referenceTime.AddDays(1), reader.ReadDateTime());
        }
        private uint DecompressUInt(int offset)
        {
            uint length = 0;
            byte first  = _stream.GetByte(offset);

            // bytes are read in reverse order to get back to little endian format for windows, these
            // numbers are stored in big endian format.

            if (first <= 127)
            {
                length = _stream.GetByte(offset) & CompressedByteMask;
            }
            else if (first <= 191)
            {
                byte[] toRead = new byte[2];
                toRead[0] = _stream.GetByte(offset + 1);
                toRead[1] = _stream.GetByte(offset + 0);
                length    = FieldReader.ToUInt32(toRead, 0, 2) & CompressedShortMask;
            }
            else if (first <= 223)
            {
                byte[] toRead = new byte[4];
                toRead[0] = _stream.GetByte(offset + 3);
                toRead[1] = _stream.GetByte(offset + 2);
                toRead[2] = _stream.GetByte(offset + 1);
                toRead[3] = _stream.GetByte(offset + 0);
                length    = FieldReader.ToUInt32(toRead, 0, 4) & CompressedIntMask;
            }

            return(length);
        }
예제 #9
0
        public void Can_append()
        {
            const string fileName = "c:\\temp\\resin_tests\\FieldFileTests\\Can_append\\0.fld";

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            using (var writer = new FieldFile(fileName))
            {
                writer.Write(0, "Hello", 0);
            }

            var terms = FieldReader.Load(fileName).GetAllTokens();

            Assert.AreEqual(1, terms.Count);
            Assert.IsTrue(terms.Contains("Hello"));
            Assert.IsFalse(terms.Contains("World!"));

            using (var writer = new FieldFile(fileName))
            {
                writer.Write(0, "World!", 1);
            }

            terms = FieldReader.Load(fileName).GetAllTokens();

            Assert.AreEqual(2, terms.Count);
            Assert.IsTrue(terms.Contains("Hello"));
            Assert.IsTrue(terms.Contains("World!"));
        }
예제 #10
0
        public WDC1Row(WDC1Reader reader, BitReader data, int id, int refId, Dictionary <long, string> stringsTable)
        {
            m_reader = reader;
            m_data   = data;
            m_refId  = refId;

            m_dataOffset = m_data.Offset;

            m_fieldMeta    = reader.Meta;
            m_columnMeta   = reader.ColumnMeta;
            m_palletData   = reader.PalletData;
            m_commonData   = reader.CommonData;
            m_stringsTable = stringsTable;

            if (id != -1)
            {
                m_id = id;
            }
            else
            {
                int idFieldIndex = reader.IdFieldIndex;

                m_data.Position = m_columnMeta[idFieldIndex].RecordOffset;

                m_id = FieldReader.GetFieldValue <int>(0, m_data, m_fieldMeta[idFieldIndex], m_columnMeta[idFieldIndex], m_palletData[idFieldIndex], m_commonData[idFieldIndex]);
            }
        }
예제 #11
0
 public Enumerator(DbQueryExecutor executor, DbDataReader reader, Func <FieldReader, T> projector)
 {
     this.executor    = executor;
     this.dataReader  = reader;
     this.fieldReader = new DbFieldReader(executor, reader);
     this.projector   = projector;
 }
예제 #12
0
        public void CheckBoolArray()
        {
            MemoryStream buffer = new MemoryStream();
            IFieldWriter writer = new FieldWriter(buffer);
            IFieldReader reader = new FieldReader(buffer);

            bool[][] list = new bool[][] { new bool[0], new bool[1], new bool[2], new bool[31], new bool[32], new bool[33],
                                           new bool[63], new bool[64], new bool[65], new bool[127], new bool[128], new bool[129] };
            Random rand     = new Random(0);
            int    bitCount = 0;

            for (int i = 0; i < list.Length; i++)
            {
                bool[] current = list[i];
                bitCount += current.Length;
                for (int j = 0; j < current.Length; j++)
                {
                    current[j] = rand.NextDouble() >= 0.5;
                }
                writer.Write(current);
            }

            Assert.AreEqual(675, bitCount);
            Assert.AreEqual(buffer.Length, buffer.Position);
            buffer.Position = 0;
            for (int i = 0; i < list.Length; i++)
            {
                bool[] current = list[i];
                bool[] actual  = reader.ReadBoolArray();
                CompareArray(current, actual);
            }
            Assert.AreEqual(buffer.Length, buffer.Position);
        }
예제 #13
0
        public void CheckDoubleArray()
        {
            MemoryStream buffer = new MemoryStream();
            IFieldWriter writer = new FieldWriter(buffer);
            IFieldReader reader = new FieldReader(buffer);

            Double[] array1 = new Double[] {};
            Double[] array2 = new Double[] { 1 };
            Double[] array3 = new Double[] { 0, 0, 0, 0, 0, 0 };
            Double[] array4 = new Double[] { 0, 1, 2, 3, 4, 5 };
            Double[] array5 = new Double[] { 0, 1, 1, 2, 2, 2 };
            Double[] array6 = new Double[] { 0, 1, 1, 2, 2, 2, 3 };
            writer.Write(array1);
            writer.Write(array2);
            writer.Write(array3);
            writer.Write(array4);
            writer.Write(array5);
            writer.Write(array6);
            buffer.Position = 0;
            CompareArray(array1, reader.ReadDoubleArray());
            CompareArray(array2, reader.ReadDoubleArray());
            CompareArray(array3, reader.ReadDoubleArray());
            CompareArray(array4, reader.ReadDoubleArray());
            CompareArray(array5, reader.ReadDoubleArray());
            CompareArray(array6, reader.ReadDoubleArray());
        }
예제 #14
0
        public void CheckString()
        {
            IFieldWriter writer = new FieldWriter();

            writer.Write((string)null);
            Assert.AreEqual(2, writer.Position, "Expected position ");

            writer.Write("");
            Assert.AreEqual(3, writer.Position, "Expected position ");

            writer.Write(" ");
            Assert.AreEqual(5, writer.Position, "Expected position ");

            writer.Write("Hello");
            Assert.AreEqual(11, writer.Position, "Expected position ");

            writer.Write("Hello");
            Assert.AreEqual(17, writer.Position, "Expected position ");

            writer.Write("Hi");
            Assert.AreEqual(20, writer.Position, "Expected position ");

            IFieldReader reader = new FieldReader(writer.ToArray());

            Assert.AreEqual(null, reader.ReadString(), "Expected string ");
            Assert.AreEqual("", reader.ReadString(), "Expected string ");
            Assert.AreEqual(" ", reader.ReadString(), "Expected string ");
            Assert.AreEqual("Hello", reader.ReadString(), "Expected string ");
            Assert.AreEqual("Hello", reader.ReadString(), "Expected string2 ");
            Assert.AreEqual("Hi", reader.ReadString(), "Expected string ");
        }
        /// <summary>
        /// Initialises a new instance of the ParamMetadataTableRow class
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        public ParamMetadataTableRow(byte[] contents, Offset offset, byte sizeOfStringIndex)
        {
            this.FileOffset = offset;

            _flags    = (ParamAttributeFlags)FieldReader.ToUInt16(contents, offset.Shift(2));
            _sequence = FieldReader.ToUInt16(contents, offset.Shift(2));
            _name     = new StringIndex(contents, sizeOfStringIndex, offset);
        }
예제 #16
0
 public StringIndex(byte[] fileContents, byte sizeOfStringIndexes, Offset offset)
 {
     Value = FieldReader.ToUInt32(
         fileContents,
         offset.Shift(sizeOfStringIndexes),
         sizeOfStringIndexes
         );
 }
예제 #17
0
 public BlobIndex(byte sizeOfBlobIndexes, byte[] fileContents, Signatures.Signatures signitureType, Offset offset)
 {
     SignitureType = signitureType;
     Value         = FieldReader.ToUInt32(
         fileContents,
         offset.Shift(sizeOfBlobIndexes),
         sizeOfBlobIndexes);
 }
        /// <summary>
        /// Initialises a new instance of the FieldRVAMetadataTableRow class
        /// </summary>
        /// <param name="content">The content of the file</param>
        /// <param name="offset">The offset for the current row</param>
        public FieldRVAMetadataTableRow(byte[] content, Offset offset, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            byte sizeOfFieldIndex = indexDetails.GetSizeOfIndex(MetadataTables.Field);

            _rva        = FieldReader.ToUInt32(content, offset.Shift(4));
            _fieldIndex = new Index(content, offset, sizeOfFieldIndex);
        }
예제 #19
0
        public bool CreateReader <T>(MessageField field, out FieldReader <T> reader)
        {
            DynamicMethod builder = Message.BeginReadMethod(_property.DeclaringType, typeof(T));

            AppendRead(builder.GetILGenerator(), field);
            reader = Message.EndMethod <FieldReader <T> >(builder);

            return(true);
        }
예제 #20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: @Override public Object getFieldValue(net.sf.jasperreports.engine.JRField jrField) throws net.sf.jasperreports.engine.JRException
        public override object getFieldValue(JRField jrField)
        {
            FieldReader reader = fieldReaders[jrField.Name];

            if (reader == null)
            {
                throw new JRRuntimeException("No filed reader for " + jrField.Name);
            }
            return(reader.getFieldValue(currentReturnValue));
        }
예제 #21
0
        internal Func <FieldReader, object> GetRowReader()
        {
            ParameterExpression reader = Expression.Parameter(typeof(FieldReader));

            var tupleConstructor = TupleReflection.TupleChainConstructor(
                table.Columns.Values.Select((c, i) => FieldReader.GetExpression(reader, i, GetColumnType(c)))
                );

            return(Expression.Lambda <Func <FieldReader, object> >(tupleConstructor, reader).Compile());
        }
예제 #22
0
        /// <summary>
        /// Initialises a new instance of the PropertyMetadataTableRow class
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of this row</param>
        public PropertyMetadataTableRow(byte[] contents, Offset offset, IIndexDetails indexDetails)
        {
            FileOffset = offset;

            byte sizeOfBlobIndex   = indexDetails.GetSizeOfBlobIndex();
            byte sizeOfStringIndex = indexDetails.GetSizeOfStringIndex();

            _attributes = (PropertyAttributes)FieldReader.ToUInt16(contents, offset.Shift(2));
            _nameIndex  = new StringIndex(contents, sizeOfStringIndex, offset);
            _typeIndex  = FieldReader.ToUInt32(contents, offset.Shift(sizeOfBlobIndex), sizeOfBlobIndex);
        }
예제 #23
0
        /// <summary>
        /// Initialises a new instance of the FileMetadataTableRow class
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        public FileMetadataTableRow(byte[] contents, Offset offset, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            byte sizeOfStringIndex = indexDetails.GetSizeOfStringIndex();
            byte sizeOfBlobIndex   = indexDetails.GetSizeOfBlobIndex();

            _flags     = (FileAttributes)FieldReader.ToUInt32(contents, offset.Shift(4));
            _nameIndex = new StringIndex(contents, sizeOfStringIndex, offset);
            _hashValue = FieldReader.ToUInt32(contents, offset.Shift(sizeOfBlobIndex), sizeOfBlobIndex);
        }
        public Expression GetColumnExpression(Expression row, Alias alias, string name, Type type)
        {
            if (alias != Alias)
            {
                throw new InvalidOperationException("alias '{0}' not found".FormatWith(alias));
            }

            int position = Positions.GetOrThrow(name, "column name '{0}' not found in alias '" + alias + "'");

            return(FieldReader.GetExpression(Expression.Property(row, miReader), position, type));
        }
    public static void Test()
    {
        var fieldReader = new FieldReader <TestClass>();
        var obj1        = new TestClass(12, "Angie");
        var obj2        = new TestClass(42, "Bob");

        Debug.WriteLine("Angie:");
        fieldReader.ShowFieldValuesforObject(obj1);
        Debug.WriteLine("Bob:");
        fieldReader.ShowFieldValuesforObject(obj2);
    }
        /// <summary>
        /// Initialises a new instance of the FieldMetadataTableRow
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        public FieldMetadataTableRow(byte[] contents, Offset offset, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            byte sizeOfStringIndex = indexDetails.GetSizeOfStringIndex();
            byte sizeOfBlobIndex   = indexDetails.GetSizeOfBlobIndex();

            _flags          = (FieldAttributes)FieldReader.ToUInt16(contents, offset.Shift(2));
            _nameIndex      = new StringIndex(contents, sizeOfStringIndex, offset);
            _signitureIndex = new BlobIndex(sizeOfBlobIndex, contents, Reflection.Signatures.Signatures.Field, offset);
        }
예제 #27
0
        private static void CheckDouble(double expectedValue, int expectedSize)
        {
            IFieldWriter writer = new FieldWriter();

            writer.Write(expectedValue);

            IFieldReader reader      = new FieldReader(writer.ToArray());
            double       actualValue = reader.ReadDouble();

            Assert.AreEqual(expectedValue, actualValue, "Expected deserialized value ");
            Assert.AreEqual(expectedSize, writer.Position, "Unexpected size for {0} ", expectedValue);
        }
예제 #28
0
        /// <summary>
        /// Initialises a new instance of the InterfaceImplMetadataTableRow
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of this row</param>
        public InterfaceImplMetadataTableRow(byte[] contents, Offset offset, ICodedIndexResolver resolver, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            int  sizeOfCodedIndex   = resolver.GetSizeOfIndex(CodedIndexes.TypeDefOrRef);
            byte sizeOfTypeDefIndex = indexDetails.GetSizeOfIndex(MetadataTables.TypeDef);

            _class     = new Index(contents, offset, sizeOfTypeDefIndex);
            _interface = resolver.Resolve(CodedIndexes.TypeDefOrRef,
                                          FieldReader.ToUInt32(contents, offset.Shift(sizeOfCodedIndex), sizeOfCodedIndex)
                                          );
        }
예제 #29
0
        /// <summary>
        /// Initialises a new instance of the ModuleMetadataTableRow class
        /// </summary>
        /// <param name="contents">The byte contents of the file</param>
        /// <param name="offset">The offset of this row</param>
        public ModuleMetadataTableRow(byte[] contents, Offset offset, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            byte sizeOfGuidIndex = indexDetails.GetSizeOfGuidIndex();

            _generation = FieldReader.ToUInt16(contents, offset.Shift(2));
            _name       = new StringIndex(contents, indexDetails.GetSizeOfStringIndex(), offset);
            _mvid       = FieldReader.ToInt32(contents, offset.Shift(sizeOfGuidIndex), sizeOfGuidIndex);
            _encId      = FieldReader.ToInt32(contents, offset.Shift(sizeOfGuidIndex), sizeOfGuidIndex);
            _encBaseId  = FieldReader.ToInt32(contents, offset.Shift(sizeOfGuidIndex), sizeOfGuidIndex);
        }
        /// <summary>
        /// Initialises a new instance of the MethodSpecMetadataTableRow class
        /// </summary>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        public MethodSpecMetadataTableRow(byte[] contents, Offset offset, ICodedIndexResolver resolver, IIndexDetails indexDetails)
        {
            this.FileOffset = offset;

            int  sizeOfCodedIndex = resolver.GetSizeOfIndex(CodedIndexes.MethodDefOrRef);
            byte sizeOfBlobIndex  = indexDetails.GetSizeOfBlobIndex();

            _method = resolver.Resolve(CodedIndexes.MethodDefOrRef,
                                       FieldReader.ToUInt32(contents, offset.Shift(sizeOfCodedIndex), sizeOfCodedIndex)
                                       );
            _instantiation = FieldReader.ToUInt32(contents, offset.Shift(sizeOfBlobIndex), sizeOfBlobIndex);
        }
예제 #31
0
        /// <summary>
        /// Initialises a new instance of the GenericParamConstraintMetadataTableRow class
        /// </summary>
        /// <param name="stream">The stream containing the metadata</param>
        /// <param name="contents">The contents of the file</param>
        /// <param name="offset">The offset of the current row</param>
        public GenericParamConstraintMetadataTableRow(byte[] contents, Offset offset, ICodedIndexResolver resolver, IIndexDetails indexDetails)
        {
            FileOffset = offset;

            int  sizeOfCodedIndex        = resolver.GetSizeOfIndex(CodedIndexes.TypeDefOrRef);
            byte sizeOfGenericParamIndex = indexDetails.GetSizeOfIndex(MetadataTables.GenericParam);

            _owner      = new Index(contents, offset, sizeOfGenericParamIndex);
            _constraint = resolver.Resolve(
                CodedIndexes.TypeDefOrRef,
                FieldReader.ToUInt32(contents, offset.Shift(sizeOfCodedIndex), sizeOfCodedIndex)
                );
        }
예제 #32
0
                public SegmentTermsEnum(FieldReader fieldReader, BlockTermsReader blockTermsReader)
                {
                    _fieldReader = fieldReader;
                    _blockTermsReader = blockTermsReader;

                    _input = (IndexInput) _blockTermsReader._input.Clone();
                    _input.Seek(_fieldReader._termsStartPointer);
                    _indexEnum = _blockTermsReader._indexReader.GetFieldEnum(_fieldReader._fieldInfo);
                    _doOrd = _blockTermsReader._indexReader.SupportsOrd;
                    _fieldTerm.Field = _fieldReader._fieldInfo.Name;
                    _state = _blockTermsReader._postingsReader.NewTermState();
                    _state.TotalTermFreq = -1;
                    _state.Ord = -1;

                    _termSuffixes = new byte[128];
                    _docFreqBytes = new byte[64];
                    _longs = new long[_fieldReader._longsSize];
                }
예제 #33
0
        public void ExecuteDataReaderDependency(SqlPreCommandSimple preCommand, OnChangeEventHandler change, Action reconect, Action<FieldReader> forEach, CommandType commandType)
        {
            bool reconected = false; 
            retry:
            try
            {
                using (SqlConnection con = EnsureConnection())
                using (SqlCommand cmd = NewCommand(preCommand, con, commandType))
                using (HeavyProfiler.Log("SQL-Dependency"))
                using (HeavyProfiler.Log("SQL", () => preCommand.PlainSql()))
                {
                    try
                    {
                        if (change != null)
                        {
                            SqlDependency dep = new SqlDependency(cmd);
                            dep.OnChange += change;
                        }

                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            FieldReader fr = new FieldReader(reader);
                            int row = -1;
                            try
                            {
                                while (reader.Read())
                                {
                                    row++;
                                    forEach(fr);
                                }
                            }
                            catch (Exception ex)
                            {
                                FieldReaderException fieldEx = fr.CreateFieldReaderException(ex);
                                fieldEx.Command = preCommand;
                                fieldEx.Row = row;
                                throw fieldEx;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        var nex = HandleException(ex, preCommand);
                        if (nex == ex)
                            throw;

                        throw nex;
                    }
                }
            }
            catch (InvalidOperationException ioe)
            {
                if (ioe.Message.Contains("SqlDependency.Start()") && !reconected)
                {
                    reconect();

                    reconected = true;

                    goto retry;
                }

                throw;
            }
        }
예제 #34
0
            internal virtual void StartBlock(FieldReader.SegmentTermsEnum.Frame frame, bool isFloor)
            {
                TotalBlockCount++;
                if (isFloor)
                {
                    if (frame.Fp == frame.FpOrig)
                    {
                        FloorBlockCount++;
                    }
                    FloorSubBlockCount++;
                }
                else
                {
                    NonFloorBlockCount++;
                }

                if (BlockCountByPrefixLen.Length <= frame.Prefix)
                {
                    BlockCountByPrefixLen = ArrayUtil.Grow(BlockCountByPrefixLen, 1 + frame.Prefix);
                }
                BlockCountByPrefixLen[frame.Prefix]++;
                StartBlockCount++;
                TotalBlockSuffixBytes += frame.SuffixesReader.Length();
                TotalBlockStatsBytes += frame.StatsReader.Length();
            }
예제 #35
0
 internal virtual void EndBlock(FieldReader.SegmentTermsEnum.Frame frame)
 {
     int termCount = frame.IsLeafBlock ? frame.EntCount : frame.State.TermBlockOrd;
     int subBlockCount = frame.EntCount - termCount;
     TotalTermCount += termCount;
     if (termCount != 0 && subBlockCount != 0)
     {
         MixedBlockCount++;
     }
     else if (termCount != 0)
     {
         TermsOnlyBlockCount++;
     }
     else if (subBlockCount != 0)
     {
         SubBlocksOnlyBlockCount++;
     }
     else
     {
         throw new InvalidOperationException();
     }
     EndBlockCount++;
     long otherBytes = frame.FpEnd - frame.Fp - frame.SuffixesReader.Length() - frame.StatsReader.Length();
     Debug.Assert(otherBytes > 0, "otherBytes=" + otherBytes + " frame.fp=" + frame.Fp + " frame.fpEnd=" + frame.FpEnd);
     TotalBlockOtherBytes += otherBytes;
 }