@Override public String toString() { return getUnwrapped().toString(); }
@Override public String toString() { return "{ collection: " + collection.getNamespace() + ", " + "filter: " + (filter == null ? "null" : filter.toString()) + ", " + (keys == null ? "null" : keys.toString()) + ", " + (hint == null ? "null" : hint.toString()) + ", " + "sort: " + (sort == null ? "null" : sort.toString()) + ", " + "skipped: " + skipped + ", " + "cursorId: " + cursorId + "}"; }
/** * @param aVars RequestContext.getAggregationVars() * @return the map function with bound aggregation variables */ public String getResolvedMap(BsonDocument aVars) { if (aVars == null || aVars.isEmpty()) { return map; } else { String escapedAVars = "\"" + aVars.toString().replaceAll("\"", "\\\\\\\\\"") + "\""; String ret = map == null ? null : map.replaceAll( Matcher.quoteReplacement("$") + "vars", escapedAVars); return ret; } }
/** * @param aVars RequestContext.getAggregationVars() * @return the reduce function with bound aggregation variables */ public String getResolvedReduce(BsonDocument aVars) { if (aVars == null || aVars.isEmpty()) { return reduce; } else { String escapedAVars = "\"" + aVars.toString().replaceAll("\"", "\\\\\\\\\"") + "\""; String ret = reduce == null ? null : reduce.replaceAll( Matcher.quoteReplacement("$") + "vars", escapedAVars ); return ret; } } }
@Override public Optional<WriteModel<BsonDocument>> handle(SinkDocument doc) { BsonDocument keyDoc = doc.getKeyDoc().orElseThrow( () -> new DataException("error: key document must not be missing for CDC mode") ); BsonDocument valueDoc = doc.getValueDoc() .orElseGet(BsonDocument::new); if(keyDoc.containsKey(JSON_ID_FIELD_PATH) && valueDoc.isEmpty()) { logger.debug("skipping debezium tombstone event for kafka topic compaction"); return Optional.empty(); } logger.debug("key: "+keyDoc.toString()); logger.debug("value: "+valueDoc.toString()); return Optional.of(getCdcOperation(valueDoc).perform(doc)); }
@Override public Optional<WriteModel<BsonDocument>> handle(SinkDocument doc) { BsonDocument keyDoc = doc.getKeyDoc().orElseThrow( () -> new DataException("error: key document must not be missing for CDC mode") ); BsonDocument valueDoc = doc.getValueDoc() .orElseGet(BsonDocument::new); if(keyDoc.containsKey(JSON_ID_FIELD_PATH) && valueDoc.isEmpty()) { logger.debug("skipping debezium tombstone event for kafka topic compaction"); return Optional.empty(); } logger.debug("key: "+keyDoc.toString()); logger.debug("value: "+valueDoc.toString()); return Optional.of(getCdcOperation(valueDoc).perform(doc)); }
@Override public boolean check( HttpServerExchange exchange, RequestContext context, BsonDocument contentToCheck, BsonValue args) { if (contentToCheck == null) { return false; } try { schema.validate(new JSONObject(contentToCheck.toString())); } catch (ValidationException ve) { context.addWarning(ve.getMessage()); ve.getCausingExceptions().stream() .map(ValidationException::getMessage) .forEach(context::addWarning); return false; } return true; }
@Override public InputStream get(String uri) { LOGGER.trace("@@@ loading schema {}", uri); if (isLocalSchemaStore(uri)) { try { SchemaStoreURL _uri = new SchemaStoreURL(uri); BsonDocument s = JsonSchemaCacheSingleton .getInstance() .getRaw( _uri.getSchemaDb(), _uri.getSchemaId()); return new ByteArrayInputStream(s.toString().getBytes("UTF-8")); } catch (JsonSchemaNotFoundException | UnsupportedEncodingException ex) { throw new RuntimeException(ex); } } else { return WRAPPED.get(uri); } }