//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Object getProperty(String key) throws org.neo4j.graphdb.NotFoundException public override object GetProperty(string key) { if (null == key) { throw new System.ArgumentException("(null) property key is not allowed"); } KernelTransaction transaction = SafeAcquireTransaction(); int propertyKey = transaction.TokenRead().propertyKey(key); if (propertyKey == [email protected]_Fields.NO_TOKEN) { throw new NotFoundException(format("No such property, '%s'.", key)); } NodeCursor nodes = transaction.AmbientNodeCursor(); PropertyCursor properties = transaction.AmbientPropertyCursor(); SingleNode(transaction, nodes); nodes.Properties(properties); while (properties.Next()) { if (propertyKey == properties.PropertyKey()) { Value value = properties.PropertyValue(); if (value == Values.NO_VALUE) { throw new NotFoundException(format("No such property, '%s'.", key)); } return(value.AsObjectCopy()); } } throw new NotFoundException(format("No such property, '%s'.", key)); }
public override object GetProperty(string key, object defaultValue) { if (null == key) { throw new System.ArgumentException("(null) property key is not allowed"); } KernelTransaction transaction = _spi.kernelTransaction(); RelationshipScanCursor relationships = transaction.AmbientRelationshipCursor(); PropertyCursor properties = transaction.AmbientPropertyCursor(); int propertyKey = transaction.TokenRead().propertyKey(key); if (propertyKey == [email protected]_Fields.NO_TOKEN) { return(defaultValue); } SingleRelationship(transaction, relationships); relationships.Properties(properties); while (properties.Next()) { if (propertyKey == properties.PropertyKey()) { Value value = properties.PropertyValue(); return(value == Values.NO_VALUE ? defaultValue : value.AsObjectCopy()); } } return(defaultValue); }
public override IDictionary <string, object> GetProperties(params string[] keys) { Objects.requireNonNull(keys, "Properties keys should be not null array."); if (keys.Length == 0) { return(Collections.emptyMap()); } KernelTransaction transaction = SafeAcquireTransaction(); int itemsToReturn = keys.Length; IDictionary <string, object> properties = new Dictionary <string, object>(itemsToReturn); TokenRead token = transaction.TokenRead(); //Find ids, note we are betting on that the number of keys //is small enough not to use a set here. int[] propertyIds = new int[itemsToReturn]; for (int i = 0; i < itemsToReturn; i++) { string key = keys[i]; if (string.ReferenceEquals(key, null)) { throw new System.NullReferenceException(string.Format("Key {0:D} was null", i)); } propertyIds[i] = token.PropertyKey(key); } NodeCursor nodes = transaction.AmbientNodeCursor(); PropertyCursor propertyCursor = transaction.AmbientPropertyCursor(); SingleNode(transaction, nodes); nodes.Properties(propertyCursor); int propertiesToFind = itemsToReturn; while (propertiesToFind > 0 && propertyCursor.Next()) { //Do a linear check if this is a property we are interested in. int currentKey = propertyCursor.PropertyKey(); for (int i = 0; i < itemsToReturn; i++) { if (propertyIds[i] == currentKey) { properties[keys[i]] = propertyCursor.PropertyValue().asObjectCopy(); propertiesToFind--; break; } } } return(properties); }
private Value[] GetValueTuple(NodeCursor node, PropertyCursor propertyCursor, int changedPropertyKeyId, Value changedValue, int[] indexPropertyIds, MutableIntObjectMap <Value> materializedValues) { Value[] values = new Value[indexPropertyIds.Length]; int missing = 0; // First get whatever values we already have on the stack, like the value change that provoked this update in the first place // and already loaded values that we can get from the map of materialized values. for (int k = 0; k < indexPropertyIds.Length; k++) { values[k] = indexPropertyIds[k] == changedPropertyKeyId ? changedValue : materializedValues.get(indexPropertyIds[k]); if (values[k] == null) { missing++; } } // If we couldn't get all values that we wanted we need to load from the node. While we're loading values // we'll place those values in the map so that other index updates from this change can just used them. if (missing > 0) { node.Properties(propertyCursor); while (missing > 0 && propertyCursor.Next()) { int k = ArrayUtils.IndexOf(indexPropertyIds, propertyCursor.PropertyKey()); if (k >= 0 && values[k] == null) { int propertyKeyId = indexPropertyIds[k]; bool thisIsTheChangedProperty = propertyKeyId == changedPropertyKeyId; values[k] = thisIsTheChangedProperty ? changedValue : propertyCursor.PropertyValue(); if (!thisIsTheChangedProperty) { materializedValues.put(propertyKeyId, values[k]); } missing--; } } } return(values); }
public virtual bool AcceptsValueAt(PropertyCursor property) { return(AcceptsValue(property.PropertyValue())); }