2014-10-17 52 views
0

我有一个小泰坦0.5.1的问题。我尝试将我的源代码从0.4.4升级到0.5.1。我有不同的问题,我没有在新的文档中找到。泰坦0.5.1 AttributeSerializer无法解析

在我的项目中我有自定义类。当我使用泰坦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 

    } 


} 

所以,当我使用泰坦0.5.1我有这样的错误: AttributeSerializer不能被解析为一个类型。

我的问题是:我如何升级我的源代码?

在此先感谢所有

回答

0

AttributeSerializer移动到attribute分装在泰坦0.5.0。更改

import com.thinkaurelius.titan.core.AttributeSerializer;

import com.thinkaurelius.titan.core.attribute.AttributeSerializer;

有可能是移植0.4.x应用0.5.x.其他迁移问题我只看着你粘贴的AttributeSerializer类型解析错误。

+0

感谢Dan提供此信息,并感谢自动完成;) – AkrogAmes 2014-10-20 07:48:18