コード例 #1
0
 private void deleteNode2(
     long node, DefinedProperty prop1, DefinedProperty prop2, DefinedProperty prop3)
     throws IOException {
   ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
   xaCon.getTransaction().nodeLoadProperties(node, false, newPropertyReceiver(props));
   int count = 0;
   for (int keyId : props.keySet()) {
     long id = props.get(keyId).other();
     PropertyRecord record = pStore.getRecord(id);
     PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
     DefinedProperty data = block.newPropertyData(pStore);
     if (data.propertyKeyId() == prop1.propertyKeyId()) {
       assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals("-string2", data.value());
     } else if (data.propertyKeyId() == prop2.propertyKeyId()) {
       assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals(-2, data.value());
     } else if (data.propertyKeyId() == prop3.propertyKeyId()) {
       assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals(true, data.value());
       xaCon.getTransaction().nodeRemoveProperty(node, prop3.propertyKeyId());
     } else {
       throw new IOException();
     }
     count++;
   }
   assertEquals(3, count);
   CountingPropertyReceiver propertyCounter = new CountingPropertyReceiver();
   xaCon.getTransaction().nodeLoadProperties(node, false, propertyCounter);
   assertEquals(3, propertyCounter.count);
   MutableRelationshipLoadingPosition pos = getPosition(xaCon, node);
   Iterator<RelationshipRecord> rels = getMore(xaCon, node, pos).iterator();
   assertTrue(rels.hasNext());
   xaCon.getTransaction().nodeDelete(node);
 }
コード例 #2
0
 private void deleteRel1(
     long rel,
     DefinedProperty prop1,
     DefinedProperty prop2,
     DefinedProperty prop3,
     long firstNode,
     long secondNode,
     int relType)
     throws IOException {
   ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
   xaCon.getTransaction().relLoadProperties(rel, false, newPropertyReceiver(props));
   int count = 0;
   for (int keyId : props.keySet()) {
     long id = props.get(keyId).other();
     PropertyRecord record = pStore.getRecord(id);
     PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
     DefinedProperty data = block.newPropertyData(pStore);
     if (data.propertyKeyId() == prop1.propertyKeyId()) {
       assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals("-string1", data.value());
     } else if (data.propertyKeyId() == prop2.propertyKeyId()) {
       assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals(-1, data.value());
     } else if (data.propertyKeyId() == prop3.propertyKeyId()) {
       assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals(false, data.value());
       xaCon.getTransaction().relRemoveProperty(rel, prop3.propertyKeyId());
     } else {
       throw new IOException();
     }
     count++;
   }
   assertEquals(3, count);
   CountingPropertyReceiver propertyCounter = new CountingPropertyReceiver();
   xaCon.getTransaction().relLoadProperties(rel, false, propertyCounter);
   assertEquals(3, propertyCounter.count);
   RelationshipRecord relData = xaCon.getTransaction().relLoadLight(rel);
   assertEquals(firstNode, relData.getFirstNode());
   assertEquals(secondNode, relData.getSecondNode());
   assertEquals(relType, relData.getType());
   xaCon.getTransaction().relDelete(rel);
   MutableRelationshipLoadingPosition firstPos = getPosition(xaCon, firstNode);
   Iterator<RelationshipRecord> first = getMore(xaCon, firstNode, firstPos).iterator();
   first.next();
   MutableRelationshipLoadingPosition secondPos = getPosition(xaCon, secondNode);
   Iterator<RelationshipRecord> second = getMore(xaCon, secondNode, secondPos).iterator();
   second.next();
   assertTrue(first.hasNext());
   assertTrue(second.hasNext());
 }
コード例 #3
0
  @Test
  public void testSetBlockSize() throws Exception {
    targetDirectory.cleanup();

    Config config =
        new Config(
            MapUtil.stringMap("string_block_size", "62", "array_block_size", "302"),
            GraphDatabaseSettings.class);
    StoreFactory sf =
        new StoreFactory(
            config,
            new DefaultIdGeneratorFactory(),
            new DefaultWindowPoolFactory(),
            fs.get(),
            StringLogger.DEV_NULL,
            null);
    sf.createNeoStore(file("neo")).close();

    initializeStores();
    assertEquals(62 + AbstractDynamicStore.BLOCK_HEADER_SIZE, pStore.getStringBlockSize());
    assertEquals(302 + AbstractDynamicStore.BLOCK_HEADER_SIZE, pStore.getArrayBlockSize());
    ds.stop();
  }
コード例 #4
0
 @Test
 public void testProps1() throws Exception {
   initializeStores();
   startTx();
   long nodeId = ds.nextId(Node.class);
   xaCon.getTransaction().nodeCreate(nodeId);
   pStore.nextId();
   DefinedProperty prop =
       xaCon.getTransaction().nodeAddProperty(nodeId, index("nisse"), new Integer(10));
   commitTx();
   ds.stop();
   initializeStores();
   startTx();
   xaCon.getTransaction().nodeChangeProperty(nodeId, prop.propertyKeyId(), new Integer(5));
   xaCon.getTransaction().nodeRemoveProperty(nodeId, prop.propertyKeyId());
   xaCon.getTransaction().nodeDelete(nodeId);
   commitTx();
   ds.stop();
 }
コード例 #5
0
 private void validateRel2(
     long rel,
     DefinedProperty prop1,
     DefinedProperty prop2,
     DefinedProperty prop3,
     long firstNode,
     long secondNode,
     int relType)
     throws IOException {
   ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
   xaCon.getTransaction().relLoadProperties(rel, false, newPropertyReceiver(props));
   int count = 0;
   for (int keyId : props.keySet()) {
     long id = props.get(keyId).other();
     PropertyRecord record = pStore.getRecord(id);
     PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
     DefinedProperty data = block.newPropertyData(pStore);
     if (data.propertyKeyId() == prop1.propertyKeyId()) {
       assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals("string2", data.value());
       xaCon.getTransaction().relChangeProperty(rel, prop1.propertyKeyId(), "-string2");
     } else if (data.propertyKeyId() == prop2.propertyKeyId()) {
       assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals(2, data.value());
       xaCon.getTransaction().relChangeProperty(rel, prop2.propertyKeyId(), new Integer(-2));
     } else if (data.propertyKeyId() == prop3.propertyKeyId()) {
       assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals(false, data.value());
       xaCon.getTransaction().relChangeProperty(rel, prop3.propertyKeyId(), true);
     } else {
       throw new IOException();
     }
     count++;
   }
   assertEquals(3, count);
   RelationshipRecord relData = xaCon.getTransaction().relLoadLight(rel);
   assertEquals(firstNode, relData.getFirstNode());
   assertEquals(secondNode, relData.getSecondNode());
   assertEquals(relType, relData.getType());
 }
コード例 #6
0
  private void validateNodeRel2(
      long node,
      DefinedProperty prop1,
      DefinedProperty prop2,
      DefinedProperty prop3,
      long rel1,
      long rel2,
      int relType1,
      int relType2)
      throws IOException {
    NodeRecord nodeRecord = xaCon.getTransaction().nodeLoadLight(node);
    assertTrue(nodeRecord != null);
    ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
    xaCon.getTransaction().nodeLoadProperties(node, false, newPropertyReceiver(props));
    int count = 0;
    for (int keyId : props.keySet()) {
      long id = props.get(keyId).other();
      PropertyRecord record = pStore.getRecord(id);
      PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
      DefinedProperty data = block.newPropertyData(pStore);
      if (data.propertyKeyId() == prop1.propertyKeyId()) {
        assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
        assertEquals("string2", data.value());
        xaCon.getTransaction().nodeChangeProperty(node, prop1.propertyKeyId(), "-string2");
      } else if (data.propertyKeyId() == prop2.propertyKeyId()) {
        assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
        assertEquals(2, data.value());
        xaCon.getTransaction().nodeChangeProperty(node, prop2.propertyKeyId(), new Integer(-2));
      } else if (data.propertyKeyId() == prop3.propertyKeyId()) {
        assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
        assertEquals(false, data.value());
        xaCon.getTransaction().nodeChangeProperty(node, prop3.propertyKeyId(), true);
      } else {
        throw new IOException();
      }
      count++;
    }
    assertEquals(3, count);
    count = 0;

    MutableRelationshipLoadingPosition pos = getPosition(xaCon, node);
    while (true) {
      Iterable<RelationshipRecord> relData = getMore(xaCon, node, pos);
      if (!relData.iterator().hasNext()) {
        break;
      }
      for (RelationshipRecord rel : relData) {
        if (rel.getId() == rel1) {
          assertEquals(node, rel.getSecondNode());
          assertEquals(relType1, rel.getType());
        } else if (rel.getId() == rel2) {
          assertEquals(node, rel.getFirstNode());
          assertEquals(relType2, rel.getType());
        } else {
          throw new IOException();
        }
        count++;
      }
    }
    assertEquals(2, count);
  }