org.apache.accumulo.core.security.ColumnVisibility Java Examples

The following examples show how to use org.apache.accumulo.core.security.ColumnVisibility. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JoinSelectStatsUtil.java    From rya with Apache License 2.0 6 votes vote down vote up
public static Mutation createMutation(TripleRow tripleRow) {
  Mutation mutation = new Mutation(new Text(tripleRow.getRow()));
  byte[] columnVisibility = tripleRow.getColumnVisibility();
  ColumnVisibility cv = columnVisibility == null ? EMPTY_CV : new ColumnVisibility(columnVisibility);
  Long timestamp = tripleRow.getTimestamp();
  boolean hasts = timestamp != null;
  timestamp = timestamp == null ? 0l : timestamp;
  byte[] value = tripleRow.getValue();
  Value v = value == null ? EMPTY_VALUE : new Value(value);
  byte[] columnQualifier = tripleRow.getColumnQualifier();
  Text cqText = columnQualifier == null ? EMPTY_TEXT : new Text(columnQualifier);
  byte[] columnFamily = tripleRow.getColumnFamily();
  Text cfText = columnFamily == null ? EMPTY_TEXT : new Text(columnFamily);

  if (hasts) {
    mutation.put(cfText, cqText, cv, timestamp, v);
  } else {
    mutation.put(cfText, cqText, cv, v);

  }
  return mutation;
}
 
Example #2
Source File: FacetedTransformer.java    From datawave with Apache License 2.0 6 votes vote down vote up
protected FacetsBase buildResponse(Document document, Key documentKey, ColumnVisibility eventCV, String colf, String row, MarkingFunctions mf)
                throws MarkingFunctions.Exception {
    
    FacetsBase facetedResponse = responseObjectFactory.getFacets();
    
    final Collection<FieldCardinalityBase> documentFields = buildFacets(documentKey, null, document, eventCV, mf);
    
    facetedResponse.setMarkings(mf.translateFromColumnVisibility(eventCV));
    facetedResponse.setFields(new ArrayList<>(documentFields));
    
    // assign an estimate of the event size based on the document size
    // in practice this is about 2.5 times the size of the document estimated size
    // we need to set something here for page size trigger purposes.
    facetedResponse.setSizeInBytes(Math.round(document.sizeInBytes() * 2.5d));
    
    return facetedResponse;
}
 
Example #3
Source File: EdgeQueryTransformerSupport.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Override
public BaseQueryResponse createResponse(List<Object> resultList) {
    try {
        EdgeQueryResponseBase response = responseObjectFactory.getEdgeQueryResponse();
        
        Set<ColumnVisibility> uniqueColumnVisibilities = Sets.newHashSet();
        for (Object result : resultList) {
            EdgeBase edge = (EdgeBase) result;
            Map<String,String> markings = edge.getMarkings();
            uniqueColumnVisibilities.add(this.markingFunctions.translateToColumnVisibility(markings));
            response.addEdge(edge);
        }
        
        ColumnVisibility combinedVisibility = this.markingFunctions.combine(uniqueColumnVisibilities);
        response.setMarkings(this.markingFunctions.translateFromColumnVisibility(combinedVisibility));
        return response;
    } catch (Exception ex) {
        throw new RuntimeException("could not handle markings in resultList ", ex);
    }
}
 
Example #4
Source File: ElementMutationBuilder.java    From vertexium with Apache License 2.0 6 votes vote down vote up
public Iterable<KeyValuePair> getVertexTableKeyValuePairsEdge(AccumuloEdge edge) {
    List<KeyValuePair> results = new ArrayList<>();
    ColumnVisibility edgeColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility());
    String edgeLabel = edge.getNewEdgeLabel() != null ? edge.getNewEdgeLabel() : edge.getLabel();
    Text edgeIdText = new Text(edge.getId());
    long timestamp = edge.getTimestamp();

    // out vertex.
    Text vertexOutIdRowKey = new Text(edge.getVertexId(Direction.OUT));
    AccumuloEdgeInfo edgeInfo = new AccumuloEdgeInfo(getNameSubstitutionStrategy().deflate(edgeLabel), edge.getVertexId(Direction.IN));
    results.add(new KeyValuePair(new Key(vertexOutIdRowKey, AccumuloVertex.CF_OUT_EDGE, edgeIdText, edgeColumnVisibility, timestamp), edgeInfo.toValue()));

    // in vertex.
    Text vertexInIdRowKey = new Text(edge.getVertexId(Direction.IN));
    edgeInfo = new AccumuloEdgeInfo(getNameSubstitutionStrategy().deflate(edgeLabel), edge.getVertexId(Direction.OUT));
    results.add(new KeyValuePair(new Key(vertexInIdRowKey, AccumuloVertex.CF_IN_EDGE, edgeIdText, edgeColumnVisibility, timestamp), edgeInfo.toValue()));

    return results;
}
 
Example #5
Source File: AccumuloTemporalLastNStore.java    From accumulo-recipes with Apache License 2.0 6 votes vote down vote up
@Override
public void put(String group, Event entry) {
    try {
        for (Attribute attribute : entry.getAttributes()) {
            Mutation m = new Mutation(group + GROUP_DELIM + generateTimestamp(entry.getTimestamp(), TimeUnit.DAYS));
            m.put(
                new Text(generateTimestamp(entry.getTimestamp(), TimeUnit.MINUTES)),
                new Text(encoder.encode(entry.getTimestamp()) + ONE_BYTE + entry.getType() + ONE_BYTE + entry.getId()),
                new ColumnVisibility(getVisibility(attribute, "")),
                new Value(buildEventValue(attribute).getBytes())
            );
            writer.addMutation(m);
        }

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #6
Source File: AccumuloWriter.java    From geowave with Apache License 2.0 6 votes vote down vote up
public static Mutation rowToMutation(final GeoWaveRow row) {
  final Mutation mutation = new Mutation(GeoWaveKey.getCompositeId(row));
  for (final GeoWaveValue value : row.getFieldValues()) {
    if ((value.getVisibility() != null) && (value.getVisibility().length > 0)) {
      mutation.put(
          new Text(ByteArrayUtils.shortToString(row.getAdapterId())),
          new Text(value.getFieldMask()),
          new ColumnVisibility(value.getVisibility()),
          new Value(value.getValue()));
    } else {
      mutation.put(
          new Text(ByteArrayUtils.shortToString(row.getAdapterId())),
          new Text(value.getFieldMask()),
          new Value(value.getValue()));
    }
  }
  return mutation;
}
 
Example #7
Source File: DateIndexHelperTest.java    From datawave with Apache License 2.0 6 votes vote down vote up
public static KeyValue getDateIndexEntry(String shardDate, int[] shardIndicies, String dataType, String type, String dateField, String dateValue,
                ColumnVisibility visibility) throws ParseException {
    // The row is the date to index yyyyMMdd
    
    // the colf is the type (e.g. LOAD or ACTIVITY)
    
    // the colq is the event date yyyyMMdd \0 the datatype \0 the field name
    String colq = shardDate + '\0' + dataType + '\0' + dateField;
    
    // the value is a bitset denoting the shard
    BitSet bits = DateIndexUtil.getBits(shardIndicies[0]);
    for (int i = 1; i < shardIndicies.length; i++) {
        bits = DateIndexUtil.merge(bits, DateIndexUtil.getBits(shardIndicies[i]));
    }
    Value shardList = new Value(bits.toByteArray());
    
    // create the key
    Key key = new Key(dateValue, type, colq, visibility, DateIndexUtil.getBeginDate(dateValue).getTime());
    
    return new KeyValue(key, shardList);
}
 
Example #8
Source File: AccumuloMetadataWriter.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Override
public void write(final GeoWaveMetadata metadata) {
  final Mutation mutation = new Mutation(new Text(metadata.getPrimaryId()));
  final Text cf = metadataTypeName;
  final Text cq =
      metadata.getSecondaryId() != null ? new Text(metadata.getSecondaryId()) : new Text();
  final byte[] visibility = metadata.getVisibility();
  if (visibility != null) {
    mutation.put(cf, cq, new ColumnVisibility(visibility), new Value(metadata.getValue()));
  } else {
    mutation.put(cf, cq, new Value(metadata.getValue()));
  }
  try {
    writer.addMutation(mutation);
  } catch (final MutationsRejectedException e) {
    LOGGER.error("Unable to write metadata", e);
  }
}
 
Example #9
Source File: AccumuloUtils.java    From mrgeo with Apache License 2.0 6 votes vote down vote up
/**
 * Wrapper around ColumnVisibility to make sure that protection
 * levels are valid.
 *
 * @param protectionLevel
 * @return
 */
@SuppressWarnings({"squid:S1166", "squid:S1848"})
// BadArgumentException exception is caught and returned as false, Using object creation for valid check
public static boolean validateProtectionLevel(final String protectionLevel)
{
  try
  {
    new ColumnVisibility(protectionLevel);
  }
  catch (BadArgumentException ignored)
  {
    return false;
  }

  return true;
}
 
Example #10
Source File: ElementMutationBuilder.java    From vertexium with Apache License 2.0 6 votes vote down vote up
public void addPropertyMetadataItemToMutation(
    Mutation m,
    ElementId elementId,
    Property property,
    String metadataKey,
    Object metadataValue,
    Visibility visibility
) {
    Text columnQualifier = getPropertyMetadataColumnQualifierText(property, metadataKey);
    ColumnVisibility metadataVisibility = visibilityToAccumuloVisibility(visibility);
    if (metadataValue == null) {
        addPropertyMetadataItemDeleteToMutation(m, columnQualifier, metadataVisibility);
    } else {
        addPropertyMetadataItemAddToMutation(
            m,
            elementId,
            property,
            columnQualifier,
            metadataVisibility,
            metadataKey,
            visibility,
            metadataValue
        );
    }
}
 
Example #11
Source File: ChunkInputFormatIT.java    From accumulo-examples with Apache License 2.0 6 votes vote down vote up
@Test
public void testInfoWithoutChunks() throws Exception {
  client.tableOperations().create(tableName);
  BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig());
  for (Entry<Key,Value> e : baddata) {
    Key k = e.getKey();
    Mutation m = new Mutation(k.getRow());
    m.put(k.getColumnFamily(), k.getColumnQualifier(),
        new ColumnVisibility(k.getColumnVisibility()), k.getTimestamp(), e.getValue());
    bw.addMutation(m);
  }
  bw.close();

  assertEquals(0, CIFTester.main(tableName, CIFTester.TestBadData.class.getName()));
  assertEquals(1, assertionErrors.get(tableName).size());
}
 
Example #12
Source File: ElementMutationBuilder.java    From vertexium with Apache License 2.0 5 votes vote down vote up
public void addPropertySoftDeleteToMutation(Mutation m, Property property, long timestamp, Object data) {
    Preconditions.checkNotNull(m, "mutation cannot be null");
    Preconditions.checkNotNull(property, "property cannot be null");
    Text columnQualifier = KeyHelper.getColumnQualifierFromPropertyColumnQualifier(property, getNameSubstitutionStrategy());
    ColumnVisibility columnVisibility = visibilityToAccumuloVisibility(property.getVisibility());
    m.put(AccumuloElement.CF_PROPERTY_SOFT_DELETE, columnQualifier, columnVisibility, timestamp, toSoftDeleteDataToValue(data));
}
 
Example #13
Source File: RandomBatchWriter.java    From accumulo-examples with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a mutation on a specified row with column family "foo", column qualifier "1", specified
 * visibility, and a random value of specified size.
 *
 * @param rowid
 *          the row of the mutation
 * @param dataSize
 *          the size of the random value
 * @param visibility
 *          the visibility of the entry to insert
 * @return a mutation
 */
public static Mutation createMutation(long rowid, int dataSize, ColumnVisibility visibility) {
  Text row = new Text(String.format("row_%010d", rowid));

  Mutation m = new Mutation(row);

  // create a random value that is a function of the
  // row id for verification purposes
  byte value[] = createValue(rowid, dataSize);

  m.put(new Text("foo"), new Text("1"), visibility, new Value(value));

  return m;
}
 
Example #14
Source File: AccumuloEventStorageBoltTest.java    From cognition with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetColumnVisibility(
    @Injectable LogRecord record,
    @Mocked ColumnVisibility vis) {
  bolt.visibility = "visibility";

  new Expectations() {{
    new ColumnVisibility(bolt.visibility);
    result = vis;
  }};

  assertThat(bolt.getColumnVisibility(record), is(vis));
}
 
Example #15
Source File: GroupingTestWithModel.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Test
public void testCountingMap() {
    MarkingFunctions markingFunctions = new MarkingFunctions.Default();
    GroupingTransform.GroupCountingHashMap map = new GroupingTransform.GroupCountingHashMap(markingFunctions);
    GroupingTypeAttribute attr1 = new GroupingTypeAttribute(new LcType("FOO"), new Key("FOO"), true);
    attr1.setColumnVisibility(new ColumnVisibility("A"));
    map.add(Collections.singleton(attr1));
    
    GroupingTypeAttribute attr2 = new GroupingTypeAttribute(new LcType("FOO"), new Key("FOO"), true);
    attr2.setColumnVisibility(new ColumnVisibility("B"));
    map.add(Collections.singleton(attr2));
    GroupingTypeAttribute attr3 = new GroupingTypeAttribute(new LcType("BAR"), new Key("BAR"), true);
    attr3.setColumnVisibility(new ColumnVisibility("C"));
    map.add(Collections.singleton(attr3));
    
    log.debug("map is: " + map);
    
    for (Map.Entry<Collection<GroupingTypeAttribute<?>>,Integer> entry : map.entrySet()) {
        Attribute<?> attr = entry.getKey().iterator().next(); // the first and only one
        int count = entry.getValue();
        if (attr.getData().toString().equals("FOO")) {
            Assert.assertEquals(2, count);
            Assert.assertEquals(new ColumnVisibility("A&B"), attr.getColumnVisibility());
        } else if (attr.getData().toString().equals("BAR")) {
            Assert.assertEquals(1, count);
            Assert.assertEquals(new ColumnVisibility("C"), attr.getColumnVisibility());
        }
    }
}
 
Example #16
Source File: FieldIndexCountingIterator.java    From datawave with Apache License 2.0 5 votes vote down vote up
/**
 * Row : shardId Fam : fieldName Qual: fieldValue \x00 datatype
 * 
 * @return our new top key with the aggregated columnVisibility
 */
private Key buildReturnKey() {
    if (log.isTraceEnabled()) {
        log.trace("buildReturnKey, currentRow: " + this.currentRow);
        log.trace("buildReturnKey, currentFieldName: " + this.currentFieldName);
        log.trace("buildReturnKey, currentFieldValue: " + this.currentFieldValue);
    }
    
    Text cq = new Text(this.currentFieldValue);
    if (this.uniqByDataTypeOption) {
        TextUtil.textAppend(cq, this.currentDataType);
    }
    
    // Combine the column visibilities into a single one
    // NOTE: key.getColumnVisibility actually returns a Text object so we need to convert them
    Set<ColumnVisibility> columnVisibilities = new HashSet<>();
    for (Text t : this.visibilitySet) {
        columnVisibilities.add(new ColumnVisibility(t));
    }
    ColumnVisibility cv;
    try {
        cv = markingFunctions.combine(columnVisibilities);
    } catch (MarkingFunctions.Exception e) {
        log.error("Could not combine visibilities: " + visibilitySet + "  " + e);
        return null;
    }
    
    return new Key(this.currentRow, new Text(this.currentFieldName), cq, new Text(cv.getExpression()), this.maxTimeStamp);
}
 
Example #17
Source File: FieldIndexCountQueryLogic.java    From datawave with Apache License 2.0 5 votes vote down vote up
public ColumnVisibility getColumnVisibility() {
    try {
        Set<ColumnVisibility> columnVisibilities = new HashSet<>();
        for (Text t : this.uniqueVisibilities) {
            columnVisibilities.add(new ColumnVisibility(t));
        }
        return tupleMarkingFunctions.combine(columnVisibilities);
        
    } catch (MarkingFunctions.Exception e) {
        logger.error("Could not create combined column visibility for the count", e);
        return null;
    }
}
 
Example #18
Source File: EntityCentricIndex.java    From rya with Apache License 2.0 5 votes vote down vote up
private static Mutation createMutation(final TripleRow tripleRow) {
    final Mutation mutation = new Mutation(new Text(tripleRow.getRow()));
    final byte[] columnVisibility = tripleRow.getColumnVisibility();
    final ColumnVisibility cv = columnVisibility == null ? EMPTY_CV : new ColumnVisibility(columnVisibility);
    final Long timestamp = tripleRow.getTimestamp();
    final byte[] value = tripleRow.getValue();
    final Value v = value == null ? EMPTY_VALUE : new Value(value);
    final byte[] columnQualifier = tripleRow.getColumnQualifier();
    final Text cqText = columnQualifier == null ? EMPTY_TEXT : new Text(columnQualifier);
    final byte[] columnFamily = tripleRow.getColumnFamily();
    final Text cfText = columnFamily == null ? EMPTY_TEXT : new Text(columnFamily);

    mutation.put(cfText, cqText, cv, timestamp, v);
    return mutation;
}
 
Example #19
Source File: AccumuloItem.java    From cognition with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the contents of <code>items</code> to the row represented by <code>out</code> as Column Qualifiers an Values
 * in the Column Family <code>columnFamily</code>
 *
 * @param out
 * @param columnFamily
 * @param items
 * @param vis          Accumulo entry visibility
 */
public static void writeMap(Mutation out, String columnFamily, Map<String, String> items, ColumnVisibility vis) {
  if (items == null) {
    return;
  }

  for (Entry<String, String> entry : items.entrySet()) {
    if (!(entry.getKey() == null || entry.getValue() == null)) {
      out.put(columnFamily, entry.getKey(), vis, entry.getValue());
    }
  }
}
 
Example #20
Source File: QueryUtil.java    From datawave with Apache License 2.0 5 votes vote down vote up
public static <T extends Query> Mutation toMutation(T query, ColumnVisibility vis) {
    // Store by sid for backwards compatibility
    Mutation m = new Mutation(query.getOwner());
    try {
        @SuppressWarnings("unchecked")
        Schema<T> schema = (Schema<T>) RuntimeSchema.getSchema(query.getClass());
        byte[] bytes = ProtobufIOUtil.toByteArray(query, schema, BUFFER.get());
        m.put(query.getQueryName(), query.getId() + NULL_BYTE + query.getClass().getName(), vis, query.getExpirationDate().getTime(), new Value(bytes));
        return m;
    } finally {
        BUFFER.get().clear();
    }
}
 
Example #21
Source File: AccumuloLastNStore.java    From accumulo-recipes with Apache License 2.0 5 votes vote down vote up
/**
 * Add the index which will be managed by the versioning iterator and the data rows to scan from the index
 *
 * @param group
 * @param entry
 */
@Override
public void put(String group, Event entry) {
    checkNotNull(group);
    checkNotNull(entry);

    // first put the main index pointing to the contextId (The column family is prefixed with the NULL_BYTE to guarantee it shows up first
    Mutation indexMutation = new Mutation(group);
    indexMutation.put(NULL_BYTE + "INDEX", "", new ColumnVisibility(), entry.getTimestamp(), new Value((entry.getType() + ONE_BYTE + entry.getId()).getBytes()));

    for (Attribute attribute : entry.getAttributes()) {
        String fam = String.format("%s%s%s%s", END_BYTE, entry.getType(), ONE_BYTE, entry.getId());
        Object value = attribute.getValue();
        try {
            String serialize = typeRegistry.encode(value);
            String aliasForType = typeRegistry.getAlias(value);
            String qual = String.format("%s%s%s%s%s", attribute.getKey(), NULL_BYTE, serialize, NULL_BYTE, aliasForType);
            indexMutation.put(fam, qual, new ColumnVisibility(getVisibility(attribute, "")), entry.getTimestamp(),
                    new Value("".getBytes()));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    try {
        writer.addMutation(indexMutation);
    } catch (MutationsRejectedException ex) {
        throw new RuntimeException("There was an error writing the mutation for [index=" + group + ",entryId=" + entry.getId() + "]", ex);
    }
}
 
Example #22
Source File: AccumuloRecordWriter.java    From datawave with Apache License 2.0 5 votes vote down vote up
private int printMutation(Text table, Mutation m) {
    if (log.isTraceEnabled()) {
        log.trace(String.format("Table %s row key: %s", table, hexDump(m.getRow())));
        for (ColumnUpdate cu : m.getUpdates()) {
            log.trace(String.format("Table %s column: %s:%s", table, hexDump(cu.getColumnFamily()), hexDump(cu.getColumnQualifier())));
            log.trace(String.format("Table %s security: %s", table, new ColumnVisibility(cu.getColumnVisibility()).toString()));
            log.trace(String.format("Table %s value: %s", table, hexDump(cu.getValue())));
        }
    }
    return m.getUpdates().size();
}
 
Example #23
Source File: DiscoveryLogicTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
protected void insertForwardModel(String from, String to) throws Throwable {
    BatchWriterConfig config = new BatchWriterConfig().setMaxMemory(1024L).setMaxLatency(1, TimeUnit.SECONDS).setMaxWriteThreads(1);
    ColumnVisibility viz = new ColumnVisibility("FOO");
    
    try (BatchWriter writer = connector.createBatchWriter(QueryTestTableHelper.METADATA_TABLE_NAME, config)) {
        Mutation m = new Mutation(from.toUpperCase());
        m.put("DATAWAVE", to.toUpperCase() + "\u0000forward", viz, blank);
        writer.addMutation(m);
    }
}
 
Example #24
Source File: FileDataIngest.java    From accumulo-examples with Apache License 2.0 5 votes vote down vote up
public FileDataIngest(int chunkSize, ColumnVisibility colvis) {
  this.chunkSize = chunkSize;
  chunkSizeBytes = intToBytes(chunkSize);
  buf = new byte[chunkSize];
  try {
    md5digest = MessageDigest.getInstance("MD5");
  } catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }
  cv = colvis;
}
 
Example #25
Source File: DiscoveryIteratorTest.java    From datawave with Apache License 2.0 5 votes vote down vote up
void writeSample(BatchWriter writer, String term) throws MutationsRejectedException {
    int nShards = 10;
    String date = "20130101";
    String[] types = new String[] {"t1", "t2", "t3"};
    Value value = new Value(makeUidList(24).toByteArray());
    Mutation m = new Mutation(term);
    for (String type : types) {
        for (int i = 0; i < nShards; i++) {
            m.put("field", date + "_" + i + "\u0000" + type, new ColumnVisibility("FOO"), value);
        }
    }
    writer.addMutation(m);
}
 
Example #26
Source File: ElementMutationBuilder.java    From vertexium with Apache License 2.0 5 votes vote down vote up
private Mutation createMutationForEdgeBuilder(AccumuloGraph graph, EdgeBuilderBase edgeBuilder, ColumnVisibility edgeColumnVisibility, long timestamp) {
    String edgeRowKey = edgeBuilder.getId();
    Mutation m = new Mutation(edgeRowKey);
    String edgeLabel = edgeBuilder.getEdgeLabel();
    if (edgeBuilder.getNewEdgeLabel() != null) {
        edgeLabel = edgeBuilder.getNewEdgeLabel();
        m.putDelete(AccumuloEdge.CF_SIGNAL, new Text(edgeBuilder.getEdgeLabel()), edgeColumnVisibility, currentTimeMillis());
    }
    m.put(AccumuloEdge.CF_SIGNAL, new Text(edgeLabel), edgeColumnVisibility, timestamp, ElementMutationBuilder.EMPTY_VALUE);
    m.put(AccumuloEdge.CF_OUT_VERTEX, new Text(edgeBuilder.getVertexId(Direction.OUT)), edgeColumnVisibility, timestamp, ElementMutationBuilder.EMPTY_VALUE);
    m.put(AccumuloEdge.CF_IN_VERTEX, new Text(edgeBuilder.getVertexId(Direction.IN)), edgeColumnVisibility, timestamp, ElementMutationBuilder.EMPTY_VALUE);
    createMutationForElementBuilder(graph, edgeBuilder, edgeRowKey, m);
    return m;
}
 
Example #27
Source File: GroupingTransform.java    From datawave with Apache License 2.0 5 votes vote down vote up
private ColumnVisibility combine(Collection<ColumnVisibility> in) {
    try {
        ColumnVisibility columnVisibility = markingFunctions.combine(in);
        log.trace("combined {} into {}", in, columnVisibility);
        return columnVisibility;
    } catch (MarkingFunctions.Exception e) {
        log.warn("unable to combine visibilities from {}", in);
    }
    return new ColumnVisibility();
}
 
Example #28
Source File: RawRecordContainerImpl.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void readFields(DataInput in) throws IOException {
    clear();
    int length = in.readInt();
    byte[] buf = new byte[length];
    in.readFully(buf);
    Data data = Data.parseFrom(buf);
    
    this.eventDate = data.getDate();
    if (data.hasDataType())
        try {
            this.dataType = TypeRegistry.getType(data.getDataType());
        } catch (IllegalStateException ise) {
            // Try to initialize the registry and try again.
            // This was put in so that hadoop fs -conf <confFiles> -text <fileName> would work.
            if (null != conf)
                TypeRegistry.getInstance(conf);
            this.dataType = TypeRegistry.getType(data.getDataType());
        }
    if (data.hasUid())
        this.uid = UID.parse(data.getUid());
    errors = new ConcurrentSkipListSet<>();
    if (0 != data.getErrorsCount()) {
        errors.addAll(data.getErrorsList());
    }
    if (data.hasVisibility() && null != data.getVisibility())
        setVisibility(new ColumnVisibility(data.getVisibility().toByteArray()));
    if (data.hasRawFileName())
        this.rawFileName = data.getRawFileName();
    if (data.hasRawFileTimeStamp())
        this.rawFileTimeStamp = data.getRawFileTimeStamp();
    if (data.hasRawRecordNumber())
        this.rawRecordNumber = data.getRawRecordNumber();
    if (0 != data.getUuidsCount())
        this.ids = new ArrayList<>(data.getUuidsList());
    if (data.hasRawData() && null != data.getRawData())
        this.rawData = data.getRawData().toByteArray();
    this.requiresMasking = data.getRequiresMasking();
}
 
Example #29
Source File: ExtendedAccumuloBlobStore.java    From accumulo-recipes with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Mutation generateMutation(String key, String type, byte[] data, int sequenceNum, long timestamp, ColumnVisibility visibility) {
    Mutation m = super.generateMutation(key, type, data, sequenceNum, timestamp, visibility);

    //add a size value to the mutation
    m.put(SIZE_CF, "", visibility, Integer.toString(data.length));

    return m;
}
 
Example #30
Source File: ElementMutationBuilder.java    From vertexium with Apache License 2.0 5 votes vote down vote up
public void addAdditionalVisibilityToMutation(
    Mutation m,
    AdditionalVisibilityAddMutation additionalVisibility
) {
    Value value = toAddAdditionalVisibilityValue(additionalVisibility.getEventData());
    m.put(AccumuloElement.CF_ADDITIONAL_VISIBILITY, new Text(additionalVisibility.getAdditionalVisibility()), new ColumnVisibility(), value);
}