本文整理汇总了Java中io.netty.util.internal.PlatformDependent.putShort方法的典型用法代码示例。如果您正苦于以下问题:Java PlatformDependent.putShort方法的具体用法?Java PlatformDependent.putShort怎么用?Java PlatformDependent.putShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.util.internal.PlatformDependent
的用法示例。
在下文中一共展示了PlatformDependent.putShort方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeShort
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
@Override
public ByteBuf writeShort(int value) {
ensure(2);
PlatformDependent.putShort(addr(writerIndex), (short) value);
writerIndex += 2;
return this;
}
示例2: writeChar
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
@Override
public ByteBuf writeChar(int value) {
ensure(2);
PlatformDependent.putShort(addr(writerIndex), (short) value);
writerIndex += 2;
return this;
}
示例3: intRoundtrip
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
@Test
public void intRoundtrip(){
final int count = 1024;
try(
NullableIntVector in = new NullableIntVector("in", allocator);
NullableIntVector out = new NullableIntVector("out", allocator);
){
in.allocateNew(count);
for(int i = 0; i < count; i++){
if(i % 5 == 0){
in.getMutator().setSafe(i, i);
}
}
in.getMutator().setValueCount(count);
List<FieldBufferCopier> copiers = FieldBufferCopier.getCopiers(ImmutableList.<FieldVector>of(in), ImmutableList.<FieldVector>of(out));
try(
final SelectionVector2 sv2 = new SelectionVector2(allocator);
){
sv2.allocateNew(count);
// create full sv2.
int x = 0;
for(long mem = sv2.memoryAddress(); mem < sv2.memoryAddress() + count * 2; mem+=2){
PlatformDependent.putShort(mem, (short) (char) x);
x++;
}
sv2.setRecordCount(count);
copy(copiers, sv2);
out.getMutator().setValueCount(count);
for(int i =0; i < count; i++){
assertEquals(in.getAccessor().getObject(i), out.getAccessor().getObject(i));
}
}
}
}
示例4: bigintRoundtrip
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
@Test
public void bigintRoundtrip(){
final int count = 1024;
try(
NullableBigIntVector in = new NullableBigIntVector("in", allocator);
NullableBigIntVector out = new NullableBigIntVector("out", allocator);
){
in.allocateNew(count);
for(int i = 0; i < count; i++){
if(i % 5 == 0){
in.getMutator().setSafe(i, i);
}
}
in.getMutator().setValueCount(count);
List<FieldBufferCopier> copiers = FieldBufferCopier.getCopiers(ImmutableList.<FieldVector>of(in), ImmutableList.<FieldVector>of(out));
try(
final SelectionVector2 sv2 = new SelectionVector2(allocator);
){
sv2.allocateNew(count);
// create full sv2.
int x = 0;
for(long mem = sv2.memoryAddress(); mem < sv2.memoryAddress() + count * 2; mem+=2){
PlatformDependent.putShort(mem, (short) (char) x);
x++;
}
sv2.setRecordCount(count);
copy(copiers, sv2);
out.getMutator().setValueCount(count);
for(int i =0; i < count; i++){
assertEquals(in.getAccessor().getObject(i), out.getAccessor().getObject(i));
}
}
}
}
示例5: setShort
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
@Override
public ByteBuf setShort(int index, int value) {
chk(index, 2);
PlatformDependent.putShort(addr(index), (short) value);
return this;
}
示例6: setChar
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
@Override
public ByteBuf setChar(int index, int value) {
chk(index, 2);
PlatformDependent.putShort(addr(index), (short) value);
return this;
}
示例7: _setShort
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
private void _setShort(int index, int value) {
PlatformDependent.putShort(addr(index), (short) value);
}
示例8: projectBuildNonMatches
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
/**
* Project any remaining build items that were not matched. Only used when doing a FULL or RIGHT join.
* @return Negative output if records were output but batch wasn't completed. Positive output if batch was completed.
*/
public int projectBuildNonMatches() {
assert projectUnmatchedBuild;
projectBuildNonMatchesWatch.start();
final int targetRecordsPerBatch = this.targetRecordsPerBatch;
int outputRecords = 0;
int remainderBuildSetIndex = this.remainderBuildSetIndex;
int nextClearIndex = remainderBuildElementIndex;
BitSet currentBitset = remainderBuildSetIndex < 0 ? null : matches[remainderBuildSetIndex];
final long projectBuildOffsetAddr = this.projectBuildOffsetAddr;
// determine the next set of unmatched bits.
while(outputRecords < targetRecordsPerBatch) {
if(nextClearIndex == -1){
// we need to move to the next bit set since the current one has no more matches.
remainderBuildSetIndex++;
if (remainderBuildSetIndex < matches.length) {
currentBitset = matches[remainderBuildSetIndex];
nextClearIndex = 0;
} else {
// no bitsets left.
this.remainderBuildSetIndex = matches.length;
remainderBuildSetIndex = -1;
break;
}
}
nextClearIndex = currentBitset.nextClearBit(nextClearIndex);
if(nextClearIndex != -1){
// the clear bit is only valid if it is within the batch it corresponds to.
if(nextClearIndex >= matchMaxes[remainderBuildSetIndex]){
nextClearIndex = -1;
}else{
final long projectBuildOffsetAddrStart = projectBuildOffsetAddr + outputRecords * BUILD_RECORD_LINK_SIZE;
PlatformDependent.putInt(projectBuildOffsetAddrStart, remainderBuildSetIndex);
PlatformDependent.putShort(projectBuildOffsetAddrStart + 4, (short)(nextClearIndex & HashTable.BATCH_MASK));
outputRecords++;
nextClearIndex++;
}
}
}
projectBuildNonMatchesWatch.stop();
allocateOnlyProbe(outputRecords);
projectBuild(projectBuildOffsetAddr, outputRecords);
this.remainderBuildSetIndex = remainderBuildSetIndex;
this.remainderBuildElementIndex = nextClearIndex;
if(remainderBuildElementIndex == -1){
return outputRecords;
} else {
return -outputRecords;
}
}
示例9: setLinks
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
private void setLinks(long indexAddr, final int buildBatch, final int records){
for(int incomingRecordIndex = 0; incomingRecordIndex < records; incomingRecordIndex++, indexAddr+=4){
final int hashTableIndex = PlatformDependent.getInt(indexAddr);
if(hashTableIndex == -1){
continue;
}
/* Use the global index returned by the hash table, to store
* the current record index and batch index. This will be used
* later when we probe and find a match.
*/
/* set the current record batch index and the index
* within the batch at the specified keyIndex. The keyIndex
* denotes the global index where the key for this record is
* stored in the hash table
*/
int hashTableBatch = hashTableIndex >>> 16;
int hashTableOffset = hashTableIndex & BATCH_MASK;
final ArrowBuf startIndex = startIndices.get(hashTableBatch);
final long startIndexMemStart = startIndex.memoryAddress() + hashTableOffset * HashTable.BUILD_RECORD_LINK_SIZE;
// If head of the list is empty, insert current index at this position
final int linkBatch = PlatformDependent.getInt(startIndexMemStart);
if (linkBatch == INDEX_EMPTY) {
PlatformDependent.putInt(startIndexMemStart, buildBatch);
PlatformDependent.putShort(startIndexMemStart + 4, (short) incomingRecordIndex);
} else {
/* Head of this list is not empty, if the first link
* is empty insert there
*/
hashTableBatch = linkBatch;
hashTableOffset = PlatformDependent.getShort(startIndexMemStart + 4);
final ArrowBuf firstLink = buildInfoList.get(hashTableBatch).getLinks();
final long firstLinkMemStart = firstLink.memoryAddress() + hashTableOffset * HashTable.BUILD_RECORD_LINK_SIZE;
final int firstLinkBatch = PlatformDependent.getInt(firstLinkMemStart);
if (firstLinkBatch == INDEX_EMPTY) {
PlatformDependent.putInt(firstLinkMemStart, buildBatch);
PlatformDependent.putShort(firstLinkMemStart + 4, (short) incomingRecordIndex);
} else {
/* Insert the current value as the first link and
* make the current first link as its next
*/
final short firstLinkOffset = PlatformDependent.getShort(firstLinkMemStart + 4);
final ArrowBuf nextLink = buildInfoList.get(buildBatch).getLinks();
final long nextLinkMemStart = nextLink.memoryAddress() + incomingRecordIndex * HashTable.BUILD_RECORD_LINK_SIZE;
PlatformDependent.putInt(nextLinkMemStart, firstLinkBatch);
PlatformDependent.putShort(nextLinkMemStart + 4, firstLinkOffset);
// As the existing (batch, offset) pair is moved out of firstLink into nextLink,
// now put the new (batch, offset) in the firstLink
PlatformDependent.putInt(firstLinkMemStart, buildBatch);
PlatformDependent.putShort(firstLinkMemStart + 4, (short) incomingRecordIndex);
}
}
}
}
示例10: setCurrentIndex
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
private void setCurrentIndex(final int hashTableIndex, final int buildBatch, final int incomingRecordIndex) throws SchemaChangeException {
/* set the current record batch index and the index
* within the batch at the specified keyIndex. The keyIndex
* denotes the global index where the key for this record is
* stored in the hash table
*/
int hashTableBatch = hashTableIndex / HashTable.BATCH_SIZE;
int hashTableOffset = hashTableIndex % HashTable.BATCH_SIZE;
final ArrowBuf startIndex = startIndices.get(hashTableBatch);
final long startIndexMemStart = startIndex.memoryAddress() + hashTableOffset * BUILD_RECORD_LINK_SIZE;
// If head of the list is empty, insert current index at this position
final int linkBatch = PlatformDependent.getInt(startIndexMemStart);
if (linkBatch == INDEX_EMPTY) {
PlatformDependent.putInt(startIndexMemStart, buildBatch);
PlatformDependent.putShort(startIndexMemStart + 4, (short) incomingRecordIndex);
} else {
/* Head of this list is not empty, if the first link
* is empty insert there
*/
hashTableBatch = linkBatch;
hashTableOffset = PlatformDependent.getShort(startIndexMemStart + 4);
final ArrowBuf firstLink = buildInfoList.get(hashTableBatch).getLinks();
final long firstLinkMemStart = firstLink.memoryAddress() + hashTableOffset * BUILD_RECORD_LINK_SIZE;
final int firstLinkBatch = PlatformDependent.getInt(firstLinkMemStart);
if (firstLinkBatch == INDEX_EMPTY) {
PlatformDependent.putInt(firstLinkMemStart, buildBatch);
PlatformDependent.putShort(firstLinkMemStart + 4, (short) incomingRecordIndex);
} else {
/* Insert the current value as the first link and
* make the current first link as its next
*/
final short firstLinkOffset = PlatformDependent.getShort(firstLinkMemStart + 4);
final ArrowBuf nextLink = buildInfoList.get(buildBatch).getLinks();
final long nextLinkMemStart = nextLink.memoryAddress() + incomingRecordIndex * BUILD_RECORD_LINK_SIZE;
PlatformDependent.putInt(nextLinkMemStart, firstLinkBatch);
PlatformDependent.putShort(nextLinkMemStart + 4, firstLinkOffset);
// As the existing (batch, offset) pair is moved out of firstLink into nextLink,
// now put the new (batch, offset) in the firstLink
PlatformDependent.putInt(firstLinkMemStart, buildBatch);
PlatformDependent.putShort(firstLinkMemStart + 4, (short) incomingRecordIndex);
}
}
}
示例11: varcharRoundtrip
import io.netty.util.internal.PlatformDependent; //导入方法依赖的package包/类
@Test
public void varcharRoundtrip(){
final int count = 1024;
try(
NullableVarCharVector in = new NullableVarCharVector("in", allocator);
NullableVarCharVector out = new NullableVarCharVector("out", allocator);
){
in.allocateNew(count * 8, count);
for(int i = 0; i < count; i++){
if(i % 5 == 0){
byte[] data = ("hello-" + i).getBytes(Charsets.UTF_8);
in.getMutator().setSafe(i, data, 0, data.length);
}
}
in.getMutator().setValueCount(count);
List<FieldBufferCopier> copiers = FieldBufferCopier.getCopiers(ImmutableList.<FieldVector>of(in), ImmutableList.<FieldVector>of(out));
try(
final SelectionVector2 sv2 = new SelectionVector2(allocator);
){
sv2.allocateNew(count);
// create full sv2.
int x = 0;
for(long mem = sv2.memoryAddress(); mem < sv2.memoryAddress() + count * 2; mem+=2){
PlatformDependent.putShort(mem, (short) (char) x);
x++;
}
sv2.setRecordCount(count);
copy(copiers, sv2);
out.getMutator().setValueCount(count);
for(int i =0; i < count; i++){
assertEquals(in.getAccessor().getObject(i), out.getAccessor().getObject(i));
}
}
}
}