Ejemplo n.º 1
0
		public override void Accept(Disk d)
		{
			var ms = new MemoryStream();
			_serializer.Serialize(new JsonTextWriter(new StreamWriter(ms)), d);
			ms.Position = 0;
			var key = new Slice(EndianBitConverter.Big.GetBytes(counter++));
			_currentBatch.Add(key, ms, "albums");

			foreach (var diskId in d.DiskIds)
			{
				_currentBatch.MultiAdd(diskId, key, "ix_diskids");
			}

			if(d.Artist != null)
				_currentBatch.MultiAdd(d.Artist.ToLower(), key, "ix_artists");
			if (d.Title != null)
				_currentBatch.MultiAdd(d.Title.ToLower(), key, "ix_titles");

			if (counter%1000 == 0)
			{
				_storageEnvironment.Writer.Write(_currentBatch);
				_currentBatch = new WriteBatch();
			}

		}
Ejemplo n.º 2
0
        private static void AddDocShortVersion(Disk disk)
        {
            ReusableDoc.GetFields().Clear();

            fields[0].SetValue(disk.Artist);
            if (string.IsNullOrEmpty(disk.Artist) == false)
                ReusableDoc.Add(fields[0]);

            fields[1].SetValue(disk.Title);
            if(string.IsNullOrEmpty(disk.Title) == false)
                ReusableDoc.Add(fields[1]);

            fields[2].SetValue(disk.DiskIds.FirstOrDefault() ?? Guid.NewGuid().ToString());
            ReusableDoc.Add(fields[2]);

            _indexWriter.AddDocument(ReusableDoc);
        }
Ejemplo n.º 3
0
		public Disk Parse(string text)
		{
			var disk = new Disk();
			foreach (var action in actions)
			{
				var collection = action.Item1.Matches(text);
				try
				{
					action.Item2(disk, collection);
				}
				catch (Exception e)
				{
					Console.WriteLine();
					Console.WriteLine(text);
					Console.WriteLine(action.Item1);
					Console.WriteLine(e);
					throw;
				}
			}

			return disk;
		}
Ejemplo n.º 4
0
 public abstract void Accept(Disk d);
Ejemplo n.º 5
0
 public override void Accept(Disk d)
 {
 }
		public override void Accept(Disk d)
		{
			_serializer.Serialize(new JsonTextWriter(_writer), d);
			_writer.WriteLine();
		}