@Override public void writeInt(int v) { assert buffer != null; buffer.putInt((int) position, v); position += 4; }
public void putInt(long index, int data) { buf.putInt((int) index, data); }
@Override public void writeInt(int offset, int v) { assert buffer != null; buffer.putInt((int) (start + offset), v); }
@Override public void add(long id) { if (numRecords == MAX_NUM_RECORDS) { throw new IllegalStateException( String.format("DmaIdList reaches its maximum number of records: %d", numRecords)); } if (numRecords == capacity) { buffer = ByteBufferUtil.expandBuffer(filename, buffer, META_DATA_SIZE + Math.min(MAX_NUM_RECORDS, 2 * capacity) * SIZE_OF_DATA); capacity *= 2; } buffer.putLong(id); buffer.putInt(0, ++numRecords); }
private void updateEndIndex(int position) { this.endIndex = position; this.header.position(IDENTIFIER.length + 2 + 1 + 4); this.header.putInt(position); int recordUnit = CONSTANTS_RECORD_SIZE + 1; int textLength = this.endIndex - CONSTANTS_START_INDEX; int startIndex = textLength / recordUnit; for (int index = this.recordList.size() - 1; index >= startIndex; index--) { CleanupRecord record = this.recordList.remove(index); if (record == null) { continue; } // end-if (record == null) this.unRegisterRecord(record); } // end-for (int index = this.recordList.size() - 1; index >= startIndex; index--) }
public void putInt(long index, int data) { dumpBuffer[getBufferIndex(index)].putInt(getBufferOffset(index),data); }
private void checkStartIndex() { this.header.position(IDENTIFIER.length + 2 + 1); int start = this.header.getInt(); if (start == IDENTIFIER.length + 2 + 1 + 8) { // ignore } else if (start == 0) { this.header.position(IDENTIFIER.length + 2 + 1); this.header.putInt(IDENTIFIER.length + 2 + 1 + 8); } else { throw new IllegalStateException(); } }
private int checkEndIndex() { this.header.position(IDENTIFIER.length + 2 + 1 + 4); int end = this.header.getInt(); if (end == 0) { this.header.position(IDENTIFIER.length + 2 + 1 + 4); this.header.putInt(IDENTIFIER.length + 2 + 1 + 8); return IDENTIFIER.length + 2 + 1 + 8; } else if (end < CONSTANTS_START_INDEX) { throw new IllegalStateException(); } else { return end; } }
+ this.indexHeader.getIndexCount() * indexSize; this.mappedByteBuffer.putInt(absIndexPos, keyHash); this.mappedByteBuffer.putLong(absIndexPos + 4, phyOffset); this.mappedByteBuffer.putInt(absIndexPos + 4 + 8, (int) timeDiff); this.mappedByteBuffer.putInt(absIndexPos + 4 + 8 + 4, slotValue); this.mappedByteBuffer.putInt(absSlotPos, this.indexHeader.getIndexCount());
private void flushBuffer() throws BufferOverflowException { if (pagedIn) { MappedByteBuffer buffer; // Only flush if page was changed if (dirtyPage) { Collection<byte[]> values = pageMap.values(); buffer = spillFile.getPage(pageIndex); buffer.clear(); // number of elements buffer.putInt(values.size()); for (byte[] value : values) { // element length buffer.putInt(value.length); // element buffer.put(value, 0, value.length); } } buffer = null; // Reset page stats pageMap.clear(); totalResultSize = 0; } pagedIn = false; dirtyPage = false; }
private void flushBuffer() throws BufferOverflowException { if (pagedIn) { MappedByteBuffer buffer; // Only flush if page was changed if (dirtyPage) { Collection<byte[]> values = pageMap.values(); buffer = spillFile.getPage(pageIndex); buffer.clear(); // number of elements buffer.putInt(values.size()); for (byte[] value : values) { // element length buffer.putInt(value.length); // element buffer.put(value, 0, value.length); } } buffer = null; // Reset page stats pageMap.clear(); totalResultSize = 0; } pagedIn = false; dirtyPage = false; }
writeBuffer.putInt(EOF); // end fc.force(true); fc.close();
@Override protected void writeToBuffer(MappedByteBuffer buffer, ResultEntry e) { int totalLen = 0; List<KeyValue> keyValues = toKeyValues(e); for (KeyValue kv : keyValues) { totalLen += (kv.getLength() + Bytes.SIZEOF_INT); } buffer.putInt(totalLen); for (KeyValue kv : keyValues) { buffer.putInt(kv.getLength()); buffer.put(kv.getBuffer(), kv.getOffset(), kv .getLength()); } ImmutableBytesWritable[] sortKeys = e.sortKeys; buffer.putInt(sortKeys.length); for (ImmutableBytesWritable sortKey : sortKeys) { if (sortKey != null) { buffer.putInt(sortKey.getLength()); buffer.put(sortKey.get(), sortKey.getOffset(), sortKey.getLength()); } else { buffer.putInt(0); } } }
@SuppressWarnings("deprecation") @Override protected void writeToBuffer(MappedByteBuffer buffer, Tuple e) { KeyValue kv = PhoenixKeyValueUtil.maybeCopyCell(e.getValue(0)); buffer.putInt(kv.getLength() + Bytes.SIZEOF_INT); buffer.putInt(kv.getLength()); buffer.put(kv.getBuffer(), kv.getOffset(), kv.getLength()); }
totalLen += (kv.getLength() + Bytes.SIZEOF_INT); writeBuffer.putInt(totalLen); for (KeyValue kv : keyValues) { writeBuffer.putInt(kv.getLength()); writeBuffer.put(kv.getBuffer(), kv.getOffset(), kv .getLength()); writeBuffer.putInt(sortKeys.length); for (ImmutableBytesWritable sortKey : sortKeys) { if (sortKey != null) { writeBuffer.putInt(sortKey.getLength()); writeBuffer.put(sortKey.get(), sortKey.getOffset(), sortKey.getLength()); } else { writeBuffer.putInt(0); writeBuffer.putInt(-1); // end flushedCount = results.size(); results.clear();
+ this.indexHeader.getIndexCount() * indexSize; this.mappedByteBuffer.putInt(absIndexPos, keyHash); this.mappedByteBuffer.putLong(absIndexPos + 4, phyOffset); this.mappedByteBuffer.putInt(absIndexPos + 4 + 8, (int) timeDiff); this.mappedByteBuffer.putInt(absIndexPos + 4 + 8 + 4, slotValue); this.mappedByteBuffer.putInt(absSlotPos, this.indexHeader.getIndexCount());
public void set(int x, int d) { long p = x * 4; int mapN = (int) (p / MAPPING_SIZE); int offN = (int) (p % MAPPING_SIZE); mappings.get(mapN).putInt(offN, d); }
public void putWriteCounter(int writeCounter) { this.writeIndex.position(WRITE_CNT_OFFSET); this.writeIndex.putInt(writeCounter); this.writeCounter = writeCounter; }
public void putReadNum(int readNum) { this.readIndex.position(READ_NUM_OFFSET); this.readIndex.putInt(readNum); this.readNum = readNum; }
@Override protected void writeDefaultData() throws IOException { buffer.position(WindowPos); buffer.putInt(this.window); buffer.putLong(this.timeout); for(int i=0;i<MaxWindowCount;i++) { availableEntries.add(i); } }