Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-144

MongoCollection Can't distinct a large size of data

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.0
    • Affects Version/s: 0.9
    • Component/s: None
    • None
    • Environment:
      OS:WIn7 x64 Enterprise
      VS:VS2010

      I have a collection contains about 821463 documents in my local mongodb.I try to distinct TrackID in C# Program with the method Distinct(string key) of MongoCollection.I got a Exception,Message is:
      Invalid BSONObj spec size: 25354392 (98E08201)
      The stack trace is below:
      At MongoDB.Driver.Internal.MongoReplyMessage`1.ReadFrom(BsonBuffer buffer)
      At MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument]()
      At MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.GetReply(MongoRequestMessage message)
      At MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.GetFirst()
      At MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.MoveNext()
      At System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
      At MongoDB.Driver.MongoCollection.FindOneAs[TQuery,TDocument](TQuery query)
      At MongoDB.Driver.MongoCollection`1.FindOne[TQuery](TQuery query)
      At MongoDB.Driver.MongoDatabase.RunCommand[TCommand](TCommand command)
      At MongoDB.Driver.MongoCollection.Distinct[TQuery](String key, TQuery query)
      At MongoDB.Driver.MongoCollection.Distinct(String key)
      At MongoWriteSpeed.Program.Main(String[] args) Location E:\Program\WindowsProject\MongoWriteSpeed\MongoWriteSpeed\Program.cs:row 27

      My Program is Below:

      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;

      using MongoDB.Driver;
      using MongoDB.Bson;

      namespace MongoWriteSpeed
      {
      class Program
      {
      static void Main(string[] args)
      {
      MongoServer _dbServer = MongoServer.Create();

      try
      {
      if ((_dbServer.State == MongoServerState.Disconnected) || (_dbServer.State == MongoServerState.None))

      { _dbServer.Connect(); MongoDatabase _db = _dbServer.GetDatabase("music"); MongoCollection<MongoDB.Bson.BsonDocument> _document = _db.GetCollection("tTrack"); IEnumerable<BsonValue> _trackIdList = _document.Distinct("TrackID"); }

      }
      catch (Exception ex)
      {
      System.Console.WriteLine(string.Format("Faile?Exception?

      {0}

      ", ex.Message));
      }
      finally

      { _dbServer.Disconnect(); }

      }
      }
      }

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            xuqing xuqing
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: