Skip to content

Commit

Permalink
parsed doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pgomulka committed Jul 10, 2024
1 parent a2f954d commit 1391c74
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,15 @@ public Map<String, Object> map() throws IOException {
}

@Override
public long normalisedBytesParsed() {
public long raiNormalisedBytes() {
return mapCounter;
}

@Override
public long rasNormalisedBytes() {
return 0;
}

@Override
public void setNormalisedBytesParsedOn(IndexRequest indexRequest) {
indexRequest.setNormalisedBytesParsed(mapCounter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ public IndexResult index(Index index) throws IOException {
DocumentSizeAccumulator.EMPTY_INSTANCE
);
ParsedDocument parsedDocument = index.parsedDoc();
DocumentSizeObserver documentSizeObserver = parsedDocument.getDocumentSizeObserver();
documentParsingReporter.onIndexingCompleted(documentSizeObserver);
documentParsingReporter.onIndexingCompleted(parsedDocument);

return result;
}
Expand Down Expand Up @@ -151,8 +150,8 @@ public TestDocumentSizeReporter(String indexName) {
}

@Override
public void onIndexingCompleted(NormalisedBytesWrapper documentSizeObserver) {
COUNTER.addAndGet(documentSizeObserver.raiNormalisedBytes());
public void onIndexingCompleted(ParsedDocument parsedDocument) {
COUNTER.addAndGet(parsedDocument.raiNormalisedBytes());
assertThat(indexName, equalTo(TEST_INDEX_NAME));
}
}
Expand All @@ -177,11 +176,6 @@ public Token nextToken() throws IOException {
};
}

@Override
public long normalisedBytesParsed() {
return counter;
}

@Override
public void setNormalisedBytesParsedOn(IndexRequest indexRequest) {
indexRequest.setNormalisedBytesParsed(counter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.index.mapper.MapperService.MergeReason;
import org.elasticsearch.plugins.internal.DocumentSizeObserver;
import org.elasticsearch.plugins.internal.NormalisedBytesToReport;
import org.elasticsearch.xcontent.XContentType;

import java.util.Collections;
Expand Down Expand Up @@ -179,7 +180,7 @@ public String documentDescription() {
return "id";
}

public DocumentSizeObserver getDocumentSizeObserver() {
public NormalisedBytesToReport getDocumentSizeObserver() {
return documentSizeObserver;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* An interface to allow wrapping an XContentParser and observe the events emitted while parsing
* A default implementation returns a noop DocumentSizeObserver
*/
public interface DocumentSizeObserver extends NormalisedBytesWrapper {
public interface DocumentSizeObserver extends NormalisedBytesToReport {
/**
* a default noop implementation
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

package org.elasticsearch.plugins.internal;

import org.elasticsearch.index.mapper.ParsedDocument;

/**
* An interface to allow performing an action when parsing and indexing has been completed
*/
Expand All @@ -21,10 +23,10 @@ public interface DocumentSizeReporter {
/**
* An action to be performed upon finished indexing.
*/
default void onParsingCompleted(NormalisedBytesWrapper documentSizeObserver) {}
default void onParsingCompleted(ParsedDocument parsedDocument) {}

/**
* An action to be performed upon finished indexing.
*/
default void onIndexingCompleted(NormalisedBytesWrapper documentSizeObserver) {}
default void onIndexingCompleted(ParsedDocument parsedDocument) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package org.elasticsearch.plugins.internal;

public interface NormalisedBytesWrapper {
public interface NormalisedBytesToReport {

/**
* Returns the state gathered during parsing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,6 @@ public XContentParser wrapParser(XContentParser xContentParser) {
return xContentParser;
}


@Override
public void setNormalisedBytesParsedOn(IndexRequest indexRequest) {
parsedValueWasUsed.incrementAndGet();
Expand Down

0 comments on commit 1391c74

Please sign in to comment.