cool-core/src/main/java/com/nus/cool/loader/CoolModel.java
public synchronized void reload(String cube) throws IOException {
    // Remove the old version of the cube
    this.metaStore.remove(cube);
    this.cohortStore.clear();

    // Check the existence of cube under this repository
    File cubeRoot = new File(this.localRepo, cube);
      if (!cubeRoot.exists()) {
        throw new FileNotFoundException("[x] Cube " + cube + " was not found");
      }

    // Read schema information
    TableSchema schema = TableSchema.read(new FileInputStream(new File(cubeRoot, "table.yaml")));
    CubeRS cubeRS = new CubeRS(schema);
    File[] versions = cubeRoot.listFiles(new FileFilter() {
      @Override
      public boolean accept(File file) {
        return file.isDirectory();
      }
    });
    checkNotNull(versions);
      if (versions.length == 0) {
          return;
      }
    Arrays.sort(versions);

    // Only load the latest version
    File currentVersion = versions[versions.length - 1];
    File[] cubletFiles = currentVersion.listFiles(new FilenameFilter() {
      @Override
      public boolean accept(File file, String s) {
        return s.endsWith(".dz");
      }
    });
    System.out.println("Cube " + cube + ", versions: " + Arrays.toString(versions));
    System.out.println("Cube " + cube + ", Use version: " + currentVersion.getName());

    // Load all cubes under latest version
    checkNotNull(cubletFiles);
      for (File cubletFile : cubletFiles) {
          cubeRS.addCublet(cubletFile);
      }
    this.metaStore.put(cube, cubeRS);
    System.out.println("Cube " + cube + ", metaStore: " + this.metaStore.keySet());
  }
/**
   * Load a cube (a set of cube files) from the repository into memory
   *
   * @param cube the cube name
   * @throws IOException
   */
Load a cube (a set of cube files) from the repository into memory
@param cube the cube name
@throws IOException
Load a cube ( a set of cube files ) from the repository into memory @param cube the cube name @throws IOException
public synchronized void reload(String cube) throws IOException {
    this.metaStore.remove(cube);
    this.cohortStore.clear();
    File cubeRoot = new File(this.localRepo, cube);
      if (!cubeRoot.exists()) {
        throw new FileNotFoundException("[x] Cube " + cube + " was not found");
      }
    TableSchema schema = TableSchema.read(new FileInputStream(new File(cubeRoot, "table.yaml")));
    CubeRS cubeRS = new CubeRS(schema);
    File[] versions = cubeRoot.listFiles(new FileFilter() {
      @Override
      public boolean accept(File file) {
        return file.isDirectory();
      }
    });
    checkNotNull(versions);
      if (versions.length == 0) {
          return;
      }
    Arrays.sort(versions);
    File currentVersion = versions[versions.length - 1];
    File[] cubletFiles = currentVersion.listFiles(new FilenameFilter() {
      @Override
      public boolean accept(File file, String s) {
        return s.endsWith(".dz");
      }
    });
    System.out.println("Cube " + cube + ", versions: " + Arrays.toString(versions));
    System.out.println("Cube " + cube + ", Use version: " + currentVersion.getName());
    checkNotNull(cubletFiles);
      for (File cubletFile : cubletFiles) {
          cubeRS.addCublet(cubletFile);
      }
    this.metaStore.put(cube, cubeRS);
    System.out.println("Cube " + cube + ", metaStore: " + this.metaStore.keySet());
  }
public synchronized void reload ( String cube ) throws IOException { this . metaStore . remove ( cube ) ; this . cohortStore . clear ( ) ; File cubeRoot = new File ( this . localRepo , cube ) ; if ( ! cubeRoot . exists ( ) ) { throw new FileNotFoundException ( "[x] Cube " + cube + " was not found" ) ; } TableSchema schema = TableSchema . read ( new FileInputStream ( new File ( cubeRoot , "table.yaml" ) ) ) ; CubeRS cubeRS = new CubeRS ( schema ) ; File [ ] versions = cubeRoot . listFiles ( new FileFilter ( ) { @ Override public boolean accept ( File file ) { return file . isDirectory ( ) ; } } ) ; checkNotNull ( versions ) ; if ( versions . length == 0 ) { return ; } Arrays . sort ( versions ) ; File currentVersion = versions [ versions . length - 1 ] ; File [ ] cubletFiles = currentVersion . listFiles ( new FilenameFilter ( ) { @ Override public boolean accept ( File file , String s ) { return s . endsWith ( ".dz" ) ; } } ) ; System . out . println ( "Cube " + cube + ", versions: " + Arrays . toString ( versions ) ) ; System . out . println ( "Cube " + cube + ", Use version: " + currentVersion . getName ( ) ) ; checkNotNull ( cubletFiles ) ; for ( File cubletFile : cubletFiles ) { cubeRS . addCublet ( cubletFile ) ; } this . metaStore . put ( cube , cubeRS ) ; System . out . println ( "Cube " + cube + ", metaStore: " + this . metaStore . keySet ( ) ) ; }
Load a cube (a set of cube files) from the repository into memory
 @param cube the cube name
 @throws IOException
Load a cube ( a set of cube files ) from the repository into memory @param cube the cube name @throws IOException
// Remove the old version of the cube // Check the existence of cube under this repository // Read schema information // Only load the latest version // Load all cubes under latest version