Package org.hivedb

Examples of org.hivedb.Hive


  }

  private void prepare() {
    try {
      new HiveConfigurationSchemaInstaller(getConnectString(H2TestCase.TEST_DB)).run();
      Hive hive = Hive.create(getConnectString(H2TestCase.TEST_DB), partitionDimensionName(), Types.INTEGER, CachingDataSourceProvider.getInstance(), null);
      dimension = createPopulatedPartitionDimension();
      dimension.setId(hive.getPartitionDimension().getId());
      hive.setPartitionDimension(dimension);
      resource = Atom.getFirstOrThrow(dimension.getResources());
      hive.addResource(resource);
      numIndex = resource.getSecondaryIndex("num");
      nameIndex = resource.getSecondaryIndex("name");
      for (SecondaryIndex secondaryIndex : resource.getSecondaryIndexes()) {
        hive.addSecondaryIndex(resource, secondaryIndex);
      }
      hive.addNode(new Node("node", H2TestCase.TEST_DB, "", HiveDbDialect.H2));
      SimpleJdbcDaoSupport dao = new SimpleJdbcDaoSupport();
      dao.setDataSource(hive.getDataSourceProvider().getDataSource(getConnectString(H2TestCase.TEST_DB)));
      //    dao.getJdbcTemplate().update("SET TRACE_LEVEL_SYSTEM_OUT 3");
    }
    catch (Exception e) {
      throw new RuntimeException(e);
    }
View Full Code Here


  }

  // Test for HiveIndexer.exists(EntityIndexConfiguration config, Object entity)
  @Test
  public void existsTest() throws Exception {
    Hive hive = getHive();
    HiveIndexer indexer = new HiveIndexer(hive);
    WeatherReport report = generateInstance();
    assertFalse(indexer.exists(getWeatherReportConfig(report), report));
    indexer.insert(getWeatherReportConfig(report), report);
    assertTrue(indexer.exists(getWeatherReportConfig(report), report));
View Full Code Here

  @Test
  public void testInsertPrimaryIndexKey() throws Exception {
    Directory d = getDirectory();
    Integer key = new Integer(43);
    Hive hive = getHive();
    Node firstNode = Atom.getFirst(hive.getNodes());
    d.insertPrimaryIndexKey(Atom.getFirst(hive.getNodes()), key);
    for (Integer id : Transform.map(semaphoreToId(), d.getKeySemamphoresOfPrimaryIndexKey(key)))
      assertEquals((Integer) firstNode.getId(), id);
  }
View Full Code Here

  }

  @Test
  public void testInsertPrimaryIndexKeyMultipleNodes() throws Exception {
    Directory d = getDirectory();
    Hive hive = getHive();
    Integer key = new Integer(43);
    for (Node node : hive.getNodes())
      d.insertPrimaryIndexKey(node, key);
    Collection<Integer> nodeIds = Transform.map(semaphoreToId(), d.getKeySemamphoresOfPrimaryIndexKey(key));
    AssertUtils.assertUnique(nodeIds);
    assertEquals(hive.getNodes().size(), nodeIds.size());
  }
View Full Code Here

  }

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

      assertEquals(1, d.getKeySemaphoresOfResourceId(resource, key).size());
  }

  @Test
  public void testGetKeySemaphoresOfPartitioningResourceIds() throws Exception {
    Hive hive = Hive.load(getConnectString(H2TestCase.TEST_DB), CachingDataSourceProvider.getInstance());
    hive.deleteResource(resource);
    resource = Atom.getFirstOrNull(dimension.getResources());
    resource.setIsPartitioningResource(true);
    hive.addResource(resource);

    resource = hive.getPartitionDimension().getResource(resource.getName());

    insertKeys(getHive());
    Directory d = getDirectory();
    for (String key : getPrimaryIndexOrResourceKeys())
      assertEquals(1, d.getKeySemaphoresOfResourceId(resource, key).size());
View Full Code Here

  }

  @Test
  public void testGetPrimaryIndexKeysOfResourceId() throws Exception {
    Directory d = getDirectory();
    Hive hive = getHive();
    for (String key : getPrimaryIndexOrResourceKeys()) {
      d.insertPrimaryIndexKey(Atom.getFirstOrThrow(hive.getNodes()), key);
      d.insertResourceId(resource, key + 1, key);
      assertEquals(key, d.getPrimaryIndexKeyOfResourceId(resource, key + 1).toString());
    }
  }
View Full Code Here

  @Test
  public void testInsertRelatedSecondaryIndexKeys() throws Exception {
    //beforeMethod = false;
    //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,
View Full Code Here

  }

  @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

public class HiveInterceptorDecoratorTest extends HiveTest {

  @Test
  public void testInstantiate() throws Exception {
    EntityHiveConfig config = getEntityHiveConfig();
    Hive hive = getHive();
    HiveInterceptorDecorator interceptor = new HiveInterceptorDecorator(config, hive);
    Object o = interceptor.instantiate("org.hivedb.util.database.test.WeatherReport", EntityMode.POJO, 7);
    assertEquals(GeneratedClassFactory.getGeneratedClass(WeatherReport.class), o.getClass());
  }
View Full Code Here

TOP

Related Classes of org.hivedb.Hive

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.