Example usage for com.mongodb Bytes QUERYOPTION_PARTIAL

List of usage examples for com.mongodb Bytes QUERYOPTION_PARTIAL

Introduction

In this page you can find the example usage for com.mongodb Bytes QUERYOPTION_PARTIAL.

Prototype

int QUERYOPTION_PARTIAL

To view the source code for com.mongodb Bytes QUERYOPTION_PARTIAL.

Click Source Link

Document

Use with sharding (mongos).

Usage

From source file:com.edgytech.umongo.OptionDialog.java

License:Apache License

void update(int options, WriteConcern wc, ReadPreference rp) {
    // reset//from w ww  . j a va2  s.  c om
    xmlLoadCheckpoint();

    setBooleanFieldValue(Item.tailable, (options & Bytes.QUERYOPTION_TAILABLE) != 0);
    setBooleanFieldValue(Item.slaveOk, (options & Bytes.QUERYOPTION_SLAVEOK) != 0);
    setBooleanFieldValue(Item.opLogReplay, (options & Bytes.QUERYOPTION_OPLOGREPLAY) != 0);
    setBooleanFieldValue(Item.noTimeout, (options & Bytes.QUERYOPTION_NOTIMEOUT) != 0);
    setBooleanFieldValue(Item.awaitData, (options & Bytes.QUERYOPTION_AWAITDATA) != 0);
    setBooleanFieldValue(Item.exhaust, (options & Bytes.QUERYOPTION_EXHAUST) != 0);
    setBooleanFieldValue(Item.partial, (options & Bytes.QUERYOPTION_PARTIAL) != 0);

    Object w = wc.getWObject();
    int wInt = (Integer) (w instanceof Integer ? w : 0);
    String wStr = (String) (w instanceof String ? w : "");
    setIntFieldValue(Item.writeFactor, wInt);
    setStringFieldValue(Item.writePolicy, wStr);
    setIntFieldValue(Item.writeTimeout, wc.getWtimeout());
    //        setBooleanFieldValue(Item.fsync, wc.fsync());

    DBObject rpObj = rp.toDBObject();
    ComboBox readBox = (ComboBox) getBoundUnit(Item.rpPreference);
    ReadPref rpEnm = ReadPref.primary;
    if (rp != null)
        rpEnm = ReadPref.valueOf(rp.getName());
    readBox.value = rpEnm.ordinal();
    if (rpObj.containsField("tags")) {
        List tags = (List) rpObj.get("tags");
        if (tags.size() > 0) {
            ((DocBuilderField) getBoundComponentUnit(Item.rpTag)).setDBObject((DBObject) tags.get(0));
        }
    }
}

From source file:com.edgytech.umongo.OptionDialog.java

License:Apache License

int getQueryOptions() {
    int options = 0;
    if (getBooleanFieldValue(Item.tailable))
        options |= Bytes.QUERYOPTION_TAILABLE;
    if (getBooleanFieldValue(Item.slaveOk))
        options |= Bytes.QUERYOPTION_SLAVEOK;
    if (getBooleanFieldValue(Item.opLogReplay))
        options |= Bytes.QUERYOPTION_OPLOGREPLAY;
    if (getBooleanFieldValue(Item.noTimeout))
        options |= Bytes.QUERYOPTION_NOTIMEOUT;
    if (getBooleanFieldValue(Item.awaitData))
        options |= Bytes.QUERYOPTION_AWAITDATA;
    if (getBooleanFieldValue(Item.exhaust))
        options |= Bytes.QUERYOPTION_EXHAUST;
    if (getBooleanFieldValue(Item.partial))
        options |= Bytes.QUERYOPTION_PARTIAL;
    return options;
}

From source file:org.eclipse.birt.data.oda.mongodb.internal.impl.MDbOperation.java

License:Open Source License

/**
 * Applies data set query properties and hints on DBCursor, except
 * for cursor limit./*from ww w  .  j  a  v  a2 s  .c o m*/
 * @see #applyPropertiesToCursor(DBCursor,QueryProperties,boolean,boolean)
 */
static void applyPropertiesToCursor(DBCursor rowsCursor, QueryProperties queryProps, boolean includeSortExpr) {
    if (includeSortExpr) // normally done only when executing a query to get full result set
    {
        DBObject sortExprObj = null;
        try {
            sortExprObj = queryProps.getSortExprAsParsedObject();
        } catch (OdaException ex) {
            // log warning and ignore
            DriverUtil.getLogger().log(Level.WARNING,
                    Messages.bind("Unable to parse the user-defined Sort Expression: {0}", //$NON-NLS-1$
                            queryProps.getSortExpr()), ex);
        }

        if (sortExprObj != null)
            rowsCursor.sort(sortExprObj);
    }

    ReadPreference readPref = queryProps.getTaggableReadPreference();
    if (readPref != null)
        rowsCursor.setReadPreference(readPref);

    if (queryProps.getBatchSize() > 0)
        rowsCursor.batchSize(queryProps.getBatchSize());

    if (queryProps.getNumDocsToSkip() > 0)
        rowsCursor.skip(queryProps.getNumDocsToSkip());

    DBObject hintObj = queryProps.getIndexHintsAsParsedObject();
    if (hintObj != null)
        rowsCursor.hint(hintObj);
    else // try to pass the hint string value as is
    {
        String hintValue = queryProps.getIndexHints();
        if (!hintValue.isEmpty())
            rowsCursor.hint(hintValue);
    }

    if (queryProps.hasNoTimeOut())
        rowsCursor.addOption(Bytes.QUERYOPTION_NOTIMEOUT);
    if (queryProps.isPartialResultsOk())
        rowsCursor.addOption(Bytes.QUERYOPTION_PARTIAL);
}