Java 类com.mongodb.client.DistinctIterable 实例源码

项目:ibm-performance-monitor    文件:ProfiledMongoClientTest.java   
@Test
public void testDistinct()
{
    DistinctIterable<String> distinct = coll.distinct("color", String.class);
    List<String> strList = toDocumentList(distinct);
    assertEquals(6, strList.size());
    assertTrue(strList.contains("Red"));

    distinct = coll.distinct("color", Filters.eq("name", "Alto"), String.class);
    strList = toDocumentList(distinct);
    assertEquals(4, strList.size());
    assertTrue(strList.contains("Red"));
}
项目:ibm-performance-monitor    文件:ProfiledMongoCollection.java   
@Override
public <TResult> DistinctIterable<TResult> distinct(String fieldName, Class<TResult> arg1)
{
    DistinctIterable<TResult> find = collection.distinct(fieldName, arg1);
    ProfiledDistinctIterable<TDocument, TResult> profiledFindIterable = new ProfiledDistinctIterable<TDocument, TResult>(
        find, fieldName, this);
    return profiledFindIterable;
}
项目:ibm-performance-monitor    文件:ProfiledMongoCollection.java   
@Override
public <TResult> DistinctIterable<TResult> distinct(String arg0, Bson filter, Class<TResult> arg2)
{
    DistinctIterable<TResult> find = collection.distinct(arg0, filter, arg2);
    ProfiledDistinctIterable<TDocument, TResult> profiledFindIterable = new ProfiledDistinctIterable<TDocument, TResult>(
        find, arg0, this);
    profiledFindIterable.filter(filter);
    return profiledFindIterable;
}
项目:ibm-performance-monitor    文件:ProfiledDistinctIterable.java   
public ProfiledDistinctIterable(DistinctIterable<TResult> findIterable, String fieldName,
    ProfiledMongoCollection<TDocument> collection)
{
    super();
    this.distinctIterable = findIterable;
    this.fieldName = fieldName;
    this.collection = collection;
}
项目:ibm-performance-monitor    文件:ProfiledDistinctIterable.java   
public DistinctIterable<TResult> getDistinceIterable()
{
    return distinctIterable;
}
项目:openbd-core    文件:MongoCollectionDistinct.java   
public cfData execute( cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException {
    MongoDatabase db = getMongoDatabase( _session, argStruct );

    String collection = getNamedStringParam( argStruct, "collection", null );
    if ( collection == null )
        throwException( _session, "please specify a collection" );

    String key = getNamedStringParam( argStruct, "key", null );
    if ( key == null )
        throwException( _session, "please specify a key" );

    cfData query = getNamedParam( argStruct, "query", null );

    try {

        DistinctIterable<String> result;
        if ( query != null )
            result = db.getCollection( collection ).distinct( key, String.class ).filter( getDocument( query ) );
        else
            result = db.getCollection( collection ).distinct( key, String.class );

        cfArrayData arr = cfArrayData.createArray( 1 );

        result.forEach( new Block<String>() {

            @Override
            public void apply( final String st ) {
                try {
                    arr.addElement( new cfStringData( st ) );
                } catch ( cfmRunTimeException e ) {}
            }
        } );


        return arr;

    } catch ( MongoException me ) {
        throwException( _session, me.getMessage() );
        return null;
    }
}
项目:ymate-platform-v2    文件:IMongoSession.java   
<T extends IEntity, RESULT> DistinctIterable<RESULT> distinct(Class<T> entity, Class<RESULT> resultClass, String fieldName) throws Exception;
项目:ymate-platform-v2    文件:IMongoSession.java   
<T extends IEntity, RESULT> DistinctIterable<RESULT> distinct(Class<T> entity, Class<RESULT> resultClass, String fieldName, Query query) throws Exception;