我对Titan 0.5.1有一点问题。我尝试将源代码从0.4.4升级到0.5.1。我有不同的问题,我在新文档中找不到。
在我的项目中,我有自定义课程。当我使用Titan 0.4.4时,我会为KryoSerializer写这个:
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import org.apache.commons.lang.ArrayUtils;
import com.thinkaurelius.titan.core.AttributeSerializer;
import com.thinkaurelius.titan.diskstorage.ScanBuffer;
import com.thinkaurelius.titan.diskstorage.WriteBuffer;
public class CharacteristicSerializer implements AttributeSerializer<Characteristic> {
public Characteristic read(ScanBuffer buffer) {
Characteristic object = null;
ArrayList<Byte> records = new ArrayList<Byte>();
try {
while (buffer.hasRemaining()) {
records.add(Byte.valueOf(buffer.getByte()));
}
Byte[] bytes = records.toArray(new Byte[records.size()]);
ByteArrayInputStream bis = new ByteArrayInputStream(ArrayUtils.toPrimitive(bytes));
ObjectInput in = new ObjectInputStream(bis);
object = (Characteristic) in.readObject();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return object;
}
public void writeObjectData(WriteBuffer out, Characteristic charac) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutput outobj;
outobj = new ObjectOutputStream(bos);
outobj.writeObject(charac);
byte[] propertybyte = bos.toByteArray();
for (int i = 0; i < propertybyte.length; i++) {
out.putByte(propertybyte[i]);
}
} catch (IOException e) {
e.printStackTrace();
}
}
public Characteristic convert(Object arg0) {
// TODO Auto-generated method stub
return null;
}
public void verifyAttribute(Characteristic arg0) {
// TODO Auto-generated method stub
}
}
所以当我使用Titan 0.5.1时,我有这个错误: 无法将AttributeSerializer解析为类型。
我的问题是:如何升级源代码?
提前感谢所有
答案 0 :(得分:0)
AttributeSerializer
移至Titan 0.5.0中的attribute
子包。变化
import com.thinkaurelius.titan.core.AttributeSerializer;
到
import com.thinkaurelius.titan.core.attribute.AttributeSerializer;
将0.4.x应用程序移植到0.5.x可能存在其他迁移问题。我只看了你粘贴的AttributeSerializer类型解析错误。