private Entry getEntry(
      InternalTitanTransaction tx,
      InternalRelation edge,
      InternalTitanVertex perspective,
      Map<TitanType, TypeSignature> signatures,
      boolean columnOnly) {
    TitanType et = edge.getType();
    long etid = et.getID();

    int dirID;
    if (edge.isProperty()) {
      dirID = 0;
    } else if (edge.getVertex(0).equals(perspective)) {
      // Out TitanRelation
      assert edge.isDirected() || edge.isUnidirected();
      dirID = 2;
    } else {
      // In TitanRelation
      assert !edge.isUnidirected() && edge.getVertex(1).equals(perspective);
      dirID = 3;
    }

    int etIDLength = IDHandler.edgeTypeLength(etid, idManager);

    ByteBuffer column = null, value = null;
    if (et.isSimple()) {
      if (et.isFunctional()) {
        column = ByteBuffer.allocate(etIDLength);
        IDHandler.writeEdgeType(column, etid, dirID, idManager);
      } else {
        column = ByteBuffer.allocate(etIDLength + VariableLong.positiveLength(edge.getID()));
        IDHandler.writeEdgeType(column, etid, dirID, idManager);
        VariableLong.writePositive(column, edge.getID());
      }
      column.flip();
      if (!columnOnly) {
        if (edge.isEdge()) {
          long nodeIDDiff =
              ((TitanEdge) edge).getOtherVertex(perspective).getID() - perspective.getID();
          int nodeIDDiffLength = VariableLong.length(nodeIDDiff);
          if (et.isFunctional()) {
            value =
                ByteBuffer.allocate(nodeIDDiffLength + VariableLong.positiveLength(edge.getID()));
            VariableLong.write(value, nodeIDDiff);
            VariableLong.writePositive(value, edge.getID());
          } else {
            value = ByteBuffer.allocate(nodeIDDiffLength);
            VariableLong.write(value, nodeIDDiff);
          }
          value.flip();
        } else {
          assert edge.isProperty();
          DataOutput out = serializer.getDataOutput(defaultOutputCapacity, true);
          // Write object
          writeAttribute(out, (TitanProperty) edge);
          if (et.isFunctional()) {
            VariableLong.writePositive(out, edge.getID());
          }
          value = out.getByteBuffer();
        }
      }
    } else {
      TypeSignature ets = getSignature(tx, et, signatures);

      InternalRelation[] keys = new InternalRelation[ets.keyLength()],
          values = new InternalRelation[ets.valueLength()];
      List<InternalRelation> rest = new ArrayList<InternalRelation>();
      ets.sort(edge.getRelations(SimpleAtomicQuery.queryAll(edge), false), keys, values, rest);

      DataOutput out = serializer.getDataOutput(defaultOutputCapacity, true);
      IDHandler.writeEdgeType(out, etid, dirID, idManager);

      for (int i = 0; i < keys.length; i++) writeInlineEdge(out, keys[i], ets.getKeyType(i));

      if (!et.isFunctional()) {
        VariableLong.writePositive(out, edge.getID());
      }
      column = out.getByteBuffer();

      if (!columnOnly) {
        out = serializer.getDataOutput(defaultOutputCapacity, true);

        if (edge.isEdge()) {
          long nodeIDDiff =
              ((TitanEdge) edge).getOtherVertex(perspective).getID() - perspective.getID();
          VariableLong.write(out, nodeIDDiff);
        } else {
          assert edge.isProperty();
          writeAttribute(out, (TitanProperty) edge);
        }

        if (et.isFunctional()) {
          assert edge.isEdge();
          VariableLong.writePositive(out, edge.getID());
        }
        for (int i = 0; i < values.length; i++)
          writeInlineEdge(out, values[i], ets.getValueType(i));
        for (InternalRelation v : rest) writeInlineEdge(out, v);
        value = out.getByteBuffer();
      }
    }
    return new Entry(column, value);
  }