Package org.apache.lucene.store

Examples of org.apache.lucene.store.IndexInput.readBytes()


                  {
                     long remaining = in.length();
                     while (remaining > 0)
                     {
                        int num = (int)Math.min(remaining, buffer.length);
                        in.readBytes(buffer, 0, num);
                        out.writeBytes(buffer, num);
                        remaining -= num;
                     }
                  }
                  finally
View Full Code Here


        try {
          data.seek(address);
          // NOTE: we could have one buffer, but various consumers (e.g. FieldComparatorSource)
          // assume "they" own the bytes after calling this!
          final byte[] buffer = new byte[bytes.maxLength];
          data.readBytes(buffer, 0, buffer.length);
          result.bytes = buffer;
          result.offset = 0;
          result.length = buffer.length;
        } catch (IOException e) {
          throw new RuntimeException(e);
View Full Code Here

        try {
          data.seek(startAddress);
          // NOTE: we could have one buffer, but various consumers (e.g. FieldComparatorSource)
          // assume "they" own the bytes after calling this!
          final byte[] buffer = new byte[length];
          data.readBytes(buffer, 0, buffer.length);
          result.bytes = buffer;
          result.offset = 0;
          result.length = length;
        } catch (IOException e) {
          throw new RuntimeException(e);
View Full Code Here

            }
            in.skip(skip);
            src.seek(skip);
            offset = skip;
          }
          src.readBytes(srcBytes, offset, srcBytes.length - offset);
          in.read(inBytes, offset, inBytes.length - offset);
          assertArrayEquals(srcBytes, inBytes);
          IOUtils.close(src, in);
        }
      }
View Full Code Here

          LOG.info("Context [{0}] index closed", context);
          return;
        }
      }
      int len = (int) Math.min(length, buf.length);
      input.readBytes(buf, 0, len);
      length -= len;
      bytesReadPerPass += len;
    }
    long now = System.nanoTime();
    double seconds = (now - start) / 1000000000.0;
View Full Code Here

                    throw new Exception("length incorrect");

                byte[] data = new byte[length];
                byte[] read = new byte[length];
                gen.nextBytes(data);
                file.readBytes(read, 0, length);

                if (!Arrays.equals(data, read))
                    throw new Exception("contents incorrect");

                file.close();
View Full Code Here

            long remainder = length;
            int chunk = buffer.length;

            while(remainder > 0) {
                int len = (int) Math.min(chunk, remainder);
                is.readBytes(buffer, 0, len, false);
                os.writeBytes(buffer, len);
                remainder -= len;
                if (checkAbort != null)
                  // Roughly every 2 MB we will check if
                  // it's time to abort
View Full Code Here

         if (seekTo != 0) {
            input.seek(seekTo);
         }
         bufferSize = (int) Math.min(length - seekTo, (long)bufferSize);
         buffer = new byte[bufferSize];
         input.readBytes(buffer, 0, bufferSize);
      }
      finally {
         input.close();
      }
      return buffer;
View Full Code Here

        byte[] test = new byte[]{1, 2, 3, 4, 5, 6, 7, 8};
        assertThat(dir.fileExists("value1"), equalTo(true));
        assertThat(dir.fileLength("value1"), equalTo(38l));

        IndexInput indexInput = dir.openInput("value1");
        indexInput.readBytes(test, 0, 5);
        assertThat(test[0], equalTo((byte) 8));
        assertThat(indexInput.readInt(), equalTo(-1));
        assertThat(indexInput.readLong(), equalTo((long) 10));
        assertThat(indexInput.readInt(), equalTo(0));
        assertThat(indexInput.readInt(), equalTo(0));
View Full Code Here

        assertThat(test[0], equalTo((byte) 8));
        assertThat(indexInput.readInt(), equalTo(-1));
        assertThat(indexInput.readLong(), equalTo((long) 10));
        assertThat(indexInput.readInt(), equalTo(0));
        assertThat(indexInput.readInt(), equalTo(0));
        indexInput.readBytes(test, 0, 8);
        assertThat(test[0], equalTo((byte) 1));
        assertThat(test[7], equalTo((byte) 8));
        indexInput.readBytes(test, 0, 5);
        assertThat(test[0], equalTo((byte) 1));
        assertThat(test[4], equalTo((byte) 5));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.