org.apache.rya.api.domain.RyaStatement.getColumnVisibility()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(15.4k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中org.apache.rya.api.domain.RyaStatement.getColumnVisibility方法的一些代码示例,展示了RyaStatement.getColumnVisibility的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RyaStatement.getColumnVisibility方法的具体详情如下:
包路径:org.apache.rya.api.domain.RyaStatement
类名称:RyaStatement
方法名:getColumnVisibility

RyaStatement.getColumnVisibility介绍

暂无

代码示例

代码示例来源:origin: org.apache.rya/rya.export.client

@Override
  public Optional<RyaStatement> merge(final Optional<RyaStatement> parent, final Optional<RyaStatement> child)
      throws MergerException {
    if(parent.isPresent()) {
      final RyaStatement parentStatement = parent.get();
      if(child.isPresent()) {
        final RyaStatement childStatement = child.get();
        final String pVis = new String(parentStatement.getColumnVisibility(), StandardCharsets.UTF_8);
        final String cVis = new String(childStatement.getColumnVisibility(), StandardCharsets.UTF_8);
        String visibility = "";
        final Joiner join = Joiner.on(")&(");
        if(pVis.isEmpty() || cVis.isEmpty()) {
          visibility = (pVis + cVis).trim();
        } else {
          visibility = "(" + join.join(pVis, cVis) + ")";
        }
        parentStatement.setColumnVisibility(visibility.getBytes(StandardCharsets.UTF_8));
        return Optional.of(parentStatement);
      }
      return parent;
    } else if(child.isPresent()) {
      return child;
    }
    return Optional.absent();
  }
}

代码示例来源:origin: apache/incubator-rya

@Override
  public Optional<RyaStatement> merge(final Optional<RyaStatement> parent, final Optional<RyaStatement> child)
      throws MergerException {
    if(parent.isPresent()) {
      final RyaStatement parentStatement = parent.get();
      if(child.isPresent()) {
        final RyaStatement childStatement = child.get();
        final String pVis = new String(parentStatement.getColumnVisibility(), StandardCharsets.UTF_8);
        final String cVis = new String(childStatement.getColumnVisibility(), StandardCharsets.UTF_8);
        String visibility = "";
        final Joiner join = Joiner.on(")&(");
        if(pVis.isEmpty() || cVis.isEmpty()) {
          visibility = (pVis + cVis).trim();
        } else {
          visibility = "(" + join.join(pVis, cVis) + ")";
        }
        parentStatement.setColumnVisibility(visibility.getBytes(StandardCharsets.UTF_8));
        return Optional.of(parentStatement);
      }
      return parent;
    } else if(child.isPresent()) {
      return child;
    }
    return Optional.absent();
  }
}

代码示例来源:origin: org.apache.rya/rya.pcj.fluo.app

private void insertTriples(TransactionBase tx, final Collection<RyaStatement> triples) {
  for (final RyaStatement triple : triples) {
    Optional<byte[]> visibility = Optional.fromNullable(triple.getColumnVisibility());
    try {
      tx.set(spoFormat(triple), FluoQueryColumns.TRIPLES, Bytes.of(visibility.or(new byte[0])));
    } catch (final TripleRowResolverException e) {
      log.error("Could not convert a Triple into the SPO format: " + triple);
    }
  }
}

代码示例来源:origin: apache/incubator-rya

private void insertTriples(TransactionBase tx, final Collection<RyaStatement> triples) {
  for (final RyaStatement triple : triples) {
    Optional<byte[]> visibility = Optional.fromNullable(triple.getColumnVisibility());
    try {
      tx.set(spoFormat(triple), FluoQueryColumns.TRIPLES, Bytes.of(visibility.or(new byte[0])));
    } catch (final TripleRowResolverException e) {
      log.error("Could not convert a Triple into the SPO format: " + triple);
    }
  }
}

代码示例来源:origin: apache/incubator-rya

private void simplifyVisibilities(final RyaSubGraph subgraph) throws UnsupportedEncodingException {
  final Set<RyaStatement> statements = subgraph.getStatements();
  if (statements.size() > 0) {
    final byte[] visibilityBytes = statements.iterator().next().getColumnVisibility();
    // Simplify the result's visibilities and cache new simplified
    // visibilities
    final String visibility = new String(visibilityBytes, "UTF-8");
    if (!simplifiedVisibilities.containsKey(visibility)) {
      final String simplified = VisibilitySimplifier.simplify(visibility);
      simplifiedVisibilities.put(visibility, simplified);
    }
    for (final RyaStatement statement : statements) {
      statement.setColumnVisibility(simplifiedVisibilities.get(visibility).getBytes("UTF-8"));
    }
    
    subgraph.setStatements(statements);
  }
}

代码示例来源:origin: org.apache.rya/rya.pcj.fluo.app

private void simplifyVisibilities(final RyaSubGraph subgraph) throws UnsupportedEncodingException {
  final Set<RyaStatement> statements = subgraph.getStatements();
  if (statements.size() > 0) {
    final byte[] visibilityBytes = statements.iterator().next().getColumnVisibility();
    // Simplify the result's visibilities and cache new simplified
    // visibilities
    final String visibility = new String(visibilityBytes, "UTF-8");
    if (!simplifiedVisibilities.containsKey(visibility)) {
      final String simplified = VisibilitySimplifier.simplify(visibility);
      simplifiedVisibilities.put(visibility, simplified);
    }
    for (final RyaStatement statement : statements) {
      statement.setColumnVisibility(simplifiedVisibilities.get(visibility).getBytes("UTF-8"));
    }
    
    subgraph.setStatements(statements);
  }
}

代码示例来源:origin: apache/incubator-rya

public VisibilityStatementSet(Set<RyaStatement> statements) {
  this.statements = new HashSet<>();
  statements.forEach(x -> {
    this.statements.add(RyaToRdfConversions.convertStatement(x));
    if (visibility == null) {
      if (x.getColumnVisibility() != null) {
        visibility = new String(x.getColumnVisibility());
      } else {
        this.visibility = "";
      }
    }
  });
}

代码示例来源:origin: apache/incubator-rya

public VisibilityStatementSet(Set<RyaStatement> statements) {
  this.statements = new HashSet<>();
  statements.forEach(x -> {
    this.statements.add(RyaToRdfConversions.convertStatement(x));
    if (visibility == null) {
      if (x.getColumnVisibility() != null) {
        visibility = new String(x.getColumnVisibility());
      } else {
        this.visibility = "";
      }
    }
  });
}

代码示例来源:origin: org.apache.rya/rya.pcj.fluo.api

/**
 * Insert a batch of RyaStatements into Fluo.
 *
 * @param fluo - A connection to the Fluo table that will be updated. (not null)
 * @param triples - The triples to insert. (not null)
 */
public void insert(final FluoClient fluo, final Collection<RyaStatement> triples) {
  checkNotNull(fluo);
  checkNotNull(triples);
  try(Transaction tx = fluo.newTransaction()) {
    for(final RyaStatement triple : triples) {
      Optional<byte[]> visibility = Optional.fromNullable(triple.getColumnVisibility());
      try {
        tx.set(spoFormat(triple), FluoQueryColumns.TRIPLES, Bytes.of(visibility.or(new byte[0])));
      } catch (final TripleRowResolverException e) {
        log.error("Could not convert a Triple into the SPO format: " + triple);
      }
    }
    tx.commit();
  }
}

代码示例来源:origin: apache/incubator-rya

/**
 * Insert a batch of RyaStatements into Fluo.
 *
 * @param fluo - A connection to the Fluo table that will be updated. (not null)
 * @param triples - The triples to insert. (not null)
 */
public void insert(final FluoClient fluo, final Collection<RyaStatement> triples) {
  checkNotNull(fluo);
  checkNotNull(triples);
  try(Transaction tx = fluo.newTransaction()) {
    for(final RyaStatement triple : triples) {
      Optional<byte[]> visibility = Optional.fromNullable(triple.getColumnVisibility());
      try {
        tx.set(spoFormat(triple), FluoQueryColumns.TRIPLES, Bytes.of(visibility.or(new byte[0])));
      } catch (final TripleRowResolverException e) {
        log.error("Could not convert a Triple into the SPO format: " + triple);
      }
    }
    tx.commit();
  }
}

代码示例来源:origin: apache/incubator-rya

private void writeRyaMutations(final RyaStatement ryaStatement, final Context context, final boolean isDelete) throws IOException, InterruptedException {
  if (ryaStatement.getColumnVisibility() == null) {
    ryaStatement.setColumnVisibility(AccumuloRdfConstants.EMPTY_CV.getExpression());
  }
  final Map<TABLE_LAYOUT, Collection<Mutation>> mutationMap = ryaTableMutationFactory.serialize(ryaStatement);
  final Collection<Mutation> spoMutations = mutationMap.get(TABLE_LAYOUT.SPO);
  final Collection<Mutation> poMutations = mutationMap.get(TABLE_LAYOUT.PO);
  final Collection<Mutation> ospMutations = mutationMap.get(TABLE_LAYOUT.OSP);
  for (final Mutation mutation : spoMutations) {
    writeMutation(spoTable, mutation, context, isDelete);
  }
  for (final Mutation mutation : poMutations) {
    writeMutation(poTable, mutation, context, isDelete);
  }
  for (final Mutation mutation : ospMutations) {
    writeMutation(ospTable, mutation, context, isDelete);
  }
}

代码示例来源:origin: org.apache.rya/mongodb.rya

@Override
public void add(final Iterator<RyaStatement> statementIter) throws RyaDAOException {
  final List<DBObject> dbInserts = new ArrayList<>();
  while (statementIter.hasNext()){
    final RyaStatement ryaStatement = statementIter.next();
    final boolean canAdd = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility());
    if (canAdd) {
      final DBObject insert = storageStrategy.serialize(ryaStatement);
      dbInserts.add(insert);
      try {
        for (final RyaSecondaryIndexer index : secondaryIndexers) {
          index.storeStatement(ryaStatement);
        }
      } catch (final IOException e) {
        log.error("Failed to add: " + ryaStatement.toString() + " to the indexer");
      }
    } else {
      throw new RyaDAOException("User does not have the required authorizations to add statement");
    }
  }
  try {
    mongoDbBatchWriter.addObjectsToQueue(dbInserts);
    if (flushEachUpdate.get()) {
      flush();
    }
  } catch (final MongoDbBatchWriterException e) {
    throw new RyaDAOException("Error adding statements", e);
  }
}

代码示例来源:origin: org.apache.rya/mongodb.rya

@Override
public void delete(final Iterator<RyaStatement> statements,
    final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException {
  while (statements.hasNext()){
    final RyaStatement ryaStatement = statements.next();
    final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility());
    if (canDelete) {
      coll.remove(storageStrategy.getQuery(ryaStatement));
      for (final RyaSecondaryIndexer index : secondaryIndexers) {
        try {
          index.deleteStatement(ryaStatement);
        } catch (final IOException e) {
          log.error("Unable to remove statement: " + ryaStatement.toString() + " from secondary indexer: " + index.getTableName(), e);
        }
      }
    } else {
      throw new RyaDAOException("User does not have the required authorizations to delete statement");
    }
  }
}

代码示例来源:origin: apache/incubator-rya

@Override
public void delete(final Iterator<RyaStatement> statements,
    final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException {
  while (statements.hasNext()){
    final RyaStatement ryaStatement = statements.next();
    final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility());
    if (canDelete) {
      coll.remove(storageStrategy.getQuery(ryaStatement));
      for (final RyaSecondaryIndexer index : secondaryIndexers) {
        try {
          index.deleteStatement(ryaStatement);
        } catch (final IOException e) {
          log.error("Unable to remove statement: " + ryaStatement.toString() + " from secondary indexer: " + index.getTableName(), e);
        }
      }
    } else {
      throw new RyaDAOException("User does not have the required authorizations to delete statement");
    }
  }
}

代码示例来源:origin: org.apache.rya/rya.mapreduce

/**
 * Writes a (key,value) pair to Rya. Adds the statement to a buffer, and
 * flushes the statement buffer to the database if full.
 * @param   key     Arbitrary Writable, not used.
 * @param   value   Contains statement to insert to Rya.
 * @throws  IOException if writing to Accumulo fails.
 */
@Override
public void write(final Writable key, final RyaStatementWritable value) throws IOException {
  final RyaStatement ryaStatement = value.getRyaStatement();
  if (ryaStatement.getColumnVisibility() == null) {
    ryaStatement.setColumnVisibility(cv);
  }
  if (ryaStatement.getContext() == null) {
    ryaStatement.setContext(defaultContext);
  }
  buffer.add(ryaStatement);
  bufferCurrentSize += statementSize(ryaStatement);
  if (bufferCurrentSize >= bufferSizeLimit) {
    flushBuffer();
  }
}

代码示例来源:origin: apache/incubator-rya

/**
 * Writes a (key,value) pair to Rya. Adds the statement to a buffer, and
 * flushes the statement buffer to the database if full.
 * @param   key     Arbitrary Writable, not used.
 * @param   value   Contains statement to insert to Rya.
 * @throws  IOException if writing to Accumulo fails.
 */
@Override
public void write(final Writable key, final RyaStatementWritable value) throws IOException {
  final RyaStatement ryaStatement = value.getRyaStatement();
  if (ryaStatement.getColumnVisibility() == null) {
    ryaStatement.setColumnVisibility(cv);
  }
  if (ryaStatement.getContext() == null) {
    ryaStatement.setContext(defaultContext);
  }
  buffer.add(ryaStatement);
  bufferCurrentSize += statementSize(ryaStatement);
  if (bufferCurrentSize >= bufferSizeLimit) {
    flushBuffer();
  }
}

代码示例来源:origin: org.apache.rya/mongodb.rya

@Override
public void delete(final RyaStatement statement, final StatefulMongoDBRdfConfiguration conf)
    throws RyaDAOException {
  final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, statement.getColumnVisibility());
  if (canDelete) {
    final DBObject obj = storageStrategy.getQuery(statement);
    coll.remove(obj);
    for (final RyaSecondaryIndexer index : secondaryIndexers) {
      try {
        index.deleteStatement(statement);
      } catch (final IOException e) {
        log.error("Unable to remove statement: " + statement.toString() + " from secondary indexer: " + index.getTableName(), e);
      }
    }
  } else {
    throw new RyaDAOException("User does not have the required authorizations to delete statement");
  }
}

代码示例来源:origin: apache/incubator-rya

@Override
public void delete(final RyaStatement statement, final StatefulMongoDBRdfConfiguration conf)
    throws RyaDAOException {
  final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, statement.getColumnVisibility());
  if (canDelete) {
    final DBObject obj = storageStrategy.getQuery(statement);
    coll.remove(obj);
    for (final RyaSecondaryIndexer index : secondaryIndexers) {
      try {
        index.deleteStatement(statement);
      } catch (final IOException e) {
        log.error("Unable to remove statement: " + statement.toString() + " from secondary indexer: " + index.getTableName(), e);
      }
    }
  } else {
    throw new RyaDAOException("User does not have the required authorizations to delete statement");
  }
}

代码示例来源:origin: org.apache.rya/rya.indexing

private static List<TripleRow> serializeStatement(final RyaStatement stmt) throws RyaTypeResolverException {
  final RyaURI subject = stmt.getSubject();
  final RyaURI predicate = stmt.getPredicate();
  final RyaType object = stmt.getObject();
  final RyaURI context = stmt.getContext();
  final Long timestamp = stmt.getTimestamp();
  final byte[] columnVisibility = stmt.getColumnVisibility();
  final byte[] value = stmt.getValue();
  assert subject != null && predicate != null && object != null;
  final byte[] cf = (context == null) ? EMPTY_BYTES : context.getData().getBytes(StandardCharsets.UTF_8);
  final byte[] subjBytes = subject.getData().getBytes(StandardCharsets.UTF_8);
  final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8);
  final byte[][] objBytes = RyaContext.getInstance().serializeType(object);
  return Lists.newArrayList(new TripleRow(subjBytes,
    predBytes,
    Bytes.concat(cf, DELIM_BYTES,
      OBJECT.getBytes(StandardCharsets.UTF_8), DELIM_BYTES,
      objBytes[0], objBytes[1]),
    timestamp,
    columnVisibility,
    value),
    new TripleRow(objBytes[0],
      predBytes,
      Bytes.concat(cf, DELIM_BYTES,
        SUBJECT.getBytes(StandardCharsets.UTF_8), DELIM_BYTES,
        subjBytes, objBytes[1]),
      timestamp,
      columnVisibility,
      value));
}

代码示例来源:origin: org.apache.rya/rya.mapreduce

/**
 * Comparison method for natural ordering. Compares based on the logical
 * triple (the s/p/o/context information in the underlying RyaStatement)
 * and then by the metadata contained in the RyaStatement if the triples are
 * the same.
 * @return  Zero if both RyaStatementWritables contain equivalent statements
 *          or both have null statements; otherwise, an integer whose sign
 *          corresponds to a consistent ordering.
 */
@Override
public int compareTo(RyaStatementWritable other) {
  CompareToBuilder builder = new CompareToBuilder();
  RyaStatement rsThis = this.getRyaStatement();
  RyaStatement rsOther = other.getRyaStatement(); // should throw NPE if other is null, as per Comparable contract
  builder.append(rsThis == null, rsOther == null);
  if (rsThis != null && rsOther != null) {
    builder.append(rsThis.getSubject(), rsOther.getSubject());
    builder.append(rsThis.getPredicate(), rsOther.getPredicate());
    builder.append(rsThis.getObject(), rsOther.getObject());
    builder.append(rsThis.getContext(), rsOther.getContext());
    builder.append(rsThis.getQualifer(), rsOther.getQualifer());
    builder.append(rsThis.getColumnVisibility(), rsOther.getColumnVisibility());
    builder.append(rsThis.getValue(), rsOther.getValue());
    builder.append(rsThis.getTimestamp(), rsOther.getTimestamp());
  }
  return builder.toComparison();
}

相关文章