Package org.hivedb.meta.directory

Examples of org.hivedb.meta.directory.Directory


    //afterMethod = false;
    //System.out.println("insertRelated begin");
    Hive hive = getHive();
    //System.out.println(hive.toString());
    //insertKeys(getHive());
    Directory d = getDirectory();
    for (String primaryIndexKey : getPrimaryIndexOrResourceKeys()) {
      hive.directory().insertPrimaryIndexKey(primaryIndexKey);
      d.insertResourceId(resource, primaryIndexKey, primaryIndexKey);

      Map<SecondaryIndex, Collection<Object>> secondaryIndexKeyMap = new Hashtable<SecondaryIndex, Collection<Object>>();
      secondaryIndexKeyMap.put(nameIndex, Arrays.asList(new Object[]{
        secondaryKeyString
      }));
      secondaryIndexKeyMap.put(numIndex, Arrays.asList(new Object[]{
        secondaryKeyNum
      }));
      // TODO: for some reason the BatchIndexWriter won't find the tables when running through maven
      //d.batch().insertSecondaryIndexKeys(secondaryIndexKeyMap, primaryIndexKey);
      for (SecondaryIndex secondaryIndex : secondaryIndexKeyMap.keySet()) {
        for (Object secondaryIndexKeyNum : secondaryIndexKeyMap.get(secondaryIndex)) {
          hive.directory().insertSecondaryIndexKey(secondaryIndex.getResource().getName(), secondaryIndex.getName(), secondaryIndexKeyNum, primaryIndexKey);
        }
      }
      hive.directory().insertSecondaryIndexKey(numIndex.getResource().getName(), numIndex.getName(), secondaryKeyNum, primaryIndexKey);
      assertEquals(1, d.getSecondaryIndexKeysOfResourceId(nameIndex, primaryIndexKey).size());
      assertEquals(secondaryKeyString, Atom.getFirst(d.getSecondaryIndexKeysOfResourceId(nameIndex, primaryIndexKey)));
      assertEquals(1,
        d.getSecondaryIndexKeysOfResourceId(numIndex, primaryIndexKey).size());
      assertEquals(secondaryKeyNum,
        Atom.getFirst(d.getSecondaryIndexKeysOfResourceId(numIndex, primaryIndexKey)));
    }
  }
View Full Code Here


  }

  @Test
  public void testUpdatePrimaryIndexKeyReadOnly() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    for (String key : getPrimaryIndexOrResourceKeys()) {
      d.updatePrimaryIndexKeyReadOnly(key, true);
      for (KeySemaphore s : d.getKeySemamphoresOfPrimaryIndexKey(key))
        assertTrue(s.getStatus().equals(Status.readOnly));
    }
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void testDeleteSecondaryIndexKey() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    for (String pkey : getPrimaryIndexOrResourceKeys()) {
      Collection secondaryKeys = d.getSecondaryIndexKeysOfResourceId(nameIndex, pkey);
      assertTrue(secondaryKeys.size() > 0);
      for (Object skey : secondaryKeys)
        d.deleteSecondaryIndexKey(nameIndex, skey, pkey);
      assertTrue(d.getSecondaryIndexKeysOfResourceId(nameIndex, pkey).size() == 0);
    }
  }
View Full Code Here

  }

  @Test
  public void testDoesPrimaryIndexKeyExist() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    assertTrue(d.doesPrimaryIndexKeyExist(Atom.getFirst(getPrimaryIndexOrResourceKeys())));
    assertTrue(!d.doesPrimaryIndexKeyExist(new Integer(378465784)));
  }
View Full Code Here

  }

  @Test
  public void testGetKeySemaphoresOfPrimaryIndexKey() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    for (String pkey : getPrimaryIndexOrResourceKeys())
      assertEquals(1, d.getKeySemamphoresOfPrimaryIndexKey(pkey).size());
  }
View Full Code Here

      assertEquals(1, d.getKeySemamphoresOfPrimaryIndexKey(pkey).size());
  }

  @Test
  public void testGetKeySemaphoresOfPrimaryIndexKeyMultiNode() throws Exception {
    Directory d = getDirectory();
    Hive hive = getHive();
    for (String pkey : getPrimaryIndexOrResourceKeys()) {
      for (Node node : hive.getNodes())
        d.insertPrimaryIndexKey(node, pkey);
      assertEquals(hive.getNodes().size(), d.getKeySemamphoresOfPrimaryIndexKey(pkey).size());
    }
  }
View Full Code Here

  }

  @Test
  public void testGetReadOnlyOfPrimaryIndexKey() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    for (String pkey : getPrimaryIndexOrResourceKeys()) {
      assertEquals(false, Lists.or(Transform.map(DirectoryWrapper.semaphoreToReadOnly(), d.getKeySemamphoresOfPrimaryIndexKey(pkey))));
      d.updatePrimaryIndexKeyReadOnly(pkey, true);
      assertTrue(Lists.or(Transform.map(DirectoryWrapper.semaphoreToReadOnly(), d.getKeySemamphoresOfPrimaryIndexKey(pkey))));
    }
  }
View Full Code Here

  }

  @Test
  public void testGetReadOnlyOfResourceId() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    for (String pkey : getPrimaryIndexOrResourceKeys()) {
      assertEquals(false, Lists.or(Transform.map(DirectoryWrapper.semaphoreToReadOnly(), d.getKeySemaphoresOfResourceId(resource, pkey))));
      d.updatePrimaryIndexKeyReadOnly(pkey, true);
      assertTrue(Lists.or(Transform.map(DirectoryWrapper.semaphoreToReadOnly(), d.getKeySemaphoresOfResourceId(resource, pkey))));
    }
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void testGetNodeIdsOfSecondaryIndexKey() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    for (String pkey : getPrimaryIndexOrResourceKeys()) {
      Collection skeys = d.getSecondaryIndexKeysOfResourceId(nameIndex, pkey);
      for (Object skey : skeys) {
        assertTrue(d.getKeySemaphoresOfSecondaryIndexKey(nameIndex, skey).size() > 0);
      }
    }
  }
View Full Code Here

  }

  @Test
  public void testGetNodeSemphoresOfSecondaryIndexKey() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    Collection<KeySemaphore> skeys = d.getKeySemaphoresOfSecondaryIndexKey(nameIndex, secondaryKeyString);
    assertEquals(1, skeys.size());
  }
View Full Code Here

TOP

Related Classes of org.hivedb.meta.directory.Directory

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.