org.vertexium.accumulo.AccumuloExtendedDataRow Maven / Gradle / Ivy
package org.vertexium.accumulo;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.vertexium.*;
import org.vertexium.accumulo.iterator.model.KeyBase;
import java.util.*;
public class AccumuloExtendedDataRow extends ExtendedDataRowBase {
private final ExtendedDataRowId rowId;
private final Set properties;
public AccumuloExtendedDataRow(
ExtendedDataRowId rowId,
SortedMap row,
FetchHints fetchHints,
VertexiumSerializer vertexiumSerializer
) {
super(fetchHints);
this.rowId = rowId;
this.properties = rowToProperties(rowId, row, fetchHints, vertexiumSerializer);
}
private Set rowToProperties(
ExtendedDataRowId rowId,
SortedMap row,
FetchHints fetchHints,
VertexiumSerializer vertexiumSerializer
) {
Set results = new HashSet<>();
for (Map.Entry rowEntry : row.entrySet()) {
String[] columnQualifierParts = KeyBase.splitOnValueSeparator(rowEntry.getKey().getColumnQualifier().toString());
if (columnQualifierParts.length != 1 && columnQualifierParts.length != 2) {
throw new VertexiumException("Invalid column qualifier for extended data row: " + rowId + " (expected 1 or 2 parts, found " + columnQualifierParts.length + ")");
}
String propertyName = columnQualifierParts[0];
String propertyKey = columnQualifierParts.length > 1 ? columnQualifierParts[1] : null;
Object propertyValue = vertexiumSerializer.bytesToObject(rowEntry.getValue().get());
long timestamp = rowEntry.getKey().getTimestamp();
Visibility visibility = AccumuloGraph.accumuloVisibilityToVisibility(rowEntry.getKey().getColumnVisibility());
AccumuloExtendedDataRowProperty prop = new AccumuloExtendedDataRowProperty(
propertyName,
propertyKey,
propertyValue,
fetchHints,
timestamp,
visibility
);
results.add(prop);
}
return results;
}
@Override
public ExtendedDataRowId getId() {
return rowId;
}
@Override
public Iterable getProperties() {
return properties;
}
private static class AccumuloExtendedDataRowProperty extends Property {
private final String propertyName;
private final String propertyKey;
private final Object propertyValue;
private final FetchHints fetchHints;
private final long timestamp;
private final Visibility visibility;
public AccumuloExtendedDataRowProperty(
String propertyName,
String propertyKey,
Object propertyValue,
FetchHints fetchHints,
long timestamp,
Visibility visibility
) {
this.propertyName = propertyName;
this.propertyKey = propertyKey;
this.propertyValue = propertyValue;
this.fetchHints = fetchHints;
this.timestamp = timestamp;
this.visibility = visibility;
}
@Override
public String getKey() {
return propertyKey;
}
@Override
public String getName() {
return propertyName;
}
@Override
public Object getValue() {
return propertyValue;
}
@Override
public long getTimestamp() {
return timestamp;
}
@Override
public Visibility getVisibility() {
return visibility;
}
@Override
public Metadata getMetadata() {
return new Metadata(fetchHints);
}
@Override
public FetchHints getFetchHints() {
return fetchHints;
}
@Override
public Iterable getHiddenVisibilities() {
return new ArrayList<>();
}
@Override
public boolean isHidden(Authorizations authorizations) {
return false;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy