Package org.bson.types

Examples of org.bson.types.BasicBSONList


      return null;
    }

    BasicDBObject capabilitiesObj = new BasicDBObject();
    for (Capability capability : capabilities.getCapabilitiesMap().values()) {
      BasicBSONList contexts = new BasicBSONList();
      for (Context c : capability.getContexts()) {
        contexts.add(c.name());
      }
      capabilitiesObj.put(capability.getEventType().name(),
          new BasicDBObject()
              .append(CAPABILITY_CONTEXTS_FIELD, contexts)
              .append(CAPABILITY_FILTER_FIELD, capability.getFilter()));
View Full Code Here


  protected BSONObject create(QueryList queryList) {
    BSONObject bsonQueryList = new BasicBSONObject();
    bsonQueryList.put("TransactionId", queryList.getSession().getTransactionId());
    bsonQueryList.put("SessionId", queryList.getSession().getSessionId());

    BasicBSONList bsonQueries = new BasicBSONList();
    for (int i = 0; i < queryList.getQueriesCount(); i++) {
      BoundQuery boundQuery = queryList.getQueries(i);
      BSONObject bsonQuery = new BasicBSONObject();
      bsonQuery.put("BindVariables", bindVariablesToMap(boundQuery.getBindVariablesList()));
      bsonQuery.put("Sql", boundQuery.getSql().toStringUtf8());
      bsonQueries.put(i, bsonQuery);
    }

    bsonQueryList.put("Queries", bsonQueries);
    return bsonQueryList;
View Full Code Here

    Object session = null;
    if (reply.containsField("Session")) {
      session = reply.get("Session");
    }
    List<QueryResult> qrs = new LinkedList<>();
    BasicBSONList results = (BasicBSONList) reply.get("List");
    for (Object result : results) {
      qrs.add(bsonToQueryResult((BSONObject) result, null));
    }
    return new BatchQueryResponse(qrs, session, error);
  }
View Full Code Here

    return new QueryResult(rows, fields, rowsAffected, lastRowId);
  }

  public static List<Field> bsonToFields(BSONObject result) {
    List<Field> fieldList = new LinkedList<>();
    BasicBSONList fields = (BasicBSONList) result.get("Fields");
    for (Object field : fields) {
      BSONObject fieldBson = (BSONObject) field;
      String fieldName = new String((byte[]) fieldBson.get("Name"));
      int mysqlType = Ints.checkedCast((Long) fieldBson.get("Type"));
      FieldType fieldType = FieldType.get(mysqlType);
View Full Code Here

    return fieldList;
  }

  public static List<Row> bsonToRows(BSONObject result, List<Field> fields) {
    List<Row> rowList = new LinkedList<>();
    BasicBSONList rows = (BasicBSONList) result.get("Rows");
    for (Object row : rows) {
      LinkedList<Cell> cells = new LinkedList<>();
      BasicBSONList cols = (BasicBSONList) row;
      Iterator<Field> fieldsIter = fields.iterator();
      for (Object col : cols) {
        byte[] val = col != null ? (byte[]) col : null;
        Field field = fieldsIter.next();
        FieldType ft = field.getType();
View Full Code Here

      byte[] err = (byte[]) reply.get("Error");
      if (err.length > 0) {
        error = new String(err);
      }
    }
    BasicBSONList result = (BasicBSONList) reply.get("Splits");
    Map<Query, Long> queries = new HashMap<>();
    for (Object split : result) {
      BSONObject splitObj = (BasicBSONObject) split;
      BSONObject query = (BasicBSONObject) (splitObj.get("Query"));
      String sql = new String((byte[]) query.get("Sql"));
View Full Code Here

  @Test
  public void testResultParse() throws InvalidFieldException {
    BSONObject result = new BasicBSONObject();
    result.put("RowsAffected", UnsignedLong.valueOf("12"));
    result.put("InsertId", UnsignedLong.valueOf("12345"));
    BasicBSONList fields = new BasicBSONList();
    for (long l = 0; l < 4; l++) {
      BSONObject field = new BasicBSONObject();
      field.put("Name", ("col_" + l).getBytes());
      field.put("Type", l);
      fields.add(field);
    }
    result.put("Fields", fields);
    BasicBSONList rows = new BasicBSONList();
    for (int i = 0; i < 3; i++) {
      BasicBSONList row = new BasicBSONList();
      row.add(new Double(i).toString().getBytes());
      row.add(String.valueOf(i).getBytes());
      row.add(String.valueOf(i).getBytes());
      row.add(new Long(i).toString().getBytes());
      rows.add(row);
    }
    result.put("Rows", rows);

    QueryResult qr = Bsonify.bsonToQueryResult(result, null);
View Full Code Here

      }
    }   
   
    protected void setupOutput() {
      JavascriptUtils objFactory = this; // (clone creates BSONWritables)
      BasicBSONList listFactory = new BasicBSONList();
      _engine.put("objFactory", objFactory);
      _engine.put("listFactory", listFactory);
    }
View Full Code Here

    }
   
    protected BasicBSONList generateOutput()
    {     
      setupOutput();
      BasicBSONList outList = new BasicBSONList();
      _engine.put("outList", outList);     
     
      try {
        _engine.eval("s1(_emit_list); ");
      } catch (ScriptException e) {
View Full Code Here

    public void map( Object key, BSONObject value, Context context ) throws IOException, InterruptedException
    {
      _javascript.map(key, value);
     
      if (!_javascript.isMemoryOptimized()) {
        BasicBSONList out = _javascript.generateOutput();
        for (Object bson: out) {
          BSONWritable bsonObj = (BSONWritable) bson;
          BSONWritable outkey = (BSONWritable) bsonObj.get("key");
          BSONWritable outval = (BSONWritable) bsonObj.get("val");
          if (null == outkey) {
View Full Code Here

TOP

Related Classes of org.bson.types.BasicBSONList

Copyright © 2018 www.massapicom. 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.