All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sirix.node.Utils Maven / Gradle / Ivy

Go to download

SirixDB is a hybrid on-disk and in-memory document oriented, versioned database system. It has a lightweight buffer manager, stores everything in a huge persistent and durable tree and allows efficient reconstruction of every revision. Furthermore, SirixDB implements change tracking, diffing and supports time travel queries.

There is a newer version: 0.11.0
Show newest version
package org.sirix.node;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;

public final class Utils {

  /**
   * Store a "compressed" variable-length long value.
   * 
   * @param output {@link ByteArrayDataOutput} reference
   * @param value long value
   */
  public static final void putVarLong(final DataOutput output, long value) throws IOException {
    while ((value & ~0x7F) != 0) {
      output.write(((byte) ((value & 0x7f) | 0x80)));
      value >>>= 7;
    }
    output.write((byte) value);
  }

  /**
   * Get a "compressed" variable-length long value.
   * 
   * @param input {@link ByteArrayDataInput} reference
   * @return long value
   */
  public static final long getVarLong(final DataInput input) throws IOException {
    byte singleByte = input.readByte();
    long value = singleByte & 0x7F;
    for (int shift = 7; (singleByte & 0x80) != 0; shift += 7) {
      singleByte = input.readByte();
      value |= (singleByte & 0x7FL) << shift;
    }
    return value;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy