Ejemplo n.º 1
0
  public void create() throws HyracksDataException {
    synchronized (lcManager) {
      long resourceID = getResourceID();
      index = lcManager.getIndex(resourceID);
      if (index != null) {
        lcManager.unregister(resourceID);
      } else {
        index = createIndexInstance();
      }

      // The previous resource ID needs to be removed since calling IIndex.create() may possibly
      // destroy
      // any physical artifact that the LocalResourceRepository is managing (e.g. a file containing
      // the resource ID).
      // Once the index has been created, a new resource ID can be generated.
      if (resourceID != -1) {
        localResourceRepository.deleteResourceByName(file.getFile().getPath());
      }
      index.create();
      try {
        // TODO Create LocalResource through LocalResourceFactory interface
        resourceID = resourceIdFactory.createId();
        ILocalResourceFactory localResourceFactory =
            opDesc.getLocalResourceFactoryProvider().getLocalResourceFactory();
        localResourceRepository.insert(
            localResourceFactory.createLocalResource(
                resourceID, file.getFile().getPath(), partition));
      } catch (IOException e) {
        throw new HyracksDataException(e);
      }
      lcManager.register(resourceID, index);
    }
  }
Ejemplo n.º 2
0
 public IndexTestContext(ISerializerDeserializer[] fieldSerdes, IIndex index) {
   this.fieldSerdes = fieldSerdes;
   this.index = index;
   this.indexAccessor =
       (IIndexAccessor)
           index.createAccessor(TestOperationCallback.INSTANCE, TestOperationCallback.INSTANCE);
   this.tupleBuilder = new ArrayTupleBuilder(fieldSerdes.length);
 }
Ejemplo n.º 3
0
  public void destroy() throws HyracksDataException {
    synchronized (lcManager) {
      long resourceID = getResourceID();
      index = lcManager.getIndex(resourceID);
      if (index != null) {
        lcManager.unregister(resourceID);
      } else {
        index = createIndexInstance();
      }

      if (resourceID != -1) {
        localResourceRepository.deleteResourceByName(file.getFile().getPath());
      }
      index.destroy();
    }
  }