Package org.hivedb.meta

Examples of org.hivedb.meta.Resource


  protected class ResourceRowMapper implements RowMapper {
    public Object mapRow(ResultSet rs, int rowNumber) throws SQLException {
      SecondaryIndexDao sDao = new SecondaryIndexDao(ds);
      List<SecondaryIndex> indexes = sDao.findByResource(rs.getInt("id"));
      return new Resource(rs.getInt("id"), rs.getString("name"), JdbcTypeMapper.parseJdbcType(rs.getString("db_type")), rs.getBoolean("is_partitioning_resource"), indexes);
    }
View Full Code Here


    return new PartitionDimension(Hive.NEW_OBJECT_ID, getHive().getPartitionDimension().getName(), Types.INTEGER,
      getConnectString(getHiveDatabaseName()), new ArrayList<Resource>());
  }

  protected Resource createResource() {
    final Resource resource = new Resource("FOO", Types.INTEGER, false);
    resource.setPartitionDimension(createEmptyPartitionDimension());
    return resource;
  }
View Full Code Here

        String name = (String) resource.get("name");
        int type = JdbcTypeMapper.parseJdbcType(stringToVarchar((String) resource.get("type")));
        Collection<SecondaryIndex> secondaryIndexes = getSecondaryIndexes((List<Map<String, String>>) resource.get("indexes"));
        boolean isPartitioningResource = hive.getPartitionDimension().getName().equals(name) && hive.getPartitionDimension().getColumnType() == type;
        try {
          hive.addResource(new Resource(name, type, isPartitioningResource, secondaryIndexes));
        } catch (HiveLockableException ex) {
          throw new RuntimeException(ex);
        }
      }
    }
View Full Code Here

    Collection<Resource> missingResources = Lists.newArrayList();
    Map<Resource, Collection<SecondaryIndex>> indexMap = Maps.newHashMap();

    for(EntityConfig config : updater.getEntityConfigs()) {
      try {
        Resource resource = hive.getPartitionDimension().getResource(config.getResourceName());
        for(EntityIndexConfig indexConfig : getHiveIndexes(config)) {
          try {
            resource.getSecondaryIndex(indexConfig.getIndexName());
          } catch(HiveKeyNotFoundException ex) {
            if(!indexMap.containsKey(resource))
              indexMap.put(resource, new ArrayList<SecondaryIndex>());
            indexMap.get(resource).add(configToIndex().f(indexConfig));
          }
        }
      } catch(HiveKeyNotFoundException e) {
        Resource resource = new Resource(
            config.getResourceName(),
            JdbcTypeMapper.primitiveTypeToJdbcType(config.getIdClass()),
            config.isPartitioningResource());
        missingResources.add(resource);
        indexMap.put(resource, Transform.map(configToIndex(), config.getEntityIndexConfigs()));
View Full Code Here

    directory.insertSecondaryIndexKey(getSecondaryIndex(resource, secondaryIndex), secondaryIndexKey, resourceId);
  }

  public void updatePrimaryIndexKeyOfResourceId(String resource, Object resourceId, Object newPrimaryIndexKey) throws HiveLockableException {
    Preconditions.isWritable(directory.getKeySemamphoresOfPrimaryIndexKey(newPrimaryIndexKey), semaphore);
    final Resource r = getResource(resource);
    if (r.isPartitioningResource())
      throw new HiveRuntimeException(String.format("Resource %s is a partitioning dimension, you cannot update its primary index key because it is the resource id", r.getName()));

    directory.updatePrimaryIndexKeyOfResourceId(r, resourceId, newPrimaryIndexKey);
  }
View Full Code Here

  public String insertResourceId(Resource resource) {
    return String.format("insert into %s (id, pkey) values(?, ?)", Schemas.getResourceIndexTableName(resource));
  }
 
  public String selectResourceIdsOfSecondaryIndexKey(SecondaryIndex secondaryIndex) {
    final Resource resource = secondaryIndex.getResource();
    if (resource.isPartitioningResource())
      return selectPrimaryIndexKeysOfSecondaryIndexKey(secondaryIndex);
    return String.format(
        "select r.id from %s r join %s s on s.pkey = r.id where s.id = ?",
        Schemas.getResourceIndexTableName(resource),
        Schemas.getSecondaryIndexTableName(secondaryIndex));
View Full Code Here

    //Set up a secondary index on products so that we can query them by name

    // First create a Resource.  All Secondary Indexes will be associated with this Resource.
    String resourceName = "Product";
    Resource product = new Resource(resourceName, Types.INTEGER, false, new ArrayList<SecondaryIndex>());

    // Add it to the Hive
    product = hive.addResource(product);

    //Now create a SecondaryIndex
View Full Code Here

    resources.add(createResource());
    return resources;
  }

  protected Resource createResource() {
    final Resource resource = new Resource("FOO", Types.INTEGER, false, createSecondaryIndexes());
    return resource;
  }
View Full Code Here

    return Arrays.asList(new String[]{"1", "2", "3", "4"});
  }

  private void insertKeys(Hive hive) throws HiveLockableException {
    DbDirectory 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.Resource

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.