You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2019/06/12 23:03:09 UTC
[lucene-solr] branch branch_8x updated (5f6df28 -> fe871b9)
This is an automated email from the ASF dual-hosted git repository.
noble pushed a change to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.
from 5f6df28 SOLR-13509: add omitHeader=false for shards requests to avoid NPE on partialResuls check
new e91c5c5 SOLR-13347: Add support for reading/writing UUID from/to TransactionLog (#681)
new fe871b9 SOLR-13347: Transaction log to natively support UUID types
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
solr/CHANGES.txt | 2 ++
.../org/apache/solr/update/TransactionLog.java | 22 ++++++++++++++-
.../org/apache/solr/update/TransactionLogTest.java | 33 +++++++++++++++++++++-
.../org/apache/solr/common/util/JavaBinCodec.java | 1 +
4 files changed, 56 insertions(+), 2 deletions(-)
[lucene-solr] 01/02: SOLR-13347: Add support for reading/writing
UUID from/to TransactionLog (#681)
Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
noble pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit e91c5c5b758d76b99159c4d70c61a145534a199b
Author: Thomas Wöckinger <th...@users.noreply.github.com>
AuthorDate: Thu Jun 13 00:56:41 2019 +0200
SOLR-13347: Add support for reading/writing UUID from/to TransactionLog (#681)
SOLR-13347: Transaction log to natively support UUID types
---
.../org/apache/solr/update/TransactionLog.java | 22 ++++++++++++++-
.../org/apache/solr/update/TransactionLogTest.java | 33 +++++++++++++++++++++-
.../org/apache/solr/common/util/JavaBinCodec.java | 1 +
3 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/update/TransactionLog.java b/solr/core/src/java/org/apache/solr/update/TransactionLog.java
index a5f55c2..b4db6ef 100644
--- a/solr/core/src/java/org/apache/solr/update/TransactionLog.java
+++ b/solr/core/src/java/org/apache/solr/update/TransactionLog.java
@@ -102,6 +102,7 @@ public class TransactionLog implements Closeable {
};
public class LogCodec extends JavaBinCodec {
+
public LogCodec(JavaBinCodec.ObjectResolver resolver) {
super(resolver);
}
@@ -128,7 +129,7 @@ public class TransactionLog implements Closeable {
public CharSequence readExternString(DataInputInputStream fis) throws IOException {
int idx = readSize(fis);
if (idx != 0) {// idx != 0 is the index of the extern string
- // no need to synchronize globalStringList - it's only updated before the first record is written to the log
+ // no need to synchronize globalStringList - it's only updated before the first record is written to the log
return globalStringList.get(idx - 1);
} else {// idx == 0 means it has a string value
// this shouldn't happen with this codec subclass.
@@ -136,6 +137,25 @@ public class TransactionLog implements Closeable {
}
}
+ @Override
+ protected Object readObject(DataInputInputStream dis) throws IOException {
+ if (UUID == tagByte) {
+ return new java.util.UUID(dis.readLong(), dis.readLong());
+ }
+ return super.readObject(dis);
+ }
+
+ @Override
+ public boolean writePrimitive(Object val) throws IOException {
+ if (val instanceof java.util.UUID) {
+ java.util.UUID uuid = (java.util.UUID) val;
+ daos.writeByte(UUID);
+ daos.writeLong(uuid.getMostSignificantBits());
+ daos.writeLong(uuid.getLeastSignificantBits());
+ return true;
+ }
+ return super.writePrimitive(val);
+ }
}
TransactionLog(File tlogFile, Collection<String> globalStrings) {
diff --git a/solr/core/src/test/org/apache/solr/update/TransactionLogTest.java b/solr/core/src/test/org/apache/solr/update/TransactionLogTest.java
index 167b3b4..594bc89 100644
--- a/solr/core/src/test/org/apache/solr/update/TransactionLogTest.java
+++ b/solr/core/src/test/org/apache/solr/update/TransactionLogTest.java
@@ -18,19 +18,24 @@
package org.apache.solr.update;
import java.io.File;
+import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
+import java.util.UUID;
import org.apache.solr.SolrTestCase;
import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.update.TransactionLog.LogReader;
import org.junit.Test;
public class TransactionLogTest extends SolrTestCase {
@Test
public void testBigLastAddSize() {
- String tlogFileName = String.format(Locale.ROOT, UpdateLog.LOG_FILENAME_PATTERN, UpdateLog.TLOG_NAME, Long.MAX_VALUE);
+ String tlogFileName = String.format(Locale.ROOT, UpdateLog.LOG_FILENAME_PATTERN, UpdateLog.TLOG_NAME,
+ Long.MAX_VALUE);
Path path = createTempDir();
File logFile = new File(path.toFile(), tlogFileName);
try (TransactionLog transactionLog = new TransactionLog(logFile, new ArrayList<>())) {
@@ -41,4 +46,30 @@ public class TransactionLogTest extends SolrTestCase {
}
}
+ @Test
+ public void testUUID() throws IOException, InterruptedException {
+ String tlogFileName = String.format(Locale.ROOT, UpdateLog.LOG_FILENAME_PATTERN, UpdateLog.TLOG_NAME,
+ Long.MAX_VALUE);
+ Path path = createTempDir();
+ File logFile = new File(path.toFile(), tlogFileName);
+ UUID uuid = UUID.randomUUID();
+ try (TransactionLog tlog = new TransactionLog(logFile, new ArrayList<>())) {
+ tlog.deleteOnClose = false;
+ AddUpdateCommand updateCommand = new AddUpdateCommand(null);
+
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("uuid", uuid);
+ updateCommand.solrDoc = doc;
+
+ tlog.write(updateCommand);
+ }
+
+ try (TransactionLog tlog = new TransactionLog(logFile, new ArrayList<>(), true)) {
+ LogReader reader = tlog.getReader(0);
+ Object entry = reader.next();
+ assertNotNull(entry);
+ SolrInputDocument doc = (SolrInputDocument) ((List<?>) entry).get(2);
+ assertEquals(uuid, (UUID) doc.getFieldValue("uuid"));
+ }
+ }
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
index 434e2f9..7d6f2e4 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
@@ -100,6 +100,7 @@ public class JavaBinCodec implements PushWriter {
MAP_ENTRY_ITER = 17,
ENUM_FIELD_VALUE = 18,
MAP_ENTRY = 19,
+ UUID = 20, // This is reserved to be used only in LogCodec
// types that combine tag + length (or other info) in a single byte
TAG_AND_LEN = (byte) (1 << 5),
STR = (byte) (1 << 5),
[lucene-solr] 02/02: SOLR-13347: Transaction log to natively
support UUID types
Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
noble pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit fe871b906bb2e872d48b15b828abfc6208d57808
Author: Noble Paul <no...@users.noreply.github.com>
AuthorDate: Thu Jun 13 09:00:58 2019 +1000
SOLR-13347: Transaction log to natively support UUID types
---
solr/CHANGES.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e2e1549..4125ac9 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -112,6 +112,8 @@ Other Changes
* SOLR-13371: Re-structure and clarify Security chapters in Ref Guide (janhoy)
+* SOLR-13347: Transaction log to natively support UUID types (Thomas Wöckinger via noble)
+
================== 8.1.2 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.