[GitHub] [lucene] original-brownbear opened a new pull request, #12455: Clean up writing String to ByteBuffersDataOutput

2023-07-23 Thread via GitHub


original-brownbear opened a new pull request, #12455:
URL: https://github.com/apache/lucene/pull/12455

   Resolving TODO to use UnicodeUtil instead of a copy of its code here. Maybe 
slightly slower from the extra check for high-surrogate but that may be 
outweigh or better by more compact code and saving the capturing lambda that 
might not inline.
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

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] original-brownbear commented on a diff in pull request #12453: Faster bulk numeric reads from BufferedIndexInput

2023-07-23 Thread via GitHub


original-brownbear commented on code in PR #12453:
URL: https://github.com/apache/lucene/pull/12453#discussion_r1271422741


##
lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java:
##
@@ -159,6 +159,63 @@ public final long readLong() throws IOException {
 }
   }
 
+  @Override
+  public void readFloats(float[] floats, int offset, int len) throws 
IOException {
+int remaining = len;
+while (remaining > 0) {
+  int cnt = Math.min(buffer.remaining() / Float.BYTES, remaining);
+  buffer.asFloatBuffer().get(floats, offset + len - remaining, cnt);
+  buffer.position(buffer.position() + Float.BYTES * cnt);
+  remaining -= cnt;
+  if (remaining > 0) {
+if (buffer.hasRemaining()) {
+  floats[offset + len - remaining] = Float.intBitsToFloat(readInt());
+  --remaining;
+} else {
+  refill();
+}
+  }
+}
+  }
+
+  @Override
+  public void readLongs(long[] dst, int offset, int length) throws IOException 
{

Review Comment:
   I think it would come out to about that code if we inlined `readBytes` with 
`useBuffer=true` except  that
   
   ```java
   if (buffer.hasRemaining()) {
 dst[offset + len - remaining] = readByte();
 --remaining;
   }
   ```
   
   is never entered, `hasRemaining` is just always false because we don't have 
anything like 1 one of 4 int bytes available.
   
   



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

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] original-brownbear commented on a diff in pull request #12453: Faster bulk numeric reads from BufferedIndexInput

2023-07-23 Thread via GitHub


original-brownbear commented on code in PR #12453:
URL: https://github.com/apache/lucene/pull/12453#discussion_r1271422741


##
lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java:
##
@@ -159,6 +159,63 @@ public final long readLong() throws IOException {
 }
   }
 
+  @Override
+  public void readFloats(float[] floats, int offset, int len) throws 
IOException {
+int remaining = len;
+while (remaining > 0) {
+  int cnt = Math.min(buffer.remaining() / Float.BYTES, remaining);
+  buffer.asFloatBuffer().get(floats, offset + len - remaining, cnt);
+  buffer.position(buffer.position() + Float.BYTES * cnt);
+  remaining -= cnt;
+  if (remaining > 0) {
+if (buffer.hasRemaining()) {
+  floats[offset + len - remaining] = Float.intBitsToFloat(readInt());
+  --remaining;
+} else {
+  refill();
+}
+  }
+}
+  }
+
+  @Override
+  public void readLongs(long[] dst, int offset, int length) throws IOException 
{

Review Comment:
   I think it would come out to about that code if we inlined `readBytes` with 
`useBuffer=true` except  that
   
   ```java
   if (buffer.hasRemaining()) {
 dst[offset + len - remaining] = readByte();
 --remaining;
   }
   ```
   
   is never entered, `hasRemaining` is just always false because we don't have 
anything like 1 one of 4 int bytes available.
   
   -> the difference I think is just in that we have to deal with the alignment 
at the buffer boundary



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

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