Examples of BSONTimestamp


Examples of org.bson.types.BSONTimestamp

            break;
        case BsonConstants.TYPE_INT32:
            value = Integer.valueOf(buffer.readInt());
            break;
        case BsonConstants.TYPE_TIMESTAMP:
            value = new BSONTimestamp(buffer.readInt(), buffer.readInt());
            break;
        case BsonConstants.TYPE_INT64:
            value = Long.valueOf(buffer.readLong());
            break;
        case BsonConstants.TYPE_MAX_KEY:

Examples of org.bson.types.BSONTimestamp

        setEnumBinding(Item.values(), null);
    }

    @Override
    public Object getValue() {
        return new BSONTimestamp(getIntFieldValue(Item.time), getIntFieldValue(Item.increment));
    }

Examples of org.bson.types.BSONTimestamp

        return new BSONTimestamp(getIntFieldValue(Item.time), getIntFieldValue(Item.increment));
    }

    @Override
    public void setValue(Object value) {
        BSONTimestamp ts = (BSONTimestamp) value;
        setIntFieldValue(Item.time, ts.getTime());
        setIntFieldValue(Item.increment, ts.getInc());
    }

Examples of org.bson.types.BSONTimestamp

                }

                // find highest current timestamp
                DBCursor cur = chunks.find().sort(new BasicDBObject("lastmod", -1)).batchSize(-1);
                BasicDBObject chunk = (BasicDBObject) (cur.hasNext() ? cur.next() : null);
                BSONTimestamp ts = (BSONTimestamp) (chunk != null ? chunk.get("lastmod") : null);

                // now infer chunk ranges
                long count = tmpchunks.count();
                result.put("uniqueKeys", count);
                int numChunks = 0;

Examples of org.bson.types.BSONTimestamp

        return chunk;
    }

    BSONTimestamp getNextTimestamp(BSONTimestamp ts) {
        if (ts == null) {
            return new BSONTimestamp(1000, 0);
        }
        return new BSONTimestamp(ts.getTime(), ts.getInc() + 1);
    }

Examples of org.bson.types.BSONTimestamp

        if (!firstc.hasNext() || !lastc.hasNext()) {
            return null;
        }
        BasicDBObject first = (BasicDBObject) firstc.next();
        BasicDBObject last = (BasicDBObject) lastc.next();
        BSONTimestamp tsfirst = (BSONTimestamp) first.get("ts");
        BSONTimestamp tslast = (BSONTimestamp) last.get("ts");
        if (tsfirst == null || tslast == null) {
            return null;
        }

        int ftime = tsfirst.getTime();
        int ltime = tslast.getTime();
        int timeDiffSec = ltime - ftime;
        result.put("timeDiff", timeDiffSec);
        result.put("timeDiffHours", Float.valueOf(String.format("%.2f", timeDiffSec / 3600f)));
        result.put("tFirst", new Date(ftime * 1000l));
        result.put("tLast", new Date(ltime * 1000l));
 

Examples of org.bson.types.BSONTimestamp

        } else if (type.startsWith("Double")) {
            val = new Double(0.0);
        } else if (type.equals("Pattern")) {
            val = Pattern.compile("");
        } else if (type.equals("Timestamp")) {
            val = new BSONTimestamp((int) (System.currentTimeMillis() / 1000), 0);
        } else if (type.equals("Document")) {
            val = new BasicDBObject();
        } else if (type.equals("List")) {
            val = new BasicDBList();
        } else if (type.equals("Null")) {

Examples of org.bson.types.BSONTimestamp

        } else if (value instanceof ObjectId) {
            ObjectId id = (ObjectId)value;
            value = new org.bson.types.ObjectId(id.getBytes());
        } else if (value instanceof Timestamp) {
            Timestamp ts = (Timestamp)value;
            value = new BSONTimestamp(ts.getTime(), ts.getInc());
        } else if (value instanceof CodeWithScope) {
            CodeWithScope code = (CodeWithScope)value;
            value = new org.bson.types.CodeWScope(code.getCode(), createMongoData(code.getScope()));
        } else if (value instanceof Code) {
            Code code = (Code)value;

Examples of org.bson.types.BSONTimestamp

        assertThat(value, equalTo(result));

        result = serde.deserializeField(d, serde.columnTypes.get(0), "");
        assertThat(value, equalTo(result));

        BSONTimestamp bts = new BSONTimestamp(((Long) (d.getTime() / 1000L)).intValue(), 1);
        result = serde.deserializeField(bts, serde.columnTypes.get(0), "");
        // BSONTimestamp only takes an int, so the long returned in the Timestamp won't be the same
        assertThat((long) bts.getTime(), equalTo(((Timestamp) result).getTime() / 1000L));

        // Utilizes a timestampWritable because there's no native timestamp type in java for
        // object inspector class to relate to
        ObjectInspector innerInspector =
            PrimitiveObjectInspectorFactory.getPrimitiveObjectInspectorFromClass(TimestampWritable.class);

Examples of org.bson.types.BSONTimestamp

        }
        return object;
    }

    private Object convertToBSONTimestamp(Timestamp ts) {
        return new BSONTimestamp(ts.getTime(), ts.getInc());
    }
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.