Tabnine Logo
DataAtom
Code IndexAdd Tabnine to your IDE (free)

How to use
DataAtom
in
it.unibz.inf.ontop.model.atom

Best Java code snippets using it.unibz.inf.ontop.model.atom.DataAtom (Showing top 20 results out of 315)

origin: ontop/ontop

private static boolean extendHomomorphism(Map<Variable, VariableOrGroundTerm> map, DataAtom from, DataAtom to) {
  return from.getPredicate().equals(to.getPredicate())
      && extendHomomorphism(map, from.getArguments(), to.getArguments());
}
origin: it.unibz.inf.ontop/ontop-model

@Override
public boolean hasSamePredicateAndArity(DataAtom otherAtom) {
  if (!predicate.equals(otherAtom.getPredicate()))
    return false;
  if (getEffectiveArity() != otherAtom.getEffectiveArity())
    return false;
  return true;
}
origin: ontop/ontop

/**
 * Checks if the atom is unary or not.
 */
private static boolean isUnary(DataAtom atom) {
  return atom.getArity() == 1;
}
origin: ontop/ontop

/**
 * Returns the list of the terms from atom corresponding
 * to the positions
 * TODO: explain
 */
protected static ImmutableList<VariableOrGroundTerm> extractArguments(DataAtom atom,
                                   ImmutableList<Integer> positions) {
  ImmutableList.Builder<VariableOrGroundTerm> listBuilder = ImmutableList.builder();
  int atomLength = atom.getArguments().size();
  for (Integer keyIndex : positions) {
    if (keyIndex > atomLength) {
      // TODO: find another exception
      throw new RuntimeException("The key index does not respect the arity of the atom " + atom);
    }
    else {
      listBuilder.add(atom.getTerm(keyIndex - 1));
    }
  }
  return listBuilder.build();
}
origin: it.unibz.inf.ontop/ontop-model

  protected static boolean hasDuplicates(DataAtom atom) {
    ImmutableList<? extends VariableOrGroundTerm> termList = atom.getArguments();
    Set<VariableOrGroundTerm> termSet = new HashSet<>(termList);

    return termSet.size() < termList.size();
  }
}
origin: it.unibz.inf.ontop/ontop-optimization

private static ImmutableSubstitution<VariableOrGroundTerm> extractSubstitution(DistinctVariableOnlyDataAtom sourceAtom,
                                        DataAtom targetAtom) {
  if (!sourceAtom.getPredicate().equals(targetAtom.getPredicate())) {
    throw new IllegalStateException("Incompatible predicates");
  }
  else if (sourceAtom.getEffectiveArity() != targetAtom.getEffectiveArity()) {
    throw new IllegalStateException("Different arities");
  }
  ImmutableMap<Variable, VariableOrGroundTerm> newMap = FunctionalTools.zip(
      sourceAtom.getArguments(),
      (ImmutableList<VariableOrGroundTerm>) targetAtom.getArguments()).stream()
      .collect(ImmutableCollectors.toMap());
  return SUBSTITUTION_FACTORY.getSubstitution(newMap);
}
origin: ontop/ontop

@Override
protected Optional<IQ> getDefinition(IntensionalDataNode dataNode) {
  return Optional.ofNullable(map.get(dataNode.getProjectionAtom().getPredicate()));
}
origin: it.unibz.inf.ontop/ontop-model

@Override
public DistinctVariableDataAtom applyToDistinctVariableDataAtom(DistinctVariableDataAtom dataAtom)
    throws ConversionException {
  DataAtom newDataAtom = applyToDataAtom(dataAtom);
  if (newDataAtom instanceof DistinctVariableDataAtom) {
    return (DistinctVariableDataAtom) newDataAtom;
  }
  /**
   * Checks if new data atom can be converted into a DistinctVariableDataAtom
   */
  if (newDataAtom.getArguments().size() == newDataAtom.getVariables().size()) {
    return ATOM_FACTORY.getDistinctVariableDataAtom(newDataAtom.getPredicate(),
        (ImmutableList<Variable>)newDataAtom.getArguments());
  }
  else {
    throw new ConversionException("The substitution has transformed a DistinctVariableDataAtom into" +
        "a non-DistinctVariableDataAtom: " + newDataAtom);
  }
}
origin: ontop/ontop

VariableOrGroundTerm leftArgument = leftAtom.getTerm(dependentIndex);
VariableOrGroundTerm rightArgument = rightAtom.getTerm(dependentIndex);
origin: it.unibz.inf.ontop/ontop-optimization

private Optional<GroundTermRemovalFromDataNodeProposal> makeProposal(IntermediateQuery query) {
  ImmutableList.Builder<DataNode> dataNodesToSimplifyBuilder = ImmutableList.builder();
  for (QueryNode node : query.getNodesInTopDownOrder()) {
    if (node instanceof DataNode) {
      DataNode dataNode = (DataNode) node;
      if (dataNode.getProjectionAtom().containsGroundTerms()) {
        dataNodesToSimplifyBuilder.add(dataNode);
      }
    }
  }
  ImmutableList<DataNode> dataNodesToSimplify = dataNodesToSimplifyBuilder.build();
  if (dataNodesToSimplify.isEmpty()) {
    return Optional.empty();
  }
  else {
    GroundTermRemovalFromDataNodeProposal proposal = new GroundTermRemovalFromDataNodeProposalImpl(
        dataNodesToSimplify);
    return Optional.of(proposal);
  }
}
origin: ontop/ontop

protected static boolean hasDuplicates(DataAtom atom) {
  ImmutableList<? extends VariableOrGroundTerm> termList = atom.getArguments();
  Set<VariableOrGroundTerm> termSet = new HashSet<>(termList);
  return termSet.size() < termList.size();
}
origin: ontop/ontop

  private ImmutableSubstitution<VariableOrGroundTerm> extractSubstitution(DistinctVariableOnlyDataAtom sourceAtom,
                                      DataAtom targetAtom) {
    if (!sourceAtom.getPredicate().equals(targetAtom.getPredicate())) {
      throw new IllegalStateException("Incompatible predicates");
    }
    else if (sourceAtom.getEffectiveArity() != targetAtom.getEffectiveArity()) {
      throw new IllegalStateException("Different arities");
    }
    ImmutableMap<Variable, VariableOrGroundTerm> newMap = FunctionalTools.zip(
        sourceAtom.getArguments(),
        (ImmutableList<VariableOrGroundTerm>) targetAtom.getArguments()).stream()
        .collect(ImmutableCollectors.toMap());
    return substitutionFactory.getSubstitution(newMap);
  }
}
origin: ontop/ontop

private RDFAtomPredicate getRDFAtomPredicate(DataAtom atom){
  return Optional.of(atom.getPredicate())
      .filter(p -> p instanceof RDFAtomPredicate)
      .map(p -> (RDFAtomPredicate) p)
      .orElseThrow(() -> new CanonicalTransformerException(RDFAtomPredicate.class.getName() + " expected"));
}
origin: it.unibz.inf.ontop/ontop-optimization

/**
 * Returns the list of the terms from atom corresponding
 * to the positions
 * TODO: explain
 */
protected static ImmutableList<VariableOrGroundTerm> extractArguments(DataAtom atom,
                                   ImmutableList<Integer> positions) {
  ImmutableList.Builder<VariableOrGroundTerm> listBuilder = ImmutableList.builder();
  int atomLength = atom.getArguments().size();
  for (Integer keyIndex : positions) {
    if (keyIndex > atomLength) {
      // TODO: find another exception
      throw new RuntimeException("The key index does not respect the arity of the atom " + atom);
    }
    else {
      listBuilder.add(atom.getTerm(keyIndex - 1));
    }
  }
  return listBuilder.build();
}
origin: it.unibz.inf.ontop/ontop-optimization

VariableOrGroundTerm leftArgument = leftAtom.getTerm(dependentIndex);
VariableOrGroundTerm rightArgument = rightAtom.getTerm(dependentIndex);
origin: ontop/ontop

public Function convertToMutableFunction(DataAtom dataAtom) {
  return convertToMutableFunction(dataAtom.getPredicate(), dataAtom.getArguments());
}
origin: ontop/ontop

private ImmutableList<VariableOrGroundTerm> extractDeterminantArguments(DataAtom dataAtom,
                                    ImmutableList<Integer> determinantIndexes) {
  ImmutableList<? extends VariableOrGroundTerm> arguments = dataAtom.getArguments();
  return determinantIndexes.stream()
      .map(i -> arguments.get(i - 1))
      .collect(ImmutableCollectors.toList());
}
origin: ontop/ontop

protected static ImmutableMultimap<RelationPredicate, ExtensionalDataNode> extractDataNodes(ImmutableList<QueryNode> siblings) {
  ImmutableMultimap.Builder<RelationPredicate, ExtensionalDataNode> mapBuilder = ImmutableMultimap.builder();
  for (QueryNode node : siblings) {
    if (node instanceof ExtensionalDataNode) {
      ExtensionalDataNode dataNode = (ExtensionalDataNode) node;
      mapBuilder.put(dataNode.getProjectionAtom().getPredicate(), dataNode);
    }
  }
  return mapBuilder.build();
}
origin: ontop/ontop

private Optional<IRI> getPropertyIRI(DataAtom atom) {
  AtomPredicate atomPredicate = atom.getPredicate();
  return Optional.of(atomPredicate)
      .filter(p -> p instanceof RDFAtomPredicate)
      .map(p -> (RDFAtomPredicate) p)
      .flatMap(p -> p.getPropertyIRI(atom.getArguments()));
}
origin: ontop/ontop

@Override
public ImmutableSet<Variable> getLocalVariables() {
  return atom.getArguments()
      .stream()
      .filter(Variable.class::isInstance)
      .map(Variable.class::cast)
      .collect(ImmutableCollectors.toSet());
}
it.unibz.inf.ontop.model.atomDataAtom

Javadoc

Immutable data atom that only accepts variables and ground terms as arguments. In the future, this class could be disassociated from the Function class.

Most used methods

  • getArguments
  • getPredicate
  • getEffectiveArity
    Effective arity (number of sub-terms).
  • containsGroundTerms
  • getArity
  • getTerm
  • getVariables
  • hasSamePredicateAndArity

Popular in Java

  • Running tasks concurrently on multiple threads
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (Timer)
  • startActivity (Activity)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Option (scala)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now