use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class DebugTars method filterNodeStates.
private void filterNodeStates(Set<UUID> uuids, List<String> paths, SegmentNodeState state, String path) {
Set<String> localPaths = newTreeSet();
for (PropertyState ps : state.getProperties()) {
if (ps instanceof SegmentPropertyState) {
SegmentPropertyState sps = (SegmentPropertyState) ps;
RecordId recordId = sps.getRecordId();
UUID id = recordId.getSegmentId().asUUID();
if (uuids.contains(id)) {
if (ps.getType().tag() == PropertyType.STRING) {
String val = "";
if (ps.count() > 0) {
// only shows the first value, do we need more?
val = displayString(ps.getValue(Type.STRING, 0));
}
localPaths.add(getLocalPath(path, ps, val, recordId));
} else {
localPaths.add(getLocalPath(path, ps, recordId));
}
}
if (ps.getType().tag() == PropertyType.BINARY) {
// look for extra segment references
for (int i = 0; i < ps.count(); i++) {
Blob b = ps.getValue(Type.BINARY, i);
for (SegmentId sbid : SegmentBlob.getBulkSegmentIds(b)) {
UUID bid = sbid.asUUID();
if (!bid.equals(id) && uuids.contains(bid)) {
localPaths.add(getLocalPath(path, ps, recordId));
}
}
}
}
}
}
RecordId stateId = state.getRecordId();
if (uuids.contains(stateId.getSegmentId().asUUID())) {
localPaths.add(path + " [SegmentNodeState@" + stateId + "]");
}
RecordId templateId = getTemplateId(state);
if (uuids.contains(templateId.getSegmentId().asUUID())) {
localPaths.add(path + "[Template@" + templateId + "]");
}
paths.addAll(localPaths);
for (ChildNodeEntry ce : state.getChildNodeEntries()) {
NodeState c = ce.getNodeState();
if (c instanceof SegmentNodeState) {
filterNodeStates(uuids, paths, (SegmentNodeState) c, path + ce.getName() + "/");
}
}
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class OakSolrNodeStateConfiguration method getStringValuesFor.
private Iterable<String> getStringValuesFor(String propertyName) {
Iterable<String> values = null;
PropertyState property = definition.getProperty(propertyName);
if (property != null && property.isArray()) {
values = property.getValue(Type.STRINGS);
}
return values;
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class OakSolrNodeStateConfiguration method getIntValueFor.
private int getIntValueFor(String propertyName, int defaultValue) {
long value = defaultValue;
PropertyState property = definition.getProperty(propertyName);
if (property != null) {
value = property.getValue(Type.LONG);
}
return (int) value;
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class OakSolrNodeStateConfiguration method getStringValueFor.
private String getStringValueFor(String propertyName, String defaultValue) {
String value = defaultValue;
PropertyState property = definition.getProperty(propertyName);
if (property != null) {
value = property.getValue(Type.STRING);
}
return value;
}
use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.
the class SolrIndexEditor method docFromState.
private SolrInputDocument docFromState(NodeState state) {
SolrInputDocument inputDocument = new SolrInputDocument();
String path = getPath();
inputDocument.addField(configuration.getPathField(), path);
inputDocument.addField(configuration.getPathDepthField(), PathUtils.getDepth(path));
if (configuration.collapseJcrContentNodes()) {
int jcrContentIndex = path.lastIndexOf(JcrConstants.JCR_CONTENT);
if (jcrContentIndex >= 0) {
int index = jcrContentIndex + JcrConstants.JCR_CONTENT.length();
String collapsedPath = path.substring(0, index);
inputDocument.addField(configuration.getCollapsedPathField(), collapsedPath);
}
}
for (PropertyState property : state.getProperties()) {
if ((configuration.getUsedProperties().size() > 0 && configuration.getUsedProperties().contains(property.getName())) || !configuration.getIgnoredProperties().contains(property.getName())) {
// try to get the field to use for this property from configuration
String fieldName = configuration.getFieldNameFor(property.getType());
Object fieldValue;
if (fieldName != null) {
fieldValue = property.getValue(property.getType());
} else {
fieldName = property.getName();
if (Type.BINARY.tag() == property.getType().tag()) {
fieldValue = extractTextValues(property, state);
} else if (property.isArray()) {
fieldValue = property.getValue(Type.STRINGS);
} else {
fieldValue = property.getValue(Type.STRING);
}
}
// add property field
inputDocument.addField(fieldName, fieldValue);
Object sortValue;
if (fieldValue instanceof Iterable) {
Iterable values = (Iterable) fieldValue;
StringBuilder builder = new StringBuilder();
String stringValue = null;
for (Object value : values) {
builder.append(value);
if (builder.length() > 1024) {
stringValue = builder.substring(0, 1024);
break;
}
}
if (stringValue == null) {
stringValue = builder.toString();
}
sortValue = stringValue;
} else {
if (fieldValue.toString().length() > 1024) {
sortValue = fieldValue.toString().substring(0, 1024);
} else {
sortValue = fieldValue;
}
}
// add sort field
inputDocument.addField(getSortingField(property.getType().tag(), property.getName()), sortValue);
}
}
return inputDocument;
}
Aggregations