Package org.hivedb.meta.directory

Examples of org.hivedb.meta.directory.Directory


  @SuppressWarnings("unchecked")
  @Test
  public void testGetSecondaryIndexKeysOfPrimaryIndexKey() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    for (String pkey : getPrimaryIndexOrResourceKeys()) {
      Collection skeys = d.getSecondaryIndexKeysOfResourceId(nameIndex, pkey);
      assertTrue(skeys.size() > 0);
      assertEquals(secondaryKeyString, Atom.getFirst(skeys));
    }

  }
View Full Code Here


  }

  @Test
  public void testDeleteAllSecondaryKeyForResourceId() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    for (String key : getPrimaryIndexOrResourceKeys()) {
      assertTrue(d.getSecondaryIndexKeysOfResourceId(numIndex, key).size() > 0);
      // TODO: for some reason the BatchIndexWriter won't find the tables when running through maven
      //d.batch().deleteAllSecondaryIndexKeysOfResourceId(resource, key);
      for (SecondaryIndex secondaryIndex : resource.getSecondaryIndexes()) {
        for (Object secondaryIndexKey : d.getSecondaryIndexKeysOfResourceId(secondaryIndex, key)) {
          d.deleteSecondaryIndexKey(secondaryIndex, secondaryIndexKey, key);
          ;
        }
      }
      assertEquals(0, d.getSecondaryIndexKeysOfResourceId(numIndex, key).size());
    }
  }
View Full Code Here

  }

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

  }

  @Test
  public void testDeleteResourceId() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    for (String key : getPrimaryIndexOrResourceKeys()) {
      // TODO: for some reason the BatchIndexWriter won't find the tables when running through maven
      //d.batch().deleteAllSecondaryIndexKeysOfResourceId(resource, key);
      for (SecondaryIndex secondaryIndex : resource.getSecondaryIndexes()) {
        for (Object secondaryIndexKey : d.getSecondaryIndexKeysOfResourceId(secondaryIndex, key)) {
          d.deleteSecondaryIndexKey(secondaryIndex, secondaryIndexKey, key);
          ;
        }
      }
      assertEquals(0, d.getSecondaryIndexKeysOfResourceId(numIndex, key).size());
      d.deleteResourceId(resource, key);
      assertFalse(d.doesResourceIdExist(resource, key));
      assertEquals(0, d.getSecondaryIndexKeysOfResourceId(nameIndex, key).size());
      assertEquals(0, d.getSecondaryIndexKeysOfResourceId(numIndex, key).size());
    }
  }
View Full Code Here

  }

  @Test
  public void testUpdatePrimaryIndexKeyOfResourceId() throws Exception {
    insertKeys(getHive());
    Directory d = getDirectory();
    String firstKey = Atom.getFirst(getPrimaryIndexOrResourceKeys());
    for (String key : getPrimaryIndexOrResourceKeys()) {
      d.updatePrimaryIndexKeyOfResourceId(resource, key, firstKey);
      assertEquals(firstKey, d.getPrimaryIndexKeyOfResourceId(resource, key).toString());
    }
  }
View Full Code Here

  private Collection<String> getPrimaryIndexOrResourceKeys() {
    return Arrays.asList(new String[]{"1", "2", "3", "4"});
  }

  private void insertKeys(Hive hive) throws HiveLockableException {
    Directory d = getDirectory();
    Resource resource = dimension.getResource(createResource().getName());
    for (String key : getPrimaryIndexOrResourceKeys()) {
      hive.directory().insertPrimaryIndexKey(key);
      d.insertResourceId(resource, key, key);
      hive.directory().insertSecondaryIndexKey(nameIndex.getResource().getName(), nameIndex.getName(), secondaryKeyString, key);
      hive.directory().insertSecondaryIndexKey(numIndex.getResource().getName(), numIndex.getName(), secondaryKeyNum, key);
    }
  }
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.