Mercurial > hg > Database > Alice
view src/alice/test/codesegment/api/UpdateCodeSegment.java @ 290:4074077d118d
Refactor iterating process with for-each sentence.
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 Oct 2013 03:26:38 +0900 |
parents | fec0726bb126 |
children |
line wrap: on
line source
package alice.test.codesegment.api; import org.msgpack.type.Value; import org.msgpack.type.ValueFactory; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class UpdateCodeSegment extends CodeSegment { Receiver ds1 = ids.create(CommandType.PEEK); @Override public void run() { UpdateCodeSegment cs1 = new UpdateCodeSegment(); cs1.ds1.setKey("key", ds1.index); Value[] array = ((Value)ds1.getVal()).asArrayValue().getElementArray(); int val = array[0].asIntegerValue().getInt(); if (val % 10 == 0) System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "MB"); if (val >= 10000000) { System.exit(0); } array[0] = ValueFactory.createIntegerValue(val + 1); ods.update("local", "key", array); } }