stateless_lambda.patch
new/src/com/goldencode/p2j/jmx/NanoTimer.java 2023-02-15 15:52:30 +0000 | ||
---|---|---|
120 | 120 |
* @param r |
121 | 121 |
* operation to be executed |
122 | 122 |
*/ |
123 |
public void timer(Operation r) |
|
123 |
public void timer(Operation r, Object... args)
|
|
124 | 124 |
{ |
125 | 125 |
if (!enabled) |
126 | 126 |
{ |
127 | 127 |
try |
128 | 128 |
{ |
129 |
r.exec(); |
|
129 |
r.exec(args);
|
|
130 | 130 |
} |
131 | 131 |
catch (RuntimeException re) |
132 | 132 |
{ |
... | ... | |
142 | 142 |
start(); |
143 | 143 |
try |
144 | 144 |
{ |
145 |
r.exec(); |
|
145 |
r.exec(args); |
|
146 |
} |
|
147 |
catch (RuntimeException re) |
|
148 |
{ |
|
149 |
// unchecked exception propagate as is. otherwise, we can't process ConditionException. |
|
150 |
throw re; |
|
151 |
} |
|
152 |
catch (Exception e) |
|
153 |
{ |
|
154 |
throw new RuntimeException(e); |
|
155 |
} |
|
156 |
finally |
|
157 |
{ |
|
158 |
stop(); |
|
159 |
} |
|
160 |
} |
|
161 | ||
162 |
/** |
|
163 |
* Execute operation and measure execution time |
|
164 |
* @param r |
|
165 |
* operation to be executed |
|
166 |
*/ |
|
167 |
public Object timer(ReturningOperation r, Object... args) |
|
168 |
{ |
|
169 |
if (!enabled) |
|
170 |
{ |
|
171 |
try |
|
172 |
{ |
|
173 |
return r.exec(args); |
|
174 |
} |
|
175 |
catch (RuntimeException re) |
|
176 |
{ |
|
177 |
// unchecked exception propagate as is. otherwise, we can't process ConditionException. |
|
178 |
throw re; |
|
179 |
} |
|
180 |
catch (Exception e) |
|
181 |
{ |
|
182 |
throw new RuntimeException(e); |
|
183 |
} |
|
184 |
} |
|
185 |
start(); |
|
186 |
try |
|
187 |
{ |
|
188 |
return r.exec(args); |
|
146 | 189 |
} |
147 | 190 |
catch (RuntimeException re) |
148 | 191 |
{ |
new/src/com/goldencode/p2j/jmx/Operation.java 2023-02-15 15:52:10 +0000 | ||
---|---|---|
73 | 73 |
* Execute operation |
74 | 74 |
* @throws Exception |
75 | 75 |
*/ |
76 |
public void exec() |
|
76 |
public void exec(Object... args)
|
|
77 | 77 |
throws Exception; |
78 | 78 |
} |
new/src/com/goldencode/p2j/jmx/ReturningOperation.java 2023-02-15 15:55:51 +0000 | ||
---|---|---|
1 |
package com.goldencode.p2j.jmx; |
|
2 | ||
3 |
/** Functional interface for operations which may throw exceptions */ |
|
4 |
@FunctionalInterface |
|
5 |
public interface ReturningOperation |
|
6 |
{ |
|
7 |
/** |
|
8 |
* Execute operation |
|
9 |
* @throws Exception |
|
10 |
*/ |
|
11 |
public Object exec(Object... args) |
|
12 |
throws Exception; |
|
13 |
} |
new/src/com/goldencode/p2j/net/Message.java 2023-02-15 16:28:18 +0000 | ||
---|---|---|
426 | 426 |
key.readExternal(in); |
427 | 427 | |
428 | 428 |
// System.err.printf("Deserializing payload for %d; ", requestID); |
429 |
NANO_TIMER.timer( |
|
430 |
() -> setPayload(PayloadSerializer.readPayload(in)) |
|
431 |
); |
|
429 |
NANO_TIMER.timer((Operation) (args) -> setPayload(PayloadSerializer.readPayload((ObjectInput) args[0])), in); |
|
432 | 430 |
// onRead(); |
433 | 431 |
} |
434 | 432 | |
... | ... | |
452 | 450 |
out.writeInt(requestID); |
453 | 451 |
key.writeExternal(out); |
454 | 452 |
// onWrite(); |
455 |
NANO_TIMER.timer( |
|
456 |
() -> PayloadSerializer.writePayload(out, payload) |
|
457 |
); |
|
453 |
NANO_TIMER.timer((Operation) (args) -> |
|
454 |
PayloadSerializer.writePayload((ObjectOutput) args[0], args[1]), out, payload); |
|
458 | 455 |
} |
459 | 456 |
|
460 | 457 |
/* |
new/src/com/goldencode/p2j/net/Protocol.java 2023-02-15 16:11:30 +0000 | ||
---|---|---|
648 | 648 |
// Java approach handles reading an entire array as a single |
649 | 649 |
// entity which is something we want to avoid doing ourselves |
650 | 650 |
|
651 |
TO_BYTE_ARRAY_TIMER.timer( |
|
652 |
() -> setData(objToByteArray(obj)) |
|
653 |
); |
|
651 |
TO_BYTE_ARRAY_TIMER.timer((Operation) (args) -> setData(objToByteArray((Message) args[0])), obj); |
|
654 | 652 |
if (data != null) |
655 | 653 |
{ |
656 | 654 |
OUTGOING.update(data.length); |
new/src/com/goldencode/p2j/persist/BufferImpl.java 2023-02-15 16:11:28 +0000 | ||
---|---|---|
9836 | 9836 |
@Override |
9837 | 9837 |
protected boolean resourceDelete() |
9838 | 9838 |
{ |
9839 |
boolean[] res = new boolean[1]; |
|
9840 |
|
|
9841 |
RESOURCE_DEL.timer(() -> res[0] = resourceDeleteImpl()); |
|
9842 |
|
|
9843 |
return res[0]; |
|
9839 |
return (boolean) RESOURCE_DEL.timer((ReturningOperation) (args) -> resourceDeleteImpl()); |
|
9844 | 9840 |
} |
9845 | 9841 |
|
9846 | 9842 |
/** |
new/src/com/goldencode/p2j/persist/DataSet.java 2023-02-15 16:13:20 +0000 | ||
---|---|---|
526 | 526 |
*/ |
527 | 527 |
public static void associate(DataSetParameter dsSrc, DataSet dsTarget, EnumSet<ParameterOption> options) |
528 | 528 |
{ |
529 |
STATIC_PARAM.timer(() -> associateImpl(dsSrc, dsTarget, options)); |
|
529 |
STATIC_PARAM.timer((Operation) (args) -> associateImpl( |
|
530 |
(DataSetParameter) args[0], |
|
531 |
(DataSet) args[1], |
|
532 |
(EnumSet<ParameterOption>) args[2]), |
|
533 |
dsSrc, dsTarget, options); |
|
530 | 534 |
} |
531 | 535 |
|
532 | 536 |
/** |
... | ... | |
832 | 836 |
handle dsHandle, |
833 | 837 |
ParameterOption option) |
834 | 838 |
{ |
835 |
DYN_PARAM.timer(() -> createDynamicDataSetImpl(dsParam, dsHandle, option)); |
|
839 |
DYN_PARAM.timer((Operation) (args) -> createDynamicDataSetImpl( |
|
840 |
(DataSetParameter) args[0], |
|
841 |
(handle) args[1], |
|
842 |
(ParameterOption) args[2]), |
|
843 |
dsParam, dsHandle, option); |
|
836 | 844 |
} |
837 | 845 |
|
838 | 846 |
/** |
new/src/com/goldencode/p2j/persist/DynamicQueryHelper.java 2023-02-15 16:09:39 +0000 | ||
---|---|---|
142 | 142 | |
143 | 143 |
import java.io.*; |
144 | 144 |
import java.util.*; |
145 |
import java.util.List; |
|
146 |
import java.util.Map; |
|
147 | 145 |
import java.util.concurrent.atomic.*; |
148 | 146 |
import java.util.logging.*; |
149 | 147 |
import antlr.*; |
... | ... | |
297 | 295 |
* |
298 | 296 |
* @return A {@link P2JQuery} instance representing the given legacy query string. |
299 | 297 |
*/ |
298 |
@SuppressWarnings("unchecked") |
|
300 | 299 |
private static P2JQuery parse(QueryProcessor processor, |
301 | 300 |
List<Buffer> buffers, |
302 | 301 |
String predicate0, |
... | ... | |
363 | 362 |
final SymbolResolver[] sym = new SymbolResolver[1]; // build the symbol resolver |
364 | 363 |
final SchemaDictionary[] dict = new SchemaDictionary[1]; |
365 | 364 |
|
366 |
PROCESS_SYMRES.timer(() -> { |
|
365 |
// TODO: refactor to stop using stateful lambda |
|
366 |
PROCESS_SYMRES.timer((args) -> { |
|
367 | 367 |
sym[0] = SymbolResolver.newRuntimeInstance(); |
368 |
dict[0] = RecordBuffer.getSchemaDictionary(allBuffers);
|
|
369 |
sym[0].setSchemaDictionary(dict[0]); // set the schema dictionary used by this context
|
|
370 |
}); |
|
368 |
dict[0] = RecordBuffer.getSchemaDictionary((List<Buffer>) args[0]);
|
|
369 |
sym[0].setSchemaDictionary((SchemaDictionary) args[1]); // set the schema dictionary used by this context
|
|
370 |
}, allBuffers, dict[0]);
|
|
371 | 371 |
|
372 | 372 |
try |
373 | 373 |
{ |
... | ... | |
376 | 376 |
try |
377 | 377 |
{ |
378 | 378 |
// load the p2o and schema data |
379 |
PROCESS_SCHEMADICT.timer(() -> prepareTempTable(dict[0], pCode, wa.p2oFile, wa.buffers)); |
|
379 |
PROCESS_SCHEMADICT.timer((Operation) (args) -> prepareTempTable((SchemaDictionary) args[0], |
|
380 |
(StringBuilder) args[1], |
|
381 |
(String) args[2], |
|
382 |
(ArrayList<Buffer>) args[3]), |
|
383 |
dict[0], pCode, wa.p2oFile, wa.buffers); |
|
380 | 384 |
} |
381 | 385 |
catch (RuntimeException exc2) |
382 | 386 |
{ |
... | ... | |
394 | 398 |
} |
395 | 399 |
|
396 | 400 |
// add a default scope that represents the scope of the external procedure |
397 |
PROCESS_SYMRES.timer(() -> sym[0].addSchemaScope(false));
|
|
401 |
PROCESS_SYMRES.timer((Operation) (args) -> ((SymbolResolver) args[0]).addSchemaScope(false), sym[0]);
|
|
398 | 402 |
|
399 | 403 |
// parse the predicate |
400 | 404 |
String predicate = processor.preparePredicate(predicate0); |
... | ... | |
410 | 414 |
Exception err = null; |
411 | 415 |
String oeCode = pCode.toString(); |
412 | 416 |
StringReader in = new StringReader(oeCode); |
413 |
PROCESS_PARSE.timer(() -> { |
|
417 |
PROCESS_PARSE.timer((args) -> {
|
|
414 | 418 |
lexer[0] = new ProgressLexer(in, sym[0]); |
415 | 419 |
lexer[0].setUnixEscapes(!EnvironmentOps.isUnderWindowsFamily()); |
416 | 420 |
parser[0] = new ProgressParser(lexer[0], sym[0]); |
... | ... | |
430 | 434 |
// OPEN QUERY DynGenQuery <query-predicate>. |
431 | 435 |
|
432 | 436 |
// PROCESS_PARSE2.timer(() -> parser[0].external_proc()); |
433 |
PROCESS_PARSE2.timer(() -> parser[0].dynamic_query_proc());
|
|
437 |
PROCESS_PARSE2.timer((Operation) (args) -> ((ProgressParser) args[0]).dynamic_query_proc(), parser[0]);
|
|
434 | 438 |
complete = true; |
435 | 439 |
} |
436 | 440 |
catch (RuntimeException exc2) |
... | ... | |
466 | 470 |
{ |
467 | 471 |
// prepare the initial AST |
468 | 472 |
ProgressAst finalPAst0 = (ProgressAst) parser[0].getAST(); |
469 |
PROCESS_SETUP.timer(() -> { |
|
473 |
PROCESS_SETUP.timer((args) -> {
|
|
470 | 474 |
finalPAst0.brainwash(wa.dynQueryFile, true); |
471 | 475 |
prepareTree(finalPAst0, wa.buffers, wa.dynQueryFile, DYN_GEN_QUERY_CLASS); |
472 | 476 |
|
... | ... | |
491 | 495 |
if (qAst == null) |
492 | 496 |
{ |
493 | 497 |
// run conversion |
494 |
PROCESS_ANNOTATION.timer(() -> ConversionPool.runTask(ConversionProfile.ANNOTATIONS, finalPAst0)); |
|
498 |
PROCESS_ANNOTATION.timer((Operation) (args) -> |
|
499 |
ConversionPool.runTask(ConversionProfile.ANNOTATIONS, (Aast) args[0]), finalPAst0); |
|
495 | 500 |
|
496 | 501 |
ProgressAst finalPAst1 = (ProgressAst) astManager.loadTree(wa.astFile); |
497 |
PROCESS_BASE.timer(() -> ConversionPool.runTask(ConversionProfile.BASE_STRUCTURE, finalPAst1)); |
|
502 |
PROCESS_BASE.timer((Operation) (args) -> |
|
503 |
ConversionPool.runTask(ConversionProfile.BASE_STRUCTURE, (Aast) args[0]), finalPAst1); |
|
498 | 504 |
|
499 | 505 |
ProgressAst finalPAst2 = (ProgressAst) astManager.loadTree(wa.astFile); |
500 |
PROCESS_CORE.timer(() -> ConversionPool.runTask(ConversionProfile.CORE_CONVERSION, finalPAst2)); |
|
506 |
PROCESS_CORE.timer((Operation) (args) -> |
|
507 |
ConversionPool.runTask(ConversionProfile.CORE_CONVERSION, (Aast) args[0]), finalPAst2); |
|
501 | 508 |
|
502 | 509 |
ProgressAst pAst = (ProgressAst) astManager.loadTree(wa.astFile); |
503 | 510 |
|
... | ... | |
513 | 520 |
JavaAst jCode = (JavaAst) astManager.loadTree(wa.jastFile); |
514 | 521 |
// DBG: System.out.println(jCode.dumpTree(true)); |
515 | 522 |
// DBG: System.out.println(ConversionPool.runTask(ConversionProfile.BREW, jCode).getStoredObject(DYN_GEN_QUERY_CLASS)); |
516 |
PROCESS_POST.timer(() -> processor.postprocessJavaAst(jCode)); |
|
523 |
PROCESS_POST.timer((Operation) (args) -> |
|
524 |
((QueryProcessor) args[0]).postprocessJavaAst((JavaAst) args[1]), processor, jCode); |
|
517 | 525 |
|
518 | 526 |
qAst = (JavaAst) astManager.loadTree(wa.jastFile); |
519 | 527 |
if (qAst == null) |
... | ... | |
971 | 979 |
} |
972 | 980 |
}; |
973 | 981 |
|
974 |
P2JQuery[] res = new P2JQuery[1]; |
|
975 |
PARSE_QUERY.timer(() -> res[0] = parse(openQueryProcessor, buffers, predicate, qname, substBuffers)); |
|
976 |
|
|
977 |
return res[0]; |
|
982 |
return (P2JQuery) PARSE_QUERY.timer((ReturningOperation) (args) -> |
|
983 |
parse((QueryProcessor) args[0], |
|
984 |
(List<Buffer>) args[1], |
|
985 |
(String) args[2], |
|
986 |
(String) args[3], |
|
987 |
(List<Buffer>) args[4]), |
|
988 |
openQueryProcessor, buffers, predicate, qname, substBuffers); |
|
978 | 989 |
} |
979 | 990 |
|
980 | 991 |
/** |
... | ... | |
1106 | 1117 |
} |
1107 | 1118 |
}; |
1108 | 1119 |
|
1109 |
P2JQuery[] res = new P2JQuery[1]; |
|
1110 |
String pred = predicate; |
|
1111 |
PARSE_FIND.timer(() -> res[0] = parse(findQueryProcessor, buffers, pred, qname, substBuffers)); |
|
1112 |
|
|
1113 |
return res[0]; |
|
1120 | ||
1121 |
return (P2JQuery) PARSE_FIND.timer((ReturningOperation) (args) -> |
|
1122 |
parse((QueryProcessor) args[0], |
|
1123 |
(List<Buffer>) args[1], |
|
1124 |
(String) args[2], |
|
1125 |
(String) args[3], |
|
1126 |
(List<Buffer>) args[4]), |
|
1127 |
findQueryProcessor, buffers, predicate, qname, substBuffers); |
|
1114 | 1128 |
} |
1115 | 1129 |
finally |
1116 | 1130 |
{ |
new/src/com/goldencode/p2j/persist/FQLHelper.java 2023-02-15 16:14:07 +0000 | ||
---|---|---|
462 | 462 |
String fwhere = StringHelper.safeTrim(where); |
463 | 463 |
FQLHelper[] res = new FQLHelper[1]; |
464 | 464 |
|
465 |
FQL_HELPER.timer(() -> |
|
465 |
// This lamba is really big and does a lot of linking work. Try to reduce! |
|
466 |
FQL_HELPER.timer((timerArgs) -> |
|
466 | 467 |
{ |
467 | 468 |
try |
468 | 469 |
{ |
new/src/com/goldencode/p2j/persist/OutputDataSetCopier.java 2023-02-15 16:14:46 +0000 | ||
---|---|---|
108 | 108 |
@Override |
109 | 109 |
public void finished() |
110 | 110 |
{ |
111 |
COPIER.timer(() -> srcDS.performOutputCopy(outputParam));
|
|
111 |
COPIER.timer((Operation) (args) -> ((DataSet) args[0]).performOutputCopy((DataSetParameter) args[1]), srcDS, outputParam);
|
|
112 | 112 |
} |
113 | 113 | |
114 | 114 |
/** No-op. */ |
new/src/com/goldencode/p2j/persist/OutputDataSetHandleCopier.java 2023-02-15 16:15:06 +0000 | ||
---|---|---|
133 | 133 |
@Override |
134 | 134 |
public void finished() |
135 | 135 |
{ |
136 |
COPIER.timer(() -> finishedImpl()); |
|
136 |
COPIER.timer((Operation) (args) -> finishedImpl());
|
|
137 | 137 |
} |
138 | 138 |
|
139 | 139 |
/** Copies data in OUTPUT direction in DataSet-handle parameter case. */ |
new/src/com/goldencode/p2j/persist/OutputTableCopier.java 2023-02-15 16:15:45 +0000 | ||
---|---|---|
104 | 104 |
@Override |
105 | 105 |
public void finished() |
106 | 106 |
{ |
107 |
COPIER.timer(() -> srcBuf.performOutputCopy(outputParam)); |
|
107 |
COPIER.timer((Operation) (args) -> |
|
108 |
((TemporaryBuffer) args[0]).performOutputCopy((TableParameter) args[1]), srcBuf, outputParam); |
|
108 | 109 |
} |
109 | 110 | |
110 | 111 |
/** No-op. */ |
new/src/com/goldencode/p2j/persist/OutputTableHandleCopier.java 2023-02-15 16:15:57 +0000 | ||
---|---|---|
127 | 127 |
@Override |
128 | 128 |
public void finished() |
129 | 129 |
{ |
130 |
COPIER.timer(() -> finishedImpl()); |
|
130 |
COPIER.timer((Operation) (args) -> finishedImpl());
|
|
131 | 131 |
} |
132 | 132 |
|
133 | 133 |
/** Copies data in OUTPUT direction in table-handle parameter case.*/ |
new/src/com/goldencode/p2j/persist/PreselectQuery.java 2023-02-15 16:16:56 +0000 | ||
---|---|---|
6588 | 6588 | |
6589 | 6589 |
translateWhere(); |
6590 | 6590 |
|
6591 |
Operation oper = () -> |
|
6591 |
Operation oper = (args) ->
|
|
6592 | 6592 |
{ |
6593 | 6593 |
// need to put together order by clause first, as the sort criteria determined in this analysis may be |
6594 | 6594 |
// needed when composing the from-clause and where clause |
6595 | 6595 |
List<SortCriterion> sortCriteria = assembleOrderByClause(); |
6596 |
StringBuilder sb = (StringBuilder) args[0]; |
|
6596 | 6597 |
|
6597 |
assembleSelectClause(buf);
|
|
6598 |
assembleFromClause(buf, sortCriteria);
|
|
6599 |
buf.append(assembleWhereClause(sortCriteria).toFinalExpression());
|
|
6600 |
generateOrderBy(sortCriteria, buf);
|
|
6598 |
assembleSelectClause(sb);
|
|
6599 |
assembleFromClause(sb, sortCriteria);
|
|
6600 |
sb.append(assembleWhereClause(sortCriteria).toFinalExpression());
|
|
6601 |
generateOrderBy(sortCriteria, sb);
|
|
6601 | 6602 |
}; |
6602 | 6603 | |
6603 |
QUERY_ASSEMBLE.timer(oper); |
|
6604 |
QUERY_ASSEMBLE.timer(oper, buf);
|
|
6604 | 6605 |
|
6605 | 6606 |
return buf.toString().trim(); |
6606 | 6607 |
} |
new/src/com/goldencode/p2j/persist/RecordBuffer.java 2023-02-15 16:34:36 +0000 | ||
---|---|---|
2020 | 2020 |
{ |
2021 | 2021 |
Buffer[] res = new Buffer[1]; |
2022 | 2022 |
|
2023 |
DEF_BUFFER.timer(() -> |
|
2023 |
// TODO there are too many fields linked to this lambda; reduce |
|
2024 |
DEF_BUFFER.timer((args) -> |
|
2024 | 2025 |
{ |
2025 | 2026 |
RecordBuffer buffer = new RecordBuffer(def, dmoBufIface, database, null); |
2026 | 2027 |
buffer.initialize(); |
... | ... | |
2165 | 2166 |
{ |
2166 | 2167 |
Buffer[] res = new Buffer[1]; |
2167 | 2168 |
|
2168 |
DEF_BUFFER.timer(() -> |
|
2169 |
// TODO: too many lambda references |
|
2170 |
DEF_BUFFER.timer((Operation) (args) -> |
|
2169 | 2171 |
{ |
2170 | 2172 |
RecordBuffer buffer = new RecordBuffer(def, dmoBufIface, database, variable, blockDepth); |
2171 | 2173 |
|
new/src/com/goldencode/p2j/persist/RuntimeJastInterpreter.java 2023-02-15 16:20:05 +0000 | ||
---|---|---|
422 | 422 |
Aast aMethod = classMethods.get(methodName); |
423 | 423 |
if (aMethod != null) |
424 | 424 |
{ |
425 |
Object[] res = new Object[1]; |
|
426 |
QUERY_INTERPRET.timer(() -> res[0] = execMethod(aMethod, args)); |
|
427 |
return res[0]; |
|
425 |
// this lambda is linked to the args parameter |
|
426 |
return QUERY_INTERPRET.timer((ReturningOperation) (opArgs) -> execMethod(aMethod, args)); |
|
428 | 427 |
} |
429 | 428 |
throw new InterpreterException("No such method defined", null, null); |
430 | 429 |
} |
new/src/com/goldencode/p2j/persist/TableMapper.java 2023-02-15 16:20:38 +0000 | ||
---|---|---|
1650 | 1650 |
*/ |
1651 | 1651 |
static void mapTemporaryTable(TempTable table) |
1652 | 1652 |
{ |
1653 |
MAP.timer(() -> |
|
1653 |
MAP.timer((Operation) (args) ->
|
|
1654 | 1654 |
{ |
1655 |
TempTableMapper mapper = locateTemp(table);
|
|
1655 |
TempTableMapper mapper = locateTemp((TempTable) args[0]);
|
|
1656 | 1656 |
|
1657 | 1657 |
synchronized (mapper) |
1658 | 1658 |
{ |
1659 |
mapper.mapClass(table);
|
|
1659 |
mapper.mapClass((TempTable) args[0]);
|
|
1660 | 1660 |
} |
1661 |
}); |
|
1661 |
}, table);
|
|
1662 | 1662 |
} |
1663 | 1663 |
|
1664 | 1664 |
/** |
new/src/com/goldencode/p2j/persist/TempTableBuilder.java 2023-02-15 16:26:28 +0000 | ||
---|---|---|
2491 | 2491 |
} |
2492 | 2492 |
} |
2493 | 2493 |
|
2494 |
boolean[] res = new boolean[1]; |
|
2495 |
CREATE_DYN_TT.timer(() -> res[0] = DynamicTablesHelper.getInstance().createDynamicDMO(this, tableName)); |
|
2496 |
if (res[0]) |
|
2494 |
boolean res = (boolean) CREATE_DYN_TT.timer((ReturningOperation) (args) -> |
|
2495 |
DynamicTablesHelper.getInstance().createDynamicDMO((TempTableBuilder) args[0], (String) args[1]), |
|
2496 |
this, tableName); |
|
2497 |
if (res) |
|
2497 | 2498 |
{ |
2498 | 2499 |
super.name(new character(tableName)); // also makes table "prepared" |
2499 | 2500 |
createDefaultBuffer(); |
2500 | 2501 |
|
2501 | 2502 |
if (beforeName != null) |
2502 | 2503 |
{ |
2503 |
res[0] = createBeforeTable(beforeName);
|
|
2504 |
res = createBeforeTable(beforeName); |
|
2504 | 2505 |
} |
2505 | 2506 |
|
2506 | 2507 |
if (beforeTableType == BeforeType.UNKNOWN) |
... | ... | |
2513 | 2514 |
forceClear(); |
2514 | 2515 |
} |
2515 | 2516 |
|
2516 |
return new logical(res[0]);
|
|
2517 |
return new logical(res); |
|
2517 | 2518 |
} |
2518 | 2519 |
|
2519 | 2520 |
/** |
new/src/com/goldencode/p2j/persist/TemporaryBuffer.java 2023-02-15 16:25:17 +0000 | ||
---|---|---|
1059 | 1059 |
{ |
1060 | 1060 |
TempTableBuffer[] res = new TempTableBuffer[1]; |
1061 | 1061 |
|
1062 |
DEF_BUFFER.timer(() -> |
|
1062 |
// too many lambda references, reduce |
|
1063 |
DEF_BUFFER.timer((args) -> |
|
1063 | 1064 |
{ |
1064 | 1065 |
TemporaryBuffer buffer = makeBuffer(def, dmoBufIface, variable, global, new DefaultUndoState(true)); |
1065 | 1066 |
|
... | ... | |
1407 | 1408 |
{ |
1408 | 1409 |
TempTableBuffer[] res = new TempTableBuffer[1]; |
1409 | 1410 |
|
1410 |
DEF_BUFFER.timer(() -> |
|
1411 |
// too many lambda links, reduce |
|
1412 |
DEF_BUFFER.timer((args) -> |
|
1411 | 1413 |
{ |
1412 | 1414 |
TemporaryBuffer buffer = makeBuffer(def, dmoBufIface, variable, global, undoable, blockDepth); |
1413 | 1415 |
|
... | ... | |
1768 | 1770 |
{ |
1769 | 1771 |
TempTableBuffer[] res = new TempTableBuffer[1]; |
1770 | 1772 |
|
1771 |
DEF_BUFFER.timer(() -> |
|
1772 |
{ |
|
1773 |
res[0] = defineImpl(def, template, variable, legacyName, blockDepth, shared, mutable); |
|
1774 |
}); |
|
1775 |
|
|
1776 |
return (T) res[0]; |
|
1773 |
// TODO remap define parameters through the lambda args |
|
1774 |
return (T) DEF_BUFFER.timer((ReturningOperation) (args) -> |
|
1775 |
defineImpl(def, template, variable, legacyName, blockDepth, shared, mutable) |
|
1776 |
); |
|
1777 | 1777 |
} |
1778 | 1778 |
|
1779 | 1779 |
/** |
... | ... | |
2137 | 2137 |
*/ |
2138 | 2138 |
public static void associate(final TableParameter src, Temporary dstDMO, ParameterOption option) |
2139 | 2139 |
{ |
2140 |
STATIC_PARAM.timer(() -> associateImpl(src, dstDMO, EnumSet.of(option))); |
|
2140 |
STATIC_PARAM.timer((Operation) (args) -> associateImpl( |
|
2141 |
(TableParameter) args[0], |
|
2142 |
(Temporary) args[1], |
|
2143 |
(EnumSet<ParameterOption>) args[2]), |
|
2144 |
src, dstDMO, EnumSet.of(option)); |
|
2141 | 2145 |
} |
2142 | 2146 |
|
2143 | 2147 |
/** |
... | ... | |
2162 | 2166 |
*/ |
2163 | 2167 |
public static void associate(TableParameter src, Temporary dstDMO, EnumSet<ParameterOption> options) |
2164 | 2168 |
{ |
2165 |
STATIC_PARAM.timer(() -> associateImpl(src, dstDMO, options)); |
|
2169 |
STATIC_PARAM.timer((Operation) (args) -> associateImpl( |
|
2170 |
(TableParameter) args[0], |
|
2171 |
(Temporary) args[1], |
|
2172 |
(EnumSet<ParameterOption>) args[2]), |
|
2173 |
src, dstDMO, options); |
|
2166 | 2174 |
} |
2167 | 2175 |
|
2168 | 2176 |
/** |
... | ... | |
2696 | 2704 |
*/ |
2697 | 2705 |
public static void createDynamicTable(TableParameter src, handle target, ParameterOption option) |
2698 | 2706 |
{ |
2699 |
DYN_PARAM.timer(() -> createDynamicTableImpl(src, target, option)); |
|
2707 |
DYN_PARAM.timer((Operation) (args) -> createDynamicTableImpl( |
|
2708 |
(TableParameter) args[0], |
|
2709 |
(handle) args[1], |
|
2710 |
(ParameterOption) args[2]), |
|
2711 |
src, target, option); |
|
2700 | 2712 |
} |
2701 | 2713 |
|
2702 | 2714 |
/** |
... | ... | |
3601 | 3613 |
TempTable tempTable) |
3602 | 3614 |
{ |
3603 | 3615 |
Temporary[] temporary = new Temporary[1]; |
3604 |
CREATE_BUFFER.timer(() -> |
|
3616 |
// TODO: too many lambda links; reduce |
|
3617 |
CREATE_BUFFER.timer((args) -> |
|
3605 | 3618 |
{ |
3606 | 3619 |
final BufferManager bufferManager = master != null ? master.bufferManager : BufferManager.get(); |
3607 | 3620 |
String uniqueBufferName = bufferManager.generateUniqueBufferName(bufferName); |
new/src/com/goldencode/p2j/persist/orm/Query.java 2023-02-15 16:27:57 +0000 | ||
---|---|---|
345 | 345 |
{ |
346 | 346 |
if (sqlQuery == null) |
347 | 347 |
{ |
348 |
Operation op = () -> |
|
348 |
// TODO: lots of references inside this lambda: reduce |
|
349 |
Operation op = (args) -> |
|
349 | 350 |
{ |
350 | 351 |
FqlToSqlConverter fql2sql = FqlToSqlConverter.getInstance(dialect, db, params); |
351 | 352 |
rowStructure = new ArrayList<>(2); // this should be enough for most cases |
new/src/com/goldencode/p2j/persist/orm/SQLQuery.java 2023-02-15 16:31:40 +0000 | ||
---|---|---|
327 | 327 |
|
328 | 328 |
log(() -> "FWD ORM: " + stmt); |
329 | 329 |
ResultSet[] resultSetArray = new ResultSet[1]; |
330 |
SQLStatementLogger.getLogger(). |
|
331 |
log(session.getDatabase(), stmt, () -> resultSetArray[0] = stmt.executeQuery()); |
|
330 |
SQLStatementLogger.getLogger().log(session.getDatabase(), stmt, (args) -> resultSetArray[0] = stmt.executeQuery()); |
|
332 | 331 |
|
333 | 332 |
ResultSet resultSet = resultSetArray[0]; |
334 | 333 |
reportSQLWarnings(session); |
... | ... | |
377 | 376 |
|
378 | 377 |
log(() -> "FWD ORM: " + stmt); |
379 | 378 |
ResultSet[] resultSetArray = new ResultSet[1]; |
380 |
SQLStatementLogger.getLogger(). |
|
381 |
log(session.getDatabase(), stmt, () -> resultSetArray[0] = stmt.executeQuery()); |
|
379 |
SQLStatementLogger.getLogger().log(session.getDatabase(), stmt, (args) -> resultSetArray[0] = stmt.executeQuery()); |
|
382 | 380 |
|
383 | 381 |
ResultSet resultSet = resultSetArray[0]; |
384 | 382 |
return new ScrollableResults<>(stmt, resultSet, rowStructure, session); |
... | ... | |
444 | 442 |
|
445 | 443 |
log(() -> "FWD ORM: " + stmt); |
446 | 444 |
ResultSet[] resultSetArray = new ResultSet[1]; |
447 |
SQLStatementLogger.getLogger(). |
|
448 |
log(session.getDatabase(), stmt, () -> resultSetArray[0] = stmt.executeQuery()); |
|
445 |
SQLStatementLogger.getLogger().log(session.getDatabase(), stmt, (args) -> resultSetArray[0] = stmt.executeQuery()); |
|
449 | 446 |
|
450 | 447 |
ResultSet resultSet = resultSetArray[0]; |
451 | 448 |
reportSQLWarnings(session); |
... | ... | |
516 | 513 |
|
517 | 514 |
log(() -> "FWD ORM: " + stmt); |
518 | 515 |
int[] result = new int[1]; |
519 |
SQLStatementLogger.getLogger(). |
|
520 |
log(session.getDatabase(), stmt, () -> result[0] = stmt.executeUpdate()); |
|
516 |
SQLStatementLogger.getLogger().log(session.getDatabase(), stmt, (args) -> result[0] = stmt.executeUpdate()); |
|
521 | 517 |
|
522 | 518 |
return result[0]; |
523 | 519 |
} |
... | ... | |
570 | 566 |
log(() -> "FWD ORM: " + stmt); |
571 | 567 |
ResultSet[] resultSetArray = new ResultSet[1]; |
572 | 568 |
SQLStatementLogger.getLogger(). |
573 |
log(session.getDatabase(), stmt, () -> resultSetArray[0] = stmt.executeQuery()); |
|
569 |
log(session.getDatabase(), stmt, (args) -> resultSetArray[0] = stmt.executeQuery());
|
|
574 | 570 |
|
575 | 571 |
ResultSet resultSet = resultSetArray[0]; |
576 | 572 | |
... | ... | |
708 | 704 |
Session session) |
709 | 705 |
throws PersistenceException |
710 | 706 |
{ |
711 |
BaseRecord[] res = new BaseRecord[1]; |
|
712 |
HYDRATE_RECORD.timer(() -> res[0] = hydrateRecordImpl(resultSet, rowStructure, rsOffset, session)); |
|
713 |
return res[0]; |
|
707 |
return (BaseRecord) HYDRATE_RECORD.timer((ReturningOperation) (args) -> |
|
708 |
hydrateRecordImpl( |
|
709 |
(ResultSet) args[0], |
|
710 |
(RowStructure) args[1], |
|
711 |
(int) args[2], |
|
712 |
(Session) args[3]), |
|
713 |
resultSet, rowStructure, rsOffset, session); |
|
714 | 714 |
} |
715 | 715 |
|
716 | 716 |
/** |
new/src/com/goldencode/p2j/persist/orm/SavepointManager.java 2023-02-15 16:28:26 +0000 | ||
---|---|---|
89 | 89 | |
90 | 90 |
import com.goldencode.p2j.jmx.FwdJMX; |
91 | 91 |
import com.goldencode.p2j.jmx.NanoTimer; |
92 |
import com.goldencode.p2j.jmx.Operation; |
|
92 | 93 |
import com.goldencode.p2j.persist.*; |
93 | 94 |
import com.goldencode.p2j.util.*; |
94 | 95 |
import com.goldencode.p2j.util.LogHelper; |
... | ... | |
472 | 473 |
{ |
473 | 474 |
if (session != null && activeBlock != null) |
474 | 475 |
{ |
475 |
NO_UNDO_TRACE.timer(() -> { |
|
476 |
// going to be removed anyways |
|
477 |
NO_UNDO_TRACE.timer((args) -> { |
|
476 | 478 |
SQLRedo.Insert redo = new SQLRedo.Insert(session.getPersister(), dmo.deepCopy()); |
477 | 479 |
redoable.add(redo); |
478 | 480 |
}); |
... | ... | |
491 | 493 |
{ |
492 | 494 |
if (session != null && activeBlock != null && dmo.checkState(CHANGED)) |
493 | 495 |
{ |
494 |
NO_UNDO_TRACE.timer(() -> { |
|
496 |
// going to be removed anyways |
|
497 |
NO_UNDO_TRACE.timer((args) -> { |
|
495 | 498 |
SQLRedo.Update redo = new SQLRedo.Update(session.getPersister(), dmo.deepCopy()); |
496 | 499 |
redoable.add(redo); |
497 | 500 |
}); |
... | ... | |
512 | 515 |
{ |
513 | 516 |
if (session != null && activeBlock != null) |
514 | 517 |
{ |
515 |
NO_UNDO_TRACE.timer(() -> { |
|
518 |
// going to be removed anyways |
|
519 |
NO_UNDO_TRACE.timer((args) -> { |
|
516 | 520 |
SQLRedo.Delete redo = new SQLRedo.Delete(session.getPersister(), dmoClass, id); |
517 | 521 |
redoable.add(redo); |
518 | 522 |
}); |
... | ... | |
532 | 536 |
{ |
533 | 537 |
if (session != null && activeBlock != null) |
534 | 538 |
{ |
535 |
NO_UNDO_TRACE.timer(() -> { |
|
539 |
// going to be removed anyways |
|
540 |
NO_UNDO_TRACE.timer((args) -> { |
|
536 | 541 |
SQLRedo.BulkUpdate redo = new SQLRedo.BulkUpdate(session, query); |
537 | 542 |
redoable.add(redo); |
538 | 543 |
}); |
... | ... | |
647 | 652 |
// let the noUndoRolledBack flag check here to avoid profiling disabled redo |
648 | 653 |
if (session != null && lastActiveBlock != null && lastActiveBlock.noUndoRolledBack) |
649 | 654 |
{ |
650 |
REDO.timer(() -> lastActiveBlock.maybeReapplyNoUndo(session)); |
|
655 |
// going to be removed anyways |
|
656 |
REDO.timer((Operation) (args) -> lastActiveBlock.maybeReapplyNoUndo(session)); |
|
651 | 657 |
} |
652 | 658 |
|
653 | 659 |
// reactivate the next block in the stack (if any) |
new/src/com/goldencode/p2j/persist/orm/UnclosablePreparedStatement.java 2023-02-15 16:32:12 +0000 | ||
---|---|---|
468 | 468 |
{ |
469 | 469 |
Object[] res = new Object[1]; |
470 | 470 |
SQLException[] exc = new SQLException[1]; |
471 |
EXEC.timer(() -> |
|
471 |
// TODO use lambda args |
|
472 |
EXEC.timer((args) -> |
|
472 | 473 |
{ |
473 | 474 |
try |
474 | 475 |
{ |
new/src/com/goldencode/p2j/security/ContextLocal.java 2023-02-15 15:56:00 +0000 | ||
---|---|---|
454 | 454 |
* @return Context local variable. |
455 | 455 |
*/ |
456 | 456 |
public final T get(boolean create) |
457 |
{ |
|
458 |
Object[] res = new Object[1]; |
|
459 |
|
|
460 |
GET.timer(() -> res[0] = getImpl(create)); |
|
461 |
|
|
462 |
return (T) res[0]; |
|
457 |
{ |
|
458 |
return (T) GET.timer((ReturningOperation) (args) -> getImpl((boolean) args[0]), create); |
|
463 | 459 |
} |
464 | 460 |
|
465 | 461 |
/** |
new/src/com/goldencode/p2j/ui/ServerState.java 2023-02-15 15:53:42 +0000 | ||
---|---|---|
254 | 254 |
environments = readList(in, (Supplier<EnvironmentColorTable>) EnvironmentColorTable::new); |
255 | 255 |
|
256 | 256 |
deadFrames = readIntArray(in); |
257 |
NANO_TIMER.timer(() -> |
|
257 |
NANO_TIMER.timer((args) ->
|
|
258 | 258 |
{ |
259 |
setWidgetAttrIds((int[]) PayloadSerializer.readPayload(in));
|
|
260 |
setWidgetAttrValues((Object[]) PayloadSerializer.readPayload(in));
|
|
261 |
}); |
|
259 |
setWidgetAttrIds((int[]) PayloadSerializer.readPayload((ObjectInput) args[0]));
|
|
260 |
setWidgetAttrValues((Object[]) PayloadSerializer.readPayload((ObjectInput) args[0]));
|
|
261 |
}, in);
|
|
262 | 262 |
} |
263 | 263 | |
264 | 264 |
/** |
... | ... | |
288 | 288 |
|
289 | 289 |
writeIntArray(out, deadFrames); |
290 | 290 |
|
291 |
NANO_TIMER.timer(() -> |
|
291 |
NANO_TIMER.timer((args) ->
|
|
292 | 292 |
{ |
293 |
PayloadSerializer.writePayload(out, widgetAttrIds);
|
|
294 |
PayloadSerializer.writePayload(out, widgetAttrValues);
|
|
295 |
}); |
|
293 |
PayloadSerializer.writePayload((ObjectOutput) args[0], args[1]);
|
|
294 |
PayloadSerializer.writePayload((ObjectOutput) args[0], args[2]);
|
|
295 |
}, out, widgetAttrIds, widgetAttrValues);
|
|
296 | 296 |
} |
297 | 297 |
} |
new/src/com/goldencode/p2j/util/LegacyJavaAppserver.java 2023-02-15 16:33:18 +0000 | ||
---|---|---|
963 | 963 |
@Override |
964 | 964 |
public void addTableMetaData(DataObject metaData, DataObject table) |
965 | 965 |
{ |
966 |
TABLE_META.timer(() -> DataSetSDOHelper.addTableMetaData(metaData, table)); |
|
966 |
TABLE_META.timer((Operation) (args) -> |
|
967 |
DataSetSDOHelper.addTableMetaData((DataObject) args[0], (DataObject) args[1]), metaData, table); |
|
967 | 968 |
} |
968 | 969 | |
969 | 970 |
/** |
... | ... | |
1041 | 1042 |
{ |
1042 | 1043 |
LegacyJavaAppserverParameter[] res = new LegacyJavaAppserverParameter[1]; |
1043 | 1044 |
|
1044 |
JAVA_PARAM.timer(() -> |
|
1045 |
// TODO: Huge lambda; try to reduce! |
|
1046 |
JAVA_PARAM.timer((args) -> |
|
1045 | 1047 |
{ |
1046 | 1048 |
Object value = pvalue; |
1047 | 1049 |
Object orig = value; |
... | ... | |
1188 | 1190 |
{ |
1189 | 1191 |
Object[] res = new Object[1]; |
1190 | 1192 |
|
1191 |
OUTPUT_PARAM.timer(() -> |
|
1193 |
// TODO: huge lambda; try to reduce |
|
1194 |
OUTPUT_PARAM.timer((args) -> |
|
1192 | 1195 |
{ |
1193 | 1196 |
int type = param.getType(); |
1194 | 1197 |
Object arg = param.getValue(); |
new/src/com/goldencode/p2j/util/TransactionManager.java 2023-02-15 16:33:46 +0000 | ||
---|---|---|
6653 | 6653 |
return; |
6654 | 6654 |
} |
6655 | 6655 |
|
6656 |
ROLLBACK.timer(() -> |
|
6656 |
// TODO: huge lambda; try to reduce |
|
6657 |
ROLLBACK.timer((args) -> |
|
6657 | 6658 |
{ |
6658 | 6659 |
if (LOG.isLoggable(Level.FINE)) |
6659 | 6660 |
{ |
... | ... | |
6751 | 6752 |
{ |
6752 | 6753 |
return; |
6753 | 6754 |
} |
6754 |
|
|
6755 |
COMMIT.timer(() -> |
|
6755 | ||
6756 |
// TODO: huge lambda; try to reduce |
|
6757 |
COMMIT.timer((args) -> |
|
6756 | 6758 |
{ |
6757 | 6759 |
if (LOG.isLoggable(Level.FINE)) |
6758 | 6760 |
{ |
... | ... | |
7070 | 7072 |
private static void processValidate(WorkArea wa) |
7071 | 7073 |
throws ErrorConditionException |
7072 | 7074 |
{ |
7073 |
VALIDATE.timer(() -> |
|
7075 |
// TODO: huge lambda; try to reduce |
|
7076 |
VALIDATE.timer((args) -> |
|
7074 | 7077 |
{ |
7075 | 7078 |
if (LOG.isLoggable(Level.FINE)) |
7076 | 7079 |
{ |