DataStoreTextWriter implements TextWriter, Closeable, PreExtractedTextProvider { @Override public ExtractedText getText(String propertyPath, Blob blob) throws IOException { String blobId = blob.getContentIdentity(); if (blobId == null) { log.debug("No id found for blob at path {}", propertyPath); return null; } blobId = stripLength(blobId); if (InMemoryDataRecord.isInstance(blobId)) { log.debug("Pre extraction is not supported for in memory records. Path {}, BlobId {}", propertyPath, blobId); return null; } ExtractedText result = null; if (getEmptyBlobs().contains(blobId)) { result = ExtractedText.EMPTY; } else if (getErrorBlobs().contains(blobId)) { result = ExtractedText.ERROR; } else { File textFile = getFile(blobId); if (textFile.exists()) { String text = Files.toString(textFile, Charsets.UTF_8); result = new ExtractedText(ExtractionResult.SUCCESS, text); } } if (log.isDebugEnabled()){ String extractionResult = result != null ? result.getExtractionResult().toString() : null; log.debug("Extraction result for [{}] at path [{}] is [{}]", blobId, propertyPath, extractionResult); } return result; } DataStoreTextWriter(File directory, boolean readOnlyMode); @Override ExtractedText getText(String propertyPath, Blob blob); @Override void write(@NotNull String blobId,@NotNull String text); @Override synchronized void markEmpty(String blobId); @Override synchronized void markError(String blobId); @Override synchronized boolean isProcessed(String blobId); @Override synchronized void close(); @Override String toString();  }
@Test public void inMemoryRecord() throws Exception{ File fdsDir = temporaryFolder.newFolder(); FileDataStore fds = DataStoreUtils.createFDS(fdsDir, 10000); DataStoreBlobStore dbs = new DataStoreBlobStore(fds); ByteArrayInputStream is = new ByteArrayInputStream("".getBytes()); String blobId = dbs.writeBlob(is); File writerDir = temporaryFolder.newFolder(); PreExtractedTextProvider textProvider = new DataStoreTextWriter(writerDir, true); assertNull(textProvider.getText("/content", new BlobStoreBlob(dbs, blobId))); }