示例#1
0
 @Override
 public Node getNodeForNodeId(NodeId id) {
   if (NodeId.isAny(id)) return Node.ANY;
   if (passthrough) return base.getNodeForNodeId(id);
   long x = id.getId();
   if (x < allocOffset) return base.getNodeForNodeId(id);
   id = mapToJournal(id);
   Node node = nodeTableJournal.getNodeForNodeId(id);
   return node;
 }
示例#2
0
 @Override
 public NodeId getNodeIdForNode(Node node) {
   if (node == Node.ANY) return NodeId.NodeIdAny;
   if (passthrough) return base.getNodeIdForNode(node);
   NodeId nodeId = nodeTableJournal.getNodeIdForNode(node);
   if (!NodeId.isDoesNotExist(nodeId)) return mapFromJournal(nodeId);
   nodeId = base.getNodeIdForNode(node);
   return nodeId;
 }
示例#3
0
 @Override
 public NodeId getAllocateNodeId(Node node) {
   if (passthrough) return base.getAllocateNodeId(node);
   NodeId nodeId = getNodeIdForNode(node);
   if (!NodeId.isDoesNotExist(nodeId)) return nodeId;
   // add to journal
   nodeId = allocate(node);
   return nodeId;
 }
示例#4
0
  /** Copy from the journal file to the real file */
  /*package*/ void append() {
    Iterator<Pair<NodeId, Node>> iter = nodeTableJournal.all();
    Pair<NodeId, Node> firstPair = null;
    Pair<NodeId, Node> lastPair = null;

    for (; iter.hasNext(); ) {
      Pair<NodeId, Node> x = iter.next();

      if (firstPair == null) firstPair = x;
      lastPair = x;

      NodeId nodeId = x.getLeft();
      Node node = x.getRight();
      debug("  append: %s -> %s", x, mapFromJournal(nodeId));
      // This does the write.
      NodeId nodeId2 = base.getAllocateNodeId(node);
      if (!nodeId2.equals(mapFromJournal(nodeId))) inconsistent(node, nodeId, nodeId2);
    }
  }
示例#5
0
 /** Convert from a id in other to an external id */
 private NodeId mapFromJournal(NodeId id) {
   if (passthrough) throw new TDBTransactionException("Not in an active transaction");
   if (NodeId.isInline(id)) return id;
   return NodeId.create(id.getId() + allocOffset);
 }
示例#6
0
 @Override
 public boolean containsNode(Node node) {
   NodeId x = getNodeIdForNode(node);
   return NodeId.isDoesNotExist(x);
 }