HogePrice hogePrice
= operator.hogePrice(this.hoge);
JoinedMoge joinedMoge
= operator.joinedMoge
(this.moge, hogePrice.CHEEP);
@Branch
public Status hogePrice(Hoge hoge) {
int price = hoge.getPrice();
if (price < 0) {
return Status.ERROR;
}
if (price >= 1000000) {
return Status.EXPENSIVE;
}
return Status.CHEAP;
}
public enum Status {
EXPENSIVE, CHEAP, ERROR
}
In in1, in2, in3;
Out out;
@Override
protected void describe() {
CoreOperatorFactory core
= new CoreOperatorFactory();
Confluent<Hoge> op
= core.confluent(in1,in2,in3);
out.add(op);
}
// 実装不要
UpdatedHoge updatedHoge
= operator.updatedHoge(this.hoge);
out.add(updatedHoge.out);
@Update
public void updatedHoge(Hoge hoge){
hoge.setMoge("foo");
}
ConvertedHoge convertedHoge
= operator.convertedHoge(this.hoge);
out.add(convertedHoge.out);
@Convert
public Moge convertedHoge(Hoge hoge){
Moge moge = new Moge();
moge.setMoge(hoge.getHoge());
return moge;
}
In in;
Out out;
@Override
protected void describe() {
CoreOperatorFactory core
= new CoreOperatorFactory();
Extend<Foo> op
= core.extend(in, Foo.class);
out.add(op);
}
// 実装不要
In in;
Out out;
@Override
protected void describe() {
CoreOperatorFactory core
= new CoreOperatorFactory();
Project<Hoge> op
= core.project(in, Hoge.class);
out.add(op);
}
// 実装不要
In in;
Out out;
@Override
protected void describe() {
CoreOperatorFactory core
= new CoreOperatorFactory();
Restructure<Hoge> op
= core.restructure(in, Hoge.class);
out.add(op);
}
// 実装不要
ExtractFields ef
= operator.extractFields(hoge, a, b);
this.out.add(ef.aResult);
private A a = new A();
private B b = new B();
@Extract
public void extractFields(
Hoge hoge,
Result<A> aResult,
Result<B> bResult){
a.setValue(hoge.getA());
aResult.add(a);
b.setValue(hoge.getB0());
bResult.add(b);
b.setValue(hoge.getB1());
bResult.add(b);
}
Exists exists
= mainOperator.exists(master, tx);
this.out.add(exists.found);
@MasterCheck
public abstract boolean exists(
@Key(group = "id") HogeMst master,
@Key(group = "masterId") HogeTrn tx);
Join join
= operator.join(master, tx);
this.join.add(join.out);
core.stop(join.missed);
@MasterJoin
public abstract Hoge join(
HogeMst master,
HogeTrn tx);
BranchWithJoin branchWithJoin
= operator.branchWithJoin
(this.itemMaster, this.tx);
this.out.add(
branchWithJoin.expensive);
@MasterBranch
public Status branchWithJoin(
@Key(group = "id") ItemMst master,
@Key(group = "itemId") HogeTrn tx) {
if (master == null) {
return Status.ERROR;
}
int price = master.getPrice();
if (price < 0) {
return Status.ERROR;
}
if (price >= 1000000) {
return Status.EXPENSIVE;
}
return Status.CHEAP;
}
public enum Status {
EXPENSIVE,CHEAP,ERROR
}
UpdateWithMaster uwm = operator.updateWithMaster(master, tx);
this.out.add(uwm.updated);
core.stop(uwm.missed);
@MasterJoinUpdate
public void updateWithMaster(
@Key(group = "id") ItemMst master,
@Key(group = "itemId") HogeTrn tx) {
tx.setPrice(master.getPrice());
}
CheckUp checkup
= operator.checkUp(this.hoge, this.foo);
this.hoge.add(checkUp.hogeResult);
this.foo.add(checkUp.fooResult);
this.hogeErr.add(checkUp.hogeError);
this.fooErr.add(checkUp.fooError);
@CoGroup
public void checkUp(
@Key(group="id") List hogeList,
@Key(group="hogeId") List fooList,
Result<Hoge> hogeResult,
Result<Foo> fooResult,
Result<Hoge> hogeError,
Result<Foo> fooError) {
// いずれも存在+重複なしで突合成功
if (hogeList.size() == 1
&& fooList.size() == 1) {
hogeResult.add(hogeList.get(0));
fooResult.add(fooList.get(0));
}
// それ以外はエラー
else {
for (Hoge hoge : hogeList) {
hogeError.add(hoge);
}
for (Foo foo : fooList) {
fooError.add(foo);
}
}
}
Split split
= operator.split(joined);
this.hogeOut.add(split.hoge);
this.fooOut.add(split.foo);
@Split
public abstract void split(
HogeFoo joined,
Result<Hoge> hoge,
Result<Foo> foo);
Summarize sum
= operator.summarize(this.hoge);
this.out.add(sum.out);
@Summarize
public abstract HogeTotal summarize(Hoge hoge);
Fold fold
= mainOperator.fold(this.hoge);
this.out.add(fold.out);
@Fold
public void fold(
@Key(group = "name") Hoge left,
Hoge right) {
// @Summarizeを手動で行うイメージで、
// leftに次々とrightを加える
left.setValue(left.getValue()
+ right.getValue());
}