Package org.apache.lucene.store

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


        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));

        indexInput.seek(28);
        assertThat(indexInput.readByte(), equalTo((byte) 4));
View Full Code Here


        assertThat(indexInput.readByte(), equalTo((byte) 4));
        indexInput.seek(30);
        assertThat(indexInput.readByte(), equalTo((byte) 6));

        indexInput.seek(0);
        indexInput.readBytes(test, 0, 5);
        assertThat(test[0], equalTo((byte) 8));

        indexInput.close();

        indexInput = dir.openInput("value1");
View Full Code Here

                        if (delegate.fileExists(file + ".cks")) {
                            IndexInput indexInput = delegate.openInput(file + ".cks");
                            try {
                                if (indexInput.length() > 0) {
                                    byte[] checksumBytes = new byte[(int) indexInput.length()];
                                    indexInput.readBytes(checksumBytes, 0, checksumBytes.length, false);
                                    checksum = Unicode.fromBytes(checksumBytes);
                                }
                            } finally {
                                indexInput.close();
                            }
View Full Code Here

                                        if (shard.state() == IndexShardState.CLOSED) { // check if the shard got closed on us
                                            throw new IndexShardClosedException(shard.shardId());
                                        }
                                        int toRead = readCount + BUFFER_SIZE > len ? (int) (len - readCount) : BUFFER_SIZE;
                                        long position = indexInput.getFilePointer();
                                        indexInput.readBytes(buf, 0, toRead, false);
                                        transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.FILE_CHUNK, new RecoveryFileChunkRequest(request.shardId(), name, position, len, md.checksum(), buf, toRead),
                                                TransportRequestOptions.options().withCompress(compress).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet();
                                        readCount += toRead;
                                    }
                                    indexInput.close();
View Full Code Here

        int length = random.nextInt(fsBuf.length - offset);
        int pos = random.nextInt(fileLength - length);
        fsInput.seek(pos);
        fsInput.readBytes(fsBuf, offset, length);
        hdfsInput.seek(pos);
        hdfsInput.readBytes(hdfsBuf, offset, length);
        for (int f = offset; f < length; f++) {
          if (fsBuf[f] != hdfsBuf[f]) {
            fail(Long.toString(seed) + " read [" + i + "]");
          }
        }
View Full Code Here

    assertEquals(16002, input.length());
    assertEquals(1, input.readByte());
    assertEquals(2, input.readByte());

    byte[] buf = new byte[16000];
    input.readBytes(buf, 0, 16000);
    input.close();
    assertArrayEquals(b, buf);
    directory.close();
  }
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, false);
        length -= len;
        bytesReadPerPass += len;
      }
      long now = System.nanoTime();
      double seconds = (now - start) / 1000000000.0;
View Full Code Here

      int length = random.nextInt(fsBuf.length - offset);
      int pos = random.nextInt(fileLength - length);
      fsInput.seek(pos);
      fsInput.readBytes(fsBuf, offset, length);
      hdfsInput.seek(pos);
      hdfsInput.readBytes(hdfsBuf, offset, length);
      for (int f = offset; f < length; f++) {
        if (fsBuf[f] != hdfsBuf[f]) {
          fail();
        }
      }
View Full Code Here

    BytesRef actual = new BytesRef();
    for (String string : list) {
      expected.copy(string);
      actual.grow(expected.length);
      actual.length = expected.length;
      input.readBytes(actual.bytes, 0, actual.length);
      assertEquals(expected, actual);
    }
    try {
      input.readByte();
      fail("must be EOF");
View Full Code Here

      String value;
          try {
            localFieldsStream.seek(pointer);
            if (isCompressed) {
              final byte[] b = new byte[toRead];
              localFieldsStream.readBytes(b, 0, b.length);
              value = new String(uncompress(b), "UTF-8");
            } else {
              if (format >= FieldsWriter.FORMAT_VERSION_UTF8_LENGTH_IN_BYTES) {
                byte[] bytes = new byte[toRead];
                localFieldsStream.readBytes(bytes, 0, toRead);
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.