Tabnine Logo
org.apache.kylin.common.util
Code IndexAdd Tabnine to your IDE (free)

How to use org.apache.kylin.common.util

Best Java code snippets using org.apache.kylin.common.util (Showing top 20 results out of 315)

origin: apache/kylin

  @Override
  public ByteArray deserialize(ByteBuffer in) {
    //the array in ByteArray is garanteed to be completed owned by the ByteArray 
    return new ByteArray(BytesUtil.readByteArray(in));
  }
}
origin: apache/kylin

private void serializeGTRecord(GTRecord gtRecord, ByteBuffer out) {
  BytesUtil.writeVInt(gtRecord.cols.length, out);
  for (ByteArray col : gtRecord.cols) {
    col.exportData(out);
  }
}
origin: apache/kylin

@Override
public Object deserialize(ByteBuffer in) {
  int id = BytesUtil.readUnsigned(in, dict.getSizeOfId());
  return dict.getValueFromId(id);
}
origin: apache/kylin

public byte[] toBytes() {
  return Bytes.copy(this.array(), this.offset(), this.length());
}
origin: apache/kylin

@Override
public void serialize(ByteArray code, ByteBuffer buffer) {
  if (code == null)
    BytesUtil.writeByteArray(null, 0, 0, buffer);
  else
    BytesUtil.writeByteArray(code.array(), code.offset(), code.length(), buffer);
}
origin: apache/kylin

public static void writeUTFString(String str, ByteBuffer out) {
  byte[] bytes = str == null ? null : Bytes.toBytes(str);
  writeByteArray(bytes, out);
}
origin: apache/kylin

@Override
public void reload(Object measureValue) {
  if (measureValue == null) {
    value = null;
    return;
  }
  ByteArray byteArray = (ByteArray) measureValue;
  //the array in ByteArray is guaranteed to be completed owned by the ByteArray
  value = Bytes.toString(byteArray.array());
}
origin: apache/kylin

public static String readUTFString(ByteBuffer in) {
  byte[] bytes = readByteArray(in);
  return bytes == null ? null : Bytes.toString(bytes);
}
origin: apache/kylin

public int sizeOf(ImmutableBitSet selectedCols) {
  int size = 0;
  for (int i = 0; i < selectedCols.trueBitCount(); i++) {
    int c = selectedCols.trueBitAt(i);
    size += cols[c].length();
  }
  return size;
}
origin: apache/kylin

@Override
public int hashCode() {
  if (data == null) {
    return 0;
  } else {
    if (length <= Bytes.SIZEOF_LONG && length > 0) {
      // to avoid hash collision of byte arrays those are converted from nearby integers/longs, which is the case for kylin dictionary
      long value = BytesUtil.readLong(data, offset, length);
      return (int) (value ^ (value >>> 32));
    }
    return Bytes.hashCode(data, offset, length);
  }
}
origin: apache/kylin

@Override
public int hashCode() {
  int hash = 1;
  for (int i = 0; i < info.colAll.trueBitCount(); i++) {
    int c = info.colAll.trueBitAt(i);
    hash = (31 * hash) + cols[c].hashCode();
  }
  return hash;
}
origin: apache/kylin

public String toReadableText() {
  if (data == null) {
    return null;
  } else {
    return BytesUtil.toHex(data, offset, length);
  }
}
origin: apache/kylin

@Override
public void createTestMetadata(String... overlayMetadataDirs) {
  staticCreateTestMetadata(true, new OverlayMetaHook(overlayMetadataDirs));
}
origin: apache/kylin

/** reserve without wait, fail with NotEnoughBudgetException immediately if no mem */
public void reserve(MemoryConsumer consumer, int requestMB) {
  if (totalBudgetMB == 0 && requestMB > 0)
    throw new NotEnoughBudgetException();
  boolean ok = false;
  while (!ok) {
    int gap = calculateGap(consumer, requestMB);
    if (gap > 0) {
      // to void deadlock, don't hold lock when invoking consumer.freeUp()
      tryFreeUp(gap);
    }
    ok = updateBooking(consumer, requestMB);
  }
}
origin: apache/kylin

/**
 * @param b bytes to hash
 * @return Runs {@link org.apache.hadoop.io.WritableComparator#hashBytes(byte[], int)} on the
 * passed in array.  This method is what {@link org.apache.hadoop.io.Text} and
 * {@link org.apache.hadoop.hbase.io.ImmutableBytesWritable} use calculating hash code.
 */
public static int hashCode(final byte[] b) {
  return hashCode(b, b.length);
}
origin: apache/kylin

/**
 * @param a      array
 * @param length new array size
 * @return Value in <code>a</code> plus <code>length</code> prepended 0 bytes
 */
public static byte[] padHead(final byte[] a, final int length) {
  byte[] padding = new byte[length];
  for (int i = 0; i < length; i++) {
    padding[i] = 0;
  }
  return add(padding, a);
}
origin: apache/kylin

@Override
public void serialize(ByteArray value, ByteBuffer out) {
  if (value != null && value.array() != null) {
    BytesUtil.writeByteArray(value.array(), value.offset(), value.length(), out);
  } else {
    BytesUtil.writeByteArray(null, out);
  }
}
origin: apache/kylin

  @Override
  public ByteArray deserialize(ByteBuffer buffer) {
    return new ByteArray(BytesUtil.readByteArray(buffer));
  }
};
origin: apache/kylin

/**
 * @param a      array
 * @param length new array size
 * @return Value in <code>a</code> plus <code>length</code> appended 0 bytes
 */
public static byte[] padTail(final byte[] a, final int length) {
  byte[] padding = new byte[length];
  for (int i = 0; i < length; i++) {
    padding[i] = 0;
  }
  return add(a, padding);
}
origin: apache/kylin

public static ByteArray importData(ByteBuffer in) {
  byte[] bytes = BytesUtil.readByteArray(in);
  return new ByteArray(bytes);
}
org.apache.kylin.common.util

Most used classes

  • Pair
    A generic class for pairs. Copied from org.apache.hadoop.hbase.util.Pair
  • JsonUtil
  • Bytes
    Utility class that handles byte arrays, conversions to/from other types, comparisons, hash code gene
  • BytesUtil
  • ClassUtil
  • StringUtil,
  • ByteArray,
  • DateFormat,
  • RandomUtil,
  • CliCommandExecutor,
  • Dictionary,
  • Array,
  • ImmutableBitSet,
  • OptionsHelper,
  • AutoReadWriteLock,
  • DBUtils,
  • MailService,
  • HiveCmdBuilder,
  • StringSplitter
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now