Пример #1
0
 /// <summary>
 /// OBS this implementation can only provide values for properties of type <seealso cref="string"/>.
 /// Other property types will still be counted as distinct, but {@code client} won't receive <seealso cref="Value"/>
 /// instances for those. </summary>
 /// <param name="client"> <seealso cref="IndexProgressor.NodeValueClient"/> to get initialized with this progression. </param>
 /// <param name="propertyAccessor"> <seealso cref="NodePropertyAccessor"/> for reading property values. </param>
 /// <param name="needsValues"> whether or not to load string values. </param>
 public override void DistinctValues(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient client, NodePropertyAccessor propertyAccessor, bool needsValues)
 {
     try
     {
         IndexQuery[]            noQueries       = new IndexQuery[0];
         BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(client, _descriptor.schema().PropertyIds);
         Fields fields = MultiFields.getFields(IndexSearcher.IndexReader);
         foreach (ValueEncoding valueEncoding in ValueEncoding.values())
         {
             Terms terms = fields.terms(valueEncoding.key());
             if (terms != null)
             {
                 System.Func <BytesRef, Value> valueMaterializer = valueEncoding == ValueEncoding.String && needsValues ? term => Values.stringValue(term.utf8ToString()) : term => null;
                 TermsEnum termsIterator = terms.GetEnumerator();
                 if (valueEncoding == ValueEncoding.Number)
                 {
                     termsIterator = NumericUtils.filterPrefixCodedLongs(termsIterator);
                 }
                 multiProgressor.Initialize(_descriptor, new LuceneDistinctValuesProgressor(termsIterator, client, valueMaterializer), noQueries, IndexOrder.NONE, needsValues);
             }
         }
         client.Initialize(_descriptor, multiProgressor, noQueries, IndexOrder.NONE, needsValues);
     }
     catch (IOException e)
     {
         throw new UncheckedIOException(e);
     }
 }
Пример #2
0
            internal virtual Field GetFieldWithValue(int propertyNumber, Value value)
            {
                ValueEncoding encoding      = ValueEncoding.forValue(value);
                int           reuseId       = propertyNumber * ValueEncoding.values().length + encoding.ordinal();
                string        key           = encoding.key(propertyNumber);
                Field         reusableField = ReusableValueFields[reuseId];

                if (reusableField == null)
                {
                    reusableField = encoding.encodeField(key, value);
                    ReusableValueFields[reuseId] = reusableField;
                }
                else
                {
                    encoding.setFieldValue(value, reusableField);
                }
                return(reusableField);
            }