Codota Logo
RheemException
Code IndexAdd Codota to your IDE (free)

How to use
RheemException
in
org.qcri.rheem.core.api.exception

Best Java code snippets using org.qcri.rheem.core.api.exception.RheemException (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: org.qcri.rheem/rheem-core

/**
 * Creates a new instance of the given {@link Class} via the default constructor.
 *
 * @param cls the {@link Class} to be instantiated
 * @return the instance
 */
public static <T> T instantiateDefault(Class<? extends T> cls) {
  try {
    return cls.newInstance();
  } catch (InstantiationException | IllegalAccessException e) {
    throw new RheemException("Could not instantiate class.", e);
  }
}
origin: org.qcri.rheem/rheem-core

/**
 * Ensure that there is a directory represented by the given {@link File}.
 *
 * @param file the directory that should be ensured
 */
public static void ensureDir(File file) {
  if (file.exists()) {
    if (!file.isDirectory()) {
      throw new RheemException(String.format("Could not ensure directory %s: It exists, but is not a directory.", file));
    }
  } else if (!file.mkdirs()) {
    throw new RheemException(String.format("Could not ensure directory %s: It does not exist, but could also not be created.", file));
  }
}
origin: org.qcri.rheem/rheem-core

/**
 * Creates a new instance of a {@link Class} via the default constructor.
 *
 * @param className name of the {@link Class} to be instantiated
 * @return the instance
 */
public static <T> T instantiateDefault(String className) {
  try {
    @SuppressWarnings("unchecked") // Will fail anyway, if incorrect.
        Class<T> cls = (Class<T>) Class.forName(className);
    return cls.newInstance();
  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
    throw new RheemException("Could not instantiate class.", e);
  }
}
origin: org.qcri.rheem/rheem-core

  @Override
  @SuppressWarnings("unchecked")
  public T deserialize(JSONObject json, Class<? extends T> cls) {
    if (json == null || json.equals(JSONObject.NULL)) return null;
    try {
      final Method fromJsonMethod = cls.getMethod("fromJson", JSONObject.class);
      return (T) fromJsonMethod.invoke(null, json);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
      throw new RheemException(String.format("Could not execute %s.fromJson(...).", cls.getCanonicalName()), e);
    }
  }
}
origin: org.qcri.rheem/rheem-core

private PlanImplementation selectBestPlanNary(List<PlanImplementation> planImplementation) {
  assert !planImplementation.isEmpty();
  return planImplementation.stream()
      .reduce(this::selectBestPlanBinary)
      .orElseThrow(() -> new RheemException("No plan was selected."));
}
origin: org.qcri.rheem/rheem-core

public void set(Key key, Value value) {
  throw new RheemException(String.format("Setting values not supported for %s.", this.getClass().getSimpleName()));
}
origin: org.qcri.rheem/rheem-core

/**
 * Converts a {@link File} object to a URL.
 *
 * @param file that should be converted
 * @return the {@link String} representation of the URL
 */
public static String toURL(File file) {
  try {
    return file.toPath().toUri().toURL().toString();
  } catch (MalformedURLException e) {
    throw new RheemException(String.format("Could not create URI for %s", file), e);
  }
}
origin: org.qcri.rheem/rheem-core

@Override
public boolean isDirectory(String url) {
  try {
    final FileStatus fileStatus = this.getHdfs(url).getFileStatus(new Path(url));
    return fileStatus.isDirectory();
  } catch (IOException e) {
    throw new RheemException(String.format("Could not access %s.", url), e);
  }
}
origin: org.qcri.rheem/rheem-core

/**
 * Create an empty file.
 *
 * @param file that should be created
 */
public static void touch(File file) {
  ensureDir(file.getParentFile());
  try (FileOutputStream fos = new FileOutputStream(file)) {
  } catch (IOException e) {
    throw new RheemException(String.format("Could not create %s.", file), e);
  }
}
origin: org.qcri.rheem/rheem-core

/**
 * As {@link #findActualInputPaths(String)} but requires the presence of only a single input file.
 */
public static String findActualSingleInputPath(String ostensibleInputFile) {
  final Collection<String> inputPaths = FileSystems.findActualInputPaths(ostensibleInputFile);
  if (inputPaths.size() != 1) {
    throw new RheemException(String.format(
        "Illegal number of files for \"%s\": %s", ostensibleInputFile, inputPaths
    )); // TODO: Add support.
  }
  return inputPaths.iterator().next();
}
origin: org.qcri.rheem/rheem-core

@Override
public Collection<String> listChildren(String url) {
  try {
    final FileStatus[] fileStatuses = this.getHdfs(url).listStatus(new Path(url));
    return Arrays.stream(fileStatuses)
        .map(status -> status.getPath().toString())
        .collect(Collectors.toList());
  } catch (IOException e) {
    throw new RheemException(String.format("Could not access %s.", url), e);
  }
}
origin: org.qcri.rheem/rheem-spark

@Override
@SuppressWarnings("unchecked")
public <T> Collection<T> getBroadcast(String name) {
  final Broadcast<?> broadcast = this.broadcasts.get(name);
  if (broadcast == null) {
    throw new RheemException("No such broadcast found: " + name);
  }
  return (Collection<T>) broadcast.getValue();
}
origin: org.qcri.rheem/rheem-core

/**
 * Initializes the {@link #writer} if it does not exist currently.
 *
 * @return the {@link #writer}
 */
private BufferedWriter getWriter() throws FileNotFoundException, UnsupportedEncodingException {
  if (this.writer == null) {
    File file = new File(this.repositoryPath);
    final File parentFile = file.getParentFile();
    if (!parentFile.exists() && !file.getParentFile().mkdirs()) {
      throw new RheemException("Could not initialize cardinality repository.");
    }
    this.writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true), "UTF-8"));
  }
  return this.writer;
}
origin: org.qcri.rheem/rheem-spark

  private ReplacementSubplanFactory createReplacementSubplanFactory() {
    return new ReplacementSubplanFactory.OfSingleOperators<PageRankOperator>(
        (matchedOperator, epoch) -> {
          // We need to instantiate the SparkPageRankOperator via reflection, because the Scala code will
          // be compiled only after the Java code, which might cause compile errors.
          try {
            final Class<?> cls = Class.forName("org.qcri.rheem.spark.operators.graph.SparkPageRankOperator");
            final Constructor<?> constructor = cls.getConstructor(PageRankOperator.class);
            return (Operator) constructor.newInstance(matchedOperator);
          } catch (Exception e) {
            throw new RheemException(String.format("Could not apply %s.", this), e);
          }
        }
    );
  }
}
origin: org.qcri.rheem/rheem-core

public static FileSystem requireFileSystem(String fileUrl) {
  return getFileSystem(fileUrl).orElseThrow(
      () -> new RheemException(String.format("Could not identify filesystem for \"%s\".", fileUrl))
  );
}
origin: org.qcri.rheem/rheem-core

private org.apache.hadoop.fs.FileSystem getHdfs(String uri) {
  this.ensureInitialized();
  try {
    Configuration conf = new Configuration(true);
    return org.apache.hadoop.fs.FileSystem.get(new URI(uri), conf);
  } catch (IOException | URISyntaxException e) {
    throw new RheemException(String.format("Could not obtain an HDFS client for %s.", uri), e);
  }
}
origin: org.qcri.rheem/rheem-java

private void tryAdvance() {
  if (this.nextElements != null && ++this.nextIndex < this.nextElements.length) return;
  try {
    if (!this.sequenceFileReader.next(this.nullWritable, this.bytesWritable)) {
      this.nextElements = null;
      return;
    }
    this.nextElements = (Object[]) new ObjectInputStream(new ByteArrayInputStream(this.bytesWritable.getBytes())).readObject();
    this.nextIndex = 0;
  } catch (IOException | ClassNotFoundException e) {
    this.nextElements = null;
    IOUtils.closeQuietly(this);
    throw new RheemException("Reading failed.", e);
  }
}
origin: org.qcri.rheem/rheem-core

/**
 * Initializes the {@link #writer} if it does not exist currently.
 *
 * @return the {@link #writer}
 */
private BufferedWriter getWriter() throws FileNotFoundException, UnsupportedEncodingException {
  if (this.writer != null) {
    return this.writer;
  }
  try {
    File file = new File(this.repositoryPath);
    final File parentFile = file.getParentFile();
    if (!parentFile.exists() && !file.getParentFile().mkdirs()) {
      throw new RheemException("Could not initialize cardinality repository.");
    }
    return this.writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true), "UTF-8"));
  } catch (RheemException e) {
    throw e;
  } catch (Exception e) {
    throw new RheemException(String.format("Cannot write to %s.", this.repositoryPath), e);
  }
}
origin: org.qcri.rheem/rheem-core

/**
 * Loads a specific {@link Platform} implementation. For platforms to interoperate with this method, they must
 * provide a {@code static}, parameterless method {@code getInstance()} that returns their singleton instance.
 *
 * @param platformClassName the class name of the {@link Platform}
 * @return the {@link Platform} instance
 */
public static Platform load(String platformClassName) {
  try {
    return ReflectionUtils.executeStaticArglessMethod(platformClassName, "getInstance");
  } catch (Exception e) {
    throw new RheemException("Could not load platform: " + platformClassName, e);
  }
}
origin: org.qcri.rheem/rheem-core

/**
 * Queries the {@link Job}-global cache.
 *
 * @param key         that is associated with the value to be retrieved
 * @param resultClass the expected {@link Class} of the retrieved value
 * @return the value associated with the key or else {@code null}
 */
public <T> T queryJobCache(String key, Class<T> resultClass) {
  final Object value = this.queryJobCache(key);
  try {
    return resultClass.cast(value);
  } catch (ClassCastException e) {
    throw new RheemException("Job-cache value cannot be casted as requested.", e);
  }
}
org.qcri.rheem.core.api.exceptionRheemException

Javadoc

Exception that declares a problem of Rheem.

Most used methods

  • <init>

Popular in Java

  • Updating database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • startActivity (Activity)
  • setContentView (Activity)
  • Color (java.awt)
    The Color class is used encapsulate colors in the default sRGB color space or colors in arbitrary co
  • PrintWriter (java.io)
    Prints formatted representations of objects to a text-output stream. This class implements all of th
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JFrame (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now