ByteArrayPointable
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.apache.hyracks.data.std.primitive.ByteArrayPointable(Showing top 15 results out of 315)

origin: apache/asterixdb

@Override
public IPointable createPointable() {
  return new ByteArrayPointable();
}
origin: apache/asterixdb

@Override
public int hash() {
  if (hash == 0) {
    int h = 0;
    int realLength = getContentLength();
    int startOffset = getContentStartOffset();
    for (int i = 0; i < realLength; ++i) {
      h = 31 * h + bytes[startOffset + i];
    }
    hash = h;
  }
  return hash;
}
origin: apache/asterixdb

@Override
protected void afterReset() {
  contentLength = getContentLength(getByteArray(), getStartOffset());
  metaLength = getNumberBytesToStoreMeta(contentLength);
  hash = 0;
}
origin: apache/asterixdb

public static ByteArrayPointable generatePointableFromPureBytes(byte[] bytes, int start, int length) {
  int metaLen = getNumberBytesToStoreMeta(length);
  byte[] ret = new byte[length + metaLen];
  VarLenIntEncoderDecoder.encode(length, ret, 0);
  for (int i = 0; i < length; ++i) {
    ret[i + metaLen] = bytes[start + i];
  }
  ByteArrayPointable ptr = new ByteArrayPointable();
  ptr.set(ret, 0, ret.length);
  return ptr;
}
origin: apache/asterixdb

public void serialize(ByteArrayPointable byteArrayPtr, DataOutput out) throws HyracksDataException {
  try {
    out.write(byteArrayPtr.getByteArray(), byteArrayPtr.getStartOffset(), byteArrayPtr.getLength());
  } catch (IOException e) {
    throw new HyracksDataException(e);
  }
}
origin: apache/asterixdb

@Override
public void normalize(byte[] bytes, int start, int length, int[] normalizedKeys, int keyStart) {
  normalizedKeys[keyStart] = ByteArrayPointable.normalize(bytes, start);
}
origin: apache/asterixdb

public int getContentStartOffset() {
  return getStartOffset() + getMetaLength();
}
origin: apache/asterixdb

public static ByteArrayPointable generatePointableFromPureBytes(byte[] bytes) {
  return generatePointableFromPureBytes(bytes, 0, bytes.length);
}
origin: apache/asterixdb

@Override
public int compareTo(IPointable pointer) {
  return compareTo(pointer.getByteArray(), pointer.getStartOffset(), pointer.getLength());
}
origin: apache/asterixdb

@Override
public void evaluate(IFrameTupleReference tuple, IPointable resultPointable) throws HyracksDataException {
  resultStorage.reset();
  for (int i = 0; i < pointables.length; ++i) {
    evaluators[i].evaluate(tuple, pointables[i]);
  }
  int fromOffset = getFromOffset(tuple);
  ATypeTag textTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0].getStartOffset()]];
  ATypeTag wordTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1].getStartOffset()]];
  checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAG, textTag, wordTag);
  textPtr.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1, pointables[0].getLength() - 1);
  wordPtr.set(pointables[1].getByteArray(), pointables[0].getStartOffset() + 1, pointables[1].getLength() - 1);
  result.setValue(1L + indexOf(textPtr.getByteArray(), textPtr.getContentStartOffset(),
      textPtr.getContentLength(), wordPtr.getByteArray(), wordPtr.getContentStartOffset(),
      wordPtr.getContentLength(), fromOffset));
  intSerde.serialize(result, dataOutput);
  resultPointable.set(resultStorage);
}
origin: apache/asterixdb

public static byte[] copyContent(ByteArrayPointable bytePtr) {
  return Arrays.copyOfRange(bytePtr.getByteArray(), bytePtr.getContentStartOffset(),
      bytePtr.getContentStartOffset() + bytePtr.getContentLength());
}
origin: apache/asterixdb

  checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAGS, argTag0, argTag1);
  byteArrayPointable.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
      pointables[0].getLength() - 1);
  byte[] startBytes = pointables[1].getByteArray();
      - 1;
  int totalLength = byteArrayPointable.getContentLength();
  int subLength = getSubLength(tuple);
  int metaLength = VarLenIntEncoderDecoder.encode(subLength, metaBuffer, 0);
  dataOutput.write(metaBuffer, 0, metaLength);
  dataOutput.write(byteArrayPointable.getByteArray(), byteArrayPointable.getContentStartOffset() + subStart,
      subLength);
} catch (IOException e) {
origin: apache/asterixdb

/**
 * Compute the normalized key of the byte array.
 * The normalized key in Hyracks is mainly used to speedup the comparison between pointable data.
 * In the ByteArray case, we compute the integer value by using the first 4 bytes.
 * The comparator will first use this integer to get the result ( <,>, or =), it will check
 * the actual bytes only if the normalized key is equal. Thus this normalized key must be
 * consistent with the comparison result.
 *
 * @param bytesPtr
 * @param start
 * @return
 */
public static int normalize(byte[] bytesPtr, int start) {
  int len = getContentLength(bytesPtr, start);
  long nk = 0;
  start = start + getNumberBytesToStoreMeta(len);
  for (int i = 0; i < 4; ++i) {
    nk <<= 8;
    if (i < len) {
      nk |= bytesPtr[start + i] & 0xff;
    }
  }
  return (int) (nk >> 1); // make it always positive.
}
origin: apache/asterixdb

@Override
public int compareTo(byte[] thatBytes, int thatStart, int thatLength) {
  int thisArrayLen = getContentLength(this.bytes, this.start);
  int thatArrayLen = getContentLength(thatBytes, thatStart);
  int thisArrayStart = this.getContentStartOffset();
  int thatArrayStart = thatStart + getNumberBytesToStoreMeta(thatArrayLen);
  for (int thisIndex = 0, thatIndex = 0; thisIndex < thisArrayLen
      && thatIndex < thatArrayLen; ++thisIndex, ++thatIndex) {
    if (this.bytes[thisArrayStart + thisIndex] != thatBytes[thatArrayStart + thatIndex]) {
      return (0xff & this.bytes[thisArrayStart + thisIndex]) - (0xff & thatBytes[thatArrayStart + thatIndex]);
    }
  }
  return thisArrayLen - thatArrayLen;
}
origin: apache/asterixdb

@Override
public int getLength() {
  return getContentLength() + getMetaLength();
}
org.apache.hyracks.data.std.primitiveByteArrayPointable

Most used methods

  • getByteArray
  • getContentLength
  • getContentStartOffset
  • getNumberBytesToStoreMeta
  • getStartOffset
  • set
  • <init>
  • compareTo
  • generatePointableFromPureBytes
  • getLength
  • getMetaLength
  • normalize
    Compute the normalized key of the byte array. The normalized key in Hyracks is mainly used to speedu
  • getMetaLength,
  • normalize

Popular classes and methods

  • compareTo (BigDecimal)
    Compares this BigDecimal with val. Returns one of the three values 1, 0, or -1. The method behaves a
  • getApplicationContext (Context)
  • findViewById (Activity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • PrintStream (java.io)
    Wraps an existing OutputStream and provides convenience methods for writing common data types in a h
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • HashSet (java.util)
    This class implements the Set interface, backed by a java.util.HashMap.

For IntelliJ IDEA,
Android Studio or Eclipse

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)