-
Notifications
You must be signed in to change notification settings - Fork 0
Computing Functions IntoCollection
anymaker edited this page Apr 3, 2021
·
2 revisions
This functions working into collection for each row.
Distinct | Return true if this row is encountered for the first time |
First | Return true is current row is first |
Last | Return true is current row is last |
MaxInRows | Detect max value in path by all rows |
RowNum | Return number of current row in collection. Starting from 0. |
RowsCount | Return the number of rows in this collection |
Return true if this row is encountered for the first time.
no parameters
if this row is first, type : boolean
List<String> list = new ArrayList<>();
list.add("one");
list.add("one");
list.add(null);
list.add("two");
list.add("two");
list.add("three");
List result = engine.calc(" .(distinct) ", list, List.class);
assertEquals(4, result.size());
assertEquals("[one, null, two, three]", result.toString());
Return true is current row is first.
no parameters
row is first, type : boolean
List<String> list = new ArrayList<>();
list.add("one");
list.add(null);
list.add("two");
list.add("three");
String result = engine.calc(".(first)", list, String.class);
assertEquals("one", result);));
Return true is current row is last.
no parameters
row is last, type : boolean
List<String> list = new ArrayList<>();
list.add("one");
list.add(null);
list.add("two");
list.add("three");
String result = engine.calc(".(last)", list, String.class);
assertEquals("three", result);
Determine the max value in the path across all rows.
Unlike the similar function "max", this function looks for the largest value in all rows processed by the filter.
path
path to find value
Maximum value, type : Object
List<Object> list = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
map.put("name", "AAA");
map.put("value", 1);
list.add(map);
map = new HashMap<>();
map.put("name", "BBB");
map.put("value", 2);
list.add(map);
map = new HashMap<>();
map.put("name", "CCC");
map.put("value", 5);
list.add(map);
map = new HashMap<>();
map.put("name", "DDD");
map.put("value", 3);
list.add(map);
String result = engine.calc(" .(.value = maxInRows(.value)).name ", list, String.class);
assertEquals("CCC", result);
Return number of current row in collection. Starting from 0.
no parameters
row number, type : int
List<String> list = new ArrayList<>();
list.add("one");
list.add(null);
list.add("two");
list.add("three");
String result = engine.calc(" .(rownum = 3) ", list, String.class);
assertEquals("three", result);
Return the number of rows in this collection
no parameters
rows count, type : int
List<String> list = new ArrayList<>();
list.add("one");
list.add(null);
list.add("two");
list.add("three");
String result = engine.calc(" .(rownum = rowscount-2) ", list, String.class);
assertEquals("two", result);
- Home
- Extendable Query Language
- Computing
- Simple Usage
- Own Value Extraction
- Functions
- What is Type
- Known Types
- Add Own Type
- Data conversion
- Generate SQL Query
- Find files