Performance improvement for returning energy summaries from DB. Change the way MQTT values are posted. Add a BOM utf-8 char to the BOM csv, yo dawg, bom.

This commit is contained in:
MarkBryanMilligan
2021-08-29 22:53:41 -05:00
parent 77ceec745c
commit d63f6df1fd
12 changed files with 71 additions and 31 deletions

View File

@@ -10,7 +10,7 @@ public abstract class CSVWriter {
}
public static String toString(CSV _csv) {
StringBuilder out = new StringBuilder();
StringBuilder out = new StringBuilder("\uFEFF");
if (CollectionUtils.isNotEmpty(_csv.getHeaders())) {
out.append(CollectionUtils.transformToCommaSeparated(_csv.getHeaders(), _h -> "\"" + _h + "\""));
out.append("\r\n");

View File

@@ -214,12 +214,7 @@ public class MongoProxy extends AbstractDaoProxy {
iter.skip(_offset);
if (_count > 0)
iter.limit(_count);
return CollectionUtils.transform(iter, new ITransformer<Document, DaoEntity>() {
@Override
public DaoEntity transform(Document _document) {
return new DaoEntity(_document);
}
});
return CollectionUtils.transform(iter, DaoEntity::new);
}
@Override

View File

@@ -195,6 +195,26 @@ public abstract class AbstractDaoProxy implements IDaoProxy {
return queryForEntities(_tableName, _query, _fields, _sort, 0, -1);
}
@Override
public <T> DaoEntity queryForEntity(Class<T> _class, DaoQuery _query) {
return queryForEntity(DaoSerializer.getTableName(_class, getType()), _query);
}
@Override
public <T> DaoEntity queryForEntity(Class<T> _class, DaoQuery _query, DaoSort _sort) {
return queryForEntity(DaoSerializer.getTableName(_class, getType()), _query, _sort);
}
@Override
public <T> DaoEntity queryForEntity(Class<T> _class, DaoQuery _query, Collection<String> _fields) {
return queryForEntity(DaoSerializer.getTableName(_class, getType()), _query, _fields);
}
@Override
public <T> DaoEntity queryForEntity(Class<T> _class, DaoQuery _query, Collection<String> _fields, DaoSort _sort) {
return queryForEntity(DaoSerializer.getTableName(_class, getType()), _query, _fields, _sort);
}
@Override
public DaoEntity queryForEntity(String _tableName, DaoQuery _query) {
return CollectionUtils.getFirst(queryForEntities(_tableName, _query, null, null, 0, 1));

View File

@@ -14,14 +14,12 @@ public class DaoEntity implements Map<String, Object> {
}
public DaoEntity(Document _doc) {
map = _doc == null?new Document():_doc;
map = (_doc == null) ? new Document() : _doc;
}
public DaoEntity(Map<String, ?> _map) {
map = new Document();
for (Entry<String, ?> e : _map.entrySet()) {
map.put(e.getKey(), e.getValue());
}
map.putAll(_map);
}
public DaoEntity(String _name, Object _o) {

View File

@@ -35,6 +35,10 @@ public interface IDaoProxy {
<T> Future<List<T>> queryImportantAsync(Class<T> _class, DaoQuery _query, DaoSort _sort);
<T> List<T> queryImportant(Class<T> _class, DaoQuery _query, DaoSort _sort, int _offset, int _count);
<T> DaoPage<T> queryImportantPage(Class<T> _class, DaoQuery _query, DaoSort _sort, int _offset, int _count);
<T> DaoEntity queryForEntity(Class<T> _class, DaoQuery _query);
<T> DaoEntity queryForEntity(Class<T> _class, DaoQuery _query, DaoSort _sort);
<T> DaoEntity queryForEntity(Class<T> _class, DaoQuery _query, Collection<String> _fields);
<T> DaoEntity queryForEntity(Class<T> _class, DaoQuery _query, Collection<String> _fields, DaoSort _sort);
DaoEntity queryForEntity(String _tableName, DaoQuery _query);
DaoEntity queryForEntity(String _tableName, DaoQuery _query, DaoSort _sort);
DaoEntity queryForEntity(String _tableName, DaoQuery _query, Collection<String> _fields);