コード例 #1
0
  /* situation options:
   *  1. ID:*:*
   *  2. URN:*:*
   *  3. ID:URN:*
   *  4. URN:ID:*
   */
  @Override
  public Iterator<Node[]> queryVersioning(
      Node[] query, int limit, String keyspace, int situation, String ID, String URN)
      throws StoreException {
    Iterator<Node[]> it = super.query(query, limit, keyspace);
    if (it != null) {
      return it;
    }
    String columnFamily = CF_S_PO;
    int[] map = _maps.get(columnFamily);
    Node[] q = Util.reorder(query, map);
    //		_log.info("query: " + Nodes.toN3(query) + " idx: " + columnFamily + " reordered: " +
    // Nodes.toN3(q));
    if (isVariable(q[0])) {
      // scan over all
      throw new UnsupportedOperationException("triple patterns must have at least one constant");
    } else {

      // SPO cf has one node as key and two nodes as colname
      Node[] nxKey = getQueryKeyBySituation(q[0], situation);
      String key_ID = nxKey[0].toN3();
      int colNameTupleLength = 2;
      // check ID and get the latest if neccessary
      if (ID != null && ID.contains("last") && URN != null)
        /*ID = String.valueOf(lastVersioningNumber(keyspace,q[0].toString()
        , URN));*/
        ID = lastCommitTxID(keyspace, q[0].toString());

      /* TM: query composite */
      SliceQuery<String, Composite, String> query_comp =
          HFactory.createSliceQuery(
              getExistingKeyspace(keyspace),
              StringSerializer.get(),
              CompositeSerializer.get(),
              StringSerializer.get());
      Composite columnStart = getCompositeStart(ID, URN, situation, q);
      Composite columnEnd = getCompositeEnd(ID, URN, situation, q);
      query_comp.setColumnFamily(columnFamily).setKey(key_ID);

      /*_log.info("QUERY COMPOSITE ...on CF " + columnFamily + "..... on key  " + key_ID);
      _log.info("QUERY COMPOSITE " + Nodes.toN3(q) + "--" + Nodes.toN3(new Node[] {q[1], q[2]})) ;
      _log.info("QUERY COMPOSITE situation: " + situation );*/

      // use the extended map
      map = _maps_ext.get(columnFamily);
      it =
          new ColumnSliceIteratorComposite<String>(
              query_comp, nxKey, columnStart, columnEnd, map, limit, colNameTupleLength, query);
    }
    return it;
  }
コード例 #2
0
 public <V> void setComposite(N columnName, Composite composite) {
   addInsertion(columnName, composite, CompositeSerializer.get(), globalTtl);
 }