view src/alice/codesegment/OutputDataSegment.java @ 39:3155337e754e

add logger
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Fri, 27 Jan 2012 16:57:26 +0900
parents ca079a730d0b
children 20616fe4d28a
line wrap: on
line source

package alice.codesegment;

import java.io.IOException;

import org.msgpack.MessagePack;
import org.msgpack.type.Value;
import org.msgpack.type.ValueFactory;

import alice.datasegment.DataSegment;

public class OutputDataSegment {
	
	CodeSegment cs;
	
	public OutputDataSegment(CodeSegment codeSegment) {
		this.cs = codeSegment;
	}

	public void put(String managerKey, String key, Value val) {
		DataSegment.get(managerKey).put(key, val);
	}
	
	public void update(String managerKey, String key, Value val) {
		DataSegment.get(managerKey).update(key, val);
	}
	
	public void put(String managerKey, String key, String val) {
		DataSegment.get(managerKey).put(key, ValueFactory.createRawValue(val));
	}
	
	public void update(String managerKey, String key, String val) {
		DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val));
	}

	public void put(String managerKey, String key, int val) {
		DataSegment.get(managerKey).put(key, ValueFactory.createIntegerValue(val));
	}
	
	public void update(String managerKey, String key, int val) {
		DataSegment.get(managerKey).update(key, ValueFactory.createIntegerValue(val));
	}
	
	public <T> void put(String managerKey, String key, T val) {
		MessagePack msgpack = new MessagePack();
		try {
			DataSegment.get(managerKey).put(key, msgpack.unconvert(val));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public <T> void update(String managerKey, String key, T val) {
		MessagePack msgpack = new MessagePack();
		try {
			DataSegment.get(managerKey).update(key, msgpack.unconvert(val));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void finish(String managerKey) {
		DataSegment.get(managerKey).finish();
	}


}