@Test public void testMerge() { System.out.println("testMerge"); UTF8Row r1 = creator.create(UTF8Util.toUtf8("{\"c0\": 100, \"c1\": 88, \"c2\": 4.7, \"c3\": 0.22, \"c4\": \"col4\", \"c5\": 300}")).get(0); UTF8Row r2 = creator.create(UTF8Util.toUtf8("{\"c0\": 100, \"c2\": 4.71, \"c3\": 0.22, \"c4\": \"col4\", \"c5\": 300}")).get(0); UTF8Row r3 = creator.create(UTF8Util.toUtf8("{\"c0\": 11, \"c1\": 88, \"c2_alias\" : 8.2, \"c3\": 0.1, \"c4\": \"col4\", \"c5\": 200}")).get(0); printRow(r1); System.out.println(); printRow(r2); System.out.println(); printRow(r3); Assert.assertNotEquals(0, comparator.compare(r1, r2)); Assert.assertEquals(0, comparator.compare(r1, r3)); r1.merge(r3); System.out.println(); System.out.println("merge:"); printRow(r1); }
public void merge(UTF8Row other) { assert creator.hasDims; assert creator.indexAggTypes != null; assert dimDataSize == other.dimDataSize; if (rowDataAddr == 0) { throw new IllegalStateException("illegal row"); } for (int index = creator.dimCount; index < creator.columnCount; index++) { byte type = creator.indexTypes[index].dataType; int aggType = creator.indexAggTypes[index]; int metricIndex = index - creator.dimCount; long offset = dimDataSize + (metricIndex << 3); long value1 = MemoryUtil.getLong(rowDataAddr + offset); long value2 = MemoryUtil.getLong(other.rowDataAddr + offset); long newValue = AggType.agg(aggType, type, value1, value2); MemoryUtil.setLong(rowDataAddr + offset, newValue); } }
UTF8Row implements Row, Serializable { public void merge(UTF8Row other) { assert creator.hasDims; assert creator.indexAggTypes != null; assert dimDataSize == other.dimDataSize; if (rowDataAddr == 0) { throw new IllegalStateException("illegal row"); } for (int index = creator.dimCount; index < creator.columnCount; index++) { byte type = creator.indexTypes[index].dataType; int aggType = creator.indexAggTypes[index]; int metricIndex = index - creator.dimCount; long offset = dimDataSize + (metricIndex << 3); long value1 = MemoryUtil.getLong(rowDataAddr + offset); long value2 = MemoryUtil.getLong(other.rowDataAddr + offset); long newValue = AggType.agg(aggType, type, value1, value2); MemoryUtil.setLong(rowDataAddr + offset, newValue); } } }
UTF8Row implements Row, Serializable { public void merge(UTF8Row other) { assert creator.hasDims; assert creator.indexAggTypes != null; assert dimDataSize == other.dimDataSize; if (rowDataAddr == 0) { throw new IllegalStateException("illegal row"); } for (int index = creator.dimCount; index < creator.columnCount; index++) { byte type = creator.indexTypes[index].dataType; int aggType = creator.indexAggTypes[index]; int metricIndex = index - creator.dimCount; long offset = dimDataSize + (metricIndex << 3); long value1 = MemoryUtil.getLong(rowDataAddr + offset); long value2 = MemoryUtil.getLong(other.rowDataAddr + offset); long newValue = AggType.agg(aggType, type, value1, value2); MemoryUtil.setLong(rowDataAddr + offset, newValue); } } private  UTF8Row(long code, Creator creator, long rowDataMemoryBase, long rowDataAddr, int rowDataSize, int dimDataSize); }
UTF8Row implements Row, Serializable { public void merge(UTF8Row other) { assert creator.hasDims; assert creator.indexAggTypes != null; assert dimDataSize == other.dimDataSize; if (rowDataAddr == 0) { throw new IllegalStateException("illegal row"); } for (int index = creator.dimCount; index < creator.columnCount; index++) { byte type = creator.indexTypes[index].dataType; int aggType = creator.indexAggTypes[index]; int metricIndex = index - creator.dimCount; long offset = dimDataSize + (metricIndex << 3); long value1 = MemoryUtil.getLong(rowDataAddr + offset); long value2 = MemoryUtil.getLong(other.rowDataAddr + offset); long newValue = AggType.agg(aggType, type, value1, value2); MemoryUtil.setLong(rowDataAddr + offset, newValue); } } private  UTF8Row(long code, Creator creator, long rowDataMemoryBase, long rowDataAddr, int rowDataSize, int dimDataSize); void free(); int memoryUsage(); @Override int hashCode(); @Override boolean equals(Object obj); static Comparator<UTF8Row> dimBytesComparator(); @Override String toString(); @Override boolean serialize(ByteBuffer byteBuffer); void merge(UTF8Row other); @Override long getUniformValue(int colId, byte type); @Override int getInt(int colId); @Override long getLong(int colId); @Override float getFloat(int colId); @Override double getDouble(int colId); @Override UTF8String getString(int colId); @Override void getRaw(int colId, BytePiece bytes); @Override byte[] getRaw(int colId); static UTF8Row from(Creator creator, Row row); }
UTF8Row implements Row, Serializable { public void merge(UTF8Row other) { assert creator.hasDims; assert creator.indexAggTypes != null; assert dimDataSize == other.dimDataSize; if (rowDataAddr == 0) { throw new IllegalStateException("illegal row"); } for (int index = creator.dimCount; index < creator.columnCount; index++) { byte type = creator.indexTypes[index].dataType; int aggType = creator.indexAggTypes[index]; int metricIndex = index - creator.dimCount; long offset = dimDataSize + (metricIndex << 3); long value1 = MemoryUtil.getLong(rowDataAddr + offset); long value2 = MemoryUtil.getLong(other.rowDataAddr + offset); long newValue = AggType.agg(aggType, type, value1, value2); MemoryUtil.setLong(rowDataAddr + offset, newValue); } } private  UTF8Row(long code, Creator creator, long rowDataMemoryBase, long rowDataAddr, int rowDataSize, int dimDataSize); void free(); int memoryUsage(); @Override int hashCode(); @Override boolean equals(Object obj); static Comparator<UTF8Row> dimBytesComparator(); @Override String toString(); @Override boolean serialize(ByteBuffer byteBuffer); void merge(UTF8Row other); @Override long getUniformValue(int colId, byte type); @Override int getInt(int colId); @Override long getLong(int colId); @Override float getFloat(int colId); @Override double getDouble(int colId); @Override UTF8String getString(int colId); @Override void getRaw(int colId, BytePiece bytes); @Override byte[] getRaw(int colId); static UTF8Row from(Creator creator, Row row);  }