Java Code Examples for org.apache.lucene.store.DataInput#readLong()

The following examples show how to use org.apache.lucene.store.DataInput#readLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FuzzySet.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public static FuzzySet deserialize(DataInput in) throws IOException
{
  int version=in.readInt();
  if (version == VERSION_SPI) {
    in.readString();
  }
  final HashFunction hashFunction = hashFunctionForVersion(version);
  int bloomSize=in.readInt();
  int numLongs=in.readInt();
  long[]longs=new long[numLongs];
  for (int i = 0; i < numLongs; i++) {
    longs[i]=in.readLong();
  }
  FixedBitSet bits = new FixedBitSet(longs,bloomSize+1);
  return new FuzzySet(bits,bloomSize,hashFunction);
}
 
Example 2
Source File: Packed64.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an array with content retrieved from the given DataInput.
 * @param in       a DataInput, positioned at the start of Packed64-content.
 * @param valueCount  the number of elements.
 * @param bitsPerValue the number of bits available for any given value.
 * @throws java.io.IOException if the values for the backing array could not
 *                             be retrieved.
 */
public Packed64(int packedIntsVersion, DataInput in, int valueCount, int bitsPerValue)
                                                          throws IOException {
  super(valueCount, bitsPerValue);
  final PackedInts.Format format = PackedInts.Format.PACKED;
  final long byteCount = format.byteCount(packedIntsVersion, valueCount, bitsPerValue); // to know how much to read
  final int longCount = format.longCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); // to size the array
  blocks = new long[longCount];
  // read as many longs as we can
  for (int i = 0; i < byteCount / 8; ++i) {
    blocks[i] = in.readLong();
  }
  final int remaining = (int) (byteCount % 8);
  if (remaining != 0) {
    // read the last bytes
    long lastLong = 0;
    for (int i = 0; i < remaining; ++i) {
      lastLong |= (in.readByte() & 0xFFL) << (56 - i * 8);
    }
    blocks[blocks.length - 1] = lastLong;
  }
  maskRight = ~0L << (BLOCK_SIZE-bitsPerValue) >>> (BLOCK_SIZE-bitsPerValue);
  bpvMinusBlockSize = bitsPerValue - BLOCK_SIZE;
}
 
Example 3
Source File: BloomFilter.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static BloomFilter deserialize(DataInput in) throws IOException {
    int version = in.readInt(); // we do nothing with this now..., defaults to 0
    int numLongs = in.readInt();
    long[] data = new long[numLongs];
    for (int i = 0; i < numLongs; i++) {
        data[i] = in.readLong();
    }
    int numberOfHashFunctions = in.readInt();
    int hashType = in.readInt();
    return new BloomFilter(new BitArray(data), numberOfHashFunctions, Hashing.fromType(hashType));
}
 
Example 4
Source File: Packed64SingleBlock.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public static Packed64SingleBlock create(DataInput in,
    int valueCount, int bitsPerValue) throws IOException {
  Packed64SingleBlock reader = create(valueCount, bitsPerValue);
  for (int i = 0; i < reader.blocks.length; ++i) {
    reader.blocks[i] = in.readLong();
  }
  return reader;
}
 
Example 5
Source File: Checkpoint.java    From crate with Apache License 2.0 5 votes vote down vote up
static Checkpoint readCheckpointV6_4_0(final DataInput in) throws IOException {
    final long offset = in.readLong();
    final int numOps = in.readInt();
    final long generation = in.readLong();
    final long minSeqNo = in.readLong();
    final long maxSeqNo = in.readLong();
    final long globalCheckpoint = in.readLong();
    final long minTranslogGeneration = in.readLong();
    final long trimmedAboveSeqNo = in.readLong();
    return new Checkpoint(offset, numOps, generation, minSeqNo, maxSeqNo, globalCheckpoint, minTranslogGeneration, trimmedAboveSeqNo);
}
 
Example 6
Source File: Checkpoint.java    From crate with Apache License 2.0 5 votes vote down vote up
static Checkpoint readCheckpointV6_0_0(final DataInput in) throws IOException {
    final long offset = in.readLong();
    final int numOps = in.readInt();
    final long generation = in.readLong();
    final long minSeqNo = in.readLong();
    final long maxSeqNo = in.readLong();
    final long globalCheckpoint = in.readLong();
    final long minTranslogGeneration = in.readLong();
    final long trimmedAboveSeqNo = SequenceNumbers.UNASSIGNED_SEQ_NO;
    return new Checkpoint(offset, numOps, generation, minSeqNo, maxSeqNo, globalCheckpoint, minTranslogGeneration, trimmedAboveSeqNo);
}
 
Example 7
Source File: Checkpoint.java    From crate with Apache License 2.0 5 votes vote down vote up
static Checkpoint readCheckpointV5_0_0(final DataInput in) throws IOException {
    final long offset = in.readLong();
    final int numOps = in.readInt();
    final long generation = in.readLong();
    final long minSeqNo = SequenceNumbers.NO_OPS_PERFORMED;
    final long maxSeqNo = SequenceNumbers.NO_OPS_PERFORMED;
    final long globalCheckpoint = SequenceNumbers.UNASSIGNED_SEQ_NO;
    final long minTranslogGeneration = -1;
    final long trimmedAboveSeqNo = SequenceNumbers.UNASSIGNED_SEQ_NO;
    return new Checkpoint(offset, numOps, generation, minSeqNo, maxSeqNo, globalCheckpoint, minTranslogGeneration, trimmedAboveSeqNo);
}
 
Example 8
Source File: Checkpoint.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
Checkpoint(DataInput in) throws IOException {
    offset = in.readLong();
    numOps = in.readInt();
    generation = in.readLong();
}