-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Use optimized text in match_only_text fields #129371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
bc11bdf
1b2d6ef
64026c2
c0ec26a
6da03eb
ba11710
ab07c34
203525c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.common.text; | ||
|
|
||
| import org.elasticsearch.xcontent.XContentString; | ||
|
|
||
| import java.io.Reader; | ||
| import java.nio.ByteBuffer; | ||
| import java.nio.CharBuffer; | ||
| import java.nio.charset.CharsetDecoder; | ||
| import java.nio.charset.StandardCharsets; | ||
|
|
||
| /** | ||
| * Reader that decodes UTF-8 formatted bytes into chars. | ||
| */ | ||
| public class UTF8DecodingReader extends Reader { | ||
|
||
| private CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder(); | ||
| private ByteBuffer bytes; | ||
|
|
||
| public UTF8DecodingReader(ByteBuffer bytes) { | ||
| this.bytes = bytes; | ||
| } | ||
|
|
||
| public UTF8DecodingReader(XContentString.UTF8Bytes utf8bytes) { | ||
| this.bytes = ByteBuffer.wrap(utf8bytes.bytes(), utf8bytes.offset(), utf8bytes.length()); | ||
| } | ||
|
|
||
| @Override | ||
| public int read(char[] cbuf, int off, int len) { | ||
| return read(CharBuffer.wrap(cbuf, off, len)); | ||
| } | ||
|
|
||
| @Override | ||
| public int read(CharBuffer cbuf) { | ||
| if (bytes.hasRemaining() == false) { | ||
| return -1; | ||
| } | ||
|
|
||
| int startPos = cbuf.position(); | ||
| decoder.decode(bytes, cbuf, true); | ||
| return cbuf.position() - startPos; | ||
| } | ||
|
|
||
| @Override | ||
| public void close() {} | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.