Package org.openrdf.sail.rdbms.schema

Examples of org.openrdf.sail.rdbms.schema.TripleTable


  {
    String union = " UNION ALL ";
    StringBuilder sb = new StringBuilder(1024);
    sb.append("(");
    for (Number pred : triples.getPredicateIds()) {
      TripleTable predicate;
      try {
        predicate = triples.getPredicateTable(pred);
      }
      catch (SQLException e) {
        throw new AssertionError(e);
      }
      TransactionTable table = findTable(pred);
      if ((table == null || table.isEmpty()) && predicate.isEmpty()) {
        continue;
      }
      sb.append("SELECT ctx, subj, ");
      if (predicate.isPredColumnPresent()) {
        sb.append(" pred,");
      }
      else {
        sb.append(pred).append(" AS pred,");
      }
      sb.append(" obj");
      sb.append("\nFROM ");
      sb.append(predicate.getNameWhenReady());
      sb.append(union);
      predicate.blockUntilReady();
    }
    if (sb.length() < union.length()) {
      return getEmptyTableName();
    }
    sb.delete(sb.length() - union.length(), sb.length());
View Full Code Here


    }
    return triples.getPredicateTable(id).isPredColumnPresent();
  }

  public ValueTypes getObjTypes(Number pred) {
    TripleTable table = triples.getExistingTable(pred);
    if (table == null) {
      return ValueTypes.UNKNOWN;
    }
    return table.getObjTypes();
  }
View Full Code Here

    }
    return table.getObjTypes();
  }

  public ValueTypes getSubjTypes(Number pred) {
    TripleTable table = triples.getExistingTable(pred);
    if (table == null) {
      return ValueTypes.RESOURCE;
    }
    return table.getSubjTypes();
  }
View Full Code Here

  public boolean isEmpty()
    throws SQLException
  {
    for (Number pred : triples.getPredicateIds()) {
      TripleTable predicate;
      try {
        predicate = triples.getPredicateTable(pred);
      }
      catch (SQLException e) {
        throw new AssertionError(e);
      }
      TransactionTable table = findTable(pred);
      if (table != null && !table.isEmpty() || !predicate.isEmpty()) {
        return false;
      }
    }
    return true;
  }
View Full Code Here

    throws SQLException
  {
    synchronized (tables) {
      TransactionTable table = tables.get(pred);
      if (table == null) {
        TripleTable predicate = triples.getPredicateTable(pred);
        Number key = pred;
        if (predicate.isPredColumnPresent()) {
          key = ids.idOf(-1);
          table = tables.get(key);
          if (table != null) {
            return table;
          }
View Full Code Here

    }
    Iterator<Entry<Number, TripleTable>> iter;
    iter = tables.entrySet().iterator();
    while (iter.hasNext()) {
      Entry<Number, TripleTable> next = iter.next();
      TripleTable table = next.getValue();
      if (table.isEmpty()) {
        predicates.remove(next.getKey());
        table.drop();
        iter.remove();
      }
      table.close();
    }
  }
View Full Code Here

    }
    String tableName = getNewTableName(pred);
    if (tables.size() >= maxTables) {
      tableName = OTHER_TRIPLES_TABLE;
    }
    TripleTable table = factory.createTripleTable(conn, tableName);
    table.setIdSequence(ids);
    if (tables.size() >= maxTables) {
      table.setPredColumnPresent(true);
      initTable(table);
      tables.put(OTHER_PRED, table);
    }
    else {
      initTable(table);
View Full Code Here

    throws SQLException
  {
    Map<Number, TripleTable> tables = new HashMap<Number, TripleTable>();
    Set<String> names = findPredicateTableNames();
    for (String tableName : names) {
      TripleTable table = factory.createTripleTable(conn, tableName);
      table.setIdSequence(ids);
      if (tableName.equalsIgnoreCase(OTHER_TRIPLES_TABLE)) {
        table.setPredColumnPresent(true);
      }
      if (indexingTriples && !table.isIndexed()) {
        table.createIndex();
      }
      table.reload();
      tables.put(key(tableName), table);
    }
    return tables;
  }
View Full Code Here

  void initThread()
    throws SQLException, InterruptedException
  {
    logger.debug("Starting helper thread {}", initThread.getName());
    while (!closed) {
      TripleTable table = null;
      synchronized (queue) {
        if (queue.isEmpty()) {
          queue.wait();
        }
        if (!queue.isEmpty()) {
          table = queue.removeFirst();
        }
      }
      if (table != null) {
        table.initTable();
        table = null;
      }
    }
    logger.debug("Closing helper thread {}", initThread.getName());
  }
View Full Code Here

    }
    Iterator<Entry<Number, TripleTable>> iter;
    iter = tables.entrySet().iterator();
    while (iter.hasNext()) {
      Entry<Number, TripleTable> next = iter.next();
      TripleTable table = next.getValue();
      if (table.isEmpty()) {
        predicates.remove(next.getKey());
        table.drop();
        iter.remove();
      }
      table.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.openrdf.sail.rdbms.schema.TripleTable

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.