use of com.eightkdata.mongowp.bson.BsonInt32 in project torodb by torodb.
the class OplogTestParser method getOps.
private static List<OplogOperation> getOps(BsonDocument doc) {
BsonValue<?> oplogValue = doc.get("oplog");
if (oplogValue == null) {
throw new AssertionError("Does not contain oplog");
}
AtomicInteger tsFactory = new AtomicInteger();
AtomicInteger tFactory = new AtomicInteger();
BsonInt32 twoInt32 = DefaultBsonValues.newInt(2);
return oplogValue.asArray().asList().stream().map(BsonValue::asDocument).map(child -> {
BsonDocumentBuilder builder = new BsonDocumentBuilder(child);
if (child.get("ts") == null) {
builder.appendUnsafe("ts", DefaultBsonValues.newTimestamp(tsFactory.incrementAndGet(), tFactory.incrementAndGet()));
}
if (child.get("h") == null) {
builder.appendUnsafe("h", DefaultBsonValues.INT32_ONE);
}
if (child.get("v") == null) {
builder.appendUnsafe("v", twoInt32);
}
return builder.build();
}).map(child -> {
try {
return OplogOperationParser.fromBson(child);
} catch (MongoException ex) {
throw new AssertionError("Invalid oplog operation", ex);
}
}).collect(Collectors.toList());
}
Aggregations