use of com.fasterxml.jackson.core.util.MinimalPrettyPrinter in project hadoop by apache.
the class TestLogInfo method writeDomainLeaveOpen.
private void writeDomainLeaveOpen(TimelineDomain domain, Path logPath) throws IOException {
if (outStreamDomain == null) {
outStreamDomain = PluginStoreTestUtils.createLogFile(logPath, fs);
}
// Write domain uses its own json generator to isolate from entity writers
JsonGenerator jsonGeneratorLocal = new JsonFactory().createGenerator(outStreamDomain);
jsonGeneratorLocal.setPrettyPrinter(new MinimalPrettyPrinter("\n"));
objMapper.writeValue(jsonGeneratorLocal, domain);
outStreamDomain.hflush();
}
use of com.fasterxml.jackson.core.util.MinimalPrettyPrinter in project jackson-core by FasterXML.
the class TestPrettyPrinter method testSimpleDocWithMinimal.
@SuppressWarnings("resource")
public void testSimpleDocWithMinimal() throws Exception {
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
// first with standard minimal
gen.setPrettyPrinter(new MinimalPrettyPrinter());
String docStr = _verifyPrettyPrinter(gen, sw);
// which should have no linefeeds, tabs
assertEquals(-1, docStr.indexOf('\n'));
assertEquals(-1, docStr.indexOf('\t'));
// And then with slightly customized variant
gen = new JsonFactory().createGenerator(sw);
gen.setPrettyPrinter(new MinimalPrettyPrinter() {
@Override
public // use TAB between array values
void beforeArrayValues(JsonGenerator jg) throws IOException, JsonGenerationException {
jg.writeRaw("\t");
}
});
docStr = _verifyPrettyPrinter(gen, sw);
assertEquals(-1, docStr.indexOf('\n'));
assertTrue(docStr.indexOf('\t') >= 0);
gen.close();
}
use of com.fasterxml.jackson.core.util.MinimalPrettyPrinter in project asterixdb by apache.
the class ResultState method toString.
@Override
public String toString() {
try {
ObjectMapper om = new ObjectMapper();
ObjectNode on = om.createObjectNode();
on.put("rspid", resultSetPartitionId.toString());
on.put("async", asyncMode);
on.put("eos", eos.get());
on.put("failed", failed.get());
on.put("fileRef", String.valueOf(fileRef));
return om.writer(new MinimalPrettyPrinter()).writeValueAsString(on);
} catch (JsonProcessingException e) {
// NOSONAR
return e.getMessage();
}
}
use of com.fasterxml.jackson.core.util.MinimalPrettyPrinter in project hadoop by apache.
the class PluginStoreTestUtils method writeEntities.
/**
* Write timeline entities to a file system
* @param entities
* @param logPath
* @param fs
* @throws IOException
*/
static void writeEntities(TimelineEntities entities, Path logPath, FileSystem fs) throws IOException {
FSDataOutputStream outStream = createLogFile(logPath, fs);
JsonGenerator jsonGenerator = new JsonFactory().createGenerator(outStream);
jsonGenerator.setPrettyPrinter(new MinimalPrettyPrinter("\n"));
ObjectMapper objMapper = createObjectMapper();
for (TimelineEntity entity : entities.getEntities()) {
objMapper.writeValue(jsonGenerator, entity);
}
outStream.close();
}
use of com.fasterxml.jackson.core.util.MinimalPrettyPrinter in project hadoop by apache.
the class TestLogInfo method writeEntitiesLeaveOpen.
// TestLogInfo needs to maintain opened hdfs files so we have to build our own
// write methods
private void writeEntitiesLeaveOpen(TimelineEntities entities, Path logPath) throws IOException {
if (outStream == null) {
outStream = PluginStoreTestUtils.createLogFile(logPath, fs);
jsonGenerator = new JsonFactory().createGenerator(outStream);
jsonGenerator.setPrettyPrinter(new MinimalPrettyPrinter("\n"));
}
for (TimelineEntity entity : entities.getEntities()) {
objMapper.writeValue(jsonGenerator, entity);
}
outStream.hflush();
}
Aggregations