@Override public void gotTimestamp(final String name, final int time, final int increment) { _put(name, new BSONTimestamp(time, increment)); }
@Override public int compareTo(Timestamp<BSON> o) { return this.ts.compareTo(((BSON) o).ts); }
public void serialize(Object obj, StringBuilder buf) { BSONTimestamp t; if (obj instanceof Timestamp) { t = new BSONTimestamp((Timestamp) obj); } else { t = (BSONTimestamp) obj; } BasicBSONObject temp = new BasicBSONObject(); temp.put("$ts", Integer.valueOf(t.getTime())); temp.put("$inc", Integer.valueOf(t.getInc())); serializer.serialize(temp, buf); }
@Override public long getTime() { return ts.getTime() * 1000L; }
public void serialize(Object obj, StringBuilder buf) { BSONTimestamp t; if (obj instanceof Timestamp) { t = new BSONTimestamp((Timestamp) obj); } else { t = (BSONTimestamp) obj; } BasicBSONObject temp = new BasicBSONObject(); temp.put("$t", Integer.valueOf(t.getTime())); temp.put("$i", Integer.valueOf(t.getInc())); BasicBSONObject timestampObj = new BasicBSONObject(); timestampObj.put("$timestamp", temp); serializer.serialize(timestampObj, buf); }
@Override public int hashCode() { int prime = 31; int result = 1; result = prime * result + inc; result = prime * result + getTime(); return result; }
/** * Tests if {@code Timestamp} objects can be deserialized * @throws Exception if something goes wrong */ @Test public void timestamp() throws Exception { org.bson.types.BSONTimestamp ts = new org.bson.types.BSONTimestamp(1, 2); TC.T obj = generateAndParse(ts, TC.T.class); assertEquals(ts.getTime(), obj.obj.getTime()); assertEquals(ts.getInc(), obj.obj.getInc()); }
@Override public BSONTimestamp decode(final BsonReader reader, final DecoderContext decoderContext) { BsonTimestamp timestamp = reader.readTimestamp(); return new BSONTimestamp(timestamp.getTime(), timestamp.getInc()); }
protected boolean shouldProcessRecord(String collection, BSONTimestamp timestamp) { boolean shouldProcess = false; if(COLLECTIONS_TO_ADD.contains(collection)){ shouldProcess = true; } if(COLLECTIONS_TO_SKIP.contains(collection)){ shouldProcess = false; } else{ if(ONLY_COLLECTION_EXCLUSIONS){ shouldProcess = true; } } if(AFTER_TIMESTAMP != null){ if(timestamp.getTime() < AFTER_TIMESTAMP.getTime()){ shouldProcess = false; } } if(BEFORE_TIMESTAMP != null){ if(timestamp.getTime() >= BEFORE_TIMESTAMP.getTime()){ shouldProcess = false; } } return shouldProcess; }
diff = ((Date) one).compareTo((Date) two); } else if (one instanceof BSONTimestamp) { diff = ((BSONTimestamp) one).compareTo((BSONTimestamp) two);
Integer ts = ((Number) b.get("$ts")).intValue(); Integer inc = ((Number) b.get("$inc")).intValue(); o = new BSONTimestamp(ts, inc); } else if (b.containsField("$timestamp")) { BSONObject tsObject = (BSONObject) b.get("$timestamp"); Integer ts = ((Number) tsObject.get("t")).intValue(); Integer inc = ((Number) tsObject.get("i")).intValue(); o = new BSONTimestamp(ts, inc); } else if (b.containsField("$code")) { if (b.containsField("$scope")) {
protected boolean shouldProcessRecord(String collection, BSONTimestamp timestamp) { boolean shouldProcess = false; if(COLLECTIONS_TO_ADD.contains(collection)){ shouldProcess = true; } if(COLLECTIONS_TO_SKIP.contains(collection)){ shouldProcess = false; } else{ if(ONLY_COLLECTION_EXCLUSIONS){ shouldProcess = true; } } if(AFTER_TIMESTAMP != null){ if(timestamp.getTime() < AFTER_TIMESTAMP.getTime()){ shouldProcess = false; } } if(BEFORE_TIMESTAMP != null){ if(timestamp.getTime() >= BEFORE_TIMESTAMP.getTime()){ shouldProcess = false; } } return shouldProcess; }
diff = ((Date) one).compareTo((Date) two); } else if (one instanceof BSONTimestamp) { diff = ((BSONTimestamp) one).compareTo((BSONTimestamp) two);
if (ctx != null) { long timestamp = Long.parseLong(ctx.toString()); timeStamp = new BSONTimestamp((int) (new Date(timestamp).getTime() / 1000), 1);
@Override public Object extractLastVal(DBObject o, String increasingField) { Object temp = o.get(increasingField); return ((BSONTimestamp) temp).getTime(); }
/** * Encodes a BSON timestamp * * @param name the field name * @param timestamp the timestamp to encode * @see org.bson.BsonType#TIMESTAMP */ protected void putTimestamp(final String name, final BSONTimestamp timestamp) { putName(name); bsonWriter.writeTimestamp(new BsonTimestamp(timestamp.getTime(), timestamp.getInc())); }