From d53d056aaaa8b66abd7286483406c17f00dee6ee Mon Sep 17 00:00:00 2001
From: David Kyle
Date: Wed, 8 May 2024 11:03:57 +0100
Subject: [PATCH 01/25] [ML] Fix startOffset must be non-negative error in
XLMRoBERTa tokenizer (#107891)
Fixes an error is when the normalisation step produces text that is longer
than the input text and an offset needs to be added to map back to the
original.
---
docs/changelog/107891.yaml | 6 +
.../PrecompiledCharMapNormalizer.java | 15 +-
.../PrecompiledCharMapNormalizerTests.java | 37 +
.../nlp/tokenizers/XLMRobertaTestVocab.java | 2179 +++++++++++++++++
.../tokenizers/XLMRobertaTokenizerTests.java | 24 +
.../xlm_roberta_test_vocabulary.json | 2172 ++++++++++++++++
6 files changed, 4431 insertions(+), 2 deletions(-)
create mode 100644 docs/changelog/107891.yaml
create mode 100644 x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/XLMRobertaTestVocab.java
create mode 100644 x-pack/plugin/ml/src/test/resources/org/elasticsearch/xpack/ml/inference/tokenizers/xlm_roberta_test_vocabulary.json
diff --git a/docs/changelog/107891.yaml b/docs/changelog/107891.yaml
new file mode 100644
index 0000000000000..deb3fbd2258ff
--- /dev/null
+++ b/docs/changelog/107891.yaml
@@ -0,0 +1,6 @@
+pr: 107891
+summary: Fix `startOffset` must be non-negative error in XLMRoBERTa tokenizer
+area: Machine Learning
+type: bug
+issues:
+ - 104626
diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/PrecompiledCharMapNormalizer.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/PrecompiledCharMapNormalizer.java
index 93dc8077196d7..bbe5bea691c35 100644
--- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/PrecompiledCharMapNormalizer.java
+++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/PrecompiledCharMapNormalizer.java
@@ -190,9 +190,20 @@ Reader normalize(CharSequence str) {
BytesRef subStr = maybeSubStr.get();
int numChars = UnicodeUtil.UTF8toUTF16(subStr.bytes, subStr.offset, subStr.length, reusableCharDecodeBuffer);
normalizedCharPos += numChars;
- if (numChars != end - startIter) {
- addOffCorrectMap(normalizedCharPos, getLastCumulativeDiff() + end - startIter - numChars);
+ int charDelta = numChars - (end - startIter); // output length - input length
+ if (charDelta < 0) {
+ // normalised form is shorter
+ int lastDiff = getLastCumulativeDiff();
+ addOffCorrectMap(normalizedCharPos, lastDiff + charDelta);
+ } else if (charDelta > 0) {
+ // inserted chars, add the offset in the output stream
+ int lastDiff = getLastCumulativeDiff();
+ int startOffset = normalizedCharPos - charDelta;
+ for (int i = 1; i <= charDelta; i++) {
+ addOffCorrectMap(startOffset + i, lastDiff - i);
+ }
}
+
strBuilder.append(reusableCharDecodeBuffer, 0, numChars);
bytePos += byteLen;
continue;
diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/PrecompiledCharMapNormalizerTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/PrecompiledCharMapNormalizerTests.java
index eef9902d35e59..20b68b2b6e750 100644
--- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/PrecompiledCharMapNormalizerTests.java
+++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/PrecompiledCharMapNormalizerTests.java
@@ -62,6 +62,28 @@ public void testCharThatNormalizesToLongText() throws IOException {
assertNormalization("ﷺ", parsed, "صلى الله عليه وسلم");
}
+ public void testOutOfBounds() throws IOException {
+ @SuppressWarnings("checkstyle:linelength")
+ String[] inputs = new String[] {
+ "ﷺ",
+ "Građevne strukture Mesa Verde dokaz su akumuliranog znanja i vještina koje su se stoljećima prenosile generacijama civilizacije Anasazi. Vrhunce svojih dosega ostvarili su u 12. i 13. stoljeću, kada su sagrađene danas najpoznatije građevine na liticama. Zidali su obrađenim pješčenjakom, tvrđim kamenom oblikovanim do veličine štruce kruha. Kao žbuku između ciglā stavljali su glinu razmočenu vodom. Tim su materijalom gradili prostorije veličine do 6 četvornih metara. U potkrovljima su skladištili žitarice i druge plodine, dok su kive - ceremonijalne prostorije - gradili ispred soba, ali ukopane u zemlju, nešto poput današnjih podruma. Kiva je bila vrhunski dizajnirana prostorija okruglog oblika s prostorom za vatru zimi te s dovodom hladnog zraka za klimatizaciju ljeti. U zidane konstrukcije stavljali su i lokalno posječena stabla, što današnjim arheolozima pomaže u preciznom datiranju nastanka pojedine građevine metodom dendrokronologije. Ta stabla pridonose i teoriji o mogućem konačnom slomu ondašnjeg društva. Nakon što su, tijekom nekoliko stoljeća, šume do kraja srušene, a njihova obnova zbog sušne klime traje i po 200 godina, nije proteklo puno vremena do konačnog urušavanja civilizacije, koja se, na svojem vrhuncu osjećala nepobjedivom. 90 % sagrađenih naseobina ispod stijena ima do deset prostorija. ⅓ od ukupnog broja sagrađenih kuća ima jednu ili dvije kamene prostorije",
+ "Histoarysk wie in acre in stik lân dat 40 roeden (oftewol 1 furlong of ⅛ myl of 660 foet) lang wie, en 4 roeden (of 66 foet) breed. Men is fan tinken dat dat likernôch de grûnmjitte wie dy't men mei in jok oksen yn ien dei beploegje koe.",
+ "創業当初の「太平洋化学工業社」から1959年太平洋化学工業株式会社へ、1987年には太平洋化学㈱に社名を変更。 1990年以降、海外拠点を増やし本格的な国際進出を始動。 創業者がつくりあげた化粧品会社を世界企業へと成長させるべく2002年3月英文社名AMOREPACIFICに改めた。",
+ "امام محمد بن جرير رح جن جي ولادت باسعادت 224 هجري طبرستان جي شهر آمل ۾ ٿي ، هي اهو دور هو جڏهن سلطنت عباسيه جو عروج هو ۽ سندس سڄي جمار عهد خلافت عباسيه ۾ گذري ، طبرستان هن وقت پڻ سياست ۽ مذهبي حلقن جنهن ۾ معتزلي ، خوارج ، باطني جو گهوارو هو ۽ ابن جرير جي ٻيهر طبرستان ورڻ وقت روافض جو عروج ٿي ويو هو ابن جرير رح جو نالو ، محمد بن جرير بن يزيد بن ڪثير بن غالب الطبري الآملي هو سندس کوڙ سار لقب آهن جنهن ۾ الامام ، المجتهد ، المفسر ، المورخ، المحدث ، الحافظ ، العلامه ، اللغوي ، المقريءَ ۽ سندس اهي سڀئي القاب سندس بزرگيت تي دلالت ڪن ٿيون . سندس ڪنيت (ابن جرير) هئي ۽ طبرستان ۽ آمل ڏينهن نسبت هجڻ ڪري پاڻ الطبري ۽ الآملي سڏرائيندا هئا. ابن جرير رح هڪ آسودي گهراني ۾ اک کولي ، سندس پيءُ هڪ ڏينهن خواب ڏٺائين ته ابن جرير رح نبي ڪريم ﷺ جي ٻنهي هٿن جي وچ ۾ آهن ۽ نبي ڪريمﷺ جي هٿن مبارڪن ۾ پٿريون آهن جنهن کي ابن جرير رح کڻي اڇلائي رهيا آهن ، عالمن کان جڏهن هن جي تعبير پڇا ڪيائين ته انهن چيو ته اوهان جو پٽ وڏو ٿي ڪري دين جي خدمت سرانجام ڏيندو ۽ اهو خواب ابن جرير جو علم حاصل ڪرڻ جو سبب بڻيو. ابن جرير رح ستن سالن ۾ قرآن مجيد حفظ ڪيائين اٺن سالم ۾ امامت جهڙو فريضو انجام ڏنائين نون سالن ۾ حديث لکڻ شروع ڪيائين ۽ جڏهن سورهن سالن جا ٿيا ته اماماحمد بن حنبل رح جي زيارت جو شوق ۾ بغداد ڏانهن سفر ڪرڻ شروع ڪيائين ، سندس سڄو خرچ ۽ بار پيءُ کڻدو هو جڏهن سندس والد جو انتقال ٿيو ته ورثي ۾ زمين جو ٽڪڙو مليس جنهن جي آمدني مان ابن جرير رح پنهنجو گذر سفر فرمائيندا هئا .",
+ "۱۔ ھن شق جي مطابق قادياني گروھ يا لاھوري گروھ جي ڪنھن رڪن کي جيڪو پاڻ کي 'احمدي' يا ڪنھن ٻي نالي سان پڪاري جي لاءِ ممنوع قرار ڏنو ويو آھي تہ ھو (الف) ڳالھائي، لکي يا ڪنھن ٻي طريقي سان ڪنھن خليفي يا آنحضور ﷺ جي ڪنھن صحابي کان علاوہڍه ڪنھن کي امير المومنين يا خليفہ المومنين يا خليفہ المسلمين يا صحابی يا رضي الله عنه چئي۔ (ب) آنحضور ﷺ جي گھروارين کان علاوه ڪنھن کي ام المومنين چئي۔ (ج) آنحضور ﷺ جي خاندان جي اھل بيت کان علاوہڍه ڪنھن کي اھل بيت چئي۔ (د) پنھنجي عبادت گاھ کي مسجد چئي۔",
+ "سعد بن فضالہ جو شام کے جہاد میں سہیل کے ساتھ تھے بیان کرتے ہیں کہ ایک مرتبہ سہیل نے کہا کہ میں نے رسول اللہ ﷺ سے سنا ہے کہ خدا کی راہ میں ایک گھڑی صرف کرنا گھر کے تمام عمر کے اعمال سے بہتر ہے، اس لیے اب میں شام کا جہاد چھوڑ کر گھر نہ جاؤں گا اور یہیں جان دونگا، اس عہد پر اس سختی سے قائم رہے کہ طاعون عمواس میں بھی نہ ہٹے اور 18ھ میں اسی وبا میں شام کے غربت کدہ میں جان دی۔",
+ "دعوت اسلام کے آغاز یعنی آنحضرتﷺ کے ارقم کے گھر میں تشریف لانے سے پہلے مشرف باسلام ہوئے،پھر ہجرت کے زمانہ میں مکہ سے مدینہ گئے آنحضرتﷺ نے غربت کی اجنبیت دورکرنے کے لیے ان میں اورابوعبیدہ بن تیہاں میں مواخاۃ کرادی۔",
+ "ضرار اپنے قبیلہ کے اصحاب ثروت میں تھے، عرب میں سب سے بڑی دولت اونٹ کے گلے تھے، ضرار کے پاس ہزار اونٹوں کا گلہ تھا، اسلام کے جذب وولولے میں تمام مال ودولت چھوڑ کر خالی ہاتھ آستانِ نبوی پر پہنچے قبول اسلام کے بعد آنحضرتﷺ نے بنی صید اوربنی ہذیل کی طرف بھیجا۔",
+ "(2) اگر زلیخا کو ملامت کرنے والی عورتیں آپ ﷺ کی جبین انور دیکھ پاتیں تو ہاتھوں کے بجائے اپنے دل کاٹنے کو ترجیح دیتیں۔صحیح بخاری میں ہے، حضرت عطاء بن یسار ؓہُنے حضرت عبداللہ بن عمرو ؓسے سیّدِ عالمﷺ کے وہ اوصاف دریافت کئے جو توریت میں مذکور ہیں تو انہوں نے فرمایا : ’’خدا کی قسم! حضور سیدُ المرسلینﷺ کے جو اوصاف قرآنِ کریم میں آئے ہیں انہیں میں سے بعض اوصاف توریت میں مذکور ہیں۔ اس کے بعد انہوں نے پڑھنا شروع کیا: اے نبی! ہم نے تمہیں شاہد و مُبَشِّر اور نذیر اور اُمِّیُّوں کا نگہبان بنا کر بھیجا، تم میرے بندے اور میرے رسول ہو، میں نے تمہارا نام متوکل رکھا،نہ بدخلق ہو نہ سخت مزاج، نہ بازاروں میں آواز بلند کرنے والے ہو نہ برائی سے برائی کو دفع کرنے والے بلکہ خطا کاروں کو معاف کرتے ہو اور ان پر احسان فرماتے ہو، اللہ تعالیٰ تمہیں نہ اٹھائے گا جب تک کہ تمہاری برکت سے غیر مستقیم ملت کو اس طرح راست نہ فرمادے کہ لوگ صدق و یقین کے ساتھ ’’ لَآاِلٰہَ اِلَّا اللہُ مُحَمَّدٌ رَّسُوْلُ اللہِ‘‘ پکارنے لگیں اور تمہاری بدولت اندھی آنکھیں بینا اور بہرے کان شنوا (سننے والے) اور پردوں میں لپٹے ہوئے دل کشادہ ہوجائیں۔ اور کعب احبارؓسے سرکارِ رسالت ﷺکی صفات میں توریت شریف کا یہ مضمون بھی منقول ہے کہ’’ اللہ تعالیٰ نے آپ ﷺکی صفت میں فرمایا کہ’’ میں اُنہیں ہر خوبی کے قابل کروں گا، اور ہر خُلقِ کریم عطا فرماؤں گا، اطمینانِ قلب اور وقار کو اُن کا لباس بناؤں گا اور طاعات وا حسان کو ان کا شعار کروں گا۔ تقویٰ کو ان کا ضمیر، حکمت کو ان کا راز، صدق و وفا کو اُن کی طبیعت ،عفوو کرم کو اُن کی عادت ، عدل کو ان کی سیرت، اظہارِ حق کو اُن کی شریعت، ہدایت کو اُن کا امام اور اسلام کو اُن کی ملت بناؤں گا۔ احمد اُن کا نام ہے، مخلوق کو اُن کے صدقے میں گمراہی کے بعد ہدایت اور جہالت کے بعد علم و معرفت اور گمنامی کے بعد رفعت و منزلت عطا کروں گا۔ اُنہیں کی برکت سے قلت کے بعد کثرت اور فقر کے بعد دولت اور تَفَرُّقے کے بعد محبت عنایت کروں گا، اُنہیں کی بدولت مختلف قبائل، غیر مجتمع خواہشوں اور اختلاف رکھنے والے دلوں میں اُلفت پیدا کروں گا اور اُن کی اُمت کو تمام اُمتوں سے بہتر کروں گا۔ ایک اور حدیث میں توریت سے حضور سید المرسلینﷺسے یہ اوصاف منقول ہیں ’’میرے بندے احمد مختار، ان کی جائے ولادت مکہ مکرمہ اور جائے ہجرت مدینہ طیبہ ہے،اُن کی اُمت ہر حال میں اللہ تعالٰی کی کثیر حمد کرنے والی ہے۔ مُنَزَّہٌ عَنْ شَرِیْکٍ فِیْ مَحَاسِنِہٖ",
+ "بالآخر آنحضرتﷺ کے اس عفو وکرم نے یہ معجزہ دکھایا کہ سہیل حنین کی واپسی کے وقت آپ کے ساتھ ہوگئے اورمقام جعرانہ پہنچ کر خلعتِ اسلام سے سرفراز ہوئے آنحضرت ﷺ نے ازراہ مرحمت حنین کے مالِ غنیمت میں سے سو اونٹ عطا فرمائے، گو فتح مکہ کے بعد کے مسلمانوں کا شمار مؤلفۃ القلوب میں ہے، لیکن سہیل اس زمرہ میں اس حیثیت سے ممتاز ہیں کہ اسلام کے بعد ان سے کوئی بات اسلام کے خلاف ظہور پزیر نہیں ہوئی ،حافظ ابن حجرعسقلانی لکھتے ہیں، کان محمودالا سلام من حین اسلم۔", };
+
+ PrecompiledCharMapNormalizer.Config parsed = loadTestCharMap();
+
+ for (var s : inputs) {
+ normalise(s, parsed);
+ }
+ }
+
private void assertNormalization(String input, PrecompiledCharMapNormalizer.Config config, String expected) throws IOException {
PrecompiledCharMapNormalizer normalizer = new PrecompiledCharMapNormalizer(
config.offsets(),
@@ -77,6 +99,21 @@ private void assertNormalization(String input, PrecompiledCharMapNormalizer.Conf
}
}
+ private void normalise(String input, PrecompiledCharMapNormalizer.Config config) throws IOException {
+ PrecompiledCharMapNormalizer normalizer = new PrecompiledCharMapNormalizer(
+ config.offsets(),
+ config.utf8str(),
+ new StringReader(input)
+ );
+ char[] output = new char[64];
+ int offset = 0;
+ int size = 64;
+ int read = normalizer.read(output, offset, size);
+ while (read > 0) {
+ read = normalizer.read(output, offset, size);
+ }
+ }
+
static PrecompiledCharMapNormalizer.Config loadTestCharMap() throws IOException {
return PrecompiledCharMapNormalizer.fromBase64EncodedResource(
"/org/elasticsearch/xpack/ml/inference.nlp.tokenizers/spm_precompiled_normalizer.txt"
diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/XLMRobertaTestVocab.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/XLMRobertaTestVocab.java
new file mode 100644
index 0000000000000..b0cce14c59114
--- /dev/null
+++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/XLMRobertaTestVocab.java
@@ -0,0 +1,2179 @@
+/*
+ * 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; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+package org.elasticsearch.xpack.ml.inference.nlp.tokenizers;
+
+import org.elasticsearch.xcontent.XContentParserConfiguration;
+import org.elasticsearch.xcontent.json.JsonXContent;
+import org.elasticsearch.xpack.ml.inference.nlp.Vocabulary;
+
+import java.io.IOException;
+
+/**
+ * {@link #loadMultiLingualTestVocab()} loads a vocabulary file containing
+ * a subset of the XLM RoBERTa vocabulary and scores sufficient to tokenize
+ * the strings in {@link #MULTILINUGAL_TEXTS}.
+ *
+ * {@link #EXPECTED_TOKENS} is the tokenization of {@link #MULTILINUGAL_TEXTS}
+ * using the vocabulary and scores in the test vocabulary returned by
+ * {@link #loadMultiLingualTestVocab()}. The expected tokens were produced by
+ * tokenizing {@link #MULTILINUGAL_TEXTS} with the HuggingFace transformers
+ * XLMRoBERTa tokenizer and mapping those tokens to the position of the same
+ * tokens in the test vocab.
+ */
+public class XLMRobertaTestVocab {
+
+ public static Vocabulary loadMultiLingualTestVocab() throws IOException {
+ try (
+ var parser = JsonXContent.jsonXContent.createParser(
+ XContentParserConfiguration.EMPTY,
+ XLMRobertaTokenizer.class.getResourceAsStream(
+ "/org/elasticsearch/xpack/ml/inference/tokenizers/xlm_roberta_test_vocabulary.json"
+ )
+ )
+ ) {
+ return Vocabulary.PARSER.apply(parser, null);
+ }
+ }
+
+ @SuppressWarnings("checkstyle:linelength")
+ public static String[] MULTILINUGAL_TEXTS = new String[] {
+ "Građevne strukture Mesa Verde dokaz su akumuliranog znanja i vještina koje su se stoljećima prenosile generacijama civilizacije Anasazi. Vrhunce svojih dosega ostvarili su u 12. i 13. stoljeću, kada su sagrađene danas najpoznatije građevine na liticama. Zidali su obrađenim pješčenjakom, tvrđim kamenom oblikovanim do veličine štruce kruha. Kao žbuku između ciglā stavljali su glinu razmočenu vodom. Tim su materijalom gradili prostorije veličine do 6 četvornih metara. U potkrovljima su skladištili žitarice i druge plodine, dok su kive - ceremonijalne prostorije - gradili ispred soba, ali ukopane u zemlju, nešto poput današnjih podruma. Kiva je bila vrhunski dizajnirana prostorija okruglog oblika s prostorom za vatru zimi te s dovodom hladnog zraka za klimatizaciju ljeti. U zidane konstrukcije stavljali su i lokalno posječena stabla, što današnjim arheolozima pomaže u preciznom datiranju nastanka pojedine građevine metodom dendrokronologije. Ta stabla pridonose i teoriji o mogućem konačnom slomu ondašnjeg društva. Nakon što su, tijekom nekoliko stoljeća, šume do kraja srušene, a njihova obnova zbog sušne klime traje i po 200 godina, nije proteklo puno vremena do konačnog urušavanja civilizacije, koja se, na svojem vrhuncu osjećala nepobjedivom. 90 % sagrađenih naseobina ispod stijena ima do deset prostorija. ⅓ od ukupnog broja sagrađenih kuća ima jednu ili dvije kamene prostorije",
+ "Histoarysk wie in acre in stik lân dat 40 roeden (oftewol 1 furlong of ⅛ myl of 660 foet) lang wie, en 4 roeden (of 66 foet) breed. Men is fan tinken dat dat likernôch de grûnmjitte wie dy't men mei in jok oksen yn ien dei beploegje koe.",
+ "創業当初の「太平洋化学工業社」から1959年太平洋化学工業株式会社へ、1987年には太平洋化学㈱に社名を変更。 1990年以降、海外拠点を増やし本格的な国際進出を始動。 創業者がつくりあげた化粧品会社を世界企業へと成長させるべく2002年3月英文社名AMOREPACIFICに改めた。",
+ "امام محمد بن جرير رح جن جي ولادت باسعادت 224 هجري طبرستان جي شهر آمل ۾ ٿي ، هي اهو دور هو جڏهن سلطنت عباسيه جو عروج هو ۽ سندس سڄي جمار عهد خلافت عباسيه ۾ گذري ، طبرستان هن وقت پڻ سياست ۽ مذهبي حلقن جنهن ۾ معتزلي ، خوارج ، باطني جو گهوارو هو ۽ ابن جرير جي ٻيهر طبرستان ورڻ وقت روافض جو عروج ٿي ويو هو ابن جرير رح جو نالو ، محمد بن جرير بن يزيد بن ڪثير بن غالب الطبري الآملي هو سندس کوڙ سار لقب آهن جنهن ۾ الامام ، المجتهد ، المفسر ، المورخ، المحدث ، الحافظ ، العلامه ، اللغوي ، المقريءَ ۽ سندس اهي سڀئي القاب سندس بزرگيت تي دلالت ڪن ٿيون . سندس ڪنيت (ابن جرير) هئي ۽ طبرستان ۽ آمل ڏينهن نسبت هجڻ ڪري پاڻ الطبري ۽ الآملي سڏرائيندا هئا. ابن جرير رح هڪ آسودي گهراني ۾ اک کولي ، سندس پيءُ هڪ ڏينهن خواب ڏٺائين ته ابن جرير رح نبي ڪريم ﷺ جي ٻنهي هٿن جي وچ ۾ آهن ۽ نبي ڪريمﷺ جي هٿن مبارڪن ۾ پٿريون آهن جنهن کي ابن جرير رح کڻي اڇلائي رهيا آهن ، عالمن کان جڏهن هن جي تعبير پڇا ڪيائين ته انهن چيو ته اوهان جو پٽ وڏو ٿي ڪري دين جي خدمت سرانجام ڏيندو ۽ اهو خواب ابن جرير جو علم حاصل ڪرڻ جو سبب بڻيو. ابن جرير رح ستن سالن ۾ قرآن مجيد حفظ ڪيائين اٺن سالم ۾ امامت جهڙو فريضو انجام ڏنائين نون سالن ۾ حديث لکڻ شروع ڪيائين ۽ جڏهن سورهن سالن جا ٿيا ته اماماحمد بن حنبل رح جي زيارت جو شوق ۾ بغداد ڏانهن سفر ڪرڻ شروع ڪيائين ، سندس سڄو خرچ ۽ بار پيءُ کڻدو هو جڏهن سندس والد جو انتقال ٿيو ته ورثي ۾ زمين جو ٽڪڙو مليس جنهن جي آمدني مان ابن جرير رح پنهنجو گذر سفر فرمائيندا هئا .",
+ "۱۔ ھن شق جي مطابق قادياني گروھ يا لاھوري گروھ جي ڪنھن رڪن کي جيڪو پاڻ کي 'احمدي' يا ڪنھن ٻي نالي سان پڪاري جي لاءِ ممنوع قرار ڏنو ويو آھي تہ ھو (الف) ڳالھائي، لکي يا ڪنھن ٻي طريقي سان ڪنھن خليفي يا آنحضور ﷺ جي ڪنھن صحابي کان علاوہڍه ڪنھن کي امير المومنين يا خليفہ المومنين يا خليفہ المسلمين يا صحابی يا رضي الله عنه چئي۔ (ب) آنحضور ﷺ جي گھروارين کان علاوه ڪنھن کي ام المومنين چئي۔ (ج) آنحضور ﷺ جي خاندان جي اھل بيت کان علاوہڍه ڪنھن کي اھل بيت چئي۔ (د) پنھنجي عبادت گاھ کي مسجد چئي۔",
+ "سعد بن فضالہ جو شام کے جہاد میں سہیل کے ساتھ تھے بیان کرتے ہیں کہ ایک مرتبہ سہیل نے کہا کہ میں نے رسول اللہ ﷺ سے سنا ہے کہ خدا کی راہ میں ایک گھڑی صرف کرنا گھر کے تمام عمر کے اعمال سے بہتر ہے، اس لیے اب میں شام کا جہاد چھوڑ کر گھر نہ جاؤں گا اور یہیں جان دونگا، اس عہد پر اس سختی سے قائم رہے کہ طاعون عمواس میں بھی نہ ہٹے اور 18ھ میں اسی وبا میں شام کے غربت کدہ میں جان دی۔",
+ "دعوت اسلام کے آغاز یعنی آنحضرتﷺ کے ارقم کے گھر میں تشریف لانے سے پہلے مشرف باسلام ہوئے،پھر ہجرت کے زمانہ میں مکہ سے مدینہ گئے آنحضرتﷺ نے غربت کی اجنبیت دورکرنے کے لیے ان میں اورابوعبیدہ بن تیہاں میں مواخاۃ کرادی۔",
+ "ضرار اپنے قبیلہ کے اصحاب ثروت میں تھے، عرب میں سب سے بڑی دولت اونٹ کے گلے تھے، ضرار کے پاس ہزار اونٹوں کا گلہ تھا، اسلام کے جذب وولولے میں تمام مال ودولت چھوڑ کر خالی ہاتھ آستانِ نبوی پر پہنچے قبول اسلام کے بعد آنحضرتﷺ نے بنی صید اوربنی ہذیل کی طرف بھیجا۔",
+ "(2) اگر زلیخا کو ملامت کرنے والی عورتیں آپ ﷺ کی جبین انور دیکھ پاتیں تو ہاتھوں کے بجائے اپنے دل کاٹنے کو ترجیح دیتیں۔صحیح بخاری میں ہے، حضرت عطاء بن یسار ؓہُنے حضرت عبداللہ بن عمرو ؓسے سیّدِ عالمﷺ کے وہ اوصاف دریافت کئے جو توریت میں مذکور ہیں تو انہوں نے فرمایا : ’’خدا کی قسم! حضور سیدُ المرسلینﷺ کے جو اوصاف قرآنِ کریم میں آئے ہیں انہیں میں سے بعض اوصاف توریت میں مذکور ہیں۔ اس کے بعد انہوں نے پڑھنا شروع کیا: اے نبی! ہم نے تمہیں شاہد و مُبَشِّر اور نذیر اور اُمِّیُّوں کا نگہبان بنا کر بھیجا، تم میرے بندے اور میرے رسول ہو، میں نے تمہارا نام متوکل رکھا،نہ بدخلق ہو نہ سخت مزاج، نہ بازاروں میں آواز بلند کرنے والے ہو نہ برائی سے برائی کو دفع کرنے والے بلکہ خطا کاروں کو معاف کرتے ہو اور ان پر احسان فرماتے ہو، اللہ تعالیٰ تمہیں نہ اٹھائے گا جب تک کہ تمہاری برکت سے غیر مستقیم ملت کو اس طرح راست نہ فرمادے کہ لوگ صدق و یقین کے ساتھ ’’ لَآاِلٰہَ اِلَّا اللہُ مُحَمَّدٌ رَّسُوْلُ اللہِ‘‘ پکارنے لگیں اور تمہاری بدولت اندھی آنکھیں بینا اور بہرے کان شنوا (سننے والے) اور پردوں میں لپٹے ہوئے دل کشادہ ہوجائیں۔ اور کعب احبارؓسے سرکارِ رسالت ﷺکی صفات میں توریت شریف کا یہ مضمون بھی منقول ہے کہ’’ اللہ تعالیٰ نے آپ ﷺکی صفت میں فرمایا کہ’’ میں اُنہیں ہر خوبی کے قابل کروں گا، اور ہر خُلقِ کریم عطا فرماؤں گا، اطمینانِ قلب اور وقار کو اُن کا لباس بناؤں گا اور طاعات وا حسان کو ان کا شعار کروں گا۔ تقویٰ کو ان کا ضمیر، حکمت کو ان کا راز، صدق و وفا کو اُن کی طبیعت ،عفوو کرم کو اُن کی عادت ، عدل کو ان کی سیرت، اظہارِ حق کو اُن کی شریعت، ہدایت کو اُن کا امام اور اسلام کو اُن کی ملت بناؤں گا۔ احمد اُن کا نام ہے، مخلوق کو اُن کے صدقے میں گمراہی کے بعد ہدایت اور جہالت کے بعد علم و معرفت اور گمنامی کے بعد رفعت و منزلت عطا کروں گا۔ اُنہیں کی برکت سے قلت کے بعد کثرت اور فقر کے بعد دولت اور تَفَرُّقے کے بعد محبت عنایت کروں گا، اُنہیں کی بدولت مختلف قبائل، غیر مجتمع خواہشوں اور اختلاف رکھنے والے دلوں میں اُلفت پیدا کروں گا اور اُن کی اُمت کو تمام اُمتوں سے بہتر کروں گا۔ ایک اور حدیث میں توریت سے حضور سید المرسلینﷺسے یہ اوصاف منقول ہیں ’’میرے بندے احمد مختار، ان کی جائے ولادت مکہ مکرمہ اور جائے ہجرت مدینہ طیبہ ہے،اُن کی اُمت ہر حال میں اللہ تعالٰی کی کثیر حمد کرنے والی ہے۔ مُنَزَّہٌ عَنْ شَرِیْکٍ فِیْ مَحَاسِنِہٖ",
+ "بالآخر آنحضرتﷺ کے اس عفو وکرم نے یہ معجزہ دکھایا کہ سہیل حنین کی واپسی کے وقت آپ کے ساتھ ہوگئے اورمقام جعرانہ پہنچ کر خلعتِ اسلام سے سرفراز ہوئے آنحضرت ﷺ نے ازراہ مرحمت حنین کے مالِ غنیمت میں سے سو اونٹ عطا فرمائے، گو فتح مکہ کے بعد کے مسلمانوں کا شمار مؤلفۃ القلوب میں ہے، لیکن سہیل اس زمرہ میں اس حیثیت سے ممتاز ہیں کہ اسلام کے بعد ان سے کوئی بات اسلام کے خلاف ظہور پزیر نہیں ہوئی ،حافظ ابن حجرعسقلانی لکھتے ہیں، کان محمودالا سلام من حین اسلم۔", };
+
+ public static int[][] EXPECTED_TOKENS = new int[][] {
+ {
+ 0,
+ 910,
+ 256,
+ 116,
+ 897,
+ 65,
+ 1039,
+ 830,
+ 287,
+ 993,
+ 660,
+ 770,
+ 67,
+ 619,
+ 455,
+ 802,
+ 73,
+ 785,
+ 993,
+ 990,
+ 565,
+ 666,
+ 194,
+ 1049,
+ 110,
+ 710,
+ 397,
+ 283,
+ 1073,
+ 666,
+ 276,
+ 79,
+ 486,
+ 30,
+ 959,
+ 912,
+ 577,
+ 571,
+ 658,
+ 1080,
+ 327,
+ 713,
+ 993,
+ 457,
+ 531,
+ 455,
+ 553,
+ 565,
+ 666,
+ 46,
+ 29,
+ 302,
+ 993,
+ 976,
+ 415,
+ 155,
+ 1050,
+ 956,
+ 65,
+ 441,
+ 65,
+ 888,
+ 84,
+ 511,
+ 30,
+ 547,
+ 908,
+ 993,
+ 174,
+ 350,
+ 74,
+ 454,
+ 500,
+ 139,
+ 1026,
+ 29,
+ 716,
+ 337,
+ 259,
+ 74,
+ 874,
+ 767,
+ 716,
+ 961,
+ 654,
+ 668,
+ 460,
+ 627,
+ 845,
+ 577,
+ 502,
+ 59,
+ 30,
+ 728,
+ 546,
+ 140,
+ 804,
+ 659,
+ 67,
+ 792,
+ 716,
+ 358,
+ 713,
+ 993,
+ 783,
+ 755,
+ 330,
+ 278,
+ 755,
+ 925,
+ 74,
+ 30,
+ 871,
+ 993,
+ 416,
+ 767,
+ 1040,
+ 713,
+ 331,
+ 1016,
+ 460,
+ 668,
+ 419,
+ 568,
+ 148,
+ 326,
+ 306,
+ 30,
+ 440,
+ 36,
+ 742,
+ 398,
+ 727,
+ 993,
+ 389,
+ 795,
+ 373,
+ 1009,
+ 681,
+ 577,
+ 455,
+ 410,
+ 246,
+ 1062,
+ 29,
+ 641,
+ 993,
+ 788,
+ 921,
+ 413,
+ 483,
+ 329,
+ 737,
+ 331,
+ 1016,
+ 413,
+ 1040,
+ 713,
+ 482,
+ 23,
+ 29,
+ 253,
+ 365,
+ 489,
+ 457,
+ 642,
+ 29,
+ 544,
+ 778,
+ 1077,
+ 68,
+ 27,
+ 379,
+ 59,
+ 30,
+ 639,
+ 965,
+ 48,
+ 52,
+ 851,
+ 773,
+ 331,
+ 1012,
+ 1076,
+ 481,
+ 661,
+ 461,
+ 331,
+ 767,
+ 166,
+ 1010,
+ 285,
+ 716,
+ 662,
+ 999,
+ 461,
+ 668,
+ 132,
+ 767,
+ 936,
+ 67,
+ 533,
+ 166,
+ 929,
+ 1046,
+ 677,
+ 456,
+ 124,
+ 30,
+ 440,
+ 183,
+ 954,
+ 730,
+ 65,
+ 716,
+ 358,
+ 713,
+ 993,
+ 455,
+ 637,
+ 748,
+ 40,
+ 472,
+ 149,
+ 527,
+ 709,
+ 29,
+ 490,
+ 1077,
+ 74,
+ 777,
+ 629,
+ 823,
+ 665,
+ 367,
+ 457,
+ 560,
+ 417,
+ 497,
+ 478,
+ 888,
+ 889,
+ 684,
+ 821,
+ 65,
+ 441,
+ 65,
+ 605,
+ 74,
+ 679,
+ 840,
+ 736,
+ 150,
+ 666,
+ 30,
+ 479,
+ 527,
+ 709,
+ 94,
+ 510,
+ 864,
+ 455,
+ 1074,
+ 667,
+ 453,
+ 308,
+ 74,
+ 390,
+ 74,
+ 647,
+ 733,
+ 469,
+ 265,
+ 67,
+ 764,
+ 30,
+ 15,
+ 490,
+ 993,
+ 29,
+ 447,
+ 971,
+ 123,
+ 29,
+ 501,
+ 65,
+ 668,
+ 559,
+ 461,
+ 591,
+ 737,
+ 29,
+ 449,
+ 233,
+ 1034,
+ 16,
+ 121,
+ 993,
+ 428,
+ 528,
+ 65,
+ 474,
+ 455,
+ 1056,
+ 275,
+ 324,
+ 29,
+ 718,
+ 991,
+ 717,
+ 473,
+ 980,
+ 668,
+ 390,
+ 67,
+ 716,
+ 711,
+ 464,
+ 224,
+ 1073,
+ 666,
+ 29,
+ 811,
+ 990,
+ 29,
+ 888,
+ 616,
+ 191,
+ 184,
+ 768,
+ 709,
+ 846,
+ 62,
+ 994,
+ 144,
+ 30,
+ 142,
+ 409,
+ 976,
+ 415,
+ 65,
+ 326,
+ 888,
+ 575,
+ 543,
+ 384,
+ 537,
+ 17,
+ 1029,
+ 668,
+ 343,
+ 331,
+ 1012,
+ 30,
+ 422,
+ 44,
+ 33,
+ 1036,
+ 279,
+ 67,
+ 1053,
+ 976,
+ 415,
+ 65,
+ 326,
+ 101,
+ 1029,
+ 54,
+ 1027,
+ 272,
+ 874,
+ 65,
+ 331,
+ 1016,
+ 2 },
+ {
+ 0,
+ 433,
+ 204,
+ 360,
+ 870,
+ 514,
+ 962,
+ 449,
+ 295,
+ 962,
+ 624,
+ 208,
+ 497,
+ 995,
+ 1071,
+ 65,
+ 538,
+ 412,
+ 760,
+ 883,
+ 592,
+ 422,
+ 707,
+ 858,
+ 1032,
+ 422,
+ 44,
+ 34,
+ 875,
+ 72,
+ 1032,
+ 716,
+ 254,
+ 896,
+ 600,
+ 24,
+ 873,
+ 514,
+ 29,
+ 695,
+ 425,
+ 1071,
+ 65,
+ 538,
+ 412,
+ 760,
+ 98,
+ 896,
+ 600,
+ 24,
+ 273,
+ 30,
+ 729,
+ 960,
+ 188,
+ 1001,
+ 596,
+ 497,
+ 497,
+ 485,
+ 76,
+ 178,
+ 579,
+ 679,
+ 914,
+ 950,
+ 74,
+ 459,
+ 883,
+ 514,
+ 686,
+ 21,
+ 80,
+ 741,
+ 745,
+ 962,
+ 781,
+ 70,
+ 716,
+ 1003,
+ 151,
+ 455,
+ 596,
+ 522,
+ 638,
+ 310,
+ 65,
+ 1066,
+ 1020,
+ 30,
+ 2 },
+ {
+ 0,
+ 716,
+ 725,
+ 652,
+ 77,
+ 9,
+ 444,
+ 463,
+ 20,
+ 232,
+ 10,
+ 270,
+ 427,
+ 886,
+ 444,
+ 463,
+ 20,
+ 588,
+ 85,
+ 4,
+ 470,
+ 886,
+ 692,
+ 444,
+ 463,
+ 22,
+ 28,
+ 24,
+ 71,
+ 232,
+ 539,
+ 100,
+ 975,
+ 6,
+ 146,
+ 886,
+ 534,
+ 4,
+ 362,
+ 432,
+ 122,
+ 100,
+ 104,
+ 90,
+ 51,
+ 992,
+ 39,
+ 359,
+ 997,
+ 32,
+ 317,
+ 100,
+ 292,
+ 424,
+ 6,
+ 716,
+ 725,
+ 171,
+ 582,
+ 96,
+ 49,
+ 58,
+ 516,
+ 705,
+ 100,
+ 320,
+ 377,
+ 968,
+ 701,
+ 333,
+ 86,
+ 47,
+ 610,
+ 886,
+ 33,
+ 979,
+ 115,
+ 232,
+ 539,
+ 731,
+ 586,
+ 581,
+ 1063,
+ 71,
+ 664,
+ 1075,
+ 6,
+ 2 },
+ {
+ 0,
+ 548,
+ 1013,
+ 948,
+ 854,
+ 215,
+ 716,
+ 799,
+ 867,
+ 865,
+ 532,
+ 953,
+ 499,
+ 298,
+ 758,
+ 853,
+ 107,
+ 819,
+ 498,
+ 865,
+ 314,
+ 657,
+ 847,
+ 274,
+ 60,
+ 117,
+ 395,
+ 190,
+ 985,
+ 402,
+ 578,
+ 267,
+ 352,
+ 231,
+ 861,
+ 154,
+ 943,
+ 402,
+ 271,
+ 525,
+ 743,
+ 135,
+ 774,
+ 374,
+ 590,
+ 352,
+ 231,
+ 274,
+ 1078,
+ 117,
+ 107,
+ 819,
+ 498,
+ 400,
+ 361,
+ 282,
+ 738,
+ 271,
+ 439,
+ 1021,
+ 849,
+ 1038,
+ 274,
+ 243,
+ 673,
+ 93,
+ 117,
+ 484,
+ 797,
+ 117,
+ 716,
+ 200,
+ 127,
+ 861,
+ 825,
+ 219,
+ 852,
+ 402,
+ 271,
+ 669,
+ 854,
+ 215,
+ 865,
+ 923,
+ 107,
+ 819,
+ 498,
+ 394,
+ 931,
+ 361,
+ 716,
+ 941,
+ 11,
+ 861,
+ 154,
+ 943,
+ 60,
+ 670,
+ 402,
+ 669,
+ 854,
+ 215,
+ 716,
+ 799,
+ 861,
+ 385,
+ 117,
+ 1013,
+ 948,
+ 854,
+ 215,
+ 948,
+ 838,
+ 948,
+ 238,
+ 91,
+ 948,
+ 831,
+ 963,
+ 832,
+ 894,
+ 108,
+ 853,
+ 402,
+ 525,
+ 899,
+ 913,
+ 12,
+ 703,
+ 562,
+ 1038,
+ 274,
+ 900,
+ 798,
+ 117,
+ 554,
+ 688,
+ 815,
+ 117,
+ 958,
+ 45,
+ 117,
+ 535,
+ 800,
+ 782,
+ 958,
+ 613,
+ 117,
+ 926,
+ 761,
+ 117,
+ 926,
+ 1008,
+ 117,
+ 957,
+ 1004,
+ 853,
+ 117,
+ 958,
+ 31,
+ 207,
+ 859,
+ 271,
+ 525,
+ 198,
+ 1014,
+ 618,
+ 926,
+ 406,
+ 525,
+ 675,
+ 211,
+ 809,
+ 1048,
+ 152,
+ 905,
+ 689,
+ 716,
+ 30,
+ 525,
+ 905,
+ 211,
+ 412,
+ 615,
+ 849,
+ 854,
+ 215,
+ 24,
+ 706,
+ 271,
+ 107,
+ 819,
+ 498,
+ 271,
+ 657,
+ 847,
+ 506,
+ 5,
+ 569,
+ 63,
+ 363,
+ 963,
+ 832,
+ 271,
+ 894,
+ 108,
+ 853,
+ 1022,
+ 1030,
+ 378,
+ 635,
+ 30,
+ 669,
+ 854,
+ 215,
+ 716,
+ 799,
+ 325,
+ 651,
+ 355,
+ 1052,
+ 229,
+ 274,
+ 813,
+ 899,
+ 93,
+ 117,
+ 525,
+ 1059,
+ 860,
+ 325,
+ 506,
+ 353,
+ 220,
+ 891,
+ 119,
+ 789,
+ 669,
+ 854,
+ 215,
+ 716,
+ 799,
+ 301,
+ 63,
+ 848,
+ 714,
+ 550,
+ 749,
+ 614,
+ 865,
+ 754,
+ 423,
+ 849,
+ 865,
+ 443,
+ 274,
+ 562,
+ 271,
+ 301,
+ 63,
+ 848,
+ 693,
+ 550,
+ 749,
+ 614,
+ 865,
+ 423,
+ 849,
+ 159,
+ 192,
+ 612,
+ 274,
+ 566,
+ 608,
+ 562,
+ 1038,
+ 904,
+ 669,
+ 854,
+ 215,
+ 716,
+ 799,
+ 982,
+ 125,
+ 898,
+ 847,
+ 687,
+ 744,
+ 562,
+ 117,
+ 368,
+ 849,
+ 690,
+ 578,
+ 400,
+ 865,
+ 720,
+ 262,
+ 806,
+ 933,
+ 789,
+ 587,
+ 536,
+ 789,
+ 202,
+ 861,
+ 266,
+ 769,
+ 60,
+ 63,
+ 1043,
+ 865,
+ 576,
+ 977,
+ 601,
+ 271,
+ 190,
+ 353,
+ 669,
+ 854,
+ 215,
+ 861,
+ 369,
+ 280,
+ 102,
+ 861,
+ 82,
+ 126,
+ 964,
+ 852,
+ 30,
+ 669,
+ 854,
+ 215,
+ 716,
+ 799,
+ 986,
+ 849,
+ 747,
+ 274,
+ 407,
+ 234,
+ 213,
+ 607,
+ 933,
+ 125,
+ 891,
+ 849,
+ 746,
+ 274,
+ 548,
+ 808,
+ 294,
+ 839,
+ 828,
+ 852,
+ 187,
+ 1018,
+ 771,
+ 716,
+ 766,
+ 747,
+ 274,
+ 19,
+ 78,
+ 347,
+ 933,
+ 271,
+ 578,
+ 451,
+ 849,
+ 747,
+ 820,
+ 509,
+ 789,
+ 548,
+ 203,
+ 948,
+ 716,
+ 739,
+ 648,
+ 716,
+ 799,
+ 865,
+ 772,
+ 861,
+ 25,
+ 274,
+ 227,
+ 380,
+ 672,
+ 102,
+ 347,
+ 933,
+ 117,
+ 525,
+ 735,
+ 214,
+ 271,
+ 952,
+ 1059,
+ 860,
+ 972,
+ 775,
+ 402,
+ 578,
+ 525,
+ 315,
+ 861,
+ 462,
+ 529,
+ 789,
+ 394,
+ 715,
+ 274,
+ 120,
+ 861,
+ 716,
+ 1058,
+ 418,
+ 241,
+ 824,
+ 1038,
+ 865,
+ 318,
+ 853,
+ 756,
+ 669,
+ 854,
+ 215,
+ 716,
+ 799,
+ 189,
+ 436,
+ 672,
+ 816,
+ 687,
+ 378,
+ 635,
+ 716,
+ 30,
+ 2 },
+ {
+ 0,
+ 268,
+ 951,
+ 7,
+ 716,
+ 903,
+ 865,
+ 584,
+ 168,
+ 887,
+ 229,
+ 653,
+ 932,
+ 421,
+ 217,
+ 932,
+ 386,
+ 653,
+ 932,
+ 865,
+ 716,
+ 835,
+ 143,
+ 612,
+ 904,
+ 593,
+ 363,
+ 904,
+ 411,
+ 203,
+ 853,
+ 21,
+ 421,
+ 716,
+ 835,
+ 185,
+ 387,
+ 81,
+ 209,
+ 597,
+ 865,
+ 296,
+ 862,
+ 901,
+ 223,
+ 1005,
+ 670,
+ 437,
+ 1033,
+ 8,
+ 412,
+ 176,
+ 24,
+ 704,
+ 687,
+ 782,
+ 289,
+ 421,
+ 716,
+ 835,
+ 185,
+ 776,
+ 853,
+ 81,
+ 716,
+ 835,
+ 716,
+ 466,
+ 26,
+ 421,
+ 656,
+ 404,
+ 714,
+ 550,
+ 749,
+ 614,
+ 865,
+ 716,
+ 835,
+ 716,
+ 1031,
+ 853,
+ 690,
+ 519,
+ 902,
+ 850,
+ 716,
+ 835,
+ 904,
+ 128,
+ 958,
+ 625,
+ 230,
+ 421,
+ 1037,
+ 225,
+ 934,
+ 958,
+ 625,
+ 230,
+ 421,
+ 1037,
+ 225,
+ 934,
+ 345,
+ 421,
+ 716,
+ 1031,
+ 942,
+ 421,
+ 371,
+ 550,
+ 408,
+ 307,
+ 951,
+ 412,
+ 807,
+ 24,
+ 656,
+ 404,
+ 714,
+ 550,
+ 749,
+ 614,
+ 865,
+ 555,
+ 219,
+ 230,
+ 690,
+ 491,
+ 716,
+ 835,
+ 904,
+ 924,
+ 958,
+ 625,
+ 230,
+ 307,
+ 951,
+ 412,
+ 810,
+ 24,
+ 656,
+ 404,
+ 714,
+ 550,
+ 749,
+ 614,
+ 865,
+ 396,
+ 865,
+ 125,
+ 1002,
+ 636,
+ 690,
+ 519,
+ 902,
+ 850,
+ 716,
+ 835,
+ 904,
+ 125,
+ 1002,
+ 636,
+ 307,
+ 951,
+ 412,
+ 815,
+ 24,
+ 206,
+ 312,
+ 791,
+ 932,
+ 904,
+ 617,
+ 307,
+ 951,
+ 2 },
+ {
+ 0,
+ 349,
+ 948,
+ 927,
+ 186,
+ 861,
+ 556,
+ 779,
+ 763,
+ 83,
+ 112,
+ 180,
+ 779,
+ 1000,
+ 496,
+ 750,
+ 784,
+ 521,
+ 967,
+ 263,
+ 435,
+ 112,
+ 180,
+ 322,
+ 1069,
+ 967,
+ 83,
+ 322,
+ 179,
+ 611,
+ 714,
+ 550,
+ 749,
+ 614,
+ 133,
+ 762,
+ 321,
+ 967,
+ 841,
+ 780,
+ 493,
+ 83,
+ 263,
+ 1051,
+ 356,
+ 465,
+ 515,
+ 555,
+ 779,
+ 1081,
+ 344,
+ 779,
+ 1061,
+ 133,
+ 939,
+ 321,
+ 782,
+ 915,
+ 589,
+ 922,
+ 83,
+ 556,
+ 682,
+ 763,
+ 420,
+ 694,
+ 555,
+ 442,
+ 820,
+ 644,
+ 791,
+ 197,
+ 342,
+ 247,
+ 814,
+ 1017,
+ 685,
+ 782,
+ 915,
+ 480,
+ 35,
+ 915,
+ 645,
+ 133,
+ 1041,
+ 552,
+ 967,
+ 106,
+ 623,
+ 357,
+ 622,
+ 83,
+ 526,
+ 442,
+ 245,
+ 1024,
+ 197,
+ 1067,
+ 932,
+ 83,
+ 988,
+ 162,
+ 632,
+ 83,
+ 556,
+ 779,
+ 545,
+ 698,
+ 934,
+ 83,
+ 814,
+ 1072,
+ 2 },
+ {
+ 0,
+ 335,
+ 316,
+ 779,
+ 467,
+ 572,
+ 656,
+ 1015,
+ 693,
+ 550,
+ 749,
+ 614,
+ 779,
+ 917,
+ 43,
+ 779,
+ 555,
+ 83,
+ 239,
+ 372,
+ 133,
+ 430,
+ 1023,
+ 944,
+ 291,
+ 1079,
+ 782,
+ 893,
+ 996,
+ 245,
+ 719,
+ 808,
+ 779,
+ 628,
+ 934,
+ 83,
+ 557,
+ 133,
+ 309,
+ 332,
+ 656,
+ 1015,
+ 693,
+ 550,
+ 749,
+ 614,
+ 322,
+ 545,
+ 780,
+ 125,
+ 517,
+ 157,
+ 985,
+ 595,
+ 236,
+ 779,
+ 589,
+ 945,
+ 83,
+ 197,
+ 615,
+ 175,
+ 732,
+ 884,
+ 948,
+ 134,
+ 257,
+ 708,
+ 83,
+ 716,
+ 319,
+ 740,
+ 937,
+ 694,
+ 966,
+ 951,
+ 2 },
+ {
+ 0,
+ 716,
+ 328,
+ 391,
+ 1070,
+ 934,
+ 779,
+ 338,
+ 399,
+ 83,
+ 496,
+ 782,
+ 293,
+ 83,
+ 989,
+ 133,
+ 564,
+ 348,
+ 947,
+ 177,
+ 779,
+ 836,
+ 949,
+ 496,
+ 782,
+ 716,
+ 328,
+ 779,
+ 523,
+ 383,
+ 947,
+ 177,
+ 255,
+ 682,
+ 836,
+ 934,
+ 103,
+ 782,
+ 316,
+ 779,
+ 216,
+ 162,
+ 609,
+ 199,
+ 83,
+ 1081,
+ 753,
+ 393,
+ 602,
+ 420,
+ 694,
+ 434,
+ 494,
+ 129,
+ 498,
+ 862,
+ 248,
+ 261,
+ 35,
+ 13,
+ 1057,
+ 316,
+ 779,
+ 475,
+ 656,
+ 1015,
+ 693,
+ 550,
+ 749,
+ 614,
+ 322,
+ 697,
+ 136,
+ 163,
+ 197,
+ 650,
+ 942,
+ 245,
+ 817,
+ 180,
+ 780,
+ 113,
+ 906,
+ 723,
+ 2 },
+ {
+ 0,
+ 339,
+ 722,
+ 145,
+ 196,
+ 740,
+ 899,
+ 244,
+ 92,
+ 492,
+ 55,
+ 299,
+ 247,
+ 680,
+ 714,
+ 550,
+ 749,
+ 614,
+ 780,
+ 818,
+ 182,
+ 567,
+ 796,
+ 520,
+ 247,
+ 787,
+ 205,
+ 779,
+ 583,
+ 391,
+ 1048,
+ 682,
+ 890,
+ 236,
+ 899,
+ 281,
+ 674,
+ 1006,
+ 911,
+ 160,
+ 879,
+ 83,
+ 321,
+ 782,
+ 303,
+ 716,
+ 909,
+ 948,
+ 250,
+ 346,
+ 716,
+ 790,
+ 934,
+ 860,
+ 236,
+ 303,
+ 173,
+ 948,
+ 540,
+ 716,
+ 790,
+ 974,
+ 118,
+ 863,
+ 815,
+ 862,
+ 368,
+ 693,
+ 550,
+ 749,
+ 614,
+ 779,
+ 340,
+ 947,
+ 313,
+ 724,
+ 726,
+ 861,
+ 351,
+ 157,
+ 83,
+ 928,
+ 521,
+ 787,
+ 594,
+ 322,
+ 699,
+ 429,
+ 626,
+ 99,
+ 780,
+ 341,
+ 18,
+ 827,
+ 541,
+ 860,
+ 958,
+ 585,
+ 182,
+ 693,
+ 550,
+ 749,
+ 614,
+ 779,
+ 861,
+ 947,
+ 313,
+ 407,
+ 862,
+ 477,
+ 83,
+ 130,
+ 521,
+ 603,
+ 83,
+ 133,
+ 448,
+ 947,
+ 313,
+ 351,
+ 157,
+ 83,
+ 928,
+ 880,
+ 915,
+ 779,
+ 475,
+ 594,
+ 322,
+ 201,
+ 111,
+ 347,
+ 193,
+ 37,
+ 842,
+ 75,
+ 18,
+ 69,
+ 322,
+ 907,
+ 221,
+ 162,
+ 159,
+ 860,
+ 807,
+ 859,
+ 826,
+ 323,
+ 819,
+ 197,
+ 161,
+ 817,
+ 169,
+ 197,
+ 125,
+ 860,
+ 848,
+ 323,
+ 942,
+ 300,
+ 255,
+ 682,
+ 716,
+ 218,
+ 934,
+ 222,
+ 381,
+ 694,
+ 526,
+ 712,
+ 782,
+ 786,
+ 573,
+ 382,
+ 949,
+ 197,
+ 573,
+ 179,
+ 66,
+ 782,
+ 83,
+ 322,
+ 786,
+ 934,
+ 877,
+ 264,
+ 580,
+ 604,
+ 1042,
+ 782,
+ 228,
+ 938,
+ 476,
+ 66,
+ 442,
+ 468,
+ 41,
+ 782,
+ 442,
+ 235,
+ 255,
+ 83,
+ 1045,
+ 114,
+ 492,
+ 56,
+ 66,
+ 442,
+ 940,
+ 765,
+ 133,
+ 940,
+ 765,
+ 899,
+ 561,
+ 492,
+ 56,
+ 471,
+ 260,
+ 643,
+ 255,
+ 899,
+ 973,
+ 784,
+ 66,
+ 197,
+ 945,
+ 35,
+ 1064,
+ 366,
+ 66,
+ 782,
+ 611,
+ 304,
+ 882,
+ 907,
+ 442,
+ 1047,
+ 702,
+ 791,
+ 818,
+ 1028,
+ 967,
+ 503,
+ 452,
+ 133,
+ 872,
+ 195,
+ 249,
+ 899,
+ 915,
+ 50,
+ 95,
+ 442,
+ 446,
+ 895,
+ 967,
+ 599,
+ 164,
+ 162,
+ 431,
+ 779,
+ 1000,
+ 626,
+ 170,
+ 859,
+ 803,
+ 806,
+ 862,
+ 847,
+ 882,
+ 934,
+ 859,
+ 125,
+ 862,
+ 847,
+ 290,
+ 806,
+ 611,
+ 860,
+ 159,
+ 860,
+ 812,
+ 859,
+ 848,
+ 290,
+ 815,
+ 855,
+ 143,
+ 290,
+ 824,
+ 860,
+ 852,
+ 866,
+ 847,
+ 860,
+ 611,
+ 862,
+ 450,
+ 105,
+ 236,
+ 392,
+ 247,
+ 197,
+ 503,
+ 938,
+ 602,
+ 945,
+ 805,
+ 288,
+ 655,
+ 806,
+ 197,
+ 869,
+ 935,
+ 690,
+ 1007,
+ 158,
+ 412,
+ 885,
+ 236,
+ 56,
+ 24,
+ 197,
+ 35,
+ 815,
+ 255,
+ 83,
+ 258,
+ 1024,
+ 1079,
+ 1048,
+ 691,
+ 620,
+ 934,
+ 876,
+ 951,
+ 197,
+ 237,
+ 981,
+ 920,
+ 192,
+ 790,
+ 974,
+ 984,
+ 676,
+ 862,
+ 458,
+ 714,
+ 550,
+ 749,
+ 614,
+ 671,
+ 969,
+ 83,
+ 351,
+ 157,
+ 354,
+ 682,
+ 342,
+ 563,
+ 526,
+ 251,
+ 918,
+ 321,
+ 967,
+ 14,
+ 14,
+ 611,
+ 304,
+ 882,
+ 322,
+ 680,
+ 714,
+ 550,
+ 749,
+ 614,
+ 671,
+ 445,
+ 83,
+ 699,
+ 967,
+ 14,
+ 14,
+ 83,
+ 125,
+ 860,
+ 649,
+ 57,
+ 388,
+ 779,
+ 881,
+ 694,
+ 255,
+ 791,
+ 782,
+ 197,
+ 57,
+ 131,
+ 860,
+ 88,
+ 862,
+ 477,
+ 97,
+ 446,
+ 644,
+ 791,
+ 782,
+ 678,
+ 862,
+ 549,
+ 197,
+ 162,
+ 405,
+ 899,
+ 125,
+ 860,
+ 849,
+ 682,
+ 334,
+ 948,
+ 700,
+ 791,
+ 197,
+ 138,
+ 1044,
+ 401,
+ 878,
+ 633,
+ 899,
+ 945,
+ 682,
+ 53,
+ 694,
+ 255,
+ 370,
+ 930,
+ 882,
+ 899,
+ 945,
+ 682,
+ 137,
+ 311,
+ 782,
+ 1055,
+ 899,
+ 945,
+ 682,
+ 109,
+ 782,
+ 164,
+ 162,
+ 716,
+ 570,
+ 899,
+ 125,
+ 860,
+ 849,
+ 780,
+ 61,
+ 117,
+ 558,
+ 852,
+ 574,
+ 899,
+ 125,
+ 860,
+ 849,
+ 780,
+ 634,
+ 117,
+ 305,
+ 899,
+ 945,
+ 780,
+ 542,
+ 808,
+ 782,
+ 438,
+ 862,
+ 892,
+ 899,
+ 125,
+ 860,
+ 849,
+ 780,
+ 507,
+ 782,
+ 504,
+ 899,
+ 125,
+ 860,
+ 849,
+ 682,
+ 548,
+ 197,
+ 316,
+ 899,
+ 125,
+ 860,
+ 849,
+ 780,
+ 249,
+ 948,
+ 700,
+ 370,
+ 505,
+ 125,
+ 860,
+ 849,
+ 682,
+ 2 },
+ {
+ 0,
+ 212,
+ 495,
+ 656,
+ 1015,
+ 693,
+ 550,
+ 749,
+ 614,
+ 779,
+ 915,
+ 716,
+ 558,
+ 162,
+ 595,
+ 848,
+ 322,
+ 342,
+ 243,
+ 721,
+ 934,
+ 1019,
+ 153,
+ 967,
+ 112,
+ 180,
+ 716,
+ 739,
+ 182,
+ 780,
+ 640,
+ 779,
+ 361,
+ 680,
+ 779,
+ 1000,
+ 518,
+ 197,
+ 848,
+ 426,
+ 135,
+ 987,
+ 284,
+ 414,
+ 694,
+ 1037,
+ 983,
+ 862,
+ 316,
+ 133,
+ 752,
+ 1079,
+ 656,
+ 1015,
+ 714,
+ 550,
+ 749,
+ 614,
+ 322,
+ 916,
+ 794,
+ 934,
+ 159,
+ 512,
+ 808,
+ 716,
+ 739,
+ 182,
+ 779,
+ 753,
+ 862,
+ 970,
+ 92,
+ 83,
+ 133,
+ 998,
+ 947,
+ 177,
+ 97,
+ 446,
+ 702,
+ 782,
+ 829,
+ 978,
+ 557,
+ 779,
+ 475,
+ 779,
+ 277,
+ 682,
+ 487,
+ 240,
+ 87,
+ 937,
+ 955,
+ 837,
+ 83,
+ 321,
+ 782,
+ 513,
+ 112,
+ 180,
+ 915,
+ 336,
+ 83,
+ 915,
+ 252,
+ 133,
+ 734,
+ 521,
+ 967,
+ 316,
+ 779,
+ 475,
+ 945,
+ 133,
+ 181,
+ 946,
+ 316,
+ 779,
+ 226,
+ 141,
+ 934,
+ 172,
+ 209,
+ 822,
+ 169,
+ 1035,
+ 1068,
+ 117,
+ 761,
+ 669,
+ 364,
+ 833,
+ 824,
+ 42,
+ 286,
+ 508,
+ 521,
+ 782,
+ 690,
+ 663,
+ 156,
+ 488,
+ 251,
+ 1065,
+ 915,
+ 89,
+ 951,
+ 2 }, };
+
+}
diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/XLMRobertaTokenizerTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/XLMRobertaTokenizerTests.java
index bff2c6a94d789..3fd51601e0138 100644
--- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/XLMRobertaTokenizerTests.java
+++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/nlp/tokenizers/XLMRobertaTokenizerTests.java
@@ -124,6 +124,30 @@ public void testMultiByteEmoji() throws IOException {
}
}
+ public void testMultilingual() throws IOException {
+ var vocab = XLMRobertaTestVocab.loadMultiLingualTestVocab();
+
+ try (
+ XLMRobertaTokenizer tokenizer = XLMRobertaTokenizer.builder(
+ vocab.get(),
+ vocab.scores(),
+ new XLMRobertaTokenization(false, null, Tokenization.Truncate.NONE, -1)
+ ).setWithSpecialTokens(true).build()
+ ) {
+ for (int i = 0; i < XLMRobertaTestVocab.MULTILINUGAL_TEXTS.length; i++) {
+ logger.info(i);
+ TokenizationResult.Tokens tokenization = tokenizer.tokenize(
+ XLMRobertaTestVocab.MULTILINUGAL_TEXTS[i],
+ Tokenization.Truncate.FIRST,
+ -1,
+ 0,
+ null
+ ).get(0);
+ assertArrayEquals(XLMRobertaTestVocab.EXPECTED_TOKENS[i], tokenization.tokenIds());
+ }
+ }
+ }
+
public void testTokenizeWithNeverSplit() throws IOException {
try (
XLMRobertaTokenizer tokenizer = XLMRobertaTokenizer.builder(
diff --git a/x-pack/plugin/ml/src/test/resources/org/elasticsearch/xpack/ml/inference/tokenizers/xlm_roberta_test_vocabulary.json b/x-pack/plugin/ml/src/test/resources/org/elasticsearch/xpack/ml/inference/tokenizers/xlm_roberta_test_vocabulary.json
new file mode 100644
index 0000000000000..99f7d2ae34a04
--- /dev/null
+++ b/x-pack/plugin/ml/src/test/resources/org/elasticsearch/xpack/ml/inference/tokenizers/xlm_roberta_test_vocabulary.json
@@ -0,0 +1,2172 @@
+{
+ "model_id": "anything_to_satisfy_the_parser",
+ "vocabulary": [
+ "",
+ "",
+ "",
+ "",
+ "、",
+ "▁نسبت",
+ "。",
+ "▁ھن",
+ "▁ھو",
+ "「",
+ "」",
+ "فض",
+ "▁سار",
+ "▁پہنچے",
+ "’",
+ "▁Nakon",
+ "nova",
+ "jena",
+ "!",
+ "▁حديث",
+ "工業",
+ "'",
+ "(",
+ "▁soba",
+ ")",
+ "▁شوق",
+ "في",
+ "▁pod",
+ "株",
+ ",",
+ ".",
+ "قر",
+ "進",
+ "3",
+ "8",
+ "▁پر",
+ "▁pot",
+ ":",
+ "▁مختار",
+ "格",
+ "▁pos",
+ "▁مزاج",
+ "قل",
+ "قم",
+ "⁄",
+ "فسر",
+ "ću",
+ "く",
+ "▁bila",
+ "あげ",
+ "▁طرح",
+ "し",
+ "▁vrhunski",
+ "▁شعار",
+ "▁jednu",
+ "▁والی",
+ "▁والے",
+ "▁ہر",
+ "た",
+ "a",
+ "▁ٿي",
+ "▁طبیعت",
+ "b",
+ "▁ڪري",
+ "▁حدیث",
+ "e",
+ "▁ہو",
+ "g",
+ "h",
+ "▁ہم",
+ "k",
+ "に",
+ "l",
+ "ština",
+ "m",
+ "▁نبی",
+ "n",
+ "の",
+ "▁لکڻ",
+ "s",
+ "t",
+ "▁سان",
+ "▁سبب",
+ "▁میں",
+ "▁lit",
+ "へ",
+ "べ",
+ "لف",
+ "لق",
+ "لم",
+ "や",
+ "ثير",
+ "مت",
+ "لي",
+ "▁pri",
+ "▁راست",
+ "り",
+ "▁عطا",
+ "▁66",
+ "خدا",
+ "を",
+ "▁kuća",
+ "▁ڪرڻ",
+ "▁تھا",
+ "増",
+ "▁پکار",
+ "▁طا",
+ "▁طب",
+ "مل",
+ "▁راز",
+ "▁prenosi",
+ "نا",
+ "▁سہ",
+ "▁طرف",
+ "▁بلند",
+ "英文",
+ "vne",
+ "▁،",
+ "▁سی",
+ "ائين",
+ "▁زمين",
+ "▁zbog",
+ "点",
+ "▁stoljeća",
+ "jeti",
+ "▁ا",
+ "▁ب",
+ "ني",
+ "▁امير",
+ "▁آ",
+ "▁آئے",
+ "▁خ",
+ "vod",
+ "▁سے",
+ "▁ت",
+ "▁ج",
+ "▁ص",
+ "▁ض",
+ "▁ط",
+ "čenja",
+ "buku",
+ "▁ظ",
+ "▁90",
+ "▁ر",
+ "vom",
+ "▁ز",
+ "▁1990",
+ "▁ش",
+ "vor",
+ "ena",
+ "ologi",
+ "▁yn",
+ "الت",
+ "یا",
+ "▁ع",
+ "ene",
+ "الا",
+ "یت",
+ "وا",
+ "▁م",
+ "یح",
+ "▁ن",
+ "▁و",
+ "ید",
+ "▁صدق",
+ "▁عن",
+ "▁za",
+ "▁ف",
+ "▁ق",
+ "یر",
+ "▁ل",
+ "者が",
+ "ور",
+ "▁عبداللہ",
+ "▁obra",
+ "وع",
+ "الف",
+ "نٹ",
+ "ô",
+ "▁رسول",
+ "یل",
+ "▁کوئی",
+ "ین",
+ "▁zi",
+ "uncu",
+ "▁ٻي",
+ "لہ",
+ "▁انجام",
+ "▁fan",
+ "▁پنهنجو",
+ "▁اهو",
+ "▁vrh",
+ "بار",
+ "▁کیا",
+ "ć",
+ "▁مستقیم",
+ "لی",
+ "▁اور",
+ "▁اهي",
+ "لے",
+ "باط",
+ "▁پڑھ",
+ "▁اوهان",
+ "احمد",
+ "isto",
+ "▁ہاتھوں",
+ "▁پنھنجي",
+ "يء",
+ "▁lân",
+ "▁پ",
+ "مہ",
+ "يت",
+ "▁بال",
+ "يد",
+ "▁خرچ",
+ "ير",
+ "▁جذب",
+ "▁لا",
+ "نگ",
+ "وار",
+ "▁ڏ",
+ "▁شاہد",
+ "بان",
+ "▁قرار",
+ "vanja",
+ "يف",
+ "▁خلاف",
+ "▁بغداد",
+ "نہ",
+ "اني",
+ "ين",
+ "يه",
+ "社",
+ "▁njihova",
+ "▁مج",
+ "▁بازار",
+ "نے",
+ "▁ک",
+ "▁ڪ",
+ "▁تشریف",
+ "▁مؤ",
+ "▁ملي",
+ "ایت",
+ "▁مع",
+ "▁ملا",
+ "▁ہ",
+ "▁plod",
+ "یں",
+ "▁نب",
+ "▁ملت",
+ "▁ی",
+ "▁من",
+ "▁حیثیت",
+ "▁ali",
+ "660",
+ "وں",
+ "đe",
+ "یہ",
+ "▁لپ",
+ "đi",
+ "▁خطا",
+ "وی",
+ "▁پڇ",
+ "▁ایک",
+ "▁نام",
+ "šnje",
+ "▁پٽ",
+ "▁سلطنت",
+ "▁۱",
+ "▁کثیر",
+ "から",
+ "▁۽",
+ "▁dvije",
+ "▁breed",
+ "▁۾",
+ "▁200",
+ "▁Ana",
+ "▁مسلمانوں",
+ "oče",
+ "▁ukupno",
+ "▁حاصل",
+ "▁ترجیح",
+ "▁پڻ",
+ "ama",
+ "انہ",
+ "tru",
+ "انی",
+ "▁dokaz",
+ "▁آنکھیں",
+ "▁لکي",
+ "َّ",
+ "سلام",
+ "始",
+ "▁عرب",
+ "▁جهڙو",
+ "cre",
+ "▁لاء",
+ "نام",
+ "▁224",
+ "▁عورت",
+ "ُّ",
+ "▁نبي",
+ "▁kada",
+ "▁حضرت",
+ "▁تعالی",
+ "▁عدل",
+ "▁metara",
+ "▁چئي",
+ "▁moguće",
+ "▁مدینہ",
+ "plo",
+ "میر",
+ "▁عبادت",
+ "صاف",
+ "▁شهر",
+ "▁والد",
+ "▁اسلام",
+ "出",
+ "▁آمدن",
+ "موا",
+ "世界",
+ "▁ہے",
+ "▁نے",
+ "ِّ",
+ "▁godina",
+ "▁هڪ",
+ "nih",
+ "▁ostvari",
+ "ضرار",
+ "jal",
+ "▁razm",
+ "▁prostor",
+ "▁گئے",
+ "させる",
+ "▁لباس",
+ "▁دعوت",
+ "▁زمرہ",
+ "tvr",
+ "▁اصحاب",
+ "▁(2)",
+ "▁وہ",
+ "▁قسم",
+ "▁یہ",
+ "▁deset",
+ "▁عمر",
+ "▁المسلمين",
+ "سار",
+ "▁شروع",
+ "▁دولت",
+ "▁سعد",
+ "đeni",
+ "▁تور",
+ "▁عباس",
+ "▁خواب",
+ "▁شریف",
+ "ودي",
+ "ڑی",
+ "▁عمو",
+ "stavlja",
+ "的な",
+ "ary",
+ "▁وقت",
+ "海外",
+ "▁پاڻ",
+ "▁حجر",
+ "▁uko",
+ "▁فرماتے",
+ "▁pomaže",
+ "▁عالم",
+ "▁علم",
+ "▁گا۔",
+ "▁رضي",
+ "▁لانے",
+ "tili",
+ "▁عهد",
+ "▁مخلوق",
+ "▁ہے۔",
+ "企業",
+ "ندا",
+ "rum",
+ "▁ڏانهن",
+ "▁بنا",
+ "▁بند",
+ "▁ہزار",
+ "▁ispod",
+ "▁نالو",
+ "وري",
+ "▁نالي",
+ "▁خوبی",
+ "▁sklad",
+ "▁konačno",
+ "▁اپنے",
+ "▁لگ",
+ "▁ود",
+ "▁ور",
+ "▁هي",
+ "▁خاندان",
+ "▁generacij",
+ "lji",
+ "▁ثروت",
+ "▁هن",
+ "▁وا",
+ "▁هو",
+ "▁معرفت",
+ "حضور",
+ "قار",
+ "قاب",
+ "▁قرآن",
+ "▁عنه",
+ "▁%",
+ "▁druge",
+ "▁'",
+ "▁(",
+ "▁-",
+ "▁پہنچ",
+ "građ",
+ "▁materijal",
+ "nom",
+ "ڙو",
+ "▁6",
+ "▁چھوڑ",
+ "▁يا",
+ "▁1",
+ "▁هٿ",
+ "動",
+ "▁4",
+ "قام",
+ "1959",
+ "šne",
+ "▁:",
+ "▁پہلے",
+ "▁یقین",
+ "拠",
+ "▁H",
+ "▁خالی",
+ "▁مرتبہ",
+ "▁گذر",
+ "▁آھي",
+ "▁اظہار",
+ "▁مذهبي",
+ "▁U",
+ "▁građevin",
+ "▁نہ",
+ "▁وچ",
+ "太平洋",
+ "▁صفت",
+ "▁فرما",
+ "▁tijekom",
+ "▁بعض",
+ "▁a",
+ "‘‘",
+ "▁سوره",
+ "▁برکت",
+ "▁o",
+ "▁p",
+ "▁i",
+ "▁l",
+ "▁u",
+ "▁رسالت",
+ "jit",
+ "▁veličine",
+ "▁s",
+ "▁انتقال",
+ "化学",
+ "ša",
+ "▁صرف",
+ "خلي",
+ "▁آغاز",
+ "▁سخت",
+ "▁onda",
+ "1987",
+ "▁بلکہ",
+ "ječ",
+ "▁puno",
+ "▁traje",
+ "▁بعد",
+ "خلق",
+ "▁کریم",
+ "iranju",
+ "▁Ta",
+ "▁عہد",
+ "log",
+ "▁ispred",
+ "▁ceremoni",
+ "▁خوا",
+ "▁liker",
+ "azi",
+ "▁شمار",
+ "▁سلام",
+ "pane",
+ "▁što",
+ "▁علاوه",
+ "▁کرنے",
+ "▁راہ",
+ "▁ہاتھ",
+ "آخر",
+ "▁تھے",
+ "▁dat",
+ "ستان",
+ "عادت",
+ "ješ",
+ "▁šum",
+ "▁kruh",
+ "▁تمہاری",
+ "▁ہدایت",
+ "▁احمد",
+ "▁ڏينهن",
+ "▁شریعت",
+ "▁لکھتے",
+ "▁ٿيا",
+ "dono",
+ "icama",
+ "رحم",
+ "▁لیکن",
+ "▁wie",
+ "▁کرنا",
+ "化粧品",
+ "جنب",
+ "▁ہوگئے",
+ "▁علاوہ",
+ "▁پات",
+ "▁ہیں",
+ "▁dei",
+ "▁پاس",
+ "▁حال",
+ "▁سندس",
+ "▁بھی",
+ "▁stab",
+ "▁klim",
+ "▁ٿيو",
+ "▁محبت",
+ "▁12.",
+ "▁ولادت",
+ "▁zraka",
+ "以降",
+ "▁المو",
+ "▁چيو",
+ "▁sti",
+ "den",
+ "名",
+ "▁عمرو",
+ "▁سید",
+ "▁سیر",
+ "bina",
+ "▁nešto",
+ "▁غربت",
+ "▁ž",
+ "▁Zi",
+ "▁امام",
+ "▁قلب",
+ "▁الله",
+ "▁قلت",
+ "▁رہے",
+ "▁13.",
+ "▁المج",
+ "▁گھر",
+ "▁شام",
+ "▁مکہ",
+ "عفو",
+ "▁kraja",
+ "▁preciz",
+ "▁دفع",
+ "▁آهن",
+ "▁مضمون",
+ "▁بڑی",
+ "▁stol",
+ "▁پٿر",
+ "▁انور",
+ "▁čet",
+ "▁هجڻ",
+ "وفا",
+ "▁svojih",
+ "▁یعنی",
+ "▁میرے",
+ "▁کرم",
+ "seo",
+ "▁خدمت",
+ "ce",
+ "▁جڏهن",
+ "ch",
+ "▁متو",
+ "ACI",
+ "つく",
+ "▁بجائے",
+ "▁مطابق",
+ "رسل",
+ "REP",
+ "▁انهن",
+ "株式会社",
+ "▁لیے",
+ "▁خلافت",
+ "ruše",
+ "wol",
+ "▁جيڪو",
+ "▁انہوں",
+ "کر",
+ "en",
+ "ڪاري",
+ "▁مختلف",
+ "▁لوگ",
+ "et",
+ "▁ڏيندو",
+ "ولت",
+ "▁انہیں",
+ "کل",
+ "▁metodo",
+ "▁منزل",
+ "▁حفظ",
+ "يون",
+ "ولو",
+ "2002",
+ "▁اللہ",
+ "ڪن",
+ "حدث",
+ "▁وسلم",
+ "اب",
+ "▁svojem",
+ "▁مسجد",
+ "ئي",
+ "▁znanja",
+ "اد",
+ "▁پیدا",
+ "اس",
+ "عون",
+ "▁stik",
+ "ومن",
+ "▁’’",
+ "▁št",
+ "▁زمان",
+ "he",
+ "▁قبائل",
+ "ال",
+ "با",
+ "ان",
+ "▁عادت",
+ "▁هئا",
+ "▁بيت",
+ "▁lokal",
+ "▁be",
+ "▁Kiva",
+ "▁واپسی",
+ "▁dok",
+ "▁zemlju",
+ "▁کار",
+ "ؤں",
+ "▁سختی",
+ "▁طیب",
+ "▁slo",
+ "بل",
+ "نہیں",
+ "بن",
+ "▁آس",
+ "当初",
+ "▁گرو",
+ "im",
+ "▁بین",
+ "▁آن",
+ "▁آم",
+ "▁dos",
+ "▁ci",
+ "▁akumul",
+ "▁oblika",
+ "zimi",
+ "▁محمود",
+ "改",
+ "zima",
+ "je",
+ "ji",
+ "▁do",
+ "▁ابن",
+ "▁ويو",
+ "کی",
+ "▁سفر",
+ "تز",
+ "▁دیتی",
+ "▁بزرگ",
+ "کار",
+ "ju",
+ "▁اطمینان",
+ "▁de",
+ "▁آپ",
+ "tari",
+ "▁کا",
+ "لفت",
+ "ka",
+ "گا",
+ "▁dy",
+ "ائي",
+ "ته",
+ "▁ٿيون",
+ "▁کان",
+ "▁کش",
+ "には",
+ "صلى",
+ "▁کر",
+ "▁en",
+ "ثر",
+ "▁بنی",
+ "▁کد",
+ "▁فرمایا",
+ "اؤں",
+ "成長",
+ "ئے",
+ "▁لقب",
+ "▁ڳالھ",
+ "会社",
+ "▁هئي",
+ "▁fur",
+ "اں",
+ "la",
+ "le",
+ "uru",
+ "جا",
+ "li",
+ "▁صلى",
+ "ثي",
+ "▁",
+ "lo",
+ "▁nije",
+ "جر",
+ "▁تعبير",
+ "جز",
+ "▁اگر",
+ "ا۔",
+ "▁دریافت",
+ "創業",
+ "▁کئے",
+ "ma",
+ "▁Kao",
+ "▁Men",
+ "▁konstrukcij",
+ "AMO",
+ "بی",
+ "mu",
+ "▁ممتاز",
+ "▁سڄو",
+ "kron",
+ "ne",
+ "▁سياست",
+ "حن",
+ "خا",
+ "▁men",
+ "krov",
+ "▁سڄي",
+ "▁رهيا",
+ "▁mei",
+ "▁سالم",
+ "▁سالن",
+ "no",
+ "▁عليه",
+ "▁بیان",
+ "▁گمراہ",
+ "▁سرفراز",
+ "▁مال",
+ "▁ٻنهي",
+ "nu",
+ "▁مان",
+ "▁رفع",
+ "▁هجر",
+ "▁اختلاف",
+ "of",
+ "حافظ",
+ "▁سنا",
+ "▁جہاد",
+ "▁društva",
+ "ائی",
+ "نون",
+ "om",
+ "▁osjeća",
+ "▁وڏو",
+ "irano",
+ "ئين",
+ "▁زيارت",
+ "irana",
+ "مار",
+ "دو",
+ "▁طريق",
+ "▁ar",
+ "▁poput",
+ "▁کے",
+ "▁کی",
+ "▁jo",
+ "،",
+ "▁gli",
+ "▁کرتے",
+ "▁koje",
+ "▁تم",
+ "▁تو",
+ "▁ki",
+ "▁ته",
+ "ؓ",
+ "▁گا",
+ "lā",
+ "جہ",
+ "را",
+ "iš",
+ "▁دیکھ",
+ "رج",
+ "مام",
+ "رح",
+ "رخ",
+ "▁تع",
+ "▁vje",
+ "آ",
+ "▁između",
+ "دھی",
+ "ا",
+ "ب",
+ "ت",
+ "▁تي",
+ "ج",
+ "▁koja",
+ "ح",
+ "▁اک",
+ "▁جان",
+ "د",
+ "▁فرم",
+ "ذ",
+ "▁جب",
+ "ر",
+ "▁جا",
+ "▁pojedin",
+ "ز",
+ "olo",
+ "س",
+ "▁گه",
+ "ش",
+ "▁حضور",
+ "ض",
+ "▁گو",
+ "▁Verde",
+ "▁غالب",
+ "ري",
+ "ع",
+ "▁گم",
+ "ڪنھن",
+ "▁گل",
+ "لوب",
+ "▁يزيد",
+ "▁فري",
+ "ndro",
+ "▁خدا",
+ "▁اے",
+ "ف",
+ "ق",
+ "ru",
+ "▁nepo",
+ "ل",
+ "م",
+ "ن",
+ "ه",
+ "▁dizajn",
+ "و",
+ "ي",
+ "▁جر",
+ "ٌ",
+ "▁جائے",
+ "ٍ",
+ "long",
+ "َ",
+ "ُ",
+ "▁جو",
+ "ِ",
+ "ّ",
+ "se",
+ "▁جي",
+ "ْ",
+ "▁جن",
+ "ٖ",
+ "▁بہ",
+ "sk",
+ "▁Tim",
+ "▁غیر",
+ "▁lang",
+ "▁kamen",
+ "▁my",
+ "▁ہوجائیں",
+ "ارا",
+ "▁حس",
+ "▁بخاری",
+ "▁ہیں۔",
+ "▁قابل",
+ "ٰ",
+ "te",
+ "دہ",
+ "سن",
+ "年",
+ "ادي",
+ "▁na",
+ "stan",
+ "ٹ",
+ "ٺ",
+ "▁حق",
+ "پ",
+ "▁الآ",
+ "دے",
+ "▁fo",
+ "▁struktur",
+ "ڇ",
+ "▁کو",
+ "▁الا",
+ "▁ممنوع",
+ "ڍ",
+ "شق",
+ "▁کي",
+ "▁ڪن",
+ "▁بھیج",
+ "▁تمہیں",
+ "dali",
+ "عطاء",
+ "▁Gra",
+ "صح",
+ "un",
+ "ڙ",
+ "▁gr",
+ "▁اس",
+ "▁از",
+ "▁ار",
+ "قول",
+ "ک",
+ "▁اح",
+ "ve",
+ "▁اب",
+ "▁ٻيهر",
+ "▁ام",
+ "▁vodo",
+ "▁ال",
+ "▁فضا",
+ "▁مذکور",
+ "▁klimat",
+ "▁تقوی",
+ "ڻ",
+ "ھ",
+ "▁ڪيائين",
+ "ہ",
+ "رے",
+ "▁hladno",
+ "ۃ",
+ "▁بد",
+ "▁بہتر",
+ "▁بر",
+ "روا",
+ "ی",
+ "روج",
+ "▁با",
+ "▁ان",
+ "▁بات",
+ "▁او",
+ "▁بن",
+ "ے",
+ "ûn",
+ "۔",
+ "▁بار",
+ "▁باس",
+ "dane",
+ "▁الق",
+ "▁najpoznatij",
+ "▁الل",
+ "▁الم",
+ "▁Vrh",
+ "▁is",
+ "oblikovan",
+ "▁in",
+ "▁الطب",
+ "ڻي",
+ "▁je",
+ "ادی",
+ "▁کہ",
+ "へと",
+ "▁صفات",
+ "▁غنی",
+ "▁nekoliko",
+ "▁کڻ",
+ "▁معاف",
+ "سے",
+ "変更",
+ "▁sa",
+ "▁سرانجام",
+ "▁فتح",
+ "月",
+ "▁vremena",
+ "عب",
+ "▁کڻي",
+ "عت",
+ "▁سر",
+ "▁دور",
+ "▁ست",
+ "عر",
+ "▁اسی",
+ "▁سب",
+ "▁se",
+ "▁protek",
+ "本",
+ "▁su",
+ "jedi",
+ "▁40",
+ "ھر",
+ "国際",
+ "▁سو",
+ "▁te",
+ "▁ساتھ",
+ "▁tink",
+ "ھل",
+ "oksen",
+ "غو",
+ "▁ڏنو",
+ "ں۔",
+ "▁شن",
+ "علامه",
+ "▁ži",
+ "▁va",
+ "حمد",
+ "ija",
+ "▁محمد",
+ "▁سڀ",
+ "حضرت",
+ "ije",
+ "▁دون",
+ "▁ڏنا",
+ "▁دکھا",
+ "▁koe",
+ "▁حلق",
+ "▁سڏ",
+ "▁مشرف",
+ "ٹے",
+ "▁خواہش",
+ "kom",
+ "▁ili",
+ "▁تک",
+ "▁ima",
+ "رائي",
+ "صحاب",
+ "▁of",
+ "▁تہ",
+ "▁ob",
+ "▁نہیں",
+ "▁od",
+ "▁خل",
+ "▁جنهن",
+ "▁Mesa",
+ "▁gradi",
+ "▁قائم",
+ "▁رکھا",
+ "▁دين",
+ "اعات",
+ "▁آواز",
+ "izaci",
+ "▁اٹھا",
+ "▁دل",
+ "ima",
+ "▁danas",
+ "▁گھ",
+ "▁گهر",
+ "▁broja",
+ "▁رکھنے",
+ "▁حکمت",
+ "▁po",
+ "▁قبول",
+ "ٽڪ",
+ "▁پيء",
+ "▁مجتمع",
+ "▁اعمال",
+ "ine",
+ "FIC",
+ "▁احسان",
+ "▁حین",
+ "gje",
+ "▁18",
+ "▁ہوئی",
+ "▁کہا",
+ "▁قبیل",
+ "▁ro",
+ "▁دی۔",
+ "▁civilizaci",
+ "▁teori",
+ "めた",
+ "▁okrug",
+ "▁današnji",
+ "▁گذري",
+ "▁ہوئے",
+ "ega",
+ "▁تمام"
+ ],
+ "scores": [
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ -6.610896110534668,
+ -11.903949737548828,
+ -6.411019802093506,
+ -13.111821174621582,
+ -12.475632667541504,
+ -8.94989013671875,
+ -8.913808822631836,
+ -12.612136840820312,
+ -13.197681427001953,
+ -14.200822830200195,
+ -6.379403591156006,
+ -12.10725212097168,
+ -11.451247215270996,
+ -12.569819450378418,
+ -6.61658239364624,
+ -12.716913223266602,
+ -12.647109031677246,
+ -6.345553398132324,
+ -7.722129821777344,
+ -13.328119277954102,
+ -5.9974517822265625,
+ -13.542387008666992,
+ -11.525911331176758,
+ -9.303495407104492,
+ -13.15868091583252,
+ -3.4635426998138428,
+ -3.625642776489258,
+ -12.082132339477539,
+ -11.200728416442871,
+ -8.533885955810547,
+ -9.478791236877441,
+ -8.830430030822754,
+ -9.85542106628418,
+ -5.629745960235596,
+ -10000.0,
+ -11.07493782043457,
+ -10.675272941589355,
+ -14.053406715393066,
+ -12.350106239318848,
+ -13.201828002929688,
+ -15.362364768981934,
+ -14.316963195800781,
+ -11.72597599029541,
+ -10.451481819152832,
+ -10.200002670288086,
+ -12.970951080322266,
+ -10.799960136413574,
+ -9.750066757202148,
+ -14.09317684173584,
+ -13.132211685180664,
+ -12.164549827575684,
+ -11.790772438049316,
+ -11.185127258300781,
+ -11.52169418334961,
+ -10.283937454223633,
+ -5.5477118492126465,
+ -10.650121688842773,
+ -13.610538482666016,
+ -8.289443016052246,
+ -10.517338752746582,
+ -10000.0,
+ -5.701941967010498,
+ -10.288777351379395,
+ -7.932966709136963,
+ -7.701241970062256,
+ -10.9612398147583,
+ -7.4715776443481445,
+ -8.438796997070312,
+ -7.762022495269775,
+ -13.653663635253906,
+ -6.647110939025879,
+ -13.096002578735352,
+ -6.093497276306152,
+ -7.835560321807861,
+ -13.766554832458496,
+ -5.072621822357178,
+ -6.071900844573975,
+ -10.290907859802246,
+ -11.627830505371094,
+ -8.404854774475098,
+ -11.820650100708008,
+ -11.6625394821167,
+ -12.946660041809082,
+ -11.946572303771973,
+ -13.20298957824707,
+ -12.11659049987793,
+ -9.643321990966797,
+ -12.949349403381348,
+ -11.78995132446289,
+ -10.989119529724121,
+ -8.787092208862305,
+ -12.648849487304688,
+ -10.379737854003906,
+ -13.063958168029785,
+ -11.535991668701172,
+ -13.839150428771973,
+ -8.22523021697998,
+ -13.274272918701172,
+ -11.137674331665039,
+ -10.805622100830078,
+ -12.990604400634766,
+ -14.285995483398438,
+ -13.078483581542969,
+ -12.852004051208496,
+ -11.508638381958008,
+ -12.764389991760254,
+ -13.693453788757324,
+ -9.525500297546387,
+ -13.369109153747559,
+ -10.901957511901855,
+ -12.365242004394531,
+ -12.302881240844727,
+ -12.062744140625,
+ -9.150372505187988,
+ -10.726777076721191,
+ -12.626052856445312,
+ -12.744816780090332,
+ -11.537252426147461,
+ -10.271102905273438,
+ -13.577858924865723,
+ -12.193032264709473,
+ -9.33310604095459,
+ -9.089756965637207,
+ -10.834887504577637,
+ -13.551883697509766,
+ -10.807448387145996,
+ -12.546935081481934,
+ -10.950186729431152,
+ -11.474028587341309,
+ -8.803434371948242,
+ -9.171648025512695,
+ -10.806365966796875,
+ -10.984315872192383,
+ -12.26717758178711,
+ -11.871655464172363,
+ -13.023716926574707,
+ -13.473764419555664,
+ -13.253439903259277,
+ -10.311766624450684,
+ -10.744394302368164,
+ -12.47635269165039,
+ -11.38111400604248,
+ -11.568384170532227,
+ -10000.0,
+ -10.497817039489746,
+ -10.765369415283203,
+ -11.620940208435059,
+ -8.651301383972168,
+ -12.216012001037598,
+ -11.396681785583496,
+ -10.353537559509277,
+ -9.594635963439941,
+ -12.703508377075195,
+ -10.891910552978516,
+ -9.981459617614746,
+ -9.07016372680664,
+ -13.325227737426758,
+ -9.9458646774292,
+ -7.174049377441406,
+ -10.452103614807129,
+ -13.543808937072754,
+ -10000.0,
+ -7.37307596206665,
+ -10000.0,
+ -10.899341583251953,
+ -11.181215286254883,
+ -9.23928451538086,
+ -13.12946605682373,
+ -10.758359909057617,
+ -14.190896987915039,
+ -10.881155967712402,
+ -11.799145698547363,
+ -13.552739143371582,
+ -12.35738754272461,
+ -10.790441513061523,
+ -11.642875671386719,
+ -11.203944206237793,
+ -11.164298057556152,
+ -10.391376495361328,
+ -10.602131843566895,
+ -13.296408653259277,
+ -12.801287651062012,
+ -13.29976749420166,
+ -11.127630233764648,
+ -9.635873794555664,
+ -13.025283813476562,
+ -11.522773742675781,
+ -12.629497528076172,
+ -11.675955772399902,
+ -10.100441932678223,
+ -9.490818977355957,
+ -12.654541015625,
+ -11.304871559143066,
+ -8.778549194335938,
+ -12.341999053955078,
+ -12.693137168884277,
+ -12.534963607788086,
+ -12.560155868530273,
+ -12.807035446166992,
+ -14.408479690551758,
+ -10.91116714477539,
+ -13.606574058532715,
+ -13.693682670593262,
+ -11.006491661071777,
+ -13.511610984802246,
+ -10.69263744354248,
+ -10000.0,
+ -10.88202953338623,
+ -9.945484161376953,
+ -11.082690238952637,
+ -13.169434547424316,
+ -10.761433601379395,
+ -12.539514541625977,
+ -9.714284896850586,
+ -10.531815528869629,
+ -11.411252975463867,
+ -12.159621238708496,
+ -13.439103126525879,
+ -12.159096717834473,
+ -10.569905281066895,
+ -11.485320091247559,
+ -11.685418128967285,
+ -11.131010055541992,
+ -13.32590389251709,
+ -12.843395233154297,
+ -11.425615310668945,
+ -9.176533699035645,
+ -10.86955738067627,
+ -11.128808975219727,
+ -13.251603126525879,
+ -12.20699405670166,
+ -11.551314353942871,
+ -10.626527786254883,
+ -11.38455581665039,
+ -11.614538192749023,
+ -14.187246322631836,
+ -12.982544898986816,
+ -11.797250747680664,
+ -10000.0,
+ -9.858101844787598,
+ -12.285886764526367,
+ -12.553010940551758,
+ -13.370101928710938,
+ -10.696676254272461,
+ -12.74817180633545,
+ -12.134454727172852,
+ -11.036406517028809,
+ -8.165318489074707,
+ -13.548136711120605,
+ -9.375162124633789,
+ -13.292466163635254,
+ -9.353793144226074,
+ -11.82857894897461,
+ -11.406195640563965,
+ -13.611187934875488,
+ -12.325207710266113,
+ -13.719786643981934,
+ -11.11467170715332,
+ -13.631454467773438,
+ -9.855673789978027,
+ -10.353020668029785,
+ -13.05349349975586,
+ -13.028356552124023,
+ -13.965872764587402,
+ -12.046480178833008,
+ -10000.0,
+ -9.703826904296875,
+ -9.335156440734863,
+ -12.247420310974121,
+ -13.311925888061523,
+ -9.245621681213379,
+ -9.983458518981934,
+ -10.990195274353027,
+ -12.795949935913086,
+ -13.135777473449707,
+ -13.378888130187988,
+ -11.403210639953613,
+ -13.6084566116333,
+ -12.680025100708008,
+ -10.440314292907715,
+ -12.222440719604492,
+ -11.42122745513916,
+ -11.383726119995117,
+ -12.9137601852417,
+ -14.476696968078613,
+ -13.467201232910156,
+ -12.135478973388672,
+ -12.71440601348877,
+ -12.663864135742188,
+ -11.900956153869629,
+ -13.902737617492676,
+ -11.216065406799316,
+ -10.742656707763672,
+ -10000.0,
+ -13.595476150512695,
+ -12.485321044921875,
+ -13.868348121643066,
+ -13.327157020568848,
+ -11.195040702819824,
+ -11.418901443481445,
+ -12.40562915802002,
+ -13.329121589660645,
+ -13.79185962677002,
+ -13.747245788574219,
+ -12.834506034851074,
+ -14.360300064086914,
+ -11.659099578857422,
+ -12.826003074645996,
+ -13.300061225891113,
+ -13.438057899475098,
+ -10.775205612182617,
+ -11.984052658081055,
+ -11.038277626037598,
+ -9.496801376342773,
+ -13.454340934753418,
+ -12.906173706054688,
+ -10.528743743896484,
+ -9.034796714782715,
+ -9.208064079284668,
+ -13.150303840637207,
+ -11.386055946350098,
+ -10.825066566467285,
+ -9.702229499816895,
+ -13.07643985748291,
+ -13.973017692565918,
+ -10.952235221862793,
+ -13.427935600280762,
+ -11.593998908996582,
+ -11.631296157836914,
+ -12.894272804260254,
+ -12.372183799743652,
+ -12.643047332763672,
+ -13.63158893585205,
+ -12.459877967834473,
+ -14.055868148803711,
+ -9.961138725280762,
+ -10.343199729919434,
+ -11.893840789794922,
+ -10.064606666564941,
+ -12.285531997680664,
+ -11.363245010375977,
+ -13.014981269836426,
+ -12.707101821899414,
+ -11.332316398620605,
+ -11.302778244018555,
+ -13.055937767028809,
+ -13.674442291259766,
+ -11.654837608337402,
+ -12.616765975952148,
+ -12.207862854003906,
+ -11.831457138061523,
+ -13.68111801147461,
+ -12.976818084716797,
+ -14.430807113647461,
+ -12.421124458312988,
+ -11.50658893585205,
+ -11.110703468322754,
+ -10.588051795959473,
+ -11.868654251098633,
+ -12.110957145690918,
+ -13.921645164489746,
+ -13.405242919921875,
+ -13.995997428894043,
+ -14.098799705505371,
+ -12.004497528076172,
+ -11.506338119506836,
+ -12.163915634155273,
+ -13.178263664245605,
+ -14.001510620117188,
+ -12.172317504882812,
+ -13.293499946594238,
+ -10000.0,
+ -10000.0,
+ -11.053098678588867,
+ -11.700507164001465,
+ -9.89022159576416,
+ -13.137804985046387,
+ -11.584470748901367,
+ -11.47780704498291,
+ -12.676255226135254,
+ -13.47961711883545,
+ -13.04322338104248,
+ -12.198275566101074,
+ -13.25001335144043,
+ -12.475261688232422,
+ -12.113178253173828,
+ -13.952543258666992,
+ -10.791595458984375,
+ -12.600780487060547,
+ -12.942652702331543,
+ -11.553879737854004,
+ -10.698843002319336,
+ -12.703505516052246,
+ -13.684463500976562,
+ -12.352499961853027,
+ -13.843332290649414,
+ -10.838998794555664,
+ -10.505772590637207,
+ -9.910398483276367,
+ -10000.0,
+ -13.492959976196289,
+ -12.739365577697754,
+ -12.663825035095215,
+ -11.77187728881836,
+ -12.291872024536133,
+ -9.96491813659668,
+ -11.795421600341797,
+ -8.20328426361084,
+ -5.926211357116699,
+ -6.1764984130859375,
+ -12.557028770446777,
+ -13.187960624694824,
+ -13.275311470031738,
+ -9.935545921325684,
+ -12.842405319213867,
+ -8.376090049743652,
+ -12.797646522521973,
+ -10.724736213684082,
+ -7.551031589508057,
+ -12.609972953796387,
+ -10.906079292297363,
+ -8.062232971191406,
+ -12.41627025604248,
+ -14.217342376708984,
+ -13.32412338256836,
+ -7.829031944274902,
+ -11.670573234558105,
+ -13.152725219726562,
+ -13.748356819152832,
+ -8.923832893371582,
+ -13.297384262084961,
+ -13.406578063964844,
+ -12.794132232666016,
+ -12.182308197021484,
+ -12.669015884399414,
+ -13.825421333312988,
+ -8.497254371643066,
+ -13.710942268371582,
+ -10.821403503417969,
+ -12.96695327758789,
+ -13.50233268737793,
+ -14.252979278564453,
+ -12.690325736999512,
+ -12.644253730773926,
+ -11.217681884765625,
+ -5.530364990234375,
+ -11.728997230529785,
+ -14.01970100402832,
+ -14.183956146240234,
+ -6.582267761230469,
+ -9.365259170532227,
+ -6.0461626052856445,
+ -7.482025623321533,
+ -7.319528579711914,
+ -13.754130363464355,
+ -12.329744338989258,
+ -14.684525489807129,
+ -7.452380657196045,
+ -12.367213249206543,
+ -13.013487815856934,
+ -10.484649658203125,
+ -11.331403732299805,
+ -13.430648803710938,
+ -11.846324920654297,
+ -11.766498565673828,
+ -11.94919490814209,
+ -13.64667797088623,
+ -12.330714225769043,
+ -12.643916130065918,
+ -12.118013381958008,
+ -12.920206069946289,
+ -9.852779388427734,
+ -13.62667465209961,
+ -12.794713020324707,
+ -13.23983097076416,
+ -9.644025802612305,
+ -13.41153335571289,
+ -10.862459182739258,
+ -13.595255851745605,
+ -12.811727523803711,
+ -12.114456176757812,
+ -12.617325782775879,
+ -12.534378051757812,
+ -12.435154914855957,
+ -11.79420280456543,
+ -13.141073226928711,
+ -10.228925704956055,
+ -12.648173332214355,
+ -10.5259370803833,
+ -13.075540542602539,
+ -12.833207130432129,
+ -12.930810928344727,
+ -11.625775337219238,
+ -8.988334655761719,
+ -11.492377281188965,
+ -14.40893268585205,
+ -12.106353759765625,
+ -13.25969409942627,
+ -13.190732955932617,
+ -14.228679656982422,
+ -13.389674186706543,
+ -11.702837944030762,
+ -12.21057415008545,
+ -13.743621826171875,
+ -14.52221393585205,
+ -13.440570831298828,
+ -12.3108491897583,
+ -13.243945121765137,
+ -13.412277221679688,
+ -11.340847969055176,
+ -9.651451110839844,
+ -11.63448429107666,
+ -14.10894775390625,
+ -13.651695251464844,
+ -13.614228248596191,
+ -12.83806037902832,
+ -13.661396026611328,
+ -9.87491512298584,
+ -9.8951416015625,
+ -11.809096336364746,
+ -10000.0,
+ -11.665786743164062,
+ -9.869390487670898,
+ -13.02005672454834,
+ -13.772218704223633,
+ -12.269754409790039,
+ -10000.0,
+ -10.893101692199707,
+ -14.356070518493652,
+ -13.704068183898926,
+ -13.16357707977295,
+ -13.131183624267578,
+ -11.631052017211914,
+ -11.685710906982422,
+ -8.907776832580566,
+ -9.99026870727539,
+ -14.045997619628906,
+ -12.187337875366211,
+ -13.198140144348145,
+ -11.964822769165039,
+ -12.250166893005371,
+ -14.266410827636719,
+ -11.802629470825195,
+ -11.381916046142578,
+ -11.162945747375488,
+ -12.44157886505127,
+ -9.786359786987305,
+ -10000.0,
+ -11.233309745788574,
+ -11.009201049804688,
+ -12.883721351623535,
+ -11.877254486083984,
+ -12.20182991027832,
+ -14.277528762817383,
+ -13.7249755859375,
+ -12.742781639099121,
+ -12.661029815673828,
+ -12.547115325927734,
+ -10.75460147857666,
+ -12.907571792602539,
+ -12.363632202148438,
+ -11.848713874816895,
+ -14.31727123260498,
+ -14.046844482421875,
+ -12.718457221984863,
+ -13.913930892944336,
+ -13.322484016418457,
+ -12.36288833618164,
+ -11.979717254638672,
+ -12.366744041442871,
+ -13.646872520446777,
+ -13.255087852478027,
+ -12.110769271850586,
+ -8.450657844543457,
+ -12.003588676452637,
+ -8.075675010681152,
+ -13.522724151611328,
+ -13.485895156860352,
+ -13.05333423614502,
+ -13.399734497070312,
+ -11.368695259094238,
+ -13.210000038146973,
+ -13.97340202331543,
+ -11.725092887878418,
+ -13.334667205810547,
+ -10.739959716796875,
+ -13.98511791229248,
+ -13.574196815490723,
+ -12.201776504516602,
+ -12.244017601013184,
+ -11.784577369689941,
+ -11.283102035522461,
+ -6.465692520141602,
+ -13.550567626953125,
+ -10000.0,
+ -11.969606399536133,
+ -7.697822093963623,
+ -14.338610649108887,
+ -13.137377738952637,
+ -12.166990280151367,
+ -11.836442947387695,
+ -13.03665542602539,
+ -10000.0,
+ -12.438132286071777,
+ -11.183541297912598,
+ -12.041357040405273,
+ -12.614006996154785,
+ -11.056611061096191,
+ -12.743069648742676,
+ -12.888111114501953,
+ -11.329586029052734,
+ -10.89394760131836,
+ -13.152234077453613,
+ -12.330127716064453,
+ -11.13021469116211,
+ -12.93645191192627,
+ -11.057968139648438,
+ -10000.0,
+ -10.721052169799805,
+ -13.35482406616211,
+ -12.192888259887695,
+ -13.680505752563477,
+ -11.670418739318848,
+ -11.871618270874023,
+ -11.242685317993164,
+ -9.557723999023438,
+ -10000.0,
+ -10000.0,
+ -11.125853538513184,
+ -9.22323226928711,
+ -13.24915599822998,
+ -11.91252613067627,
+ -12.721294403076172,
+ -11.174097061157227,
+ -7.990510940551758,
+ -13.991429328918457,
+ -13.859502792358398,
+ -11.520356178283691,
+ -13.971871376037598,
+ -10.134190559387207,
+ -13.07124137878418,
+ -13.591009140014648,
+ -10000.0,
+ -12.195642471313477,
+ -11.237064361572266,
+ -14.172703742980957,
+ -12.285969734191895,
+ -12.486908912658691,
+ -13.344427108764648,
+ -14.147533416748047,
+ -8.739598274230957,
+ -10.91167163848877,
+ -9.65263843536377,
+ -12.717270851135254,
+ -9.05600643157959,
+ -9.518941879272461,
+ -13.623188972473145,
+ -13.740755081176758,
+ -12.843908309936523,
+ -12.340595245361328,
+ -11.486748695373535,
+ -12.710258483886719,
+ -8.179301261901855,
+ -9.062299728393555,
+ -6.97949743270874,
+ -11.858112335205078,
+ -11.286624908447266,
+ -11.264288902282715,
+ -11.513409614562988,
+ -12.92937183380127,
+ -13.888775825500488,
+ -11.602699279785156,
+ -11.45335578918457,
+ -8.737150192260742,
+ -13.517394065856934,
+ -5.306643009185791,
+ -10.628350257873535,
+ -11.167513847351074,
+ -8.796040534973145,
+ -10000.0,
+ -7.871254920959473,
+ -12.365166664123535,
+ -10.174576759338379,
+ -11.040783882141113,
+ -10.433000564575195,
+ -13.301560401916504,
+ -10.412057876586914,
+ -12.430901527404785,
+ -10.438301086425781,
+ -12.994340896606445,
+ -9.674080848693848,
+ -6.31805419921875,
+ -10000.0,
+ -13.583410263061523,
+ -12.609077453613281,
+ -12.849180221557617,
+ -13.826027870178223,
+ -12.031959533691406,
+ -11.845420837402344,
+ -13.824118614196777,
+ -14.176135063171387,
+ -11.988388061523438,
+ -11.812614440917969,
+ -11.836989402770996,
+ -11.457304000854492,
+ -7.770702362060547,
+ -7.727717399597168,
+ -11.643401145935059,
+ -11.470467567443848,
+ -7.818939208984375,
+ -11.843179702758789,
+ -13.107500076293945,
+ -3.9299705028533936,
+ -8.545232772827148,
+ -10.604230880737305,
+ -11.725444793701172,
+ -14.248205184936523,
+ -12.327702522277832,
+ -10.582293510437012,
+ -13.244439125061035,
+ -12.059713363647461,
+ -12.921284675598145,
+ -12.883295059204102,
+ -8.039029121398926,
+ -12.784309387207031,
+ -9.565606117248535,
+ -13.330506324768066,
+ -13.591753005981445,
+ -11.633308410644531,
+ -8.91528034210205,
+ -13.258749961853027,
+ -14.396084785461426,
+ -12.985039710998535,
+ -7.417489528656006,
+ -13.149593353271484,
+ -12.515260696411133,
+ -12.587913513183594,
+ -8.725703239440918,
+ -12.955209732055664,
+ -13.303566932678223,
+ -12.77481460571289,
+ -10.94013786315918,
+ -12.95765495300293,
+ -12.781828880310059,
+ -7.8542914390563965,
+ -10.790460586547852,
+ -11.324527740478516,
+ -10000.0,
+ -14.37807559967041,
+ -11.92667007446289,
+ -13.613455772399902,
+ -8.873832702636719,
+ -10.859443664550781,
+ -10000.0,
+ -13.676170349121094,
+ -10000.0,
+ -10.775018692016602,
+ -12.95517349243164,
+ -13.232227325439453,
+ -14.387094497680664,
+ -12.78573989868164,
+ -11.10414981842041,
+ -12.770772933959961,
+ -8.37712574005127,
+ -13.284975051879883,
+ -12.99605655670166,
+ -12.795123100280762,
+ -12.59602165222168,
+ -14.046062469482422,
+ -12.717855453491211,
+ -11.992505073547363,
+ -11.261098861694336,
+ -11.927038192749023,
+ -7.993113040924072,
+ -12.678472518920898,
+ -8.111339569091797,
+ -8.321968078613281,
+ -9.167539596557617,
+ -6.938859939575195,
+ -10.086030006408691,
+ -11.12663459777832,
+ -10.549439430236816,
+ -10.726285934448242,
+ -9.660466194152832,
+ -8.06203842163086,
+ -9.214642524719238,
+ -13.663848876953125,
+ -11.201567649841309,
+ -11.692606925964355,
+ -10000.0,
+ -11.061088562011719,
+ -11.801623344421387,
+ -12.245379447937012,
+ -12.138701438903809,
+ -12.882545471191406,
+ -12.515228271484375,
+ -13.013315200805664,
+ -10000.0,
+ -12.440690994262695,
+ -11.182541847229004,
+ -12.293285369873047,
+ -13.289390563964844,
+ -8.25012493133545,
+ -9.714176177978516,
+ -8.54870319366455,
+ -10.123932838439941,
+ -10.123574256896973,
+ -10.787864685058594,
+ -10.535843849182129,
+ -12.084434509277344,
+ -11.367830276489258,
+ -9.272168159484863,
+ -12.730428695678711,
+ -10.77696418762207,
+ -11.299437522888184,
+ -9.2794771194458,
+ -10.121893882751465,
+ -12.715132713317871,
+ -9.817319869995117,
+ -11.207874298095703,
+ -9.38442325592041,
+ -12.960518836975098,
+ -9.32898998260498,
+ -11.51174259185791,
+ -10.884286880493164,
+ -11.72599983215332,
+ -13.018866539001465,
+ -13.688644409179688,
+ -11.104406356811523,
+ -9.628833770751953,
+ -10000.0,
+ -14.26093864440918,
+ -11.645624160766602,
+ -13.037396430969238,
+ -13.70888900756836,
+ -14.17890739440918,
+ -12.572925567626953,
+ -11.417001724243164,
+ -11.92243480682373,
+ -10000.0,
+ -10000.0,
+ -9.334487915039062,
+ -11.304604530334473,
+ -8.963071823120117,
+ -8.566967010498047,
+ -8.42164134979248,
+ -7.929381370544434,
+ -12.258378028869629,
+ -8.675025939941406,
+ -7.946563243865967,
+ -12.063398361206055,
+ -11.749732971191406,
+ -10000.0,
+ -10000.0,
+ -11.486349105834961,
+ -8.294340133666992,
+ -8.934319496154785,
+ -9.14141845703125,
+ -8.774731636047363,
+ -9.606856346130371,
+ -7.985258102416992,
+ -8.77881145477295,
+ -9.519185066223145,
+ -11.011818885803223,
+ -10000.0,
+ -12.663806915283203,
+ -9.498204231262207,
+ -11.668294906616211,
+ -11.114726066589355,
+ -10.064451217651367,
+ -12.4163236618042,
+ -9.18289566040039,
+ -14.760283470153809,
+ -12.412688255310059,
+ -12.485615730285645,
+ -13.954992294311523,
+ -10.590344429016113,
+ -11.5427827835083,
+ -10.981088638305664,
+ -7.230983257293701,
+ -12.179085731506348,
+ -11.862399101257324,
+ -8.748784065246582,
+ -12.161140441894531,
+ -6.327768802642822,
+ -10.773768424987793,
+ -11.07607364654541,
+ -12.150201797485352,
+ -11.026751518249512,
+ -10.101223945617676,
+ -12.312088966369629,
+ -13.726814270019531,
+ -10.998577117919922,
+ -11.658036231994629,
+ -12.724591255187988,
+ -8.90641975402832,
+ -10.587677001953125,
+ -13.232854843139648,
+ -12.673201560974121,
+ -12.671024322509766,
+ -9.579854965209961,
+ -12.255494117736816,
+ -13.195446968078613,
+ -13.792229652404785,
+ -12.136938095092773,
+ -14.033784866333008,
+ -11.097009658813477,
+ -12.227850914001465,
+ -8.381165504455566,
+ -11.749275207519531,
+ -10.788141250610352,
+ -9.176112174987793,
+ -8.276718139648438,
+ -12.19137954711914,
+ -12.501619338989258,
+ -10000.0,
+ -12.824344635009766,
+ -8.281817436218262,
+ -11.095662117004395,
+ -14.165250778198242,
+ -11.348094940185547,
+ -12.567456245422363,
+ -8.52457332611084,
+ -12.733758926391602,
+ -14.122416496276855,
+ -12.041360855102539,
+ -14.223989486694336,
+ -10.91444206237793,
+ -11.301746368408203,
+ -13.864544868469238,
+ -9.358236312866211,
+ -12.629053115844727,
+ -13.954301834106445,
+ -12.757906913757324,
+ -11.3294677734375,
+ -12.579774856567383,
+ -9.734641075134277,
+ -12.667106628417969,
+ -7.761864185333252,
+ -13.73751163482666,
+ -8.641522407531738,
+ -9.142242431640625,
+ -11.219501495361328,
+ -8.902569770812988,
+ -10.32934284210205,
+ -9.886985778808594,
+ -12.262642860412598,
+ -10.265408515930176,
+ -10.638322830200195,
+ -13.340587615966797,
+ -13.356618881225586,
+ -11.643696784973145,
+ -14.654583930969238,
+ -11.425148963928223,
+ -9.355377197265625,
+ -13.895018577575684,
+ -7.402246475219727,
+ -14.136250495910645,
+ -6.3201680183410645,
+ -13.139766693115234,
+ -12.429423332214355,
+ -6.986958980560303,
+ -12.735187530517578,
+ -9.379314422607422,
+ -13.72009563446045,
+ -14.089472770690918,
+ -13.748627662658691,
+ -11.978914260864258,
+ -13.91929817199707,
+ -13.818605422973633,
+ -12.800165176391602,
+ -12.482606887817383,
+ -7.0481696128845215,
+ -13.999007225036621,
+ -12.334272384643555,
+ -9.02311897277832,
+ -12.519035339355469,
+ -12.279437065124512,
+ -13.015851020812988,
+ -11.549497604370117,
+ -10.443224906921387,
+ -11.093907356262207,
+ -11.322037696838379,
+ -12.739632606506348,
+ -11.954368591308594,
+ -11.006121635437012,
+ -6.716159820556641,
+ -13.072667121887207,
+ -9.844562530517578,
+ -7.880402088165283,
+ -12.887127876281738,
+ -9.566628456115723,
+ -12.454107284545898,
+ -13.231634140014648,
+ -10.958243370056152,
+ -7.653661727905273,
+ -10.862187385559082,
+ -12.770365715026855,
+ -13.171697616577148,
+ -12.640562057495117,
+ -12.947507858276367,
+ -12.908676147460938,
+ -13.518932342529297,
+ -12.32068157196045,
+ -13.127158164978027,
+ -11.459029197692871,
+ -8.377157211303711,
+ -10000.0,
+ -10.775200843811035,
+ -10.465039253234863,
+ -12.271913528442383,
+ -14.012896537780762,
+ -11.834538459777832,
+ -11.865020751953125,
+ -13.912064552307129,
+ -13.423148155212402,
+ -12.969127655029297,
+ -13.150151252746582,
+ -13.349272727966309,
+ -13.358369827270508,
+ -13.805335998535156,
+ -10000.0,
+ -9.97810173034668,
+ -9.83073902130127,
+ -10.826997756958008,
+ -10.815749168395996,
+ -13.47970962524414,
+ -13.573468208312988,
+ -7.573562145233154,
+ -13.315520286560059,
+ -9.457472801208496,
+ -10.05649185180664,
+ -8.165127754211426,
+ -12.03433609008789,
+ -11.478641510009766,
+ -13.337766647338867,
+ -12.477649688720703,
+ -12.112797737121582,
+ -13.071025848388672,
+ -13.196009635925293,
+ -13.268590927124023,
+ -12.347124099731445,
+ -13.836188316345215,
+ -12.877021789550781,
+ -11.046356201171875,
+ -9.727120399475098,
+ -11.82292366027832,
+ -12.20386028289795,
+ -11.933242797851562,
+ -13.743108749389648,
+ -10000.0,
+ -13.26471996307373,
+ -7.864959716796875,
+ -12.188377380371094,
+ -13.456745147705078,
+ -13.93160629272461,
+ -10000.0,
+ -12.802282333374023,
+ -9.642523765563965,
+ -13.602763175964355,
+ -13.777410507202148,
+ -14.326563835144043,
+ -12.257325172424316,
+ -8.880353927612305,
+ -11.984357833862305,
+ -10.867341995239258,
+ -13.713247299194336,
+ -10.132527351379395,
+ -13.895491600036621,
+ -14.169499397277832,
+ -11.725127220153809,
+ -13.49624252319336,
+ -13.843846321105957,
+ -13.832304000854492,
+ -13.618553161621094,
+ -11.058784484863281,
+ -10.402983665466309,
+ -10.856165885925293
+ ]
+}
+
From 22d730815d0d7d3a485dc2e38d498bce353ee99f Mon Sep 17 00:00:00 2001
From: Tim Grein
Date: Wed, 8 May 2024 13:21:56 +0200
Subject: [PATCH 02/25] [Inference API] Remove unused class AzureOpenAiAccount
(#108356)
---
.../azureopenai/AzureOpenAiAccount.java | 40 -------------------
.../AzureOpenAiEmbeddingsRequest.java | 3 --
2 files changed, 43 deletions(-)
delete mode 100644 x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/azureopenai/AzureOpenAiAccount.java
diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/azureopenai/AzureOpenAiAccount.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/azureopenai/AzureOpenAiAccount.java
deleted file mode 100644
index db1f91cc751ee..0000000000000
--- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/azureopenai/AzureOpenAiAccount.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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; you may not use this file except in compliance with the Elastic License
- * 2.0.
- */
-
-package org.elasticsearch.xpack.inference.external.azureopenai;
-
-import org.elasticsearch.common.settings.SecureString;
-import org.elasticsearch.core.Nullable;
-import org.elasticsearch.xpack.inference.services.azureopenai.embeddings.AzureOpenAiEmbeddingsModel;
-
-import java.util.Objects;
-
-public record AzureOpenAiAccount(
- String resourceName,
- String deploymentId,
- String apiVersion,
- @Nullable SecureString apiKey,
- @Nullable SecureString entraId
-) {
-
- public AzureOpenAiAccount {
- Objects.requireNonNull(resourceName);
- Objects.requireNonNull(deploymentId);
- Objects.requireNonNull(apiVersion);
- Objects.requireNonNullElse(apiKey, entraId);
- }
-
- public static AzureOpenAiAccount fromModel(AzureOpenAiEmbeddingsModel model) {
- return new AzureOpenAiAccount(
- model.getServiceSettings().resourceName(),
- model.getServiceSettings().deploymentId(),
- model.getServiceSettings().apiVersion(),
- model.getSecretSettings().apiKey(),
- model.getSecretSettings().entraId()
- );
- }
-}
diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/azureopenai/AzureOpenAiEmbeddingsRequest.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/azureopenai/AzureOpenAiEmbeddingsRequest.java
index f60d0130a01b6..f20398fec0e57 100644
--- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/azureopenai/AzureOpenAiEmbeddingsRequest.java
+++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/azureopenai/AzureOpenAiEmbeddingsRequest.java
@@ -15,7 +15,6 @@
import org.elasticsearch.common.ValidationException;
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.xpack.inference.common.Truncator;
-import org.elasticsearch.xpack.inference.external.azureopenai.AzureOpenAiAccount;
import org.elasticsearch.xpack.inference.external.request.HttpRequest;
import org.elasticsearch.xpack.inference.external.request.Request;
import org.elasticsearch.xpack.inference.services.azureopenai.embeddings.AzureOpenAiEmbeddingsModel;
@@ -34,14 +33,12 @@ public class AzureOpenAiEmbeddingsRequest implements AzureOpenAiRequest {
"The request does not have any authentication methods set. One of [%s] or [%s] is required.";
private final Truncator truncator;
- private final AzureOpenAiAccount account;
private final Truncator.TruncationResult truncationResult;
private final URI uri;
private final AzureOpenAiEmbeddingsModel model;
public AzureOpenAiEmbeddingsRequest(Truncator truncator, Truncator.TruncationResult input, AzureOpenAiEmbeddingsModel model) {
this.truncator = Objects.requireNonNull(truncator);
- this.account = AzureOpenAiAccount.fromModel(model);
this.truncationResult = Objects.requireNonNull(input);
this.model = Objects.requireNonNull(model);
this.uri = model.getUri();
From 8864058f83bc485ce6c89a196e9d64b04e79b1cf Mon Sep 17 00:00:00 2001
From: Bogdan Pintea
Date: Wed, 8 May 2024 14:51:02 +0200
Subject: [PATCH 03/25] ESQL: Add more time span units (#108300)
This adds `nanosecond`, `microsecond` and `quarter` to the set of
supported time spans. It also adds a few standard and common
abbreviations to some existing ones.
---
docs/changelog/108300.yaml | 5 +++
docs/reference/esql/esql-syntax.asciidoc | 17 +++++-----
.../src/main/resources/date.csv-spec | 34 +++++++++++++++++++
.../xpack/esql/plugin/EsqlFeatures.java | 8 ++++-
.../esql/type/EsqlDataTypeConverter.java | 20 ++++++-----
.../xpack/esql/parser/ExpressionTests.java | 15 ++++++++
6 files changed, 81 insertions(+), 18 deletions(-)
create mode 100644 docs/changelog/108300.yaml
diff --git a/docs/changelog/108300.yaml b/docs/changelog/108300.yaml
new file mode 100644
index 0000000000000..c4d6e468113a4
--- /dev/null
+++ b/docs/changelog/108300.yaml
@@ -0,0 +1,5 @@
+pr: 108300
+summary: "ESQL: Add more time span units"
+area: ES|QL
+type: enhancement
+issues: []
diff --git a/docs/reference/esql/esql-syntax.asciidoc b/docs/reference/esql/esql-syntax.asciidoc
index c5d56ef15fdfd..c7f741d064310 100644
--- a/docs/reference/esql/esql-syntax.asciidoc
+++ b/docs/reference/esql/esql-syntax.asciidoc
@@ -160,14 +160,15 @@ Datetime intervals and timespans can be expressed using timespan literals.
Timespan literals are a combination of a number and a qualifier. These
qualifiers are supported:
-* `millisecond`/`milliseconds`
-* `second`/`seconds`
-* `minute`/`minutes`
-* `hour`/`hours`
-* `day`/`days`
-* `week`/`weeks`
-* `month`/`months`
-* `year`/`years`
+* `millisecond`/`milliseconds`/`ms`
+* `second`/`seconds`/`sec`/`s`
+* `minute`/`minutes`/`min`
+* `hour`/`hours`/`h`
+* `day`/`days`/`d`
+* `week`/`weeks`/`w`
+* `month`/`months`/`mo`
+* `quarter`/`quarters`/`q`
+* `year`/`years`/`yr`/`y`
Timespan literals are not whitespace sensitive. These expressions are all valid:
diff --git a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/date.csv-spec b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/date.csv-spec
index 721cff076aeaa..8d54288de552d 100644
--- a/x-pack/plugin/esql/qa/testFixtures/src/main/resources/date.csv-spec
+++ b/x-pack/plugin/esql/qa/testFixtures/src/main/resources/date.csv-spec
@@ -621,6 +621,40 @@ dt:datetime |plus_post:datetime |plus_pre:datetime
2100-01-01T01:01:01.001Z |null |null
;
+datePlusQuarter
+# "quarter" introduced in 8.15
+required_feature: esql.timespan_abbreviations
+row dt = to_dt("2100-01-01T01:01:01.000Z")
+| eval plusQuarter = dt + 2 quarters
+;
+
+dt:datetime | plusQuarter:datetime
+2100-01-01T01:01:01.000Z | 2100-07-01T01:01:01.000Z
+;
+
+datePlusAbbreviatedDurations
+# abbreviations introduced in 8.15
+required_feature: esql.timespan_abbreviations
+row dt = to_dt("2100-01-01T00:00:00.000Z")
+| eval plusDurations = dt + 1 h + 2 min + 2 sec + 1 s + 4 ms
+;
+
+dt:datetime | plusDurations:datetime
+2100-01-01T00:00:00.000Z | 2100-01-01T01:02:03.004Z
+;
+
+datePlusAbbreviatedPeriods
+# abbreviations introduced in 8.15
+required_feature: esql.timespan_abbreviations
+row dt = to_dt("2100-01-01T00:00:00.000Z")
+| eval plusDurations = dt + 0 yr + 1y + 2 q + 3 mo + 4 w + 3 d
+;
+
+dt:datetime | plusDurations:datetime
+2100-01-01T00:00:00.000Z | 2101-11-01T00:00:00.000Z
+;
+
+
dateMinusDuration
row dt = to_dt("2100-01-01T01:01:01.001Z")
| eval minus = dt - 1 hour - 1 minute - 1 second - 1 milliseconds;
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlFeatures.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlFeatures.java
index f6b534f7316df..059eec771efe8 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlFeatures.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/EsqlFeatures.java
@@ -136,6 +136,11 @@ public class EsqlFeatures implements FeatureSpecification {
*/
public static final NodeFeature METADATA_FIELDS = new NodeFeature("esql.metadata_fields");
+ /**
+ * Support for timespan units abbreviations
+ */
+ public static final NodeFeature TIMESPAN_ABBREVIATIONS = new NodeFeature("esql.timespan_abbreviations");
+
@Override
public Set getFeatures() {
return Set.of(
@@ -157,7 +162,8 @@ public Set getFeatures() {
MV_ORDERING_SORTED_ASCENDING,
METRICS_COUNTER_FIELDS,
STRING_LITERAL_AUTO_CASTING_EXTENDED,
- METADATA_FIELDS
+ METADATA_FIELDS,
+ TIMESPAN_ABBREVIATIONS
);
}
diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/type/EsqlDataTypeConverter.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/type/EsqlDataTypeConverter.java
index e4c7983d9a83a..e1360c67976ca 100644
--- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/type/EsqlDataTypeConverter.java
+++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/type/EsqlDataTypeConverter.java
@@ -234,18 +234,20 @@ public static DataType commonType(DataType left, DataType right) {
return DataTypeConverter.commonType(left, right);
}
+ // generally supporting abbreviations from https://en.wikipedia.org/wiki/Unit_of_time
public static TemporalAmount parseTemporalAmout(Number value, String qualifier, Source source) throws InvalidArgumentException,
ArithmeticException, ParsingException {
return switch (qualifier) {
- case "millisecond", "milliseconds" -> Duration.ofMillis(safeToLong(value));
- case "second", "seconds" -> Duration.ofSeconds(safeToLong(value));
- case "minute", "minutes" -> Duration.ofMinutes(safeToLong(value));
- case "hour", "hours" -> Duration.ofHours(safeToLong(value));
-
- case "day", "days" -> Period.ofDays(safeToInt(safeToLong(value)));
- case "week", "weeks" -> Period.ofWeeks(safeToInt(safeToLong(value)));
- case "month", "months" -> Period.ofMonths(safeToInt(safeToLong(value)));
- case "year", "years" -> Period.ofYears(safeToInt(safeToLong(value)));
+ case "millisecond", "milliseconds", "ms" -> Duration.ofMillis(safeToLong(value));
+ case "second", "seconds", "sec", "s" -> Duration.ofSeconds(safeToLong(value));
+ case "minute", "minutes", "min" -> Duration.ofMinutes(safeToLong(value));
+ case "hour", "hours", "h" -> Duration.ofHours(safeToLong(value));
+
+ case "day", "days", "d" -> Period.ofDays(safeToInt(safeToLong(value)));
+ case "week", "weeks", "w" -> Period.ofWeeks(safeToInt(safeToLong(value)));
+ case "month", "months", "mo" -> Period.ofMonths(safeToInt(safeToLong(value)));
+ case "quarter", "quarters", "q" -> Period.ofMonths(safeToInt(Math.multiplyExact(3L, safeToLong(value))));
+ case "year", "years", "yr", "y" -> Period.ofYears(safeToInt(safeToLong(value)));
default -> throw new ParsingException(source, "Unexpected time interval qualifier: '{}'", qualifier);
};
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/ExpressionTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/ExpressionTests.java
index a0f226946cc36..9157f186ade92 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/ExpressionTests.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/ExpressionTests.java
@@ -380,14 +380,18 @@ public void testDurationLiterals() {
assertEquals(l(Duration.ZERO, TIME_DURATION), whereExpression("0 second"));
assertEquals(l(Duration.ofSeconds(value), TIME_DURATION), whereExpression(value + "second"));
assertEquals(l(Duration.ofSeconds(value), TIME_DURATION), whereExpression(value + " seconds"));
+ assertEquals(l(Duration.ofSeconds(value), TIME_DURATION), whereExpression(value + " sec"));
+ assertEquals(l(Duration.ofSeconds(value), TIME_DURATION), whereExpression(value + " s"));
assertEquals(l(Duration.ZERO, TIME_DURATION), whereExpression("0 minute"));
assertEquals(l(Duration.ofMinutes(value), TIME_DURATION), whereExpression(value + "minute"));
assertEquals(l(Duration.ofMinutes(value), TIME_DURATION), whereExpression(value + " minutes"));
+ assertEquals(l(Duration.ofMinutes(value), TIME_DURATION), whereExpression(value + " min"));
assertEquals(l(Duration.ZERO, TIME_DURATION), whereExpression("0 hour"));
assertEquals(l(Duration.ofHours(value), TIME_DURATION), whereExpression(value + "hour"));
assertEquals(l(Duration.ofHours(value), TIME_DURATION), whereExpression(value + " hours"));
+ assertEquals(l(Duration.ofHours(value), TIME_DURATION), whereExpression(value + " h"));
assertEquals(l(Duration.ofHours(-value), TIME_DURATION), whereExpression("-" + value + " hours"));
}
@@ -395,22 +399,33 @@ public void testDurationLiterals() {
public void testDatePeriodLiterals() {
int value = randomInt(Integer.MAX_VALUE);
int weeksValue = randomInt(Integer.MAX_VALUE / 7);
+ int quartersValue = randomInt(Integer.MAX_VALUE / 3);
assertEquals(l(Period.ZERO, DATE_PERIOD), whereExpression("0 day"));
assertEquals(l(Period.ofDays(value), DATE_PERIOD), whereExpression(value + "day"));
assertEquals(l(Period.ofDays(value), DATE_PERIOD), whereExpression(value + " days"));
+ assertEquals(l(Period.ofDays(value), DATE_PERIOD), whereExpression(value + " d"));
assertEquals(l(Period.ZERO, DATE_PERIOD), whereExpression("0week"));
assertEquals(l(Period.ofDays(weeksValue * 7), DATE_PERIOD), whereExpression(weeksValue + "week"));
assertEquals(l(Period.ofDays(weeksValue * 7), DATE_PERIOD), whereExpression(weeksValue + " weeks"));
+ assertEquals(l(Period.ofDays(weeksValue * 7), DATE_PERIOD), whereExpression(weeksValue + " w"));
assertEquals(l(Period.ZERO, DATE_PERIOD), whereExpression("0 month"));
assertEquals(l(Period.ofMonths(value), DATE_PERIOD), whereExpression(value + "month"));
assertEquals(l(Period.ofMonths(value), DATE_PERIOD), whereExpression(value + " months"));
+ assertEquals(l(Period.ofMonths(value), DATE_PERIOD), whereExpression(value + " mo"));
+
+ assertEquals(l(Period.ZERO, DATE_PERIOD), whereExpression("0 quarter"));
+ assertEquals(l(Period.ofMonths(Math.multiplyExact(quartersValue, 3)), DATE_PERIOD), whereExpression(quartersValue + " quarter"));
+ assertEquals(l(Period.ofMonths(Math.multiplyExact(quartersValue, 3)), DATE_PERIOD), whereExpression(quartersValue + " quarters"));
+ assertEquals(l(Period.ofMonths(Math.multiplyExact(quartersValue, 3)), DATE_PERIOD), whereExpression(quartersValue + " q"));
assertEquals(l(Period.ZERO, DATE_PERIOD), whereExpression("0year"));
assertEquals(l(Period.ofYears(value), DATE_PERIOD), whereExpression(value + "year"));
assertEquals(l(Period.ofYears(value), DATE_PERIOD), whereExpression(value + " years"));
+ assertEquals(l(Period.ofYears(value), DATE_PERIOD), whereExpression(value + " yr"));
+ assertEquals(l(Period.ofYears(value), DATE_PERIOD), whereExpression(value + " y"));
assertEquals(l(Period.ofYears(-value), DATE_PERIOD), whereExpression("-" + value + " years"));
}
From e7350dce291921bded600cf306e4dca6138fdb25 Mon Sep 17 00:00:00 2001
From: Simon Cooper
Date: Wed, 8 May 2024 14:44:26 +0100
Subject: [PATCH 04/25] Add a capabilities API to check node and cluster
capabilities (#106820)
This adds a /_capabilities rest endpoint for checking the capabilities of a cluster - what endpoints, parameters, and endpoint capabilities the cluster supports
---
docs/changelog/106820.yaml | 5 +
.../elasticsearch/core/RestApiVersion.java | 11 ++
.../SimpleNodesCapabilitiesIT.java | 55 +++++++
server/src/main/java/module-info.java | 1 +
.../elasticsearch/action/ActionModule.java | 5 +
.../node/capabilities/NodeCapability.java | 43 ++++++
.../NodesCapabilitiesRequest.java | 75 ++++++++++
.../NodesCapabilitiesResponse.java | 46 ++++++
.../TransportNodesCapabilitiesAction.java | 140 ++++++++++++++++++
.../client/internal/ClusterAdminClient.java | 11 ++
.../elasticsearch/rest/BaseRestHandler.java | 8 +
.../elasticsearch/rest/RestController.java | 26 ++++
.../org/elasticsearch/rest/RestHandler.java | 17 +++
.../cluster/RestNodesCapabilitiesAction.java | 60 ++++++++
.../xpack/security/operator/Constants.java | 1 +
15 files changed, 504 insertions(+)
create mode 100644 docs/changelog/106820.yaml
create mode 100644 server/src/internalClusterTest/java/org/elasticsearch/nodescapabilities/SimpleNodesCapabilitiesIT.java
create mode 100644 server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodeCapability.java
create mode 100644 server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesRequest.java
create mode 100644 server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesResponse.java
create mode 100644 server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/TransportNodesCapabilitiesAction.java
create mode 100644 server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesCapabilitiesAction.java
diff --git a/docs/changelog/106820.yaml b/docs/changelog/106820.yaml
new file mode 100644
index 0000000000000..d854e3984c13d
--- /dev/null
+++ b/docs/changelog/106820.yaml
@@ -0,0 +1,5 @@
+pr: 106820
+summary: Add a capabilities API to check node and cluster capabilities
+area: Infra/REST API
+type: feature
+issues: []
diff --git a/libs/core/src/main/java/org/elasticsearch/core/RestApiVersion.java b/libs/core/src/main/java/org/elasticsearch/core/RestApiVersion.java
index 5153ba688d6a9..74acb00925e5a 100644
--- a/libs/core/src/main/java/org/elasticsearch/core/RestApiVersion.java
+++ b/libs/core/src/main/java/org/elasticsearch/core/RestApiVersion.java
@@ -61,4 +61,15 @@ public static Predicate onOrAfter(RestApiVersion restApiVersion)
};
}
+ public static RestApiVersion forMajor(int major) {
+ switch (major) {
+ case 7 -> {
+ return V_7;
+ }
+ case 8 -> {
+ return V_8;
+ }
+ default -> throw new IllegalArgumentException("Unknown REST API version " + major);
+ }
+ }
}
diff --git a/server/src/internalClusterTest/java/org/elasticsearch/nodescapabilities/SimpleNodesCapabilitiesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/nodescapabilities/SimpleNodesCapabilitiesIT.java
new file mode 100644
index 0000000000000..7e4ae040caeca
--- /dev/null
+++ b/server/src/internalClusterTest/java/org/elasticsearch/nodescapabilities/SimpleNodesCapabilitiesIT.java
@@ -0,0 +1,55 @@
+/*
+ * 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 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 or the Server
+ * Side Public License, v 1.
+ */
+
+package org.elasticsearch.nodescapabilities;
+
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
+import org.elasticsearch.action.admin.cluster.node.capabilities.NodesCapabilitiesRequest;
+import org.elasticsearch.action.admin.cluster.node.capabilities.NodesCapabilitiesResponse;
+import org.elasticsearch.test.ESIntegTestCase;
+
+import java.io.IOException;
+
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+
+@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
+public class SimpleNodesCapabilitiesIT extends ESIntegTestCase {
+
+ public void testNodesCapabilities() throws IOException {
+ internalCluster().startNodes(2);
+
+ ClusterHealthResponse clusterHealth = clusterAdmin().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get();
+ logger.info("--> done cluster_health, status {}", clusterHealth.getStatus());
+
+ // check we support the capabilities API itself. Which we do.
+ NodesCapabilitiesResponse response = clusterAdmin().nodesCapabilities(new NodesCapabilitiesRequest().path("_capabilities"))
+ .actionGet();
+ assertThat(response.getNodes(), hasSize(2));
+ assertThat(response.isSupported(), is(true));
+
+ // check we support some parameters of the capabilities API
+ response = clusterAdmin().nodesCapabilities(new NodesCapabilitiesRequest().path("_capabilities").parameters("method", "path"))
+ .actionGet();
+ assertThat(response.getNodes(), hasSize(2));
+ assertThat(response.isSupported(), is(true));
+
+ // check we don't support some other parameters of the capabilities API
+ response = clusterAdmin().nodesCapabilities(new NodesCapabilitiesRequest().path("_capabilities").parameters("method", "invalid"))
+ .actionGet();
+ assertThat(response.getNodes(), hasSize(2));
+ assertThat(response.isSupported(), is(false));
+
+ // check we don't support a random invalid api
+ // TODO this is not working yet - see https://github.com/elastic/elasticsearch/issues/107425
+ /*response = clusterAdmin().nodesCapabilities(new NodesCapabilitiesRequest().path("_invalid"))
+ .actionGet();
+ assertThat(response.getNodes(), hasSize(2));
+ assertThat(response.isSupported(), is(false));*/
+ }
+}
diff --git a/server/src/main/java/module-info.java b/server/src/main/java/module-info.java
index 475158c7a8709..e6b944262094d 100644
--- a/server/src/main/java/module-info.java
+++ b/server/src/main/java/module-info.java
@@ -65,6 +65,7 @@
exports org.elasticsearch.action.admin.cluster.desirednodes;
exports org.elasticsearch.action.admin.cluster.health;
exports org.elasticsearch.action.admin.cluster.migration;
+ exports org.elasticsearch.action.admin.cluster.node.capabilities;
exports org.elasticsearch.action.admin.cluster.node.hotthreads;
exports org.elasticsearch.action.admin.cluster.node.info;
exports org.elasticsearch.action.admin.cluster.node.reload;
diff --git a/server/src/main/java/org/elasticsearch/action/ActionModule.java b/server/src/main/java/org/elasticsearch/action/ActionModule.java
index ef73d0470b43e..ab93f98c5648b 100644
--- a/server/src/main/java/org/elasticsearch/action/ActionModule.java
+++ b/server/src/main/java/org/elasticsearch/action/ActionModule.java
@@ -29,6 +29,7 @@
import org.elasticsearch.action.admin.cluster.migration.PostFeatureUpgradeAction;
import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction;
import org.elasticsearch.action.admin.cluster.migration.TransportPostFeatureUpgradeAction;
+import org.elasticsearch.action.admin.cluster.node.capabilities.TransportNodesCapabilitiesAction;
import org.elasticsearch.action.admin.cluster.node.hotthreads.TransportNodesHotThreadsAction;
import org.elasticsearch.action.admin.cluster.node.info.TransportNodesInfoAction;
import org.elasticsearch.action.admin.cluster.node.reload.TransportNodesReloadSecureSettingsAction;
@@ -284,6 +285,7 @@
import org.elasticsearch.rest.action.admin.cluster.RestGetStoredScriptAction;
import org.elasticsearch.rest.action.admin.cluster.RestGetTaskAction;
import org.elasticsearch.rest.action.admin.cluster.RestListTasksAction;
+import org.elasticsearch.rest.action.admin.cluster.RestNodesCapabilitiesAction;
import org.elasticsearch.rest.action.admin.cluster.RestNodesHotThreadsAction;
import org.elasticsearch.rest.action.admin.cluster.RestNodesInfoAction;
import org.elasticsearch.rest.action.admin.cluster.RestNodesStatsAction;
@@ -616,6 +618,7 @@ public void reg
actions.register(TransportNodesInfoAction.TYPE, TransportNodesInfoAction.class);
actions.register(TransportRemoteInfoAction.TYPE, TransportRemoteInfoAction.class);
+ actions.register(TransportNodesCapabilitiesAction.TYPE, TransportNodesCapabilitiesAction.class);
actions.register(RemoteClusterNodesAction.TYPE, RemoteClusterNodesAction.TransportAction.class);
actions.register(TransportNodesStatsAction.TYPE, TransportNodesStatsAction.class);
actions.register(TransportNodesUsageAction.TYPE, TransportNodesUsageAction.class);
@@ -833,6 +836,7 @@ public void initRestHandlers(Supplier nodesInCluster, Predicate<
registerHandler.accept(new RestClearVotingConfigExclusionsAction());
registerHandler.accept(new RestNodesInfoAction(settingsFilter));
registerHandler.accept(new RestRemoteClusterInfoAction());
+ registerHandler.accept(new RestNodesCapabilitiesAction());
registerHandler.accept(new RestNodesStatsAction());
registerHandler.accept(new RestNodesUsageAction());
registerHandler.accept(new RestNodesHotThreadsAction());
@@ -1029,6 +1033,7 @@ public void initRestHandlers(Supplier nodesInCluster, Predicate<
@Override
protected void configure() {
+ bind(RestController.class).toInstance(restController);
bind(ActionFilters.class).toInstance(actionFilters);
bind(DestructiveOperations.class).toInstance(destructiveOperations);
bind(new TypeLiteral>() {
diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodeCapability.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodeCapability.java
new file mode 100644
index 0000000000000..c26aa673d13fd
--- /dev/null
+++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodeCapability.java
@@ -0,0 +1,43 @@
+/*
+ * 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 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 or the Server
+ * Side Public License, v 1.
+ */
+
+package org.elasticsearch.action.admin.cluster.node.capabilities;
+
+import org.elasticsearch.action.support.nodes.BaseNodeResponse;
+import org.elasticsearch.cluster.node.DiscoveryNode;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
+
+import java.io.IOException;
+
+public class NodeCapability extends BaseNodeResponse {
+
+ private final boolean supported;
+
+ public NodeCapability(StreamInput in) throws IOException {
+ super(in);
+
+ supported = in.readBoolean();
+ }
+
+ public NodeCapability(boolean supported, DiscoveryNode node) {
+ super(node);
+ this.supported = supported;
+ }
+
+ public boolean isSupported() {
+ return supported;
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ super.writeTo(out);
+
+ out.writeBoolean(supported);
+ }
+}
diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesRequest.java
new file mode 100644
index 0000000000000..c69d273727238
--- /dev/null
+++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesRequest.java
@@ -0,0 +1,75 @@
+/*
+ * 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 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 or the Server
+ * Side Public License, v 1.
+ */
+
+package org.elasticsearch.action.admin.cluster.node.capabilities;
+
+import org.elasticsearch.action.support.nodes.BaseNodesRequest;
+import org.elasticsearch.common.Strings;
+import org.elasticsearch.core.RestApiVersion;
+import org.elasticsearch.rest.RestRequest;
+
+import java.util.Set;
+
+public class NodesCapabilitiesRequest extends BaseNodesRequest {
+
+ private RestRequest.Method method = RestRequest.Method.GET;
+ private String path = "/";
+ private Set parameters = Set.of();
+ private Set capabilities = Set.of();
+ private RestApiVersion restApiVersion = RestApiVersion.current();
+
+ public NodesCapabilitiesRequest() {
+ // always send to all nodes
+ super(Strings.EMPTY_ARRAY);
+ }
+
+ public NodesCapabilitiesRequest path(String path) {
+ this.path = path;
+ return this;
+ }
+
+ public String path() {
+ return path;
+ }
+
+ public NodesCapabilitiesRequest method(RestRequest.Method method) {
+ this.method = method;
+ return this;
+ }
+
+ public RestRequest.Method method() {
+ return method;
+ }
+
+ public NodesCapabilitiesRequest parameters(String... parameters) {
+ this.parameters = Set.of(parameters);
+ return this;
+ }
+
+ public Set parameters() {
+ return parameters;
+ }
+
+ public NodesCapabilitiesRequest capabilities(String... capabilities) {
+ this.capabilities = Set.of(capabilities);
+ return this;
+ }
+
+ public Set capabilities() {
+ return capabilities;
+ }
+
+ public NodesCapabilitiesRequest restApiVersion(RestApiVersion restApiVersion) {
+ this.restApiVersion = restApiVersion;
+ return this;
+ }
+
+ public RestApiVersion restApiVersion() {
+ return restApiVersion;
+ }
+}
diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesResponse.java
new file mode 100644
index 0000000000000..63fdb9f7da08a
--- /dev/null
+++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/NodesCapabilitiesResponse.java
@@ -0,0 +1,46 @@
+/*
+ * 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 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 or the Server
+ * Side Public License, v 1.
+ */
+
+package org.elasticsearch.action.admin.cluster.node.capabilities;
+
+import org.elasticsearch.action.FailedNodeException;
+import org.elasticsearch.action.support.TransportAction;
+import org.elasticsearch.action.support.nodes.BaseNodesResponse;
+import org.elasticsearch.cluster.ClusterName;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
+import org.elasticsearch.xcontent.ToXContentFragment;
+import org.elasticsearch.xcontent.XContentBuilder;
+
+import java.io.IOException;
+import java.util.List;
+
+public class NodesCapabilitiesResponse extends BaseNodesResponse implements ToXContentFragment {
+ protected NodesCapabilitiesResponse(ClusterName clusterName, List nodes, List failures) {
+ super(clusterName, nodes, failures);
+ }
+
+ @Override
+ protected List readNodesFrom(StreamInput in) throws IOException {
+ return TransportAction.localOnly();
+ }
+
+ @Override
+ protected void writeNodesTo(StreamOutput out, List nodes) throws IOException {
+ TransportAction.localOnly();
+ }
+
+ public boolean isSupported() {
+ return getNodes().isEmpty() == false && getNodes().stream().allMatch(NodeCapability::isSupported);
+ }
+
+ @Override
+ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
+ return builder.field("supported", isSupported());
+ }
+}
diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/TransportNodesCapabilitiesAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/TransportNodesCapabilitiesAction.java
new file mode 100644
index 0000000000000..7e392775bf42e
--- /dev/null
+++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/capabilities/TransportNodesCapabilitiesAction.java
@@ -0,0 +1,140 @@
+/*
+ * 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 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 or the Server
+ * Side Public License, v 1.
+ */
+
+package org.elasticsearch.action.admin.cluster.node.capabilities;
+
+import org.elasticsearch.action.ActionType;
+import org.elasticsearch.action.FailedNodeException;
+import org.elasticsearch.action.support.ActionFilters;
+import org.elasticsearch.action.support.nodes.TransportNodesAction;
+import org.elasticsearch.cluster.node.DiscoveryNode;
+import org.elasticsearch.cluster.service.ClusterService;
+import org.elasticsearch.common.inject.Inject;
+import org.elasticsearch.common.io.stream.StreamInput;
+import org.elasticsearch.common.io.stream.StreamOutput;
+import org.elasticsearch.core.RestApiVersion;
+import org.elasticsearch.rest.RestController;
+import org.elasticsearch.rest.RestRequest;
+import org.elasticsearch.tasks.Task;
+import org.elasticsearch.threadpool.ThreadPool;
+import org.elasticsearch.transport.TransportRequest;
+import org.elasticsearch.transport.TransportService;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+
+public class TransportNodesCapabilitiesAction extends TransportNodesAction<
+ NodesCapabilitiesRequest,
+ NodesCapabilitiesResponse,
+ TransportNodesCapabilitiesAction.NodeCapabilitiesRequest,
+ NodeCapability> {
+
+ public static final ActionType TYPE = new ActionType<>("cluster:monitor/nodes/capabilities");
+
+ private final RestController restController;
+
+ @Inject
+ public TransportNodesCapabilitiesAction(
+ ThreadPool threadPool,
+ ClusterService clusterService,
+ TransportService transportService,
+ ActionFilters actionFilters,
+ RestController restController
+ ) {
+ super(
+ TYPE.name(),
+ clusterService,
+ transportService,
+ actionFilters,
+ NodeCapabilitiesRequest::new,
+ threadPool.executor(ThreadPool.Names.MANAGEMENT)
+ );
+ this.restController = restController;
+ }
+
+ @Override
+ protected NodesCapabilitiesResponse newResponse(
+ NodesCapabilitiesRequest request,
+ List responses,
+ List failures
+ ) {
+ return new NodesCapabilitiesResponse(clusterService.getClusterName(), responses, failures);
+ }
+
+ @Override
+ protected NodeCapabilitiesRequest newNodeRequest(NodesCapabilitiesRequest request) {
+ return new NodeCapabilitiesRequest(
+ request.method(),
+ request.path(),
+ request.parameters(),
+ request.capabilities(),
+ request.restApiVersion()
+ );
+ }
+
+ @Override
+ protected NodeCapability newNodeResponse(StreamInput in, DiscoveryNode node) throws IOException {
+ return new NodeCapability(in);
+ }
+
+ @Override
+ protected NodeCapability nodeOperation(NodeCapabilitiesRequest request, Task task) {
+ boolean supported = restController.checkSupported(
+ request.method,
+ request.path,
+ request.parameters,
+ request.capabilities,
+ request.restApiVersion
+ );
+ return new NodeCapability(supported, transportService.getLocalNode());
+ }
+
+ public static class NodeCapabilitiesRequest extends TransportRequest {
+ private final RestRequest.Method method;
+ private final String path;
+ private final Set parameters;
+ private final Set capabilities;
+ private final RestApiVersion restApiVersion;
+
+ public NodeCapabilitiesRequest(StreamInput in) throws IOException {
+ super(in);
+
+ method = in.readEnum(RestRequest.Method.class);
+ path = in.readString();
+ parameters = in.readCollectionAsImmutableSet(StreamInput::readString);
+ capabilities = in.readCollectionAsImmutableSet(StreamInput::readString);
+ restApiVersion = RestApiVersion.forMajor(in.readVInt());
+ }
+
+ public NodeCapabilitiesRequest(
+ RestRequest.Method method,
+ String path,
+ Set parameters,
+ Set capabilities,
+ RestApiVersion restApiVersion
+ ) {
+ this.method = method;
+ this.path = path;
+ this.parameters = Set.copyOf(parameters);
+ this.capabilities = Set.copyOf(capabilities);
+ this.restApiVersion = restApiVersion;
+ }
+
+ @Override
+ public void writeTo(StreamOutput out) throws IOException {
+ super.writeTo(out);
+
+ out.writeEnum(method);
+ out.writeString(path);
+ out.writeCollection(parameters, StreamOutput::writeString);
+ out.writeCollection(capabilities, StreamOutput::writeString);
+ out.writeVInt(restApiVersion.major);
+ }
+ }
+}
diff --git a/server/src/main/java/org/elasticsearch/client/internal/ClusterAdminClient.java b/server/src/main/java/org/elasticsearch/client/internal/ClusterAdminClient.java
index f2b9c5ef9631e..daae078ed9a68 100644
--- a/server/src/main/java/org/elasticsearch/client/internal/ClusterAdminClient.java
+++ b/server/src/main/java/org/elasticsearch/client/internal/ClusterAdminClient.java
@@ -21,6 +21,9 @@
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction;
+import org.elasticsearch.action.admin.cluster.node.capabilities.NodesCapabilitiesRequest;
+import org.elasticsearch.action.admin.cluster.node.capabilities.NodesCapabilitiesResponse;
+import org.elasticsearch.action.admin.cluster.node.capabilities.TransportNodesCapabilitiesAction;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequestBuilder;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
@@ -248,6 +251,14 @@ public NodesStatsRequestBuilder prepareNodesStats(String... nodesIds) {
return new NodesStatsRequestBuilder(this).setNodesIds(nodesIds);
}
+ public ActionFuture nodesCapabilities(final NodesCapabilitiesRequest request) {
+ return execute(TransportNodesCapabilitiesAction.TYPE, request);
+ }
+
+ public void nodesCapabilities(final NodesCapabilitiesRequest request, final ActionListener listener) {
+ execute(TransportNodesCapabilitiesAction.TYPE, request, listener);
+ }
+
public void nodesUsage(final NodesUsageRequest request, final ActionListener listener) {
execute(TransportNodesUsageAction.TYPE, request, listener);
}
diff --git a/server/src/main/java/org/elasticsearch/rest/BaseRestHandler.java b/server/src/main/java/org/elasticsearch/rest/BaseRestHandler.java
index d075983464f76..70801cdef560b 100644
--- a/server/src/main/java/org/elasticsearch/rest/BaseRestHandler.java
+++ b/server/src/main/java/org/elasticsearch/rest/BaseRestHandler.java
@@ -12,6 +12,7 @@
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
+import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.core.CheckedConsumer;
import org.elasticsearch.core.RefCounted;
import org.elasticsearch.core.Releasable;
@@ -77,6 +78,13 @@ public final long getUsageCount() {
@Override
public final void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception {
+ // check if the query has any parameters that are not in the supported set (if declared)
+ Set supported = supportedQueryParameters();
+ if (supported != null && supported.containsAll(request.params().keySet()) == false) {
+ Set unsupported = Sets.difference(request.params().keySet(), supported);
+ throw new IllegalArgumentException(unrecognized(request, unsupported, supported, "parameter"));
+ }
+
// prepare the request for execution; has the side effect of touching the request parameters
try (var action = prepareRequest(request, client)) {
diff --git a/server/src/main/java/org/elasticsearch/rest/RestController.java b/server/src/main/java/org/elasticsearch/rest/RestController.java
index 8ce9b08eba205..16813f1141e12 100644
--- a/server/src/main/java/org/elasticsearch/rest/RestController.java
+++ b/server/src/main/java/org/elasticsearch/rest/RestController.java
@@ -365,6 +365,32 @@ public void dispatchBadRequest(final RestChannel channel, final ThreadContext th
}
}
+ public boolean checkSupported(
+ RestRequest.Method method,
+ String path,
+ Set parameters,
+ Set capabilities,
+ RestApiVersion restApiVersion
+ ) {
+ Iterator allHandlers = getAllHandlers(null, path);
+ while (allHandlers.hasNext()) {
+ RestHandler handler;
+ MethodHandlers handlers = allHandlers.next();
+ if (handlers == null) {
+ handler = null;
+ } else {
+ handler = handlers.getHandler(method, restApiVersion);
+ }
+
+ if (handler != null) {
+ var supportedParams = handler.supportedQueryParameters();
+ return (supportedParams == null || supportedParams.containsAll(parameters))
+ && handler.supportedCapabilities().containsAll(capabilities);
+ }
+ }
+ return false;
+ }
+
@Override
public Map getStats() {
final Iterator methodHandlersIterator = handlers.allNodeValues();
diff --git a/server/src/main/java/org/elasticsearch/rest/RestHandler.java b/server/src/main/java/org/elasticsearch/rest/RestHandler.java
index c66fd72279670..4ab89618643f5 100644
--- a/server/src/main/java/org/elasticsearch/rest/RestHandler.java
+++ b/server/src/main/java/org/elasticsearch/rest/RestHandler.java
@@ -18,6 +18,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
/**
* Handler for REST requests
@@ -85,6 +86,22 @@ default List routes() {
return Collections.emptyList();
}
+ /**
+ * The set of query parameters accepted by this rest handler,
+ * {@code null} if query parameters should not be checked nor validated.
+ * TODO - make this not nullable when all handlers have been updated
+ */
+ default @Nullable Set supportedQueryParameters() {
+ return null;
+ }
+
+ /**
+ * The set of capabilities this rest handler supports.
+ */
+ default Set supportedCapabilities() {
+ return Set.of();
+ }
+
/**
* Controls whether requests handled by this class are allowed to to access system indices by default.
* @return {@code true} if requests handled by this class should be allowed to access system indices.
diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesCapabilitiesAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesCapabilitiesAction.java
new file mode 100644
index 0000000000000..9b89a6a932dd3
--- /dev/null
+++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesCapabilitiesAction.java
@@ -0,0 +1,60 @@
+/*
+ * 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 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 or the Server
+ * Side Public License, v 1.
+ */
+
+package org.elasticsearch.rest.action.admin.cluster;
+
+import org.elasticsearch.action.admin.cluster.node.capabilities.NodesCapabilitiesRequest;
+import org.elasticsearch.client.internal.node.NodeClient;
+import org.elasticsearch.common.Strings;
+import org.elasticsearch.rest.BaseRestHandler;
+import org.elasticsearch.rest.RestRequest;
+import org.elasticsearch.rest.Scope;
+import org.elasticsearch.rest.ServerlessScope;
+import org.elasticsearch.rest.action.RestActions.NodesResponseRestListener;
+
+import java.io.IOException;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Set;
+
+@ServerlessScope(Scope.INTERNAL)
+public class RestNodesCapabilitiesAction extends BaseRestHandler {
+
+ @Override
+ public List routes() {
+ return List.of(new Route(RestRequest.Method.GET, "/_capabilities"));
+ }
+
+ @Override
+ public Set supportedQueryParameters() {
+ return Set.of("timeout", "method", "path", "parameters", "capabilities");
+ }
+
+ @Override
+ public String getName() {
+ return "nodes_capabilities_action";
+ }
+
+ @Override
+ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
+ NodesCapabilitiesRequest r = new NodesCapabilitiesRequest().timeout(request.paramAsTime("timeout", null))
+ .method(RestRequest.Method.valueOf(request.param("method", "GET")))
+ .path(URLDecoder.decode(request.param("path"), StandardCharsets.UTF_8))
+ .parameters(request.paramAsStringArray("parameters", Strings.EMPTY_ARRAY))
+ .capabilities(request.paramAsStringArray("capabilities", Strings.EMPTY_ARRAY))
+ .restApiVersion(request.getRestApiVersion());
+
+ return channel -> client.admin().cluster().nodesCapabilities(r, new NodesResponseRestListener<>(channel));
+ }
+
+ @Override
+ public boolean canTripCircuitBreaker() {
+ return false;
+ }
+}
diff --git a/x-pack/plugin/security/qa/operator-privileges-tests/src/javaRestTest/java/org/elasticsearch/xpack/security/operator/Constants.java b/x-pack/plugin/security/qa/operator-privileges-tests/src/javaRestTest/java/org/elasticsearch/xpack/security/operator/Constants.java
index 65651b4a7eb65..2fc894c69aa4c 100644
--- a/x-pack/plugin/security/qa/operator-privileges-tests/src/javaRestTest/java/org/elasticsearch/xpack/security/operator/Constants.java
+++ b/x-pack/plugin/security/qa/operator-privileges-tests/src/javaRestTest/java/org/elasticsearch/xpack/security/operator/Constants.java
@@ -341,6 +341,7 @@ public class Constants {
"cluster:monitor/update/health/info",
"cluster:monitor/ingest/geoip/stats",
"cluster:monitor/main",
+ "cluster:monitor/nodes/capabilities",
"cluster:monitor/nodes/data_tier_usage",
"cluster:monitor/nodes/hot_threads",
"cluster:monitor/nodes/info",
From 2d8faa875c25c3173caac70596103af94a050dc6 Mon Sep 17 00:00:00 2001
From: Fang Xing <155562079+fang-xing-esql@users.noreply.github.com>
Date: Wed, 8 May 2024 10:31:57 -0400
Subject: [PATCH 05/25] [ES|QL] Create MockBigArrays with CircuitBreaker in
AbstractFunctionTestCases (#108195)
* create mockbigarrays with circuit breaker
---
.../compute/data/BytesRefBlockBuilder.java | 4 ---
.../compute/data/X-BlockBuilder.java.st | 4 ---
.../function/AbstractFunctionTestCase.java | 25 ++++++++++++++-----
3 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefBlockBuilder.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefBlockBuilder.java
index 49075789ed4a4..6232cbdd2717c 100644
--- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefBlockBuilder.java
+++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BytesRefBlockBuilder.java
@@ -21,10 +21,6 @@ final class BytesRefBlockBuilder extends AbstractBlockBuilder implements BytesRe
private BytesRefArray values;
- BytesRefBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
- this(estimatedSize, BigArrays.NON_RECYCLING_INSTANCE, blockFactory);
- }
-
BytesRefBlockBuilder(int estimatedSize, BigArrays bigArrays, BlockFactory blockFactory) {
super(blockFactory);
values = new BytesRefArray(Math.max(estimatedSize, 2), bigArrays);
diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BlockBuilder.java.st b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BlockBuilder.java.st
index 0d3d2293a1bb1..8397a0f5274f1 100644
--- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BlockBuilder.java.st
+++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BlockBuilder.java.st
@@ -31,10 +31,6 @@ final class $Type$BlockBuilder extends AbstractBlockBuilder implements $Type$Blo
$if(BytesRef)$
private BytesRefArray values;
- BytesRefBlockBuilder(int estimatedSize, BlockFactory blockFactory) {
- this(estimatedSize, BigArrays.NON_RECYCLING_INSTANCE, blockFactory);
- }
-
BytesRefBlockBuilder(int estimatedSize, BigArrays bigArrays, BlockFactory blockFactory) {
super(blockFactory);
values = new BytesRefArray(Math.max(estimatedSize, 2), bigArrays);
diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java
index 1a410c518e9b1..1fd7cfe368068 100644
--- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java
+++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java
@@ -307,7 +307,13 @@ private Object toJavaObjectUnsignedLongAware(Block block, int position) {
*
*/
public final void testEvaluateBlockWithoutNulls() {
- testEvaluateBlock(driverContext().blockFactory(), driverContext(), false);
+ assumeTrue("no warning is expected", testCase.getExpectedWarnings() == null);
+ try {
+ testEvaluateBlock(driverContext().blockFactory(), driverContext(), false);
+ } catch (CircuitBreakingException ex) {
+ assertThat(ex.getMessage(), equalTo(MockBigArrays.ERROR_MESSAGE));
+ assertFalse("Test data is too large to fit in the memory", true);
+ }
}
/**
@@ -315,7 +321,13 @@ public final void testEvaluateBlockWithoutNulls() {
* some null values inserted between.
*/
public final void testEvaluateBlockWithNulls() {
- testEvaluateBlock(driverContext().blockFactory(), driverContext(), true);
+ assumeTrue("no warning is expected", testCase.getExpectedWarnings() == null);
+ try {
+ testEvaluateBlock(driverContext().blockFactory(), driverContext(), true);
+ } catch (CircuitBreakingException ex) {
+ assertThat(ex.getMessage(), equalTo(MockBigArrays.ERROR_MESSAGE));
+ assertFalse("Test data is too large to fit in the memory", true);
+ }
}
/**
@@ -1543,17 +1555,18 @@ private static void writeToTempDir(String subdir, String str, String extension)
private final List breakers = Collections.synchronizedList(new ArrayList<>());
protected final DriverContext driverContext() {
- MockBigArrays bigArrays = new MockBigArrays(PageCacheRecycler.NON_RECYCLING_INSTANCE, ByteSizeValue.ofGb(1));
+ BigArrays bigArrays = new MockBigArrays(PageCacheRecycler.NON_RECYCLING_INSTANCE, ByteSizeValue.ofMb(256)).withCircuitBreaking();
CircuitBreaker breaker = bigArrays.breakerService().getBreaker(CircuitBreaker.REQUEST);
breakers.add(breaker);
- return new DriverContext(bigArrays.withCircuitBreaking(), new BlockFactory(breaker, bigArrays));
+ return new DriverContext(bigArrays, new BlockFactory(breaker, bigArrays));
}
protected final DriverContext crankyContext() {
- BigArrays bigArrays = new MockBigArrays(PageCacheRecycler.NON_RECYCLING_INSTANCE, new CrankyCircuitBreakerService());
+ BigArrays bigArrays = new MockBigArrays(PageCacheRecycler.NON_RECYCLING_INSTANCE, new CrankyCircuitBreakerService())
+ .withCircuitBreaking();
CircuitBreaker breaker = bigArrays.breakerService().getBreaker(CircuitBreaker.REQUEST);
breakers.add(breaker);
- return new DriverContext(bigArrays.withCircuitBreaking(), new BlockFactory(breaker, bigArrays));
+ return new DriverContext(bigArrays, new BlockFactory(breaker, bigArrays));
}
@After
From e2c19f2ac8127f12eba7d045064cb1d580d8e64e Mon Sep 17 00:00:00 2001
From: Carlos Delgado <6339205+carlosdelest@users.noreply.github.com>
Date: Wed, 8 May 2024 17:24:25 +0200
Subject: [PATCH 06/25] Fix semantic text for non snapshot tests (#108372)
---
x-pack/plugin/inference/build.gradle | 8 ++++++++
x-pack/plugin/ml/build.gradle | 7 -------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/x-pack/plugin/inference/build.gradle b/x-pack/plugin/inference/build.gradle
index 0aef8601ffcc6..3e2171d0654d5 100644
--- a/x-pack/plugin/inference/build.gradle
+++ b/x-pack/plugin/inference/build.gradle
@@ -4,6 +4,8 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
+import org.elasticsearch.gradle.internal.info.BuildParams
+
apply plugin: 'elasticsearch.internal-es-plugin'
apply plugin: 'elasticsearch.internal-cluster-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'
@@ -36,6 +38,12 @@ dependencies {
api "com.ibm.icu:icu4j:${versions.icu4j}"
}
+if (BuildParams.isSnapshotBuild() == false) {
+ tasks.named("test").configure {
+ systemProperty 'es.semantic_text_feature_flag_enabled', 'true'
+ }
+}
+
tasks.named('yamlRestTest') {
usesDefaultDistribution()
}
diff --git a/x-pack/plugin/ml/build.gradle b/x-pack/plugin/ml/build.gradle
index 26f5ea053771c..f42dcc6179d04 100644
--- a/x-pack/plugin/ml/build.gradle
+++ b/x-pack/plugin/ml/build.gradle
@@ -1,6 +1,5 @@
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.internal.dra.DraResolvePlugin
-import org.elasticsearch.gradle.internal.info.BuildParams
apply plugin: 'elasticsearch.internal-es-plugin'
apply plugin: 'elasticsearch.internal-cluster-test'
@@ -115,12 +114,6 @@ artifacts {
archives tasks.named("jar")
}
-if (BuildParams.isSnapshotBuild() == false) {
- tasks.named("test").configure {
- systemProperty 'es.semantic_text_feature_flag_enabled', 'true'
- }
-}
-
tasks.register("extractNativeLicenses", Copy) {
dependsOn configurations.nativeBundle
into "${buildDir}/extractedNativeLicenses"
From 2f94aeea0c8dfe1f448381171f80fa6ffbbcfaa5 Mon Sep 17 00:00:00 2001
From: Mark Vieira
Date: Wed, 8 May 2024 08:25:44 -0700
Subject: [PATCH 07/25] Refactor rolling upgrade tests to make it easier to
customize (#108393)
---
.../AbstractRollingUpgradeTestCase.java | 54 +++++++++++++++++++
.../upgrades/ClusterFeatureMigrationIT.java | 2 +-
.../upgrades/DesiredNodesUpgradeIT.java | 2 +-
.../elasticsearch/upgrades/DownsampleIT.java | 2 +-
.../upgrades/FeatureUpgradeIT.java | 2 +-
.../elasticsearch/upgrades/FieldCapsIT.java | 2 +-
.../upgrades/HealthNodeUpgradeIT.java | 2 +-
.../IgnoredMetaFieldRollingUpgradeIT.java | 2 +-
.../elasticsearch/upgrades/IndexingIT.java | 2 +-
.../ParameterizedRollingUpgradeTestCase.java | 49 ++++-------------
.../upgrades/SnapshotBasedRecoveryIT.java | 2 +-
.../upgrades/SystemIndicesUpgradeIT.java | 2 +-
.../org/elasticsearch/upgrades/TsdbIT.java | 2 +-
.../UpgradeWithOldIndexSettingsIT.java | 2 +-
.../upgrades/VectorSearchIT.java | 2 +-
.../org/elasticsearch/upgrades/XPackIT.java | 2 +-
.../application/InferenceUpgradeTestCase.java | 4 +-
17 files changed, 80 insertions(+), 55 deletions(-)
create mode 100644 qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java
new file mode 100644
index 0000000000000..4837afbf6ccd2
--- /dev/null
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java
@@ -0,0 +1,54 @@
+/*
+ * 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 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 or the Server
+ * Side Public License, v 1.
+ */
+
+package org.elasticsearch.upgrades;
+
+import com.carrotsearch.randomizedtesting.annotations.Name;
+
+import org.elasticsearch.core.SuppressForbidden;
+import org.elasticsearch.test.cluster.ElasticsearchCluster;
+import org.elasticsearch.test.cluster.FeatureFlag;
+import org.elasticsearch.test.cluster.local.distribution.DistributionType;
+import org.junit.ClassRule;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestRule;
+
+import java.util.function.Supplier;
+
+public abstract class AbstractRollingUpgradeTestCase extends ParameterizedRollingUpgradeTestCase {
+
+ private static final TemporaryFolder repoDirectory = new TemporaryFolder();
+
+ private static final ElasticsearchCluster cluster = ElasticsearchCluster.local()
+ .distribution(DistributionType.DEFAULT)
+ .version(getOldClusterTestVersion())
+ .nodes(NODE_NUM)
+ .setting("path.repo", new Supplier<>() {
+ @Override
+ @SuppressForbidden(reason = "TemporaryFolder only has io.File methods, not nio.File")
+ public String get() {
+ return repoDirectory.getRoot().getPath();
+ }
+ })
+ .setting("xpack.security.enabled", "false")
+ .feature(FeatureFlag.TIME_SERIES_MODE)
+ .build();
+
+ @ClassRule
+ public static TestRule ruleChain = RuleChain.outerRule(repoDirectory).around(cluster);
+
+ protected AbstractRollingUpgradeTestCase(@Name("upgradedNodes") int upgradedNodes) {
+ super(upgradedNodes);
+ }
+
+ @Override
+ protected ElasticsearchCluster getUpgradeCluster() {
+ return cluster;
+ }
+}
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java
index 0487b282179a9..73abb634dfd76 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ClusterFeatureMigrationIT.java
@@ -24,7 +24,7 @@
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.hasSize;
-public class ClusterFeatureMigrationIT extends ParameterizedRollingUpgradeTestCase {
+public class ClusterFeatureMigrationIT extends AbstractRollingUpgradeTestCase {
@Before
public void checkMigrationVersion() {
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java
index 73d91ac41fcb7..c7f99b3525f74 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DesiredNodesUpgradeIT.java
@@ -33,7 +33,7 @@
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
-public class DesiredNodesUpgradeIT extends ParameterizedRollingUpgradeTestCase {
+public class DesiredNodesUpgradeIT extends AbstractRollingUpgradeTestCase {
private final int desiredNodesVersion;
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DownsampleIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DownsampleIT.java
index 757f793ac4c46..488cd966ed65e 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DownsampleIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/DownsampleIT.java
@@ -25,7 +25,7 @@
import static org.hamcrest.Matchers.equalTo;
-public class DownsampleIT extends ParameterizedRollingUpgradeTestCase {
+public class DownsampleIT extends AbstractRollingUpgradeTestCase {
private static final String FIXED_INTERVAL = "1h";
private String index;
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java
index 4fe45c05b157b..fc77eef0ae8bb 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java
@@ -23,7 +23,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
-public class FeatureUpgradeIT extends ParameterizedRollingUpgradeTestCase {
+public class FeatureUpgradeIT extends AbstractRollingUpgradeTestCase {
public FeatureUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
super(upgradedNodes);
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FieldCapsIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FieldCapsIT.java
index 860cd2c0e8617..306447d8cc2cd 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FieldCapsIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FieldCapsIT.java
@@ -40,7 +40,7 @@
* the co-ordinating node if older nodes were included in the system
*/
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/103473")
-public class FieldCapsIT extends ParameterizedRollingUpgradeTestCase {
+public class FieldCapsIT extends AbstractRollingUpgradeTestCase {
public FieldCapsIT(@Name("upgradedNodes") int upgradedNodes) {
super(upgradedNodes);
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/HealthNodeUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/HealthNodeUpgradeIT.java
index 0f210ee4b2450..6647cb413c9f5 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/HealthNodeUpgradeIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/HealthNodeUpgradeIT.java
@@ -20,7 +20,7 @@
import static org.hamcrest.CoreMatchers.equalTo;
-public class HealthNodeUpgradeIT extends ParameterizedRollingUpgradeTestCase {
+public class HealthNodeUpgradeIT extends AbstractRollingUpgradeTestCase {
public HealthNodeUpgradeIT(@Name("upgradedNodes") int upgradedNodes) {
super(upgradedNodes);
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IgnoredMetaFieldRollingUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IgnoredMetaFieldRollingUpgradeIT.java
index 874fac615b9b1..1477e2b63cf03 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IgnoredMetaFieldRollingUpgradeIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IgnoredMetaFieldRollingUpgradeIT.java
@@ -26,7 +26,7 @@
import java.util.Locale;
import java.util.Map;
-public class IgnoredMetaFieldRollingUpgradeIT extends ParameterizedRollingUpgradeTestCase {
+public class IgnoredMetaFieldRollingUpgradeIT extends AbstractRollingUpgradeTestCase {
private static final String TERMS_AGG_QUERY = Strings.format("""
{
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IndexingIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IndexingIT.java
index 82485130f05ce..157e2293b69ae 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IndexingIT.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IndexingIT.java
@@ -51,7 +51,7 @@
* xpack rolling restart tests. We should work on a way to remove this
* duplication but for now we have no real way to share code.
*/
-public class IndexingIT extends ParameterizedRollingUpgradeTestCase {
+public class IndexingIT extends AbstractRollingUpgradeTestCase {
public IndexingIT(@Name("upgradedNodes") int upgradedNodes) {
super(upgradedNodes);
diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java
index 63ed54d05adf2..d5f645c387d61 100644
--- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java
+++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java
@@ -14,74 +14,45 @@
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
-import org.elasticsearch.test.cluster.FeatureFlag;
-import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.cluster.util.Version;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.test.rest.ObjectPath;
import org.elasticsearch.test.rest.TestFeatureService;
import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestRule;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.function.Supplier;
import java.util.stream.IntStream;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
public abstract class ParameterizedRollingUpgradeTestCase extends ESRestTestCase {
+ protected static final int NODE_NUM = 3;
private static final String OLD_CLUSTER_VERSION = System.getProperty("tests.old_cluster_version");
-
- private static final TemporaryFolder repoDirectory = new TemporaryFolder();
-
- private static final int NODE_NUM = 3;
-
- private static final ElasticsearchCluster cluster = ElasticsearchCluster.local()
- .distribution(DistributionType.DEFAULT)
- .version(getOldClusterTestVersion())
- .nodes(NODE_NUM)
- .setting("path.repo", new Supplier<>() {
- @Override
- @SuppressForbidden(reason = "TemporaryFolder only has io.File methods, not nio.File")
- public String get() {
- return repoDirectory.getRoot().getPath();
- }
- })
- .setting("xpack.security.enabled", "false")
- .feature(FeatureFlag.TIME_SERIES_MODE)
- .build();
-
- @ClassRule
- public static TestRule ruleChain = RuleChain.outerRule(repoDirectory).around(cluster);
-
- @ParametersFactory(shuffle = false)
- public static Iterable