make it possible to ignore columns using the csv ingestor

This commit is contained in:
2019-07-04 09:51:33 +02:00
parent 3a39f66e22
commit 2cb81e5acd
4 changed files with 45 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
package org.lucares.performance.db.ingestor;
package org.lucares.pdbui;
import java.util.ArrayList;
import java.util.Collections;

View File

@@ -1,4 +1,4 @@
package org.lucares.performance.db.ingestor;
package org.lucares.pdbui;
import java.io.IOException;
import java.net.ConnectException;

View File

@@ -1,4 +1,4 @@
package org.lucares.performance.db.ingestor;
package org.lucares.pdbui;
import java.io.IOException;
import java.nio.file.Files;
@@ -21,7 +21,6 @@ import org.lucares.collections.LongList;
import org.lucares.pdb.api.DateTimeRange;
import org.lucares.pdb.api.Query;
import org.lucares.pdb.datastore.internal.DataStore;
import org.lucares.pdbui.TcpIngestor;
import org.lucares.performance.db.PdbExport;
import org.lucares.performance.db.PerformanceDb;
import org.lucares.utils.file.FileUtils;
@@ -256,4 +255,30 @@ public class TcpIngestorTest {
Assert.assertEquals(LongPair.fromLongList(result), LongPair.fromLongList(expected));
}
}
public void testCsvIngestorIgnoresColumns() throws Exception {
try (TcpIngestor ingestor = new TcpIngestor(dataDirectory)) {
ingestor.start();
final Map<String, Object> entry = new HashMap<>();
entry.put("@timestamp",
Instant.ofEpochMilli(1).atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_ZONED_DATE_TIME));
entry.put("duration", 1);
entry.put("host", "someHost");
entry.put(TcpIngestor.Handler.COLUM_IGNORE_PREFIX + "ignored", "ignoredValue");
PdbTestUtil.sendAsCsv(entry);
} catch (final Exception e) {
LOGGER.error("", e);
throw e;
}
try (PerformanceDb db = new PerformanceDb(dataDirectory)) {
final List<String> availableFields = db.getFields(DateTimeRange.max());
Assert.assertEquals(availableFields.toString(), List.of("host").toString(),
"the ignored field is not returned");
}
}
}