Examples of DatabaseException


Examples of org.helidb.lang.DatabaseException

      {
        m_updateOperation.rollback(recLen);
      }
      else
      {
        throw new DatabaseException("Unknown database operation " + opCode);
      }
    }
    clearAndCloseFile();
  }
View Full Code Here

Examples of org.helidb.lang.DatabaseException

        throw new IllegalStateException("The database is closed");
      }

      if (m_cannotCommit)
      {
        throw new DatabaseException("This should only be seen during unit test runs");
      }

      m_backend.commit();
    }
    finally
View Full Code Here

Examples of org.helidb.lang.DatabaseException

    {
      return NodeHeader.valueOf((byte) b);
    }
    catch (IllegalArgumentException e)
    {
      throw new DatabaseException("At position " + pos, e);
    }
  }
View Full Code Here

Examples of org.helidb.lang.DatabaseException

    }

    BPlusTreeNode<K, ?> res = readNodeOrNull(pos, keyForFirstPointer).getSecond();
    if (res == null)
    {
      throw new DatabaseException("The node at position " + pos + " is deleted");
    }
    return res;
  }
View Full Code Here

Examples of org.helidb.lang.DatabaseException

{
  @Test
  public void testSerializeAndInterpret()
  {
    Serializer<Exception> ser = new SerializableSerializer<Exception>();
    byte[] barr = ser.serialize(new DatabaseException("foo"));
    assertEquals("foo", ser.interpret(barr).getMessage());
  }
View Full Code Here

Examples of org.helidb.lang.DatabaseException

    assertNotClosed();
    NodeSearchResult<K, V> nsr = findNodeFor(key, m_rootNodePosition, null, new LinkedList<BPlusTreeNonLeafNode<K>>());
    if (nsr == null)
    {
      // Empty file. Should not happen on writing operations.
      throw new DatabaseException("The B+ Tree index file was empty");
    }

    if (findRecord(key, nsr.m_node.getRecords()) >= 0)
    {
      throw new KeyExistsException("The key " + key + " already exists in the tree");
View Full Code Here

Examples of org.helidb.lang.DatabaseException

    assertNotClosed();
    NodeSearchResult<K, V> nsr = findNodeFor(key, m_rootNodePosition, null, new LinkedList<BPlusTreeNonLeafNode<K>>());
    if (nsr == null)
    {
      // Empty file. Should not happen on writing operations.
      throw new DatabaseException("The B+ Tree index file was empty");
    }
    List<KeyAndValue<K, V>> records = nsr.m_node.getRecords();
    int pos = findRecord(key, records);
    if (pos < 0)
    {
View Full Code Here

Examples of org.helidb.lang.DatabaseException

    NodeSearchResult<K, V> nsr = findNodeFor(key, m_rootNodePosition, null, new LinkedList<BPlusTreeNonLeafNode<K>>());
    if (nsr == null)
    {
      // Empty file. Should not happen on writing operations.
      throw new DatabaseException("The B+ Tree index file was empty");
    }
    List<KeyAndValue<K, V>> records = nsr.m_node.getRecords();
    int pos = findRecord(key, records);
    if (pos < 0)
    {
View Full Code Here

Examples of org.helidb.lang.DatabaseException

    assertNotClosed();
    NodeSearchResult<K, V> nsr = findNodeFor(key, m_rootNodePosition, null, new LinkedList<BPlusTreeNonLeafNode<K>>());
    if (nsr == null)
    {
      // Empty file. Should not happen on writing operations.
      throw new DatabaseException("The B+ Tree index file was empty");
    }
    BPlusTreeLeafNode<K, V> node = nsr.m_node;
    int pos = findRecord(key, node.getRecords());
    if (pos < 0)
    {
View Full Code Here

Examples of org.helidb.lang.DatabaseException

        if (node.isLeafNode())
        {
          K expectedKey = nodeDef.getKey();
          if (expectedKey != null && (!node.getRecords().get(0).getKey().equals(nodeDef.getKey())))
          {
            throw new DatabaseException("Expected first key " + expectedKey + ". Got " + node.getRecords().get(0).getKey());
          }

          if (m_nodeRepository.leafNodeHasPointersToAdjacentLeafNodes())
          {
            BPlusTreeLeafNode<K, V> lnode = (BPlusTreeLeafNode<K, V>) node;
            if (lnode.getLeafNodeToTheLeftPointer() != null)
            {
              BPlusTreeLeafNode<K, V> nodeToTheLeft = (BPlusTreeLeafNode<K, V>) m_nodeRepository.readNode(lnode.getLeafNodeToTheLeftPointer().longValue(), null);
              List<KeyAndValue<K, V>> lrecords = nodeToTheLeft.getRecords();
              K leftNodeLastKey = lrecords.get(lrecords.size() - 1).getKey();
              K thisNodeFirstKey = lnode.getRecords().get(0).getKey();

              if (compareKeys(thisNodeFirstKey, leftNodeLastKey) <= 0)
              {
                throw new DatabaseException("The first key of node at position " + node.getPosition() + ", " + thisNodeFirstKey + ", was less than the last key of node at position " + nodeToTheLeft.getPosition() + ", " + leftNodeLastKey);
              }

              if (nodeToTheLeft.getLeafNodeToTheRightPointer().longValue() != node.getPosition())
              {
                throw new DatabaseException("Adjacent node pointer error for node to the left: (this node) -> (node to the left) -> (this node): " + node.getPosition() + " -> " + lnode.getLeafNodeToTheLeftPointer() + " -> " + nodeToTheLeft.getLeafNodeToTheRightPointer());
              }
            }
            if (lnode.getLeafNodeToTheRightPointer() != null)
            {
              BPlusTreeLeafNode<K, V> nodeToTheRight = (BPlusTreeLeafNode<K, V>) m_nodeRepository.readNode(lnode.getLeafNodeToTheRightPointer().longValue(), null);
              K rightNodeFirstKey = nodeToTheRight.getRecords().get(0).getKey();
              K thisNodeLastKey = lnode.getRecords().get(lnode.getRecords().size() - 1).getKey();

              if (compareKeys(thisNodeLastKey, rightNodeFirstKey) >= 0)
              {
                throw new DatabaseException("The last key of node at position " + node.getPosition() + ", " + thisNodeLastKey + ", was greater than the first key of node at position " + nodeToTheRight.getPosition() + ", " + rightNodeFirstKey);
              }

              if (nodeToTheRight.getLeafNodeToTheLeftPointer().longValue() != node.getPosition())
              {
                throw new DatabaseException("Adjacent node pointer error for node to the right: (this node) -> (node to the right) -> (this node): " + node.getPosition() + " -> " + lnode.getLeafNodeToTheRightPointer() + " -> " + nodeToTheRight.getLeafNodeToTheLeftPointer());
              }
            }
          }
        }
        else
        {
          BPlusTreeNonLeafNode<K> nlNode = (BPlusTreeNonLeafNode<K>) node;
          if (!(first || nlNode.getKeyForFirstPointer() != null))
          {
            throw new DatabaseException("The key to the first pointer was null in a non-leaf node that was not the leftmost node: " + node);
          }
          nextLevelNodes.add(new KeyAndValue<K, Long>(nlNode.getKeyForFirstPointer(), nlNode.getFirstPointer(), m_keyComparator));
          for (KeyAndValue<K, Long> hap : nlNode.getRecords())
          {
            nextLevelNodes.add(hap);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.