我对土卫六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不能被解析成一个类型。
我的问题是:我如何升级我的源代码?
提前感谢所有人
发布于 2014-10-18 01:31:18
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类型解析错误。
https://stackoverflow.com/questions/26421426
复制相似问题