コード例 #1
0
 public TestRequestInterceptor(string name, string testId,
                               Codec codec, int slotId) {
     m_name = name;
     m_testId = testId;
     m_codec = codec;
     m_slotId = slotId;
 }
コード例 #2
0
 public Bitstream (Page page)
 {
    if (page == null)
       throw new ArgumentNullException ("page");
    
    // Assume that the first packet is completely enclosed. This should be
    // sufficient for codec recognition.
    _codec = Codec.GetCodec (page.Packets [0]);
    
    _first_absolute_granular_position = page.Header.AbsoluteGranularPosition;
 }
コード例 #3
0
        public override void SetUp()
        {
            base.SetUp();

            // for now its SimpleText vs Lucene46(random postings format)
            // as this gives the best overall coverage. when we have more
            // codecs we should probably pick 2 from Codec.availableCodecs()

            LeftCodec = Codec.ForName("SimpleText");
            RightCodec = new RandomCodec(Random());

            LeftDir = NewDirectory();
            RightDir = NewDirectory();

            long seed = Random().Next();

            // must use same seed because of random payloads, etc
            int maxTermLength = TestUtil.NextInt(Random(), 1, IndexWriter.MAX_TERM_LENGTH);
            MockAnalyzer leftAnalyzer = new MockAnalyzer(new Random((int)seed));
            leftAnalyzer.MaxTokenLength = maxTermLength;
            MockAnalyzer rightAnalyzer = new MockAnalyzer(new Random((int)seed));
            rightAnalyzer.MaxTokenLength = maxTermLength;

            // but these can be different
            // TODO: this turns this into a really big test of Multi*, is that what we want?
            IndexWriterConfig leftConfig = NewIndexWriterConfig(TEST_VERSION_CURRENT, leftAnalyzer);
            leftConfig.SetCodec(LeftCodec);
            // preserve docids
            leftConfig.SetMergePolicy(NewLogMergePolicy());

            IndexWriterConfig rightConfig = NewIndexWriterConfig(TEST_VERSION_CURRENT, rightAnalyzer);
            rightConfig.SetCodec(RightCodec);
            // preserve docids
            rightConfig.SetMergePolicy(NewLogMergePolicy());

            // must use same seed because of random docvalues fields, etc
            RandomIndexWriter leftWriter = new RandomIndexWriter(new Random((int)seed), LeftDir, leftConfig);
            RandomIndexWriter rightWriter = new RandomIndexWriter(new Random((int)seed), RightDir, rightConfig);

            int numdocs = AtLeast(100);
            CreateRandomIndex(numdocs, leftWriter, seed);
            CreateRandomIndex(numdocs, rightWriter, seed);

            LeftReader = MaybeWrapReader(leftWriter.Reader);
            leftWriter.Dispose();
            RightReader = MaybeWrapReader(rightWriter.Reader);
            rightWriter.Dispose();

            // check that our readers are valid
            TestUtil.CheckReader(LeftReader);
            TestUtil.CheckReader(RightReader);

            Info = "left: " + LeftCodec.ToString() + " / right: " + RightCodec.ToString();
        }
コード例 #4
0
		public EncryptionSettings(byte[] encryptionKey, Type symmetricAlgorithmType, bool encryptIndexes,int preferedEncryptionKeyBitsSize)
		{
			EncryptionKey = encryptionKey;
			this.encryptIndexes = encryptIndexes;

			Codec = new Codec(this);

			algorithmType = symmetricAlgorithmType;
			this.preferedEncryptionKeyBitsSize = preferedEncryptionKeyBitsSize;
			algorithmGenerator = Expression.Lambda<Func<SymmetricAlgorithm>>
				(Expression.New(symmetricAlgorithmType)).Compile();
		}
コード例 #5
0
ファイル: QBoxTrackFormat.cs プロジェクト: ctapang/GPUCyclops
        /// <summary>
        /// Constructor accepting a list of qboxes as input.
        /// (For reading a QBox file.)
        /// FIXME: we need to pick up the rest of the tracks (other than the first one)
        /// </summary>
        /// <param name="qboxes"></param>
        public QBoxTrackFormat(List<QBox> qboxes, ushort trackID, MediaTimeUtils mediaTime)
            : this()
        {
            _qBoxes = new List<QBox>();
              qboxes.ForEach(delegate(QBox q) { if (q.mSampleStreamId == trackID) _qBoxes.Add(q); });
              if (_qBoxes.Count == 0)
            throw new Exception(string.Format("There is no track with ID = {0}", trackID));

              _mediaTime = mediaTime;

              HasIFrameBoxes = _qBoxes.Any(box => (((uint) box.mSampleFlags & QBox.QBOX_SAMPLE_FLAGS_SYNC_POINT) != 0));

              firstQB = _qBoxes[0];
              if (firstQB.mSampleStreamType == QBox.QBOX_SAMPLE_TYPE_H264) {
            Codec = new Codec(CodecTypes.Video);
            firstQB = _qBoxes.First(q => ((q.mSampleFlags & QBox.QBOX_SAMPLE_FLAGS_CONFIGURATION_INFO) != 0u));
            if (firstQB.mSample.v != null) {
              this.videoMetaSample = firstQB.mSample;
              seqParamSetData = firstQB.mSample.v.sps;
              picParamSetData = firstQB.mSample.v.pps;
              Codec.PrivateCodecData = this.VideoCodecPrivateData;
            }
            else
              Codec.PrivateCodecData = ToHexString(firstQB.mSample.privateCodecData);
              }
              else if (firstQB.mSampleStreamType == QBox.QBOX_SAMPLE_TYPE_AAC) {
            Codec = new Codec(CodecTypes.Audio);
            firstQB =
              _qBoxes.First(q => ((q.mSample.a != null) && ((q.mSampleFlags & QBox.QBOX_SAMPLE_FLAGS_META_INFO) != 0u)) ||
                             ((q.mSample.qmed != null) && ((q.mSampleFlags & QBox.QBOX_SAMPLE_FLAGS_QMED_PRESENT) != 0u)));
            this.audioMetaSample = firstQB.mSample;

            if (audioMetaSample.privateCodecData != null)
              Codec.PrivateCodecData = ToHexString(audioMetaSample.privateCodecData);
            else {
            #if USE_WAVEFORMATEX
              GetAudioPrivateCodecDataFromWaveFormatEx();
            #else
              GetAudioPrivateCodecDataAdHoc();
            #endif
            }
              }
              else if (firstQB.mSampleStreamType == QBox.QBOX_SAMPLE_TYPE_JPEG) {
            Codec = new Codec(CodecTypes.Video);
            if (firstQB.mSample.privateCodecData != null)
              Codec.PrivateCodecData = ToHexString(firstQB.mSample.privateCodecData);
              }
              else
            throw new Exception(string.Format("QBox sample type not implemented: {0}", firstQB.mSampleStreamType));
        }
コード例 #6
0
 public HandlerReferenceBox(MediaBox inParent, Codec codec)
     : this(inParent)
 {
     base.Version = 0;
       if (codec.CodecType == CodecTypes.Audio)
       {
     HandlerType = "soun";
     Name = "Sound Media Handler";
       }
       else if (codec.CodecType == CodecTypes.Video)
       {
     HandlerType = "vide";
     Name = "Video Media Handler";
       }
       else HandlerType = "unkn"; // unknown
       this.Size += (ulong)Name.Length + 1UL;
 }
コード例 #7
0
ファイル: SegmentMerger.cs プロジェクト: paulirwin/lucene.net
 // note, just like in codec apis Directory 'dir' is NOT the same as segmentInfo.dir!!
 public SegmentMerger(IList<AtomicReader> readers, SegmentInfo segmentInfo, InfoStream infoStream, Directory dir, int termIndexInterval, MergeState.CheckAbort checkAbort, FieldInfos.FieldNumbers fieldNumbers, IOContext context, bool validate)
 {
     // validate incoming readers
     if (validate)
     {
         foreach (AtomicReader reader in readers)
         {
             reader.CheckIntegrity();
         }
     }
     MergeState = new MergeState(readers, segmentInfo, infoStream, checkAbort);
     Directory = dir;
     this.TermIndexInterval = termIndexInterval;
     this.Codec = segmentInfo.Codec;
     this.Context = context;
     this.FieldInfosBuilder = new FieldInfos.Builder(fieldNumbers);
     MergeState.SegmentInfo.DocCount = SetDocMaps();
 }
コード例 #8
0
ファイル: CodecFormat.cs プロジェクト: EnergonV/BestCS
        /// <summary>
        /// Gets all media formats for a codec.
        /// </summary>
        /// <param name="codec">Codec</param>
        /// <returns>All media formats for the specified codec</returns>
        public static CodecFormat[] GetMediaFormats(Codec codec)
        {
            var codecInfo = codec.CodecInformation;

            Guid mediaType = codec.MediaType;
            int formatCount;
            codecInfo.GetCodecFormatCount(mediaType, codec.Index, out formatCount);

            var formats = new CodecFormat[formatCount];
            for (int i = 0; i < formatCount; i++)
            {
                IWMStreamConfig config;
                codecInfo.GetCodecFormat(mediaType , codec.Index,  i, out config);
                WMStreamConfig stream = new WMStreamConfig(config);
                formats[i] = new CodecFormat(codec, stream, (int)i);
            }

            return formats;
        }
コード例 #9
0
        public virtual void TestUpdateOldSegments()
        {
            Codec[] oldCodecs = new Codec[] { new Lucene40RWCodec(), new Lucene41RWCodec(), new Lucene42RWCodec(), new Lucene45RWCodec() };
            Directory dir = NewDirectory();

            bool oldValue = OLD_FORMAT_IMPERSONATION_IS_ACTIVE;
            // create a segment with an old Codec
            IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
            conf.SetCodec(oldCodecs[Random().Next(oldCodecs.Length)]);
            OLD_FORMAT_IMPERSONATION_IS_ACTIVE = true;
            IndexWriter writer = new IndexWriter(dir, conf);
            Document doc = new Document();
            doc.Add(new StringField("id", "doc", Store.NO));
            doc.Add(new BinaryDocValuesField("f", ToBytes(5L)));
            writer.AddDocument(doc);
            writer.Dispose();

            conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
            writer = new IndexWriter(dir, conf);
            writer.UpdateBinaryDocValue(new Term("id", "doc"), "f", ToBytes(4L));
            OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false;
            try
            {
                writer.Dispose();
                Assert.Fail("should not have succeeded to update a segment written with an old Codec");
            }
            catch (System.NotSupportedException e)
            {
                writer.Rollback();
            }
            finally
            {
                OLD_FORMAT_IMPERSONATION_IS_ACTIVE = oldValue;
            }

            dir.Dispose();
        }
コード例 #10
0
 /// <summary>
 /// creates the tagged codeset component to insert into an IOR
 /// </summary>
 /// <returns></returns>
 internal static TaggedComponent CreateCodesetComponent(Codec codec, 
                                                        CharSet nativeCharSet,
                                                        WCharSet nativeWCharSet) {
     return CreateCodesetComponent(codec, (int)nativeCharSet,
                                   (int)nativeWCharSet);
 }
コード例 #11
0
 /// <summary>
 /// creates the tagged codeset component to insert into an IOR
 /// </summary>
 /// <returns></returns>
 private static TaggedComponent CreateCodesetComponent(Codec codec, 
                                                       int nativeCharSet,
                                                       int nativeWCharSet) {
     Array wCharSets = Enum.GetValues(s_wCharSetType);
     Array charSets = Enum.GetValues(s_charSetType);
     int[] wCharSetCodes = new int[wCharSets.Length];
     int[] charSetCodes = new int[charSets.Length];
     for (int i = 0; i < wCharSets.Length; i++) { // Array.CopyTo doesn't work with mono for this case
         wCharSetCodes[i] = (int)wCharSets.GetValue(i);
     }
     for (int i = 0; i < charSets.Length; i++) { // Array.CopyTo doesn't work with mono for this case
         charSetCodes[i] = (int)charSets.GetValue(i);
     }
     Services.CodeSetComponentData codeSetCompData =
         new Services.CodeSetComponentData(nativeCharSet,
                                           charSetCodes,
                                           nativeWCharSet,
                                           wCharSetCodes);            
     return new TaggedComponent(TAG_CODE_SETS.ConstVal,
                                codec.encode_value(codeSetCompData));
 }        
コード例 #12
0
 /// <summary>
 /// returns the code set component data or null if not found
 /// </summary>
 internal static object /* CodeSetComponentData */ FindCodeSetComponent(IIorProfile profile, Codec codec) {
     TaggedComponentList list = profile.TaggedComponents;
     object result = 
         list.GetComponentData(TAG_CODE_SETS.ConstVal, codec,
                               CodeSetComponentData.TypeCode);
     if (result != null) {
         return (CodeSetComponentData)result;
     }            
     return null;
 }        
コード例 #13
0
 /// <summary>
 /// creates the tagged codeset component to insert into an IOR
 /// </summary>
 /// <returns></returns>
 internal static TaggedComponent CreateDefaultCodesetComponent(Codec codec) {
     return CreateCodesetComponent(codec, 
                                   Services.CodeSetService.DefaultCharSet,
                                   Services.CodeSetService.DefaultWCharSet);
 }
コード例 #14
0
        public static void Run()
        {
            var st = new Solution297();

            Console.WriteLine("Start: {0}", DateTime.Now);

            TreeNode root = new TreeNode(0);
            root.left = new TreeNode(1);
            // root.right = new TreeNode(2);
            //root.left.right = new TreeNode(3);
            //root.right.left = new TreeNode(4);

            Codec codec = new Codec();
            var str = codec.serialize(root);
            Console.WriteLine(str);
            TreeNode tn = codec.deserialize(str);

            Console.WriteLine("End: {0}", DateTime.Now);
        }
コード例 #15
0
ファイル: QBoxTrackFormat.cs プロジェクト: ctapang/GPUCyclops
 /// <summary>
 /// QBoxTrackFormat
 /// Constructor to use when writing out to a stream.
 /// </summary>
 /// <param name="trackInfo"></param>
 public QBoxTrackFormat(IsochronousTrackInfo trackInfo)
     : this()
 {
     _qBoxes = new List<QBox>();
       firstQB = new QBox(trackInfo);
       CodecTypes codecType = (trackInfo.HandlerType == "Audio")
                        ? CodecTypes.Audio
                        : (trackInfo.HandlerType == "Video") ? CodecTypes.Video : CodecTypes.Unknown;
       Codec = new Codec(codecType);
       Codec.PrivateCodecData = trackInfo.CodecPrivateData;
       DurationIn100NanoSecs = trackInfo.DurationIn100NanoSecs;
 }
コード例 #16
0
ファイル: IOR.cs プロジェクト: JnS-Software-LLC/iiop-net
 public void SetUp()
 {
     m_serFactory =
         new SerializerFactory();
     CodecFactory codecFactory =
         new Ch.Elca.Iiop.Interception.CodecFactoryImpl(m_serFactory);
     m_codec =
         codecFactory.create_codec(
             new omg.org.IOP.Encoding(ENCODING_CDR_ENCAPS.ConstVal, 1, 2));
     IiopUrlUtil iiopUrlUtil =
         IiopUrlUtil.Create(m_codec, new object[] {
             Services.CodeSetService.CreateDefaultCodesetComponent(m_codec)});
     m_serFactory.Initalize(new SerializerFactoryConfig(), iiopUrlUtil);
 }
コード例 #17
0
 /// <summary>
 /// Set the <seealso cref="Codec"/>.
 ///
 /// <p>
 /// Only takes effect when IndexWriter is first created.
 /// </summary>
 public IndexWriterConfig SetCodec(Codec codec)
 {
     if (codec == null)
     {
         throw new System.ArgumentException("codec must not be null");
     }
     this.codec = codec;
     return this;
 }
コード例 #18
0
ファイル: Program.cs プロジェクト: cookies8710/Dojo7000
        static void Main(string[] args)
        {
            Dictionary<string, string> patterns = new Dictionary<string,string>(){ 
                {"A", ".*.*.*****.**.*" },
                {"B", "**.*.***.*.***." },
                {"C", ".*.*.**..*.*.*." },
                {"D", "**.*.**.**.***." },
                {"E", "****..**.*..***" },
                {"F", "****..**.*..*.." }
            };

            var codec = new Codec(patterns);

            StreamReader input = new StreamReader("in.txt");
            var line = "";
            var lines = new List<String>();
            while ((line = input.ReadLine()) != null) 
                lines.Add(line);

            var msg = lines;
            int i = 1;
            while (codec.Decodable(msg))
            {
                Console.WriteLine(String.Format("Decoding, it. {0}, len = {1} lines", i, msg.Count));
                msg = codec.DecodeMessage(msg);
                i++;
            }
            foreach (var item in msg)
            {                
                Console.WriteLine(item);
            }

            Console.ReadKey();
        }
コード例 #19
0
 private void TestMixedPostings(Codec codec)
 {
     Directory dir = NewDirectory();
     IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
     iwc.SetCodec(codec);
     RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);
     Document doc = new Document();
     FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
     // turn on vectors for the checkindex cross-check
     ft.StoreTermVectors = true;
     ft.StoreTermVectorOffsets = true;
     ft.StoreTermVectorPositions = true;
     Field idField = new Field("id", "", ft);
     Field dateField = new Field("date", "", ft);
     doc.Add(idField);
     doc.Add(dateField);
     for (int i = 0; i < 100; i++)
     {
         idField.StringValue = Convert.ToString(Random().Next(50));
         dateField.StringValue = Convert.ToString(Random().Next(100));
         iw.AddDocument(doc);
     }
     iw.Dispose();
     dir.Dispose(); // checkindex
 }
コード例 #20
0
ファイル: SegmentInfo.cs プロジェクト: Cefa68000/lucenenet
 /// <summary>
 /// Construct a new complete SegmentInfo instance from input.
 /// <p>Note: this is public only to allow access from
 /// the codecs package.</p>
 /// </summary>
 public SegmentInfo(Directory dir, string version, string name, int docCount, bool isCompoundFile, Codec codec, IDictionary<string, string> diagnostics)
     : this(dir, version, name, docCount, isCompoundFile, codec, diagnostics, null)
 {
 }
コード例 #21
0
ファイル: SegmentInfo.cs プロジェクト: Cefa68000/lucenenet
 /// <summary>
 /// Construct a new complete SegmentInfo instance from input.
 /// <p>Note: this is public only to allow access from
 /// the codecs package.</p>
 /// </summary>
 public SegmentInfo(Directory dir, string version, string name, int docCount, bool isCompoundFile, Codec codec, IDictionary<string, string> diagnostics, IDictionary<string, string> attributes)
 {
     Debug.Assert(!(dir is TrackingDirectoryWrapper));
     this.Dir = dir;
     this.Version_Renamed = version;
     this.Name = name;
     this.DocCount_Renamed = docCount;
     this.IsCompoundFile = isCompoundFile;
     this.Codec_Renamed = codec;
     this.Diagnostics_Renamed = diagnostics;
     this.Attributes_Renamed = attributes;
 }
コード例 #22
0
 public TestRequestInterceptor(string name, string testId,
                               Codec codec) {
     m_name = name;
     m_testId = testId;
     m_codec = codec;
 }
コード例 #23
0
 public TestIORInterceptor(string name, string testId,
                           Codec codec) {
     m_name = name;
     m_testId = testId;
     m_tc = new TaggedComponent(1000, codec.encode_value(new TestComponent(1)));            
 }        
コード例 #24
0
 private SSLComponentData GetSSLComponent(Ior ior, Codec codec) {
     object result = null;
     for (int i = 0; i < ior.Profiles.Length; i++) {
         result = GetSSLComponent(ior.Profiles[i], codec);
         if (result != null) {
             break;
         }
     }
     if (result != null) {
         return (SSLComponentData)result;
     } else {
         throw new INTERNAL(734, CompletionStatus.Completed_No);
     }
 }
コード例 #25
0
ファイル: IOR.cs プロジェクト: JnS-Software-LLC/iiop-net
        public void Setup()
        {
            m_version = new GiopVersion(1, 2);
            m_hostName = "localhost";
            m_port = 8089;
            m_objectKey = new byte[] { 65 };
            m_profile = new InternetIiopProfile(m_version, m_hostName, m_port, m_objectKey);

            m_serFactory =
                new SerializerFactory();
            CodecFactory codecFactory =
                new Ch.Elca.Iiop.Interception.CodecFactoryImpl(m_serFactory);
            m_codec =
                codecFactory.create_codec(
                    new omg.org.IOP.Encoding(ENCODING_CDR_ENCAPS.ConstVal, 1, 2));
            IiopUrlUtil iiopUrlUtil =
                IiopUrlUtil.Create(m_codec, new object[] {
                    Services.CodeSetService.CreateDefaultCodesetComponent(m_codec)});
            m_serFactory.Initalize(new SerializerFactoryConfig(), iiopUrlUtil);
        }
コード例 #26
0
		/// <summary>
		/// Gets the appropriate physical data reader for a given file and format codec
		/// </summary>
		/// <param name="path">The path of the file</param>
		/// <param name="code">The codec of the file</param>
		/// <returns>AudioDataReader able to give info about the file's contents (or the dummy reader if the format is unknown)</returns>
		public IAudioReader GetDataReader(String path, Codec codec)
		{
			IAudioReader theDataReader = null;
			
			switch(codec)
			{
				case Codec.MP3:
					theDataReader = new BinaryLogic.TMPEGaudio();
					break;

				case Codec.OGG:
					theDataReader = new BinaryLogic.TOggVorbis();
					break;

				case Codec.MPC:
					theDataReader = new BinaryLogic.TMPEGplus();
					break;

				case Codec.FLAC:
					theDataReader = new BinaryLogic.TFLACFile();
					break;

				case Codec.APE:
					theDataReader = new BinaryLogic.TMonkey();
					break;

				case Codec.WMA:
					theDataReader = new BinaryLogic.TWMAfile();
					break;

				case Codec.MIDI:
					theDataReader = new BinaryLogic.Midi();
					break;

				case Codec.AAC:
					theDataReader = new BinaryLogic.TAACfile();
					break;

				case Codec.AC3:
					theDataReader = new BinaryLogic.TAC3();
					break;

				case Codec.OFR:
					theDataReader = new BinaryLogic.TOptimFrog();
					break;

				case Codec.WAVPACK:
					theDataReader = new BinaryLogic.TWAVPackfile();
					break;

				case Codec.WAV:
					theDataReader = new BinaryLogic.TWAVfile();
					break;

				case Codec.PSF:
					theDataReader = new BinaryLogic.TPSFFile();
					break;

				case Codec.SPC:
					theDataReader = new BinaryLogic.TSPCFile();
					break;

				default:
					theDataReader = new BinaryLogic.DummyReader();
					break;
			}

			theDataReader.ReadFromFile(path);

			return theDataReader;
		}
コード例 #27
0
 public override void SetUp()
 {
     Codec_Renamed = new RandomCodec(new Random(Random().Next()), new HashSet<string>());
     base.SetUp();
 }
コード例 #28
0
ファイル: IndexWriter.cs プロジェクト: joyanta/lucene.net
        internal readonly Codec Codec; // for writing new segments

        /// <summary>
        /// Constructs a new IndexWriter per the settings given in <code>conf</code>.
        /// If you want to make "live" changes to this writer instance, use
        /// <seealso cref="#getConfig()"/>.
        ///
        /// <p>
        /// <b>NOTE:</b> after ths writer is created, the given configuration instance
        /// cannot be passed to another writer. If you intend to do so, you should
        /// <seealso cref="IndexWriterConfig#clone() clone"/> it beforehand.
        /// </summary>
        /// <param name="d">
        ///          the index directory. The index is either created or appended
        ///          according <code>conf.getOpenMode()</code>. </param>
        /// <param name="conf">
        ///          the configuration settings according to which IndexWriter should
        ///          be initialized. </param>
        /// <exception cref="IOException">
        ///           if the directory cannot be read/written to, or if it does not
        ///           exist and <code>conf.getOpenMode()</code> is
        ///           <code>OpenMode.APPEND</code> or if there is any other low-level
        ///           IO error </exception>
        public IndexWriter(Directory d, IndexWriterConfig conf)
        {
            /*if (!InstanceFieldsInitialized)
            {
                InitializeInstanceFields();
                InstanceFieldsInitialized = true;
            }*/
            readerPool = new ReaderPool(this);
            conf.SetIndexWriter(this); // prevent reuse by other instances
            Config_Renamed = new LiveIndexWriterConfig(conf);
            directory = d;
            analyzer = Config_Renamed.Analyzer;
            infoStream = Config_Renamed.InfoStream;
            mergePolicy = Config_Renamed.MergePolicy;
            mergePolicy.IndexWriter = this;
            mergeScheduler = Config_Renamed.MergeScheduler;
            Codec = Config_Renamed.Codec;

            BufferedUpdatesStream = new BufferedUpdatesStream(infoStream);
            PoolReaders = Config_Renamed.ReaderPooling;

            WriteLock = directory.MakeLock(WRITE_LOCK_NAME);

            if (!WriteLock.Obtain(Config_Renamed.WriteLockTimeout)) // obtain write lock
            {
                throw new LockObtainFailedException("Index locked for write: " + WriteLock);
            }

            bool success = false;
            try
            {
                OpenMode_e? mode = Config_Renamed.OpenMode;
                bool create;
                if (mode == OpenMode_e.CREATE)
                {
                    create = true;
                }
                else if (mode == OpenMode_e.APPEND)
                {
                    create = false;
                }
                else
                {
                    // CREATE_OR_APPEND - create only if an index does not exist
                    create = !DirectoryReader.IndexExists(directory);
                }

                // If index is too old, reading the segments will throw
                // IndexFormatTooOldException.
                segmentInfos = new SegmentInfos();

                bool initialIndexExists = true;

                if (create)
                {
                    // Try to read first.  this is to allow create
                    // against an index that's currently open for
                    // searching.  In this case we write the next
                    // segments_N file with no segments:
                    try
                    {
                        segmentInfos.Read(directory);
                        segmentInfos.Clear();
                    }
                    catch (IOException)
                    {
                        // Likely this means it's a fresh directory
                        initialIndexExists = false;
                    }

                    // Record that we have a change (zero out all
                    // segments) pending:
                    Changed();
                }
                else
                {
                    segmentInfos.Read(directory);

                    IndexCommit commit = Config_Renamed.IndexCommit;
                    if (commit != null)
                    {
                        // Swap out all segments, but, keep metadata in
                        // SegmentInfos, like version & generation, to
                        // preserve write-once.  this is important if
                        // readers are open against the future commit
                        // points.
                        if (commit.Directory != directory)
                        {
                            throw new System.ArgumentException("IndexCommit's directory doesn't match my directory");
                        }
                        SegmentInfos oldInfos = new SegmentInfos();
                        oldInfos.Read(directory, commit.SegmentsFileName);
                        segmentInfos.Replace(oldInfos);
                        Changed();
                        if (infoStream.IsEnabled("IW"))
                        {
                            infoStream.Message("IW", "init: loaded commit \"" + commit.SegmentsFileName + "\"");
                        }
                    }
                }

                RollbackSegments = segmentInfos.CreateBackupSegmentInfos();

                // start with previous field numbers, but new FieldInfos
                GlobalFieldNumberMap = FieldNumberMap;
                Config_Renamed.FlushPolicy.Init(Config_Renamed);
                DocWriter = new DocumentsWriter(this, Config_Renamed, directory);
                eventQueue = DocWriter.EventQueue();

                // Default deleter (for backwards compatibility) is
                // KeepOnlyLastCommitDeleter:
                lock (this)
                {
                    Deleter = new IndexFileDeleter(directory, Config_Renamed.DelPolicy, segmentInfos, infoStream, this, initialIndexExists);
                }

                if (Deleter.StartingCommitDeleted)
                {
                    // Deletion policy deleted the "head" commit point.
                    // We have to mark ourself as changed so that if we
                    // are closed w/o any further changes we write a new
                    // segments_N file.
                    Changed();
                }

                if (infoStream.IsEnabled("IW"))
                {
                    infoStream.Message("IW", "init: create=" + create);
                    MessageState();
                }

                success = true;
            }
            finally
            {
                if (!success)
                {
                    if (infoStream.IsEnabled("IW"))
                    {
                        infoStream.Message("IW", "init: hit exception on init; releasing write lock");
                    }
                    WriteLock.Release();
                    IOUtils.CloseWhileHandlingException(WriteLock);
                    WriteLock = null;
                }
            }
        }
コード例 #29
0
ファイル: Window1.xaml.cs プロジェクト: davidkwoods/Resources
        //Retrieve the options the user has set, making them
        //convenient to the rest of the methods in the app.
        private void GatherOptions()
        {
            inFile = InputTextbox.Text;
            outFile = OutputTextbox.Text;

            if (OptionDecode.IsChecked == true)
                codec = Codec.Decode;
            else if (OptionEncode.IsChecked == true)
                codec = Codec.Encode;
            else
                codec = Codec.Format;
        }
コード例 #30
0
 private object GetSSLComponent(IIorProfile profile, Codec codec) {
     if (profile.ProfileId == TAG_INTERNET_IOP.ConstVal) {
         return profile.TaggedComponents.GetComponentData(TAG_SSL_SEC_TRANS.ConstVal, codec,
                                                          SSLComponentData.TypeCode);
     } else {
         return null;
     }
 }