on 03-23-2016 5:10 AM
Hi All,
The following is the input structure
<ContextChange>
10
abc
asd
qwe
<ContextChange>
20
qwe
ert
hjk
<ContextChange>
10
lkj
cvb
rfg
<ContextChange>
now basing on the first field , output should be segregated like following
<ContextChange>
10
abc
asd
qwe
lkj
cvb
rfg
<ContextChange>
20
qwe
ert
hjk
<ContextChange>
the all values under the same qualifier should come under one context.Kindly help.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shaik,
Use below UDF.
public void joinQueue(String[] queue, ResultList result, Container container) throws StreamTransformationException {
SortedMap<String, List<String>> map = new TreeMap<String, List<String>>();
boolean isPreviousCC = false;
String key = "";
for (int i = 0; i < queue.length; i++) {
if (isPreviousCC || i == 0) {
key = queue[i];
isPreviousCC = false;
continue;
}
List<String> list = map.get(key);
if (list == null) {
list = new ArrayList<String>();
list.add(queue[i]);
map.put(key, list);
} else {
if (!queue[i].equals("__cC_"))
list.add(queue[i]);
}
if (queue[i].equals("__cC_"))
isPreviousCC = true;
}
boolean first = true;
for (Entry<String, List<String>> entry : map.entrySet()) {
List<String> list = entry.getValue();
if (!first)
result.addContextChange();
else
first = false;
result.addValue(entry.getKey());
for (String value : list) {
result.addValue(value);
}
}
}
Regards,
Praveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.