Package org.bson.types

Examples of org.bson.types.BasicBSONList


    throws IOException, InterruptedException
    {
      _javascript.combine(key, values);

      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


    throws IOException, InterruptedException
    {
      _javascript.reduce(key, values);
     
      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

        } else if (value instanceof Binary) {
            Binary binary = (Binary)value;
            value = new org.bson.types.Binary(binary.getBytes());
        } else if (value instanceof List) {
            List<?> values = (List<?>)value;
            BasicBSONList newValues = new BasicBSONList();
            for (Object v : values) {
                newValues.add(createMongoData(v));
            }
            value = newValues;
        } else if (value instanceof Document) {
            value = createMongoData((Document)value);
        }
View Full Code Here

        } else if (o instanceof Date) {
            return ((Date) o).getTime();
        } else if (o instanceof ObjectId) {
            return o.toString();
        } else if (o instanceof BasicBSONList) {
            BasicBSONList bl = (BasicBSONList) o;
            Tuple t = tupleFactory.newTuple(bl.size());
            for (int i = 0; i < bl.size(); i++) {
                t.set(i, convertBSONtoPigType(bl.get(i)));
            }
            return t;
        } else if (o instanceof Map) {
            //TODO make this more efficient for lazy objects?
            Map<String, Object> fieldsMap = (Map<String, Object>) o;
View Full Code Here

public class TagsMapper extends Mapper<NullWritable, BSONObject, Text, BSONWritable>
    implements org.apache.hadoop.mapred.Mapper<NullWritable, BSONWritable, Text, BSONWritable> {

    @Override
    protected void map(final NullWritable key, final BSONObject value, final Context context) throws IOException, InterruptedException {
        BasicBSONList tags = (BasicBSONList) value.get("tags");
        Text text = new Text();
        value.removeField("tags");
        for (Object tag : tags) {
            text.set((String) tag);
            context.write(text, new BSONWritable(value));
View Full Code Here

    }

    @Override
    public void map(final NullWritable key, final BSONWritable value, final OutputCollector<Text, BSONWritable> output,
                    final Reporter reporter) throws IOException {
        BasicBSONList tags = (BasicBSONList) value.getDoc().get("tags");
        Text text = new Text();
        value.getDoc().removeField("tags");
        for (Object tag : tags) {
            text.set((String) tag);
            output.collect(text, value);
View Full Code Here

    /**
     * Deserialize a List with the same listElemTypeInfo for its elements
     */
    private Object deserializeList(final Object value, final ListTypeInfo valueTypeInfo, final String ext) {
        BasicBSONList list = (BasicBSONList) value;
        TypeInfo listElemTypeInfo = valueTypeInfo.getListElementTypeInfo();

        for (int i = 0; i < list.size(); i++) {
            list.set(i, deserializeField(list.get(i), listElemTypeInfo, ext));
        }
        return list.toArray();
    }
View Full Code Here

        return null;
    }


    private Object serializeList(final Object obj, final ListObjectInspector oi, final String ext) {
        BasicBSONList list = new BasicBSONList();
        List<?> field = oi.getList(obj);

        if (field == null) {
            return list;
        }

        ObjectInspector elemOI = oi.getListElementObjectInspector();

        for (Object elem : field) {
            list.add(serializeObject(elem, elemOI, ext));
        }

        return list;
    }
View Full Code Here

        String columnTypes = "array<string>";

        String inner = "inside";
        ArrayList<String> value = new ArrayList<String>();
        value.add(inner);
        BasicBSONList b = new BasicBSONList();
        b.add(inner);
        BSONSerDe serde = new BSONSerDe();
        Object result = helpDeserialize(serde, columnNames, columnTypes, b);
        assertThat(value.toArray(), equalTo(result));

        // Since objectid is currently taken to be a string
View Full Code Here

                {
                    propList = dbc.distinct( "properties" );
                }
                catch (IllegalArgumentException ex)
                {
                    propList = new BasicBSONList();
                    propList.add( "ex nihilo" );
                }
                catch (MongoException ex)
                {
                    propList = new BasicBSONList();
                    propList.add( "ex nihilo" );
                }
                // check that layer has valid geometry and some properties defined
                if (geoList != null && propList != null && propList.size() > 0)
                {
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.