use of com.linkedin.pinot.core.data.GenericRow in project pinot by linkedin.
the class PinotSegmentRecordReaderTest method createTestData.
private List<GenericRow> createTestData() {
List<GenericRow> rows = new ArrayList<>();
Random random = new Random();
Map<String, Object> fields;
for (int i = 0; i < 10000; i++) {
fields = new HashMap<>();
fields.put(D_SV_1, D_SV_1 + "_" + RandomStringUtils.randomAlphabetic(2));
Object[] d2Array = new Object[5];
for (int j = 0; j < 5; j++) {
d2Array[j] = D_MV_1 + "_" + j + "_" + RandomStringUtils.randomAlphabetic(2);
}
fields.put(D_MV_1, d2Array);
fields.put(M1, Math.abs(random.nextInt()));
fields.put(M2, Math.abs(random.nextFloat()));
fields.put(TIME, Math.abs(random.nextLong()));
GenericRow row = new GenericRow();
row.init(fields);
rows.add(row);
}
return rows;
}
use of com.linkedin.pinot.core.data.GenericRow in project pinot by linkedin.
the class TestRecordReader method next.
@Override
public GenericRow next() {
GenericRow row = rows.get(recordNumber);
recordNumber++;
return row;
}
use of com.linkedin.pinot.core.data.GenericRow in project pinot by linkedin.
the class OffHeapStarTreeBuilder method toGenericRow.
public GenericRow toGenericRow(DimensionBuffer dimensionKey, MetricBuffer metricsHolder) {
GenericRow row = new GenericRow();
Map<String, Object> map = new HashMap<>();
for (int i = 0; i < dimensionNames.size(); i++) {
String dimName = dimensionNames.get(i);
BiMap<Integer, Object> inverseDictionary = dictionaryMap.get(dimName).inverse();
Object dimValue = inverseDictionary.get(dimensionKey.getDimension(i));
if (dimValue == null) {
dimValue = dimensionNameToStarValueMap.get(dimName);
}
map.put(dimName, dimValue);
}
for (int i = 0; i < numMetrics; i++) {
String metName = metricNames.get(i);
map.put(metName, metricsHolder.getValueConformToDataType(i));
}
row.init(map);
return row;
}
use of com.linkedin.pinot.core.data.GenericRow in project pinot by linkedin.
the class PlainFieldExtractorTest method differentIncomingOutgoingTimeSpecTest.
@Test
public void differentIncomingOutgoingTimeSpecTest() {
Schema schema = new Schema.SchemaBuilder().setSchemaName("testSchema").addTime("incoming", TimeUnit.DAYS, DataType.INT, "outgoing", TimeUnit.HOURS, DataType.LONG).build();
PlainFieldExtractor plainFieldExtractor = new PlainFieldExtractor(schema);
GenericRow row = new GenericRow();
Map<String, Object> fieldMap = new HashMap<>();
long currentDaysSinceEpoch = System.currentTimeMillis() / 1000 / 60 / 60 / 24;
fieldMap.put("incoming", currentDaysSinceEpoch);
row.init(fieldMap);
row = plainFieldExtractor.transform(row);
Assert.assertNull(row.getValue("incoming"));
Assert.assertTrue(row.getValue("outgoing") instanceof Long);
Assert.assertEquals(row.getValue("outgoing"), currentDaysSinceEpoch * 24);
}
use of com.linkedin.pinot.core.data.GenericRow in project pinot by linkedin.
the class PlainFieldExtractorTest method simpleTest.
@Test
public void simpleTest() {
Schema schema = new Schema.SchemaBuilder().setSchemaName("testSchema").addSingleValueDimension("svDimensionInt", DataType.INT).addSingleValueDimension("svDimensionDouble", DataType.DOUBLE).addSingleValueDimension("svClassObject", DataType.STRING).addMultiValueDimension("mvDimensionLong", DataType.LONG).addMultiValueDimension("mvClassObject", DataType.STRING).addMetric("metricInt", DataType.INT).addTime("timeInt", TimeUnit.DAYS, DataType.INT).build();
PlainFieldExtractor plainFieldExtractor = new PlainFieldExtractor(schema);
GenericRow row = new GenericRow();
Map<String, Object> fieldMap = new HashMap<>();
fieldMap.put("svDimensionInt", (short) 5);
fieldMap.put("svDimensionDouble", 3.2F);
fieldMap.put("svClassObject", new AnyClassWithToString());
fieldMap.put("mvDimensionLong", 13);
fieldMap.put("mvClassObject", new Object[] { new AnyClassWithToString(), new AnyClassWithToString() });
fieldMap.put("metricInt", 34.5);
long currentDaysSinceEpoch = System.currentTimeMillis() / 1000 / 60 / 60 / 24;
fieldMap.put("timeInt", currentDaysSinceEpoch);
row.init(fieldMap);
row = plainFieldExtractor.transform(row);
Assert.assertTrue(row.getValue("svDimensionInt") instanceof Integer);
Assert.assertEquals(row.getValue("svDimensionInt"), 5);
Assert.assertTrue(row.getValue("svDimensionDouble") instanceof Double);
Assert.assertEquals((double) row.getValue("svDimensionDouble"), 3.2, 0.1);
Assert.assertTrue(row.getValue("svClassObject") instanceof String);
Assert.assertEquals(row.getValue("svClassObject"), "AnyClass");
Assert.assertTrue(row.getValue("mvDimensionLong") instanceof Object[]);
Assert.assertTrue(((Object[]) row.getValue("mvDimensionLong"))[0] instanceof Long);
Assert.assertEquals(((Object[]) row.getValue("mvDimensionLong"))[0], 13L);
Assert.assertTrue(row.getValue("mvClassObject") instanceof Object[]);
Assert.assertTrue(((Object[]) row.getValue("mvClassObject"))[0] instanceof String);
Assert.assertTrue(((Object[]) row.getValue("mvClassObject"))[1] instanceof String);
Assert.assertEquals(((Object[]) row.getValue("mvClassObject"))[0], "AnyClass");
Assert.assertEquals(((Object[]) row.getValue("mvClassObject"))[1], "AnyClass");
Assert.assertTrue(row.getValue("metricInt") instanceof Integer);
Assert.assertEquals(row.getValue("metricInt"), 34);
Assert.assertTrue(row.getValue("timeInt") instanceof Integer);
Assert.assertEquals(row.getValue("timeInt"), (int) currentDaysSinceEpoch);
}
Aggregations