Package org.hivedb.meta

Examples of org.hivedb.meta.PartitionDimension


  public List<PartitionDimension> loadAll() {
    JdbcTemplate t = getJdbcTemplate();
    ArrayList<PartitionDimension> results = new ArrayList<PartitionDimension>();
    for (Object result : t.query("SELECT * FROM partition_dimension_metadata",
      new PartitionDimensionRowMapper())) {
      PartitionDimension dimension = (PartitionDimension) result;
      results.add(dimension);
    }
    return results;
  }
View Full Code Here


    if (results.size() == 0)
      throw new HiveRuntimeException("No PartitionDimension found.");
    else if (results.size() > 1)
      throw new HiveRuntimeException(String.format("Found %s PartitionDImensions, there can be only one.", results.size()));
    PartitionDimension dimension = results.get(0);
    return dimension;
  }
View Full Code Here

  protected class PartitionDimensionRowMapper implements RowMapper {
    public Object mapRow(ResultSet rs, int rowNumber) throws SQLException {
      final int id = rs.getInt("id");
      List<Resource> resources = new ResourceDao(getDataSource()).findByDimension(id);
      PartitionDimension dimension;
      dimension = new PartitionDimension(
        rs.getInt("id"),
        rs.getString("name"),
        JdbcTypeMapper.parseJdbcType(rs.getString("db_type")),
        rs.getString("index_uri"),
        resources);
View Full Code Here

    }
    return names;
  }

  protected PartitionDimension createEmptyPartitionDimension() {
    return new PartitionDimension(Hive.NEW_OBJECT_ID, getHive().getPartitionDimension().getName(), Types.INTEGER,
      getConnectString(getHiveDatabaseName()), new ArrayList<Resource>());
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public static PartitionDimension extractPartitionDimension(Class clazz) {
    Method partitionIndexMethod = AnnotationHelper.getFirstMethodWithAnnotation(clazz, PartitionIndex.class);
    return new PartitionDimension(getPartitionDimensionName(clazz), JdbcTypeMapper.primitiveTypeToJdbcType(partitionIndexMethod.getReturnType()));
  }
View Full Code Here

    Method partitionIndexMethod = AnnotationHelper.getFirstMethodWithAnnotation(clazz, PartitionIndex.class);
    return new PartitionDimension(getPartitionDimensionName(clazz), JdbcTypeMapper.primitiveTypeToJdbcType(partitionIndexMethod.getReturnType()));
  }

  public static EntityConfig readConfiguration(Class<?> clazz) {
    PartitionDimension dimension = extractPartitionDimension(clazz);

    Method versionMethod = AnnotationHelper.getFirstMethodWithAnnotation(clazz, EntityVersion.class);
    Method resourceIdMethod = AnnotationHelper.getFirstMethodWithAnnotation(clazz, EntityId.class);
    Method partitionIndexMethod = AnnotationHelper.getFirstMethodWithAnnotation(clazz, PartitionIndex.class);

    String primaryIndexPropertyName = getIndexNameForMethod(partitionIndexMethod);
    String idPropertyName = getIndexNameForMethod(resourceIdMethod);
    String versionPropertyName = versionMethod == null ? null : getIndexNameForMethod(versionMethod);

    List<EntityIndexConfig> indexes = createIndexMethods(clazz, resourceIdMethod);

    EntityConfig config = new EntityConfigImpl(
      clazz,
      dimension.getName(),
      getResourceName(clazz),
      primaryIndexPropertyName,
      idPropertyName,
      versionPropertyName,
      indexes,
View Full Code Here

  @Test
  public void testNodeLockingInMemory() throws Exception {
    final Hive hive = Hive.load(getConnectString(getHiveDatabaseName()), CachingDataSourceProvider.getInstance());
    final String key = new String("Antarctica");

    final PartitionDimension partitionDimension = hive.getPartitionDimension();
    hive.directory().insertPrimaryIndexKey(key);
    NodeResolver directory = new DbDirectory(partitionDimension, CachingDataSourceProvider.getInstance().getDataSource(hive.getUri()));
    for (Integer id : Transform.map(DirectoryWrapper.semaphoreToId(), directory.getKeySemamphoresOfPrimaryIndexKey(key)))
      hive.getNode(id).setStatus(Status.readOnly);
View Full Code Here

  @Test
  public void testNodeLockingPersistent() throws Exception {
    Hive hive = Hive.load(getConnectString(getHiveDatabaseName()), CachingDataSourceProvider.getInstance());
    final String key = new String("Asia");

    PartitionDimension partitionDimension = hive.getPartitionDimension();
    hive.directory().insertPrimaryIndexKey(key);
    NodeResolver directory = new DbDirectory(partitionDimension, CachingDataSourceProvider.getInstance().getDataSource(hive.getUri()));
    for (Integer id : Transform.map(DirectoryWrapper.semaphoreToId(), directory.getKeySemamphoresOfPrimaryIndexKey(key)))
      hive.updateNodeStatus(hive.getNode(id), Status.readOnly);
    hive = null;
View Full Code Here

  @Test
  public void testCreate() throws Exception {
    PartitionDimensionDao dao = new PartitionDimensionDao(getDataSource(getConnectString(getHiveDatabaseName())));
    int initialSize = dao.loadAll().size();
    final PartitionDimension d = new PartitionDimension(Hive.NEW_OBJECT_ID, getHive().getPartitionDimension().getName(), Types.INTEGER, getConnectString(getHiveDatabaseName()), new ArrayList<Resource>());
    dao.create(d);
    assertTrue(d.getId() > 0);
    assertEquals(initialSize + 1, dao.loadAll().size());
  }
View Full Code Here

    super.beforeMethod();
    prepare();
  }

  protected PartitionDimension createPopulatedPartitionDimension() {
    return new PartitionDimension(
      Hive.NEW_OBJECT_ID,
      partitionDimensionName(),
      Types.INTEGER,
      getConnectString(H2TestCase.TEST_DB),
      createResources());
View Full Code Here

TOP

Related Classes of org.hivedb.meta.PartitionDimension

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.