Ejemplo n.º 1
0
 public void setString(int columnIndex, String value) {
   Integer reuseIndex = stringReferences.get(value);
   if (reuseIndex != null) {
     bufferSlice.setInt(getOffset(columnIndex), reuseIndex);
   } else {
     int index = stringReferences.size();
     stringReferences.put(value, index);
     bufferSlice.setInt(getOffset(columnIndex), index);
     stringReferenceSize +=
         value.length() * 2 + 4; // assuming size of char = size of byte * 2 + length
   }
   clearNull(columnIndex);
 }
Ejemplo n.º 2
0
  private void doFlush() {
    if (buffer != null && count > 0) {
      // write page header
      bufferSlice.setInt(0, count);
      buffer.limit(position);

      // flush page
      Page page = Page.wrap(buffer).setStringReferences(getSortedStringReferences());
      buffer = null;
      bufferSlice = null;
      output.add(page);
    }
  }
Ejemplo n.º 3
0
  public void addRecord() {
    // record header
    bufferSlice.setInt(
        position, nextVariableLengthDataOffset); // nextVariableLengthDataOffset means record size
    bufferSlice.setBytes(position + 4, nullBitSet);
    count++;

    this.position += nextVariableLengthDataOffset;
    this.nextVariableLengthDataOffset = fixedRecordSize;
    Arrays.fill(nullBitSet, (byte) -1);

    // flush if next record will not fit in this buffer
    if (buffer.capacity() < position + nextVariableLengthDataOffset + stringReferenceSize) {
      flush();
    }
  }
Ejemplo n.º 4
0
 public void setTimestamp(int columnIndex, Timestamp value) {
   int offset = getOffset(columnIndex);
   bufferSlice.setLong(offset, value.getEpochSecond());
   bufferSlice.setInt(offset + 8, value.getNano());
   clearNull(columnIndex);
 }