[GitHub] [lucene-solr] iverase commented on a change in pull request #2094: LUCENE-9047: Move the Directory APIs to be little endian
iverase commented on a change in pull request #2094: URL: https://github.com/apache/lucene-solr/pull/2094#discussion_r529553632 ## File path: lucene/core/src/java/org/apache/lucene/store/DataInput.java ## @@ -92,15 +92,20 @@ public void readBytes(byte[] b, int offset, int len, boolean useBuffer) * @see DataOutput#writeByte(byte) */ public short readShort() throws IOException { -return (short) (((readByte() & 0xFF) << 8) | (readByte() & 0xFF)); +final byte b1 = readByte(); +final byte b2 = readByte(); +return (short) ((b2 << 8) | (b1 & 0xFF)); Review comment: done This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene-solr] iverase commented on a change in pull request #2094: LUCENE-9047: Move the Directory APIs to be little endian
iverase commented on a change in pull request #2094: URL: https://github.com/apache/lucene-solr/pull/2094#discussion_r529540139 ## File path: lucene/core/src/java/org/apache/lucene/store/DataOutput.java ## @@ -210,8 +210,14 @@ public final void writeZInt(int i) throws IOException { * @see DataInput#readLong() */ public void writeLong(long i) throws IOException { -writeInt((int) (i >> 32)); -writeInt((int) i); +writeByte((byte) i); +writeByte((byte)(i >> 8)); +writeByte((byte)(i >> 16)); +writeByte((byte)(i >> 24)); +writeByte((byte)(i >> 32)); +writeByte((byte)(i >> 40)); +writeByte((byte)(i >> 48)); +writeByte((byte)(i >> 56)); Review comment: Just to keep my sanity :) done This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene-solr] iverase commented on a change in pull request #2094: LUCENE-9047: Move the Directory APIs to be little endian
iverase commented on a change in pull request #2094: URL: https://github.com/apache/lucene-solr/pull/2094#discussion_r529539703 ## File path: lucene/core/src/java/org/apache/lucene/util/bkd/OfflinePointWriter.java ## @@ -54,7 +54,10 @@ public void append(byte[] packedValue, int docID) throws IOException { assert closed == false : "Point writer is already closed"; assert packedValue.length == config.packedBytesLength : "[packedValue] must have length [" + config.packedBytesLength + "] but was [" + packedValue.length + "]"; out.writeBytes(packedValue, 0, packedValue.length); -out.writeInt(docID); +out.writeByte((byte) (docID >> 24)); +out.writeByte((byte) (docID >> 16)); +out.writeByte((byte) (docID >> 8)); +out.writeByte((byte) (docID >> 0)); Review comment: done This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene-solr] iverase commented on a change in pull request #2094: LUCENE-9047: Move the Directory APIs to be little endian
iverase commented on a change in pull request #2094: URL: https://github.com/apache/lucene-solr/pull/2094#discussion_r529539404 ## File path: lucene/replicator/src/java/org/apache/lucene/replicator/nrt/CopyOneFile.java ## @@ -96,11 +96,12 @@ public boolean visit() throws IOException { // Paranoia: make sure the primary node is not smoking crack, by somehow sending us an already corrupted file whose checksum (in its // footer) disagrees with reality: long actualChecksumIn = in.readLong(); -if (actualChecksumIn != checksum) { +// CheckSum is written in Big Endian so we need to reverse bytes +if (actualChecksumIn != Long.reverseBytes(checksum)) { Review comment: yes, just need to make sure we revert bytes when writing the checksum again. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene-solr] iverase commented on a change in pull request #2094: LUCENE-9047: Move the Directory APIs to be little endian
iverase commented on a change in pull request #2094: URL: https://github.com/apache/lucene-solr/pull/2094#discussion_r529537298 ## File path: lucene/core/src/java/org/apache/lucene/store/DataInput.java ## @@ -155,26 +160,25 @@ public int readZInt() throws IOException { * @see DataOutput#writeLong(long) */ public long readLong() throws IOException { -return (((long)readInt()) << 32) | (readInt() & 0xL); +final byte b1 = readByte(); +final byte b2 = readByte(); +final byte b3 = readByte(); +final byte b4 = readByte(); +final byte b5 = readByte(); +final byte b6 = readByte(); +final byte b7 = readByte(); +final byte b8 = readByte(); +return ((b8 & 0xFFL) << 56) | (b7 & 0xFFL) << 48 | (b6 & 0xFFL) << 40 | (b5 & 0xFFL) << 32 +| (b4 & 0xFFL) << 24 | (b3 & 0xFFL) << 16 | (b2 & 0xFFL) << 8 | (b1 & 0xFFL); } /** - * Read a specified number of longs with the little endian byte order. - * This method can be used to read longs whose bytes have been - * {@link Long#reverseBytes reversed} at write time: - * - * for (long l : longs) { - * output.writeLong(Long.reverseBytes(l)); - * } - * - * @lucene.experimental Review comment: yes This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene-solr] iverase commented on a change in pull request #2094: LUCENE-9047: Move the Directory APIs to be little endian
iverase commented on a change in pull request #2094: URL: https://github.com/apache/lucene-solr/pull/2094#discussion_r529537082 ## File path: lucene/core/src/java/org/apache/lucene/search/SortedNumericSortField.java ## @@ -106,20 +107,21 @@ public Provider() { @Override public SortField readSortField(DataInput in) throws IOException { Review comment: Same as above This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene-solr] iverase commented on a change in pull request #2094: LUCENE-9047: Move the Directory APIs to be little endian
iverase commented on a change in pull request #2094: URL: https://github.com/apache/lucene-solr/pull/2094#discussion_r529536955 ## File path: lucene/core/src/java/org/apache/lucene/search/SortField.java ## @@ -148,12 +149,12 @@ public Provider() { @Override public SortField readSortField(DataInput in) throws IOException { Review comment: I introduce a wrapper to the DataOutput as well and now this classes remain unchanged. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org
[GitHub] [lucene-solr] iverase commented on a change in pull request #2094: LUCENE-9047: Move the Directory APIs to be little endian
iverase commented on a change in pull request #2094: URL: https://github.com/apache/lucene-solr/pull/2094#discussion_r529536245 ## File path: lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java ## @@ -570,6 +571,23 @@ static void writeCRC(IndexOutput output) throws IOException { if ((value & 0xL) != 0) { throw new IllegalStateException("Illegal CRC-32 checksum: " + value + " (resource=" + output + ")"); } -output.writeLong(value); +writeChecksum(output, value); } + + private static int readVersion(DataInput in) throws IOException { +return EndiannessReverserUtil.readInt(in); + } + + private static void writeVersion(DataOutput out, int version) throws IOException { +EndiannessReverserUtil.writeInt(out, version); + } + + private static long readChecksum(DataInput in) throws IOException { +return EndiannessReverserUtil.readLong(in); + } + + private static void writeChecksum(DataOutput out, long checksum) throws IOException { +EndiannessReverserUtil.writeLong(out, checksum); + } Review comment: yes, that make sense. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org