当前位置: 首页>>代码示例>>Java>>正文


Java PipeReader.tryMoveSingleMessage方法代码示例

本文整理汇总了Java中com.ociweb.pronghorn.pipe.PipeReader.tryMoveSingleMessage方法的典型用法代码示例。如果您正苦于以下问题:Java PipeReader.tryMoveSingleMessage方法的具体用法?Java PipeReader.tryMoveSingleMessage怎么用?Java PipeReader.tryMoveSingleMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ociweb.pronghorn.pipe.PipeReader的用法示例。


在下文中一共展示了PipeReader.tryMoveSingleMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
@Override
public void run() {
    
    if (moveInProgress) {
        if (!PipeReader.tryMoveSingleMessage(input, output)) {
            return;
        } else {
            moveInProgress = false;
            PipeReader.releaseReadLock(input);
        }
    }
    
    while (PipeWriter.hasRoomForWrite(output) && PipeReader.tryReadFragment(input)) {
                    
        count++;
        int value = PipeReader.readInt(input, varFieldLoc);  
        
        if (0 != (mask&value)) {
            if (!PipeReader.tryMoveSingleMessage(input, output)) {
                moveInProgress = true;
                return;
            }              
        }
        PipeReader.releaseReadLock(input);
    }        
}
 
开发者ID:oci-pronghorn,项目名称:Pronghorn,代码行数:27,代码来源:FlagFilterStage.java

示例2: run

import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
@Override
public void run() {
    
    if (moveInProgress) {
        if (!PipeReader.tryMoveSingleMessage(input, output)) {
            return;
        } else {
            moveInProgress = false;
            PipeReader.releaseReadLock(input);
        }
    }
    
    
    boolean updateFile = false;
    
    while (PipeWriter.hasRoomForWrite(output) && PipeReader.tryReadFragment(input)) {
        updateFile = true;
        byte[] backing = PipeReader.readBytesBackingArray(input, varFieldLoc);
        int pos = PipeReader.readBytesPosition(input, varFieldLoc);
        int len = PipeReader.readBytesLength(input, varFieldLoc);
        int mask = PipeReader.readBytesMask(input, varFieldLoc);
                    
        if (!filter.mayContain(backing,pos,len,mask)) {
            filter.addValue(backing,pos,len,mask);                

            if (! PipeReader.tryMoveSingleMessage(input, output)) {
                moveInProgress = true;
                return;
            }
            
        }
        
        PipeReader.releaseReadLock(input);
    }
    if (updateFile) {
        saveFilter();
    }
}
 
开发者ID:oci-pronghorn,项目名称:Pronghorn,代码行数:39,代码来源:PassUniquesFilterStage.java

示例3: run

import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
@Override
public void run() {
    if (moveInProgress) {
        if (!PipeReader.tryMoveSingleMessage(input, output)) {
            return;
        } else {
            moveInProgress = false;
            PipeReader.releaseReadLock(input);
        }
    }
    
    boolean updateFile = false;
    while (PipeWriter.hasRoomForWrite(output) && PipeReader.tryReadFragment(input)) {
        updateFile = true;            
        byte[] backing = PipeReader.readBytesBackingArray(input, varFieldLoc);
        int pos = PipeReader.readBytesPosition(input, varFieldLoc);
        int len = PipeReader.readBytesLength(input, varFieldLoc);
        int mask = PipeReader.readBytesMask(input, varFieldLoc);
        
        int i = instances;
        while (--i>=0 && filters[i].mayContain(backing,pos,len,mask)) {
        }
        
        if (i<0) {
            if (!PipeReader.tryMoveSingleMessage(input, output)) {
                 moveInProgress = true;
                return;
            }
        } else {
            //this one did not contain it so add it.
            filters[i].addValue(backing,pos,len,mask);
        }
        
        PipeReader.releaseReadLock(input);
    }
    if (updateFile) {
        saveFilter();
    }
}
 
开发者ID:oci-pronghorn,项目名称:Pronghorn,代码行数:40,代码来源:PassRepeatsFilterStage.java

示例4: run

import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
@Override
public void run() {		
    
      do {	          
            if (-2==this.msgId) {
                if (PipeReader.tryReadFragment(this.inputRing)) {
                    //shutdown logic
                    if ((this.msgId = PipeReader.getMsgIdx(this.inputRing))<0) {
                        PipeReader.releaseReadLock(this.inputRing);
                        this.requestShutdown();
                        return;
                    }       
                } else {	        
                    //nothing to read so try again
                    return;
                }
            }
    
            //continue trying to move this message until we reach the end
            if (PipeReader.tryMoveSingleMessage(this.inputRing, this.outputRings[this.targetRing])) {
                //we have reached the end of the message
                PipeReader.releaseReadLock(this.inputRing);
                if (--this.targetRing<0) {
                    this.targetRing = this.targetRingInit;
                }               
                this.msgId = -2;
            } else {
                return;
            }

        } while(true);  
}
 
开发者ID:oci-pronghorn,项目名称:Pronghorn,代码行数:33,代码来源:RoundRobinRouteStage.java

示例5: run

import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
@Override
public void run() {
    int[] slab = Pipe.slab(input);
    byte[] blob = Pipe.blob(input);
    
    int slabMask = Pipe.slabMask(input);
    int blobMask = Pipe.blobMask(input);
    do {            
        if (-2==this.msgId) {
            if (PipeReader.tryReadFragment(this.input)) {
                //Shutdown logic
                if ((this.msgId = PipeReader.getMsgIdx(this.input))<0) {
                    PipeReader.releaseReadLock(this.input);
                    this.requestShutdown();
                    return;
                }  else {
                    //////////////////
                    //NOTE: This bloom filer will only use the content of the first fragment
                    //      as the input to the hash
                    //////////////////
                    
                    int slabLength = Pipe.sizeOf(this.input, this.msgId);
                    long endOfFragment = Pipe.getWorkingTailPosition(input);                        
                    int slabPos = (int)(slabMask & (endOfFragment-slabLength));
                    
                    int blobLength = slab[(int)(slabMask & (endOfFragment-1))];                        
                    int blobPos = Pipe.bytesReadBase(input);
                                            
                    this.targetPipe = outputs[bloomFilter.add(slab,slabPos,slabMask,slabLength,blob,blobPos,blobMask,blobLength)];
                     
                }
            } else {                        
                //unable to read anything try again later
                return;
            }
        }

        if (PipeReader.tryMoveSingleMessage(this.input, this.targetPipe)) {
            PipeReader.releaseReadLock(this.input); 
            this.msgId = -2;
        } else {
            return;
        }

    } while(true);
}
 
开发者ID:oci-pronghorn,项目名称:Pronghorn,代码行数:47,代码来源:BloomFilterStage.java


注:本文中的com.ociweb.pronghorn.pipe.PipeReader.tryMoveSingleMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。