Skip to content

Commit 8a1d8eb

Browse files
committed
优化
1 parent 6fcc666 commit 8a1d8eb

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/main/java/org/jetlinks/reactor/ql/DefaultReactorQL.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected void prepare() {
102102
)
103103
)
104104
))
105-
.subscriberContext(context -> context.put(ReactorQLContext.class, context));
105+
.subscriberContext(context -> context.put(ReactorQLContext.class, ctx));
106106
} else {
107107
builder = ctx ->
108108
limit.apply(ctx,
@@ -116,7 +116,7 @@ protected void prepare() {
116116
)
117117
)
118118
)
119-
).subscriberContext(context -> context.put(ReactorQLContext.class, context));
119+
).subscriberContext(context -> context.put(ReactorQLContext.class, ctx));
120120
}
121121
}
122122

src/main/java/org/jetlinks/reactor/ql/DefaultReactorQLRecord.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,32 @@ public class DefaultReactorQLRecord implements ReactorQLRecord, Comparable<Defau
1414
@Getter
1515
private ReactorQLContext context;
1616

17-
private final Map<String, Object> records = new ConcurrentHashMap<>(32);
17+
private final Map<String, Object> records;
1818

19-
private final Map<String, Object> results = new ConcurrentHashMap<>(32);
19+
private final Map<String, Object> results;
2020

2121
private final static String THIS_RECORD = "this";
2222

2323
@Getter
2424
@Setter
2525
private String name;
2626

27+
public DefaultReactorQLRecord(
28+
String name,
29+
Map<String, Object> records,
30+
Map<String, Object> results,
31+
ReactorQLContext context) {
32+
this.name = name;
33+
this.records = records instanceof ConcurrentHashMap ? records : new ConcurrentHashMap<>(records);
34+
this.results = results instanceof ConcurrentHashMap ? results : new ConcurrentHashMap<>(results);
35+
this.context = context;
36+
}
37+
2738
public DefaultReactorQLRecord(
2839
String name,
2940
Object thisRecord,
3041
ReactorQLContext context) {
42+
this();
3143
if (name != null) {
3244
records.put(name, thisRecord);
3345
}
@@ -39,6 +51,8 @@ public DefaultReactorQLRecord(
3951
}
4052

4153
private DefaultReactorQLRecord() {
54+
records = new ConcurrentHashMap<>(32);
55+
results = new ConcurrentHashMap<>(32);
4256
}
4357

4458
@Override
@@ -102,7 +116,7 @@ public ReactorQLRecord addRecords(Map<String, Object> records) {
102116
@Override
103117
public Map<String, Object> getRecords(boolean all) {
104118
if (all) {
105-
return Collections.unmodifiableMap(records);
119+
return records;
106120
}
107121
return Maps.filterKeys(records, (k) -> !Objects.equals(THIS_RECORD, k));
108122
}

0 commit comments

Comments
 (0)