congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
IndexableField.numericValue
Code IndexAdd Tabnine to your IDE (free)

How to use
numericValue
method
in
org.apache.lucene.index.IndexableField

Best Java code snippets using org.apache.lucene.index.IndexableField.numericValue (Showing top 20 results out of 495)

origin: neo4j/neo4j

private Object getFieldValue( IndexableField field )
{
  Number numericFieldValue = field.numericValue();
  return numericFieldValue != null ? numericFieldValue : field.stringValue();
}
origin: oracle/opengrok

  private int readObjectVersion(Document doc) {
    IndexableField objver = doc.getField(QueryBuilder.OBJVER);
    return objver == null ? 1 : objver.numericValue().intValue();
  }
}
origin: apache/nifi

private long getByteOffset(final Document d, final RecordReader reader) {
  final IndexableField blockField = d.getField(FieldNames.BLOCK_INDEX);
  if ( blockField != null ) {
    final int blockIndex = blockField.numericValue().intValue();
    final TocReader tocReader = reader.getTocReader();
    return tocReader.getBlockOffset(blockIndex);
  }
  return d.getField(FieldNames.STORAGE_FILE_OFFSET).numericValue().longValue();
}
origin: apache/nifi

  @Override
  public int compare(final Document o1, final Document o2) {
    final String filename1 = o1.get(FieldNames.STORAGE_FILENAME);
    final String filename2 = o2.get(FieldNames.STORAGE_FILENAME);
    final int filenameComp = filename1.compareTo(filename2);
    if (filenameComp != 0) {
      return filenameComp;
    }
    final IndexableField fileOffset1 = o1.getField(FieldNames.BLOCK_INDEX);
    final IndexableField fileOffset2 = o1.getField(FieldNames.BLOCK_INDEX);
    if ( fileOffset1 != null && fileOffset2 != null ) {
      final int blockIndexResult = Long.compare(fileOffset1.numericValue().longValue(), fileOffset2.numericValue().longValue());
      if ( blockIndexResult != 0 ) {
        return blockIndexResult;
      }
      final long eventId1 = o1.getField(SearchableFields.Identifier.getSearchableFieldName()).numericValue().longValue();
      final long eventId2 = o2.getField(SearchableFields.Identifier.getSearchableFieldName()).numericValue().longValue();
      return Long.compare(eventId1, eventId2);
    }
    final long offset1 = o1.getField(FieldNames.STORAGE_FILE_OFFSET).numericValue().longValue();
    final long offset2 = o2.getField(FieldNames.STORAGE_FILE_OFFSET).numericValue().longValue();
    return Long.compare(offset1, offset2);
  }
});
origin: apache/geode

 private Collection<Object> getResultCollection(IndexableField[] fieldsInDoc, boolean isNumeric) {
  Collection<Object> results = new LinkedHashSet();
  for (IndexableField field : fieldsInDoc) {
   if (isNumeric) {
    results.add((Object) field.numericValue());
   } else {
    results.add(field.stringValue());
   }
  }
  return results;
 }
}
origin: apache/geode

 private Collection<Object> getResultCollection(IndexableField[] fieldsInDoc, boolean isNumeric) {
  Collection<Object> results = new LinkedHashSet();
  for (IndexableField field : fieldsInDoc) {
   if (isNumeric) {
    results.add((Object) field.numericValue());
   } else {
    results.add(field.stringValue());
   }
  }
  return results;
 }
}
origin: apache/nifi

.map(doc -> doc.getField(SearchableFields.Identifier.getSearchableFieldName()).numericValue().longValue())
.collect(Collectors.toList());
origin: apache/nifi

private ProvenanceEventRecord getRecord(final Document d, final RecordReader reader) throws IOException {
  final IndexableField blockField = d.getField(FieldNames.BLOCK_INDEX);
  if ( blockField == null ) {
    reader.skipTo(getByteOffset(d, reader));
  } else {
    reader.skipToBlock(blockField.numericValue().intValue());
  }
  StandardProvenanceEventRecord record;
  while ( (record = reader.nextRecord()) != null) {
    final IndexableField idField = d.getField(SearchableFields.Identifier.getSearchableFieldName());
    if ( idField == null || idField.numericValue().longValue() == record.getEventId() ) {
      break;
    }
  }
  if (record == null) {
    logger.warn("Failed to read Provenance Event for '" + d + "'. The event file may be missing or corrupted");
  }
  return record;
}
origin: apache/nifi

final long eventId = doc.getDocument().getField(SearchableFields.Identifier.getSearchableFieldName()).numericValue().longValue();
if (eventId < minId) {
  minId = eventId;
origin: apache/nifi

long getMaxEventId(final String partitionName) {
  final List<File> allDirectories = getDirectoryManager().getDirectories(0L, Long.MAX_VALUE, partitionName);
  if (allDirectories.isEmpty()) {
    return -1L;
  }
  Collections.sort(allDirectories, DirectoryUtils.NEWEST_INDEX_FIRST);
  for (final File directory : allDirectories) {
    final EventIndexSearcher searcher;
    try {
      searcher = indexManager.borrowIndexSearcher(directory);
    } catch (final IOException ioe) {
      logger.warn("Unable to read from Index Directory {}. Will assume that the index is incomplete and not consider this index when determining max event ID", directory);
      continue;
    }
    try {
      final IndexReader reader = searcher.getIndexSearcher().getIndexReader();
      final int maxDocId = reader.maxDoc() - 1;
      final Document document = reader.document(maxDocId);
      final long eventId = document.getField(SearchableFields.Identifier.getSearchableFieldName()).numericValue().longValue();
      logger.info("Determined that Max Event ID indexed for Partition {} is approximately {} based on index {}", partitionName, eventId, directory);
      return eventId;
    } catch (final IOException ioe) {
      logger.warn("Unable to search Index Directory {}. Will assume that the index is incomplete and not consider this index when determining max event ID", directory, ioe);
    } finally {
      indexManager.returnIndexSearcher(searcher);
    }
  }
  return -1L;
}
origin: neo4j/neo4j

@Test
void shouldBuildDocumentRepresentingNumberProperty()
{
  // given
  Document document = documentRepresentingProperties( (long) 123, 12 );
  // then
  assertEquals( "123", document.get( NODE_ID_KEY ) );
  assertEquals( 12.0, document.getField( Number.key( 0 ) ).numericValue().doubleValue(), 0.001 );
}
origin: org.apache.lucene/lucene-core

final String string;
Number number = field.numericValue();
if (number != null) {
 if (number instanceof Byte || number instanceof Short || number instanceof Integer) {
origin: apache/geode

@Test
public void testIgnoreMissing() {
 String[] fields = new String[] {"s", "i", "s2", "o"};
 PdxLuceneSerializer mapper = new PdxLuceneSerializer();
 PdxInstance pdxInstance = mock(PdxInstance.class);
 when(pdxInstance.hasField("s")).thenReturn(true);
 when(pdxInstance.hasField("i")).thenReturn(true);
 when(pdxInstance.hasField("o")).thenReturn(true);
 when(pdxInstance.hasField("o2")).thenReturn(true);
 when(pdxInstance.getField("s")).thenReturn("a");
 when(pdxInstance.getField("i")).thenReturn(5);
 when(pdxInstance.getField("o")).thenReturn(new Object());
 when(pdxInstance.getField("o2")).thenReturn(new Object());
 Document doc = invokeSerializer(mapper, pdxInstance, fields);
 assertEquals(2, doc.getFields().size());
 assertEquals("a", doc.getField("s").stringValue());
 assertEquals(5, doc.getField("i").numericValue());
}
origin: apache/geode

@Test
public void testWriteFields() {
 String[] fields = new String[] {"s", "i"};
 PdxLuceneSerializer mapper = new PdxLuceneSerializer();
 PdxInstance pdxInstance = mock(PdxInstance.class);
 when(pdxInstance.hasField("s")).thenReturn(true);
 when(pdxInstance.hasField("i")).thenReturn(true);
 when(pdxInstance.getField("s")).thenReturn("a");
 when(pdxInstance.getField("i")).thenReturn(5);
 Document doc = invokeSerializer(mapper, pdxInstance, fields);
 assertEquals(2, doc.getFields().size());
 assertEquals("a", doc.getField("s").stringValue());
 assertEquals(5, doc.getField("i").numericValue());
}
origin: org.apache.lucene/lucene-core

 fp.docValuesWriter = new NumericDocValuesWriter(fp.fieldInfo, bytesUsed);
if (field.numericValue() == null) {
 throw new IllegalArgumentException("field=\"" + fp.fieldInfo.name + "\": null value not allowed");
((NumericDocValuesWriter) fp.docValuesWriter).addValue(docID, field.numericValue().longValue());
break;
 fp.docValuesWriter = new SortedNumericDocValuesWriter(fp.fieldInfo, bytesUsed);
((SortedNumericDocValuesWriter) fp.docValuesWriter).addValue(docID, field.numericValue().longValue());
break;
origin: apache/nifi

final long byteOffset = doc.getField(FieldNames.STORAGE_FILE_OFFSET).numericValue().longValue();
origin: apache/geode

@Test
public void shouldIndexPrimitiveNumberIfRequested() {
 HeterogeneousLuceneSerializer mapper = new HeterogeneousLuceneSerializer();
 Document doc = SerializerTestHelper.invokeSerializer(mapper, 53,
   new String[] {LuceneService.REGION_VALUE_FIELD});
 assertEquals(1, doc.getFields().size());
 assertEquals(53, doc.getField(LuceneService.REGION_VALUE_FIELD).numericValue());
}
origin: apache/geode

@Test
public void shouldParseRegionValueFieldForInteger() {
 String[] fields = new String[] {"name", "contacts.name", "contacts.email", "contacts.revenue",
   "contacts.address", "contacts.homepage.id", "contacts.homepage.title",
   "contacts.homepage.content", LuceneService.REGION_VALUE_FIELD};
 FlatFormatSerializer serializer = new FlatFormatSerializer();
 Integer integer = 15;
 Document doc1 = SerializerTestHelper.invokeSerializer(serializer, integer, fields);
 assertEquals(1, doc1.getFields().size());
 assertEquals(15, doc1.getField(LuceneService.REGION_VALUE_FIELD).numericValue());
}
origin: apache/geode

@Test
public void testAllFields() {
 String[] allFields = new String[] {"s", "i", "l", "d", "f", "s2"};
 ReflectionLuceneSerializer mapper1 = new ReflectionLuceneSerializer(Type1.class, allFields);
 ReflectionLuceneSerializer mapper2 = new ReflectionLuceneSerializer(Type2.class, allFields);
 Type1 type1 = new Type1("a", 1, 2L, 3.0, 4.0f);
 Type2 type2 = new Type2("a", 1, 2L, 3.0, 4.0f, "b");
 Document doc1 = invokeSerializer(mapper1, type1, allFields);
 assertEquals(5, doc1.getFields().size());
 assertEquals("a", doc1.getField("s").stringValue());
 assertEquals(1, doc1.getField("i").numericValue());
 assertEquals(2L, doc1.getField("l").numericValue());
 assertEquals(3.0, doc1.getField("d").numericValue());
 assertEquals(4.0f, doc1.getField("f").numericValue());
 Document doc2 = invokeSerializer(mapper2, type2, allFields);
 assertEquals(6, doc2.getFields().size());
 assertEquals("a", doc2.getField("s").stringValue());
 assertEquals("b", doc2.getField("s2").stringValue());
 assertEquals(1, doc2.getField("i").numericValue());
 assertEquals(2L, doc2.getField("l").numericValue());
 assertEquals(3.0, doc2.getField("d").numericValue());
 assertEquals(4.0f, doc2.getField("f").numericValue());
}
origin: apache/geode

assertEquals(1, doc1.getField("i").numericValue());
assertEquals(2L, doc1.getField("l").numericValue());
assertEquals(3.0, doc1.getField("d").numericValue());
assertEquals(4.0f, doc1.getField("f").numericValue());
assertEquals("a", doc2.getField("s").stringValue());
assertEquals("b", doc2.getField("s2").stringValue());
assertEquals(1, doc2.getField("i").numericValue());
assertEquals(2L, doc2.getField("l").numericValue());
assertEquals(3.0, doc2.getField("d").numericValue());
assertEquals(4.0f, doc2.getField("f").numericValue());
assertEquals(5, doc3.getField("i").numericValue());
org.apache.lucene.indexIndexableFieldnumericValue

Javadoc

Non-null if this field has a numeric value

Popular methods of IndexableField

  • stringValue
    Non-null if this field has a string value
  • name
    Field name
  • binaryValue
    Non-null if this field has a binary value
  • fieldType
    IndexableFieldType describing the properties of this field.
  • tokenStream
    Creates the TokenStream used for indexing this field. If appropriate, implementations should use the
  • readerValue
    Non-null if this field has a Reader value
  • boost
    Returns the field's index-time boost. Only fields can have an index-time boost, if you want to simul

Popular in Java

  • Making http post requests using okhttp
  • getResourceAsStream (ClassLoader)
  • getSharedPreferences (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JOptionPane (javax.swing)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now