Package org.bson

Examples of org.bson.BSONObject.keySet()


      BSONObject splitObj = (BasicBSONObject) split;
      BSONObject query = (BasicBSONObject) (splitObj.get("Query"));
      String sql = new String((byte[]) query.get("Sql"));
      BSONObject bindVars = (BasicBSONObject) query.get("BindVariables");
      List<BindVariable> bindVariables = new LinkedList<>();
      for (String key : bindVars.keySet()) {
        BindVariable bv = null;
        Object val = bindVars.get(key);
        if (val == null) {
          bv = BindVariable.forNull(key);
        }
View Full Code Here


  protected QueryResult createQueryResult(BSONObject bsonBody) {
    Builder queryResult = QueryResult.newBuilder();
    queryResult.setInsertId((Long) bsonBody.get("InsertId"));
    BSONObject fields = (BSONObject) bsonBody.get("Fields");
    for (String index : fields.keySet()) {
      BSONObject field = (BSONObject) fields.get(index);
      queryResult.addFields(
          Field.newBuilder()
              .setName(new String((byte[]) field.get("Name"), StandardCharsets.UTF_8))
              .setType(Type.valueOf(Ints.checkedCast((Long) field.get("Type"))))
View Full Code Here

              .build()
      );
    }

    BSONObject rows = (BSONObject) bsonBody.get("Rows");
    for (String rowIndex : rows.keySet()) {
      BSONObject bsonRow = (BSONObject) rows.get(rowIndex);
      Row.Builder queryRow = Row.newBuilder();
      for (String cellIndex : bsonRow.keySet()) {
        queryRow.addValues(Cell.newBuilder()
            .setValue(ByteString.copyFrom((byte[]) bsonRow.get(cellIndex))));
View Full Code Here

    BSONObject rows = (BSONObject) bsonBody.get("Rows");
    for (String rowIndex : rows.keySet()) {
      BSONObject bsonRow = (BSONObject) rows.get(rowIndex);
      Row.Builder queryRow = Row.newBuilder();
      for (String cellIndex : bsonRow.keySet()) {
        queryRow.addValues(Cell.newBuilder()
            .setValue(ByteString.copyFrom((byte[]) bsonRow.get(cellIndex))));
      }
      queryResult.addRows(queryRow);
    }
View Full Code Here

                Pattern pattern = Utils.createPattern(queryObject.get("$regex").toString(), options);
                return pattern.matcher(value.toString()).find();
            }

            for (String key : queryObject.keySet()) {
                Object querySubvalue = queryObject.get(key);
                if (key.startsWith("$")) {
                    if (!checkExpressionMatch(value, valueExists, querySubvalue, key)) {
                        return false;
                    }
View Full Code Here

        final MongoCollection collection = resolveOrCreateCollection(collectionName);

        indexes.addDocument(indexDescription);

        BSONObject key = (BSONObject) indexDescription.get("key");
        if (key.keySet().equals(Collections.singleton("_id"))) {
            boolean ascending = Utils.normalizeValue(key.get("_id")).equals(Double.valueOf(1.0));
            collection.addIndex(new UniqueIndex("_id", ascending));
            log.info("adding unique _id index for collection {}", collectionName);
        } else if (Utils.isTrue(indexDescription.get("unique"))) {
            if (key.keySet().size() != 1) {
View Full Code Here

        if (key.keySet().equals(Collections.singleton("_id"))) {
            boolean ascending = Utils.normalizeValue(key.get("_id")).equals(Double.valueOf(1.0));
            collection.addIndex(new UniqueIndex("_id", ascending));
            log.info("adding unique _id index for collection {}", collectionName);
        } else if (Utils.isTrue(indexDescription.get("unique"))) {
            if (key.keySet().size() != 1) {
                throw new MongoServerException("Compound unique indices are not yet implemented");
            }

            log.info("adding unique index {} for collection {}", key.keySet(), collectionName);
View Full Code Here

        } else if (Utils.isTrue(indexDescription.get("unique"))) {
            if (key.keySet().size() != 1) {
                throw new MongoServerException("Compound unique indices are not yet implemented");
            }

            log.info("adding unique index {} for collection {}", key.keySet(), collectionName);

            final String field = key.keySet().iterator().next();
            boolean ascending = Utils.normalizeValue(key.get(field)).equals(Double.valueOf(1.0));
            collection.addIndex(new UniqueIndex(field, ascending));
        } else {
View Full Code Here

                throw new MongoServerException("Compound unique indices are not yet implemented");
            }

            log.info("adding unique index {} for collection {}", key.keySet(), collectionName);

            final String field = key.keySet().iterator().next();
            boolean ascending = Utils.normalizeValue(key.get(field)).equals(Double.valueOf(1.0));
            collection.addIndex(new UniqueIndex(field, ascending));
        } else {
            // TODO: non-unique non-id indexes not yet implemented
            log.warn("adding non-unique non-id index with key {} is not yet implemented", key);
View Full Code Here

        Object keyValue = getKeyValue(query);

        if (keyValue instanceof BSONObject) {
            BSONObject keyObj = (BSONObject) keyValue;
            if (Utils.containsQueryExpression(keyObj)) {
                if (keyObj.keySet().size() != 1) {
                    throw new UnsupportedOperationException("illegal query key: " + keyValue);
                }

                String expression = keyObj.keySet().iterator().next();
                if (expression.startsWith("$")) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.