Package org.helidb.lang

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


      {
        barr = md.digest(m_charset != null ? s.getBytes(m_charset.name()) : s.getBytes());
      }
      catch (UnsupportedEncodingException e)
      {
        throw new DatabaseException(e);
      }

      byte[] barrTruncated;
      if (barr.length < m_hashLength)
      {
View Full Code Here

    m_dbFile.seek(m_startPosOfDb);
    m_dbFile.setLength(m_startPosOfDb);
    long noCopied = StreamUtil.copyStreams(new RandomAccessToInputStreamAdapter(ra), new RandomAccessToOutputStreamAdapter(m_dbFile), m_bufferSize, dataSize);
    if (noCopied != dataSize)
    {
      throw new DatabaseException("Wanted to copy " + dataSize + " bytes. Got " + noCopied);
    }
    updateContentsVersion();
  }
View Full Code Here

TOP

Related Classes of org.helidb.lang.DatabaseException

Copyright © 2018 www.massapicom. 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.