Ejemplo n.º 1
0
 private Text getPropertyMetadataColumnQualifierText(
     Property property, Metadata.Entry metadataItem) {
   final String propertyName = property.getName();
   final String propertyKey = property.getKey();
   final String visibilityString = property.getVisibility().getVisibilityString();
   final String metadataKey = metadataItem.getKey();
   //noinspection StringBufferReplaceableByString - for speed we use StringBuilder
   StringBuilder keyBuilder =
       new StringBuilder(
           propertyName.length()
               + propertyKey.length()
               + visibilityString.length()
               + metadataKey.length());
   keyBuilder.append(getNameSubstitutionStrategy().deflate(propertyName));
   keyBuilder.append(getNameSubstitutionStrategy().deflate(propertyKey));
   keyBuilder.append(visibilityString);
   keyBuilder.append(getNameSubstitutionStrategy().deflate(metadataKey));
   String key = keyBuilder.toString();
   Text r = propertyMetadataColumnQualifierTextCache.peek(key);
   if (r == null) {
     r =
         KeyHelper.getColumnQualifierFromPropertyMetadataColumnQualifier(
             propertyName,
             propertyKey,
             visibilityString,
             metadataKey,
             getNameSubstitutionStrategy());
     propertyMetadataColumnQualifierTextCache.put(key, r);
   }
   return r;
 }
Ejemplo n.º 2
0
  public void addPropertyToMutation(
      AccumuloGraph graph, Mutation m, String rowKey, Property property) {
    Text columnQualifier =
        KeyHelper.getColumnQualifierFromPropertyColumnQualifier(
            property, getNameSubstitutionStrategy());
    ColumnVisibility columnVisibility = visibilityToAccumuloVisibility(property.getVisibility());
    Object propertyValue = property.getValue();
    if (propertyValue instanceof StreamingPropertyValue) {
      propertyValue =
          saveStreamingPropertyValue(rowKey, property, (StreamingPropertyValue) propertyValue);
    }
    if (propertyValue instanceof DateOnly) {
      propertyValue = ((DateOnly) propertyValue).getDate();
    }

    // graph can be null if this is running in Map Reduce. We can just assume the property is
    // already defined.
    if (graph != null) {
      graph.ensurePropertyDefined(property.getName(), propertyValue);
    }

    Value value = new Value(vertexiumSerializer.objectToBytes(propertyValue));
    m.put(
        AccumuloElement.CF_PROPERTY,
        columnQualifier,
        columnVisibility,
        property.getTimestamp(),
        value);
    addPropertyMetadataToMutation(m, property);
  }
Ejemplo n.º 3
0
 private void addPropertyToKeyValuePairs(
     List<KeyValuePair> results, Text elementRowKey, Property property) {
   Text columnQualifier =
       KeyHelper.getColumnQualifierFromPropertyColumnQualifier(
           property, getNameSubstitutionStrategy());
   ColumnVisibility columnVisibility = visibilityToAccumuloVisibility(property.getVisibility());
   Object propertyValue = property.getValue();
   if (propertyValue instanceof StreamingPropertyValue) {
     throw new VertexiumException("StreamingPropertyValue are not supported");
   }
   if (propertyValue instanceof DateOnly) {
     propertyValue = ((DateOnly) propertyValue).getDate();
   }
   Value value = new Value(vertexiumSerializer.objectToBytes(propertyValue));
   results.add(
       new KeyValuePair(
           new Key(
               elementRowKey,
               AccumuloElement.CF_PROPERTY,
               columnQualifier,
               columnVisibility,
               property.getTimestamp()),
           value));
   addPropertyMetadataToKeyValuePairs(results, elementRowKey, property);
 }
Ejemplo n.º 4
0
 public void addPropertyDeleteToMutation(Mutation m, PropertyDeleteMutation propertyDelete) {
   Text columnQualifier =
       KeyHelper.getColumnQualifierFromPropertyColumnQualifier(
           propertyDelete.getKey(), propertyDelete.getName(), getNameSubstitutionStrategy());
   ColumnVisibility columnVisibility =
       visibilityToAccumuloVisibility(propertyDelete.getVisibility());
   m.putDelete(
       AccumuloElement.CF_PROPERTY, columnQualifier, columnVisibility, currentTimeMillis());
   addPropertyDeleteMetadataToMutation(m, propertyDelete);
 }
Ejemplo n.º 5
0
 public void addPropertySoftDeleteToMutation(Mutation m, Property property) {
   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,
       currentTimeMillis(),
       AccumuloElement.SOFT_DELETE_VALUE);
 }
Ejemplo n.º 6
0
 public void addPropertySoftDeleteToMutation(
     Mutation m, PropertySoftDeleteMutation propertySoftDelete) {
   Text columnQualifier =
       KeyHelper.getColumnQualifierFromPropertyColumnQualifier(
           propertySoftDelete.getKey(),
           propertySoftDelete.getName(),
           getNameSubstitutionStrategy());
   ColumnVisibility columnVisibility =
       visibilityToAccumuloVisibility(propertySoftDelete.getVisibility());
   m.put(
       AccumuloElement.CF_PROPERTY_SOFT_DELETE,
       columnQualifier,
       columnVisibility,
       currentTimeMillis(),
       AccumuloElement.SOFT_DELETE_VALUE);
 }
Ejemplo n.º 7
0
 public void addPropertyDeleteToMutation(Mutation m, Property property) {
   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.putDelete(
       AccumuloElement.CF_PROPERTY, columnQualifier, columnVisibility, currentTimeMillis());
   for (Metadata.Entry metadataEntry : property.getMetadata().entrySet()) {
     Text metadataEntryColumnQualifier =
         getPropertyMetadataColumnQualifierText(property, metadataEntry);
     ColumnVisibility metadataEntryVisibility =
         visibilityToAccumuloVisibility(metadataEntry.getVisibility());
     addPropertyMetadataItemDeleteToMutation(
         m, metadataEntryColumnQualifier, metadataEntryVisibility);
   }
 }
Ejemplo n.º 8
0
 private void addPropertySoftDeleteToKeyValuePairs(
     List<KeyValuePair> results,
     Text elementRowKey,
     PropertySoftDeleteMutation propertySoftDeleteMutation) {
   Text columnQualifier =
       KeyHelper.getColumnQualifierFromPropertyColumnQualifier(
           propertySoftDeleteMutation.getKey(),
           propertySoftDeleteMutation.getName(),
           getNameSubstitutionStrategy());
   ColumnVisibility columnVisibility =
       visibilityToAccumuloVisibility(propertySoftDeleteMutation.getVisibility());
   results.add(
       new KeyValuePair(
           new Key(
               elementRowKey,
               AccumuloElement.CF_PROPERTY_SOFT_DELETE,
               columnQualifier,
               columnVisibility,
               currentTimeMillis()),
           AccumuloElement.SOFT_DELETE_VALUE));
 }