idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
32,200 | protected void extendArray ( int k ) { if ( this . size + k > this . keys . length ) { int newCapacity ; if ( this . keys . length < 1024 ) { newCapacity = 2 * ( this . size + k ) ; } else { newCapacity = 5 * ( this . size + k ) / 4 ; } this . keys = Arrays . copyOf ( this . keys , newCapacity ) ; this . values = Array... | make sure there is capacity for at least k more elements |
32,201 | public ContainerPointer getContainerPointer ( final int startIndex ) { return new ContainerPointer ( ) { int k = startIndex ; public void advance ( ) { ++ k ; } public ContainerPointer clone ( ) { try { return ( ContainerPointer ) super . clone ( ) ; } catch ( CloneNotSupportedException e ) { return null ; } } public i... | Create a ContainerPointer for this RoaringArray |
32,202 | protected void insertNewKeyValueAt ( int i , short key , Container value ) { extendArray ( 1 ) ; System . arraycopy ( keys , i , keys , i + 1 , size - i ) ; keys [ i ] = key ; System . arraycopy ( values , i , values , i + 1 , size - i ) ; values [ i ] = value ; size ++ ; } | insert a new key it is assumed that it does not exist |
32,203 | public int first ( ) { assertNonEmpty ( ) ; short firstKey = keys [ 0 ] ; Container container = values [ 0 ] ; return firstKey << 16 | container . first ( ) ; } | Gets the first value in the array |
32,204 | public int last ( ) { assertNonEmpty ( ) ; short lastKey = keys [ size - 1 ] ; Container container = values [ size - 1 ] ; return lastKey << 16 | container . last ( ) ; } | Gets the last value in the array |
32,205 | public long select ( final long j ) throws IllegalArgumentException { if ( ! doCacheCardinalities ) { return selectNoCache ( j ) ; } int indexOk = ensureCumulatives ( highestHigh ( ) ) ; if ( highToBitmap . isEmpty ( ) ) { return throwSelectInvalidIndex ( j ) ; } int position = Arrays . binarySearch ( sortedCumulatedCa... | Return the jth value stored in this bitmap . |
32,206 | public void serialize ( DataOutput out ) throws IOException { out . writeBoolean ( signedLongs ) ; out . writeInt ( highToBitmap . size ( ) ) ; for ( Entry < Integer , BitmapDataProvider > entry : highToBitmap . entrySet ( ) ) { out . writeInt ( entry . getKey ( ) . intValue ( ) ) ; entry . getValue ( ) . serialize ( o... | Serialize this bitmap . |
32,207 | public long [ ] toArray ( ) { long cardinality = this . getLongCardinality ( ) ; if ( cardinality > Integer . MAX_VALUE ) { throw new IllegalStateException ( "The cardinality does not fit in an array" ) ; } final long [ ] array = new long [ ( int ) cardinality ] ; int pos = 0 ; LongIterator it = getLongIterator ( ) ; w... | Return the set values as an array if the cardinality is smaller than 2147483648 . The long values are in sorted order . |
32,208 | public static Roaring64NavigableMap bitmapOf ( final long ... dat ) { final Roaring64NavigableMap ans = new Roaring64NavigableMap ( ) ; ans . add ( dat ) ; return ans ; } | Generate a bitmap with the specified values set to true . The provided longs values don t have to be in sorted order but it may be preferable to sort them from a performance point of view . |
32,209 | public void add ( final long rangeStart , final long rangeEnd ) { int startHigh = high ( rangeStart ) ; int startLow = low ( rangeStart ) ; int endHigh = high ( rangeEnd ) ; int endLow = low ( rangeEnd ) ; for ( int high = startHigh ; high <= endHigh ; high ++ ) { final int currentStartLow ; if ( startHigh == high ) { ... | Add to the current bitmap all longs in [ rangeStart rangeEnd ) . |
32,210 | public int serializedSizeInBytes ( ) { int count = headerSize ( ) ; for ( int k = 0 ; k < this . size ; ++ k ) { count += values [ k ] . getArraySizeInBytes ( ) ; } return count ; } | Report the number of bytes required for serialization . |
32,211 | private void appendValueLength ( int value , int index ) { int previousValue = toIntUnsigned ( getValue ( index ) ) ; int length = toIntUnsigned ( getLength ( index ) ) ; int offset = value - previousValue ; if ( offset > length ) { setLength ( index , ( short ) offset ) ; } } | Append a value length with all values until a given value |
32,212 | private boolean canPrependValueLength ( int value , int index ) { if ( index < this . nbrruns ) { int nextValue = toIntUnsigned ( getValue ( index ) ) ; if ( nextValue == value + 1 ) { return true ; } } return false ; } | To check if a value length can be prepended with a given value |
32,213 | private void closeValueLength ( int value , int index ) { int initialValue = toIntUnsigned ( getValue ( index ) ) ; setLength ( index , ( short ) ( value - initialValue ) ) ; } | To set the last value of a value length |
32,214 | public static boolean contains ( ByteBuffer buf , int position , short x , final int numRuns ) { int index = bufferedUnsignedInterleavedBinarySearch ( buf , position , 0 , numRuns , x ) ; if ( index >= 0 ) { return true ; } index = - index - 2 ; if ( index != - 1 ) { int offset = toIntUnsigned ( x ) - toIntUnsigned ( b... | Checks whether the run container contains x . |
32,215 | private void prependValueLength ( int value , int index ) { int initialValue = toIntUnsigned ( getValue ( index ) ) ; int length = toIntUnsigned ( getLength ( index ) ) ; setValue ( index , ( short ) value ) ; setLength ( index , ( short ) ( initialValue - value + length ) ) ; } | Prepend a value length with all values starting from a given value |
32,216 | private void smartAppend ( short [ ] vl , short val ) { int oldend ; if ( ( nbrruns == 0 ) || ( toIntUnsigned ( val ) > ( oldend = toIntUnsigned ( vl [ 2 * ( nbrruns - 1 ) ] ) + toIntUnsigned ( vl [ 2 * ( nbrruns - 1 ) + 1 ] ) ) + 1 ) ) { vl [ 2 * nbrruns ] = val ; vl [ 2 * nbrruns + 1 ] = 0 ; nbrruns ++ ; return ; } i... | to return ArrayContainer or BitmapContainer |
32,217 | private boolean valueLengthContains ( int value , int index ) { int initialValue = toIntUnsigned ( getValue ( index ) ) ; int length = toIntUnsigned ( getLength ( index ) ) ; return value <= initialValue + length ; } | To check if a value length contains a given value |
32,218 | static int [ ] negate ( int [ ] x , int Max ) { int [ ] ans = new int [ Max - x . length ] ; int i = 0 ; int c = 0 ; for ( int j = 0 ; j < x . length ; ++ j ) { int v = x [ j ] ; for ( ; i < v ; ++ i ) ans [ c ++ ] = i ; ++ i ; } while ( c < ans . length ) ans [ c ++ ] = i ++ ; return ans ; } | output all integers from the range [ 0 Max ) that are not in the array |
32,219 | public static boolean contains ( ByteBuffer buf , int position , final short i ) { final int x = toIntUnsigned ( i ) ; return ( buf . getLong ( x / 64 * 8 + position ) & ( 1L << x ) ) != 0 ; } | Checks whether the container contains the value i . |
32,220 | public int nextClearBit ( final int i ) { int x = i >> 6 ; long w = ~ bitmap . get ( x ) ; w >>>= i ; if ( w != 0 ) { return i + numberOfTrailingZeros ( w ) ; } int length = bitmap . limit ( ) ; for ( ++ x ; x < length ; ++ x ) { long map = ~ bitmap . get ( x ) ; if ( map != 0L ) { return x * 64 + numberOfTrailingZeros... | Find the index of the next clear bit greater or equal to i . |
32,221 | public int prevClearBit ( final int i ) { int x = i >> 6 ; long w = ~ bitmap . get ( x ) ; w <<= 64 - i - 1 ; if ( w != 0L ) { return i - Long . numberOfLeadingZeros ( w ) ; } for ( -- x ; x >= 0 ; -- x ) { long map = ~ bitmap . get ( x ) ; if ( map != 0L ) { return x * 64 + 63 - Long . numberOfLeadingZeros ( map ) ; }... | Find the index of the previous clear bit less than or equal to i . |
32,222 | public long [ ] toLongArray ( ) { long [ ] answer = new long [ bitmap . limit ( ) ] ; bitmap . rewind ( ) ; bitmap . get ( answer ) ; return answer ; } | Create a copy of the content of this container as a long array . This creates a copy . |
32,223 | public LongBuffer toLongBuffer ( ) { LongBuffer lb = LongBuffer . allocate ( bitmap . length ) ; lb . put ( bitmap ) ; return lb ; } | Return the content of this container as a LongBuffer . This creates a copy and might be relatively slow . |
32,224 | public static boolean contains ( ByteBuffer buf , int position , final short x , int cardinality ) { return BufferUtil . unsignedBinarySearch ( buf , position , 0 , cardinality , x ) >= 0 ; } | Checks whether the container contains the value x . |
32,225 | private void increaseCapacity ( boolean allowIllegalSize ) { int newCapacity = ( this . content . length == 0 ) ? DEFAULT_INIT_SIZE : this . content . length < 64 ? this . content . length * 2 : this . content . length < 1067 ? this . content . length * 3 / 2 : this . content . length * 5 / 4 ; if ( newCapacity > Array... | the illegal container does not return it . |
32,226 | private void preComputeCardinalities ( ) { if ( ! cumulatedCardinalitiesCacheIsValid ) { int nbBuckets = highLowContainer . size ( ) ; if ( highToCumulatedCardinality == null || highToCumulatedCardinality . length != nbBuckets ) { highToCumulatedCardinality = new int [ nbBuckets ] ; } if ( highToCumulatedCardinality . ... | On any . rank or . select operation we pre - compute all cumulated cardinalities . It will enable using a binary - search to spot the relevant underlying bucket . We may prefer to cache cardinality only up - to the selected rank but it would lead to a more complex implementation |
32,227 | public boolean contains ( long minimum , long supremum ) { MutableRoaringBitmap . rangeSanityCheck ( minimum , supremum ) ; short firstKey = highbits ( minimum ) ; short lastKey = highbits ( supremum ) ; int span = BufferUtil . toIntUnsigned ( lastKey ) - BufferUtil . toIntUnsigned ( firstKey ) ; int len = highLowConta... | Checks if the bitmap contains the range . |
32,228 | public int [ ] toArray ( ) { final int [ ] array = new int [ this . getCardinality ( ) ] ; int pos = 0 , pos2 = 0 ; while ( pos < this . highLowContainer . size ( ) ) { final int hs = BufferUtil . toIntUnsigned ( this . highLowContainer . getKeyAtIndex ( pos ) ) << 16 ; final MappeableContainer c = this . highLowContai... | Return the set values as an array if the cardinality is less than 2147483648 . The integer values are in sorted order . |
32,229 | public MutableRoaringBitmap toMutableRoaringBitmap ( ) { MutableRoaringBitmap c = new MutableRoaringBitmap ( ) ; MappeableContainerPointer mcp = highLowContainer . getContainerPointer ( ) ; while ( mcp . hasContainer ( ) ) { c . getMappeableRoaringArray ( ) . appendCopy ( mcp . key ( ) , mcp . getContainer ( ) ) ; mcp ... | Copies the content of this bitmap to a bitmap that can be modified . |
32,230 | public static BitmapStatistics analyse ( RoaringBitmap r ) { int acCount = 0 ; int acCardinalitySum = 0 ; int bcCount = 0 ; int rcCount = 0 ; ContainerPointer cp = r . getContainerPointer ( ) ; while ( cp . getContainer ( ) != null ) { if ( cp . isBitmapContainer ( ) ) { bcCount += 1 ; } else if ( cp . isRunContainer (... | Analyze the internal representation of bitmap |
32,231 | public static BitmapStatistics analyse ( Collection < ? extends RoaringBitmap > bitmaps ) { return bitmaps . stream ( ) . reduce ( BitmapStatistics . empty , ( acc , r ) -> acc . merge ( BitmapAnalyser . analyse ( r ) ) , BitmapStatistics :: merge ) ; } | Analyze the internal representation of bitmaps |
32,232 | protected static int getSizeInBytesFromCardinalityEtc ( int card , int numRuns , boolean isRunEncoded ) { if ( isRunEncoded ) { return 2 + numRuns * 2 * 2 ; } boolean isBitmap = card > MappeableArrayContainer . DEFAULT_MAX_SIZE ; if ( isBitmap ) { return MappeableBitmapContainer . MAX_CAPACITY / 8 ; } else { return car... | From the cardinality of a container compute the corresponding size in bytes of the container . Additional information is required if the container is run encoded . |
32,233 | public static boolean unsignedIntersects ( ShortBuffer set1 , int length1 , ShortBuffer set2 , int length2 ) { if ( ( 0 == length1 ) || ( 0 == length2 ) ) { return false ; } int k1 = 0 ; int k2 = 0 ; short s1 = set1 . get ( k1 ) ; short s2 = set2 . get ( k2 ) ; mainwhile : while ( true ) { if ( toIntUnsigned ( s2 ) < t... | Checks if two arrays intersect |
32,234 | public static void fillArrayANDNOT ( final short [ ] container , final long [ ] bitmap1 , final long [ ] bitmap2 ) { int pos = 0 ; if ( bitmap1 . length != bitmap2 . length ) { throw new IllegalArgumentException ( "not supported" ) ; } for ( int k = 0 ; k < bitmap1 . length ; ++ k ) { long bitset = bitmap1 [ k ] & ( ~ ... | Compute the bitwise ANDNOT between two long arrays and write the set bits in the container . |
32,235 | public static void flipBitmapRange ( long [ ] bitmap , int start , int end ) { if ( start == end ) { return ; } int firstword = start / 64 ; int endword = ( end - 1 ) / 64 ; bitmap [ firstword ] ^= ~ ( ~ 0L << start ) ; for ( int i = firstword ; i < endword ; i ++ ) { bitmap [ i ] = ~ bitmap [ i ] ; } bitmap [ endword ... | flip bits at start start + 1 ... end - 1 |
32,236 | protected static int hybridUnsignedBinarySearch ( final short [ ] array , final int begin , final int end , final short k ) { int ikey = toIntUnsigned ( k ) ; if ( ( end > 0 ) && ( toIntUnsigned ( array [ end - 1 ] ) < ikey ) ) { return - end - 1 ; } int low = begin ; int high = end - 1 ; while ( low + 32 <= high ) { f... | starts with binary search and finishes with a sequential search |
32,237 | public static void setBitmapRange ( long [ ] bitmap , int start , int end ) { if ( start == end ) { return ; } int firstword = start / 64 ; int endword = ( end - 1 ) / 64 ; if ( firstword == endword ) { bitmap [ firstword ] |= ( ~ 0L << start ) & ( ~ 0L >>> - end ) ; return ; } bitmap [ firstword ] |= ~ 0L << start ; f... | set bits at start start + 1 ... end - 1 |
32,238 | public static int unsignedIntersect2by2 ( final short [ ] set1 , final int length1 , final short [ ] set2 , final int length2 , final short [ ] buffer ) { final int THRESHOLD = 25 ; if ( set1 . length * THRESHOLD < set2 . length ) { return unsignedOneSidedGallopingIntersect2by2 ( set1 , length1 , set2 , length2 , buffe... | Intersect two sorted lists and write the result to the provided output array |
32,239 | public static int unsignedUnion2by2 ( final short [ ] set1 , final int offset1 , final int length1 , final short [ ] set2 , final int offset2 , final int length2 , final short [ ] buffer ) { if ( 0 == length2 ) { System . arraycopy ( set1 , offset1 , buffer , 0 , length1 ) ; return length1 ; } if ( 0 == length1 ) { Sys... | Unite two sorted lists and write the result to the provided output array |
32,240 | public static void partialRadixSort ( int [ ] data ) { final int radix = 8 ; int shift = 16 ; int mask = 0xFF0000 ; int [ ] copy = new int [ data . length ] ; int [ ] histogram = new int [ ( 1 << radix ) + 1 ] ; while ( shift < 32 ) { for ( int i = 0 ; i < data . length ; ++ i ) { ++ histogram [ ( ( data [ i ] & mask )... | Sorts the data by the 16 bit prefix . |
32,241 | public static RoaringBitmap bitmapOfUnordered ( final int ... data ) { RoaringBitmapWriter < RoaringBitmap > writer = writer ( ) . constantMemory ( ) . doPartialRadixSort ( ) . get ( ) ; writer . addMany ( data ) ; writer . flush ( ) ; return writer . getUnderlying ( ) ; } | Efficiently builds a RoaringBitmap from unordered data |
32,242 | public static boolean intersects ( final RoaringBitmap x1 , final RoaringBitmap x2 ) { final int length1 = x1 . highLowContainer . size ( ) , length2 = x2 . highLowContainer . size ( ) ; int pos1 = 0 , pos2 = 0 ; while ( pos1 < length1 && pos2 < length2 ) { final short s1 = x1 . highLowContainer . getKeyAtIndex ( pos1 ... | Checks whether the two bitmaps intersect . This can be much faster than calling and and checking the cardinality of the result . |
32,243 | public void add ( final long rangeStart , final long rangeEnd ) { rangeSanityCheck ( rangeStart , rangeEnd ) ; if ( rangeStart >= rangeEnd ) { return ; } final int hbStart = Util . toIntUnsigned ( Util . highbits ( rangeStart ) ) ; final int lbStart = Util . toIntUnsigned ( Util . lowbits ( rangeStart ) ) ; final int h... | Add to the current bitmap all integers in [ rangeStart rangeEnd ) . |
32,244 | public boolean isHammingSimilar ( RoaringBitmap other , int tolerance ) { final int size1 = highLowContainer . size ( ) ; final int size2 = other . highLowContainer . size ( ) ; int pos1 = 0 ; int pos2 = 0 ; int budget = tolerance ; while ( budget >= 0 && pos1 < size1 && pos2 < size2 ) { final short key1 = this . highL... | Returns true if the other bitmap has no more than tolerance bits differing from this bitmap . The other may be transformed into a bitmap equal to this bitmap in no more than tolerance bit flips if this method returns true . |
32,245 | public boolean hasRunCompression ( ) { for ( int i = 0 ; i < this . highLowContainer . size ( ) ; i ++ ) { Container c = this . highLowContainer . getContainerAtIndex ( i ) ; if ( c instanceof RunContainer ) { return true ; } } return false ; } | Check whether this bitmap has had its runs compressed . |
32,246 | public boolean runOptimize ( ) { boolean answer = false ; for ( int i = 0 ; i < this . highLowContainer . size ( ) ; i ++ ) { Container c = this . highLowContainer . getContainerAtIndex ( i ) . runOptimize ( ) ; if ( c instanceof RunContainer ) { answer = true ; } this . highLowContainer . setContainerAtIndex ( i , c )... | Use a run - length encoding where it is more space efficient |
32,247 | public int select ( int j ) { long leftover = Util . toUnsignedLong ( j ) ; for ( int i = 0 ; i < this . highLowContainer . size ( ) ; i ++ ) { Container c = this . highLowContainer . getContainerAtIndex ( i ) ; int thiscard = c . getCardinality ( ) ; if ( thiscard > leftover ) { int keycontrib = this . highLowContaine... | Return the jth value stored in this bitmap . The provided value needs to be smaller than the cardinality otherwise an IllegalArgumentException exception is thrown . |
32,248 | public static long maximumSerializedSize ( long cardinality , long universe_size ) { long contnbr = ( universe_size + 65535 ) / 65536 ; if ( contnbr > cardinality ) { contnbr = cardinality ; } final long headermax = Math . max ( 8 , 4 + ( contnbr + 7 ) / 8 ) + 8 * contnbr ; final long valsarray = 2 * cardinality ; fina... | Assume that one wants to store cardinality integers in [ 0 universe_size ) this function returns an upper bound on the serialized size in bytes . |
32,249 | private static RoaringBitmap selectRangeWithoutCopy ( RoaringBitmap rb , final long rangeStart , final long rangeEnd ) { final int hbStart = Util . toIntUnsigned ( Util . highbits ( rangeStart ) ) ; final int lbStart = Util . toIntUnsigned ( Util . lowbits ( rangeStart ) ) ; final int hbLast = Util . toIntUnsigned ( Ut... | had formerly failed if rangeEnd == 0 |
32,250 | public int [ ] toArray ( ) { final int [ ] array = new int [ this . getCardinality ( ) ] ; int pos = 0 , pos2 = 0 ; while ( pos < this . highLowContainer . size ( ) ) { final int hs = this . highLowContainer . getKeyAtIndex ( pos ) << 16 ; Container c = this . highLowContainer . getContainerAtIndex ( pos ++ ) ; c . fil... | Return the set values as an array if the cardinality is smaller than 2147483648 . The integer values are in sorted order . |
32,251 | public static Iterator < ImmutableRoaringBitmap > convertToImmutable ( final Iterator < MutableRoaringBitmap > i ) { return new Iterator < ImmutableRoaringBitmap > ( ) { public boolean hasNext ( ) { return i . hasNext ( ) ; } public ImmutableRoaringBitmap next ( ) { return i . next ( ) ; } public void remove ( ) { } ; ... | Convenience method converting one type of iterator into another to avoid unnecessary warnings . |
32,252 | public Response execute ( String httpUrl , String methodName , Map < String , Object > headers , Map < String , Object > queryParams , Object body ) throws Exception { httpclient = createHttpClient ( ) ; String reqBodyAsString = handleRequestBody ( body ) ; httpUrl = handleUrlAndQueryParams ( httpUrl , queryParams ) ; ... | Override this method in case you want to execute the http call differently via your http client . Otherwise the framework falls back to this implementation by default . |
32,253 | public Response handleResponse ( CloseableHttpResponse httpResponse ) throws IOException { Response serverResponse = createCharsetResponse ( httpResponse ) ; Header [ ] allHeaders = httpResponse . getAllHeaders ( ) ; Response . ResponseBuilder responseBuilder = Response . fromResponse ( serverResponse ) ; for ( Header ... | Once the client executes the http call then it receives the http response . This method takes care of handling that . In case you need to handle it differently you can override this method . |
32,254 | public RequestBuilder createDefaultRequestBuilder ( String httpUrl , String methodName , String reqBodyAsString ) { RequestBuilder requestBuilder = RequestBuilder . create ( methodName ) . setUri ( httpUrl ) ; if ( reqBodyAsString != null ) { HttpEntity httpEntity = EntityBuilder . create ( ) . setContentType ( APPLICA... | This is the usual http request builder most widely used using Apache Http Client . In case you want to build or prepare the requests differently you can override this method . |
32,255 | public RequestBuilder createFileUploadRequestBuilder ( String httpUrl , String methodName , String reqBodyAsString ) throws IOException { Map < String , Object > fileFieldNameValueMap = getFileFieldNameValue ( reqBodyAsString ) ; List < String > fileFieldsList = ( List < String > ) fileFieldNameValueMap . get ( FILES_F... | This is the http request builder for file uploads using Apache Http Client . In case you want to build or prepare the requests differently you can override this method . |
32,256 | public void handleHttpSession ( Response serverResponse , String headerKey ) { if ( "Set-Cookie" . equals ( headerKey ) ) { COOKIE_JSESSIONID_VALUE = serverResponse . getMetadata ( ) . get ( headerKey ) ; } } | This method handles the http session to be maintained between the calls . In case the session is not needed or to be handled differently then this method can be overridden to do nothing or to roll your own feature . |
32,257 | void digReplaceContent ( Map < String , Object > map ) { map . entrySet ( ) . stream ( ) . forEach ( entry -> { Object value = entry . getValue ( ) ; if ( value instanceof Map ) { digReplaceContent ( ( Map < String , Object > ) value ) ; } else { LOGGER . debug ( "Leaf node found = {}, checking for any external json fi... | Digs deep into the nested map and looks for external file reference if found replaces the place holder with the file content . This is handy when the engineers wants to drive the common contents from a central place . |
32,258 | protected List < ScenarioSpec > getChildren ( ) { TestPackageRoot rootPackageAnnotation = testClass . getAnnotation ( TestPackageRoot . class ) ; JsonTestCases jsonTestCasesAnnotation = testClass . getAnnotation ( JsonTestCases . class ) ; validateSuiteAnnotationPresent ( rootPackageAnnotation , jsonTestCasesAnnotation... | Returns a list of objects that define the children of this Runner . |
32,259 | private int maxEntryLengthOf ( List < AssertionReport > failureReportList ) { final Integer maxLength = ofNullable ( failureReportList ) . orElse ( Collections . emptyList ( ) ) . stream ( ) . map ( report -> report . toString ( ) . length ( ) ) . max ( Comparator . naturalOrder ( ) ) . get ( ) ; return maxLength > MAX... | all private functions below |
32,260 | public void setHocr ( boolean hocr ) { this . renderedFormat = hocr ? RenderedFormat . HOCR : RenderedFormat . TEXT ; prop . setProperty ( "tessedit_create_hocr" , hocr ? "1" : "0" ) ; } | Enables hocr output . |
32,261 | public void setTessVariable ( String key , String value ) { prop . setProperty ( key , value ) ; } | Set the value of Tesseract s internal parameter . |
32,262 | protected void init ( ) { handle = TessBaseAPICreate ( ) ; StringArray sarray = new StringArray ( configList . toArray ( new String [ 0 ] ) ) ; PointerByReference configs = new PointerByReference ( ) ; configs . setPointer ( sarray ) ; TessBaseAPIInit1 ( handle , datapath , language , ocrEngineMode , configs , configLi... | Initializes Tesseract engine . |
32,263 | protected void setTessVariables ( ) { Enumeration < ? > em = prop . propertyNames ( ) ; while ( em . hasMoreElements ( ) ) { String key = ( String ) em . nextElement ( ) ; TessBaseAPISetVariable ( handle , key , prop . getProperty ( key ) ) ; } } | Sets Tesseract s internal parameters . |
32,264 | public void createDocuments ( String filename , String outputbase , List < RenderedFormat > formats ) throws TesseractException { createDocuments ( new String [ ] { filename } , new String [ ] { outputbase } , formats ) ; } | Creates documents for given renderer . |
32,265 | public List < Rectangle > getSegmentedRegions ( BufferedImage bi , int pageIteratorLevel ) throws TesseractException { init ( ) ; setTessVariables ( ) ; try { List < Rectangle > list = new ArrayList < Rectangle > ( ) ; setImage ( bi , null ) ; Boxa boxes = TessBaseAPIGetComponentImages ( handle , pageIteratorLevel , TR... | Gets segmented regions at specified page iterator level . |
32,266 | public List < OCRResult > createDocumentsWithResults ( String [ ] filenames , String [ ] outputbases , List < ITesseract . RenderedFormat > formats , int pageIteratorLevel ) throws TesseractException { if ( filenames . length != outputbases . length ) { throw new RuntimeException ( "The two arrays must match in length.... | Creates documents with OCR results for given renderers at specified page iterator level . |
32,267 | public static synchronized File extractTessResources ( String resourceName ) { File targetPath = null ; try { targetPath = new File ( TESS4J_TEMP_DIR , resourceName ) ; Enumeration < URL > resources = LoadLibs . class . getClassLoader ( ) . getResources ( resourceName ) ; while ( resources . hasMoreElements ( ) ) { URL... | Extracts tesseract resources to temp folder . |
32,268 | static void copyResources ( URL resourceUrl , File targetPath ) throws IOException , URISyntaxException { if ( resourceUrl == null ) { return ; } URLConnection urlConnection = resourceUrl . openConnection ( ) ; if ( urlConnection instanceof JarURLConnection ) { copyJarResourceToPath ( ( JarURLConnection ) urlConnection... | Copies resources to target folder . |
32,269 | static void copyJarResourceToPath ( JarURLConnection jarConnection , File destPath ) { try ( JarFile jarFile = jarConnection . getJarFile ( ) ) { String jarConnectionEntryName = jarConnection . getEntryName ( ) ; if ( ! jarConnectionEntryName . endsWith ( "/" ) ) { jarConnectionEntryName += "/" ; } for ( Enumeration < ... | Copies resources from the jar file of the current thread and extract it to the destination path . |
32,270 | static void copyFromWarToFolder ( VirtualFile virtualFileOrFolder , File targetFolder ) throws IOException { if ( virtualFileOrFolder . isDirectory ( ) && ! virtualFileOrFolder . getName ( ) . contains ( "." ) ) { if ( targetFolder . getName ( ) . equalsIgnoreCase ( virtualFileOrFolder . getName ( ) ) ) { for ( Virtual... | Copies resources from WAR to target folder . |
32,271 | public double getSkewAngle ( ) { ImageDeskew . HoughLine [ ] hl ; double sum = 0.0 ; int count = 0 ; calc ( ) ; hl = getTop ( 20 ) ; if ( hl . length >= 20 ) { for ( int i = 0 ; i < 19 ; i ++ ) { sum += hl [ i ] . alpha ; count ++ ; } return ( sum / count ) ; } else { return 0.0d ; } } | Calculates the skew angle of the image cImage . |
32,272 | private ImageDeskew . HoughLine [ ] getTop ( int count ) { ImageDeskew . HoughLine [ ] hl = new ImageDeskew . HoughLine [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { hl [ i ] = new ImageDeskew . HoughLine ( ) ; } ImageDeskew . HoughLine tmp ; for ( int i = 0 ; i < ( this . cHMatrix . length - 1 ) ; i ++ ) { if ( t... | calculate the count lines in the image with most points |
32,273 | private static IIOMetadata setDPIViaAPI ( IIOMetadata imageMetadata , int dpiX , int dpiY ) throws IIOInvalidTreeException { TIFFDirectory dir = TIFFDirectory . createFromMetadata ( imageMetadata ) ; BaselineTIFFTagSet base = BaselineTIFFTagSet . getInstance ( ) ; TIFFTag tagXRes = base . getTag ( BaselineTIFFTagSet . ... | Set DPI using API . |
32,274 | public static String getImageFileFormat ( File imageFile ) { String imageFileName = imageFile . getName ( ) ; String imageFormat = imageFileName . substring ( imageFileName . lastIndexOf ( '.' ) + 1 ) ; if ( imageFormat . matches ( "(pbm|pgm|ppm)" ) ) { imageFormat = "pnm" ; } else if ( imageFormat . matches ( "(jp2|j2... | Gets image file format . |
32,275 | public static File getImageFile ( File inputFile ) throws IOException { File imageFile = inputFile ; if ( inputFile . getName ( ) . toLowerCase ( ) . endsWith ( ".pdf" ) ) { imageFile = PdfUtilities . convertPdf2Tiff ( inputFile ) ; } return imageFile ; } | Gets image file . Convert to multi - page TIFF if given PDF . |
32,276 | public static File deskewImage ( File imageFile , double minimumDeskewThreshold ) throws IOException { List < BufferedImage > imageList = getImageList ( imageFile ) ; for ( int i = 0 ; i < imageList . size ( ) ; i ++ ) { BufferedImage bi = imageList . get ( i ) ; ImageDeskew deskew = new ImageDeskew ( bi ) ; double ima... | Deskews image . |
32,277 | public static Map < String , String > readImageData ( IIOImage oimage ) { Map < String , String > dict = new HashMap < String , String > ( ) ; IIOMetadata imageMetadata = oimage . getMetadata ( ) ; if ( imageMetadata != null ) { IIOMetadataNode dimNode = ( IIOMetadataNode ) imageMetadata . getAsTree ( "javax_imageio_1.... | Reads image meta data . |
32,278 | public static BufferedImage convertImageToGrayscale ( BufferedImage image ) { BufferedImage tmp = new BufferedImage ( image . getWidth ( ) , image . getHeight ( ) , BufferedImage . TYPE_BYTE_GRAY ) ; Graphics2D g2 = tmp . createGraphics ( ) ; g2 . drawImage ( image , 0 , 0 , null ) ; g2 . dispose ( ) ; return tmp ; } | A simple method to convert an image to gray scale . |
32,279 | public static BufferedImage invertImageColor ( BufferedImage image ) { BufferedImage tmp = new BufferedImage ( image . getWidth ( ) , image . getHeight ( ) , image . getType ( ) ) ; BufferedImageOp invertOp = new LookupOp ( new ShortLookupTable ( 0 , invertTable ) , null ) ; return invertOp . filter ( image , tmp ) ; } | Inverts image color . |
32,280 | public static BufferedImage rotateImage ( BufferedImage image , double angle ) { double theta = Math . toRadians ( angle ) ; double sin = Math . abs ( Math . sin ( theta ) ) ; double cos = Math . abs ( Math . cos ( theta ) ) ; int w = image . getWidth ( ) ; int h = image . getHeight ( ) ; int newW = ( int ) Math . floo... | Rotates an image . |
32,281 | public static Image getClipboardImage ( ) { Clipboard clipboard = Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) ; try { return ( Image ) clipboard . getData ( DataFlavor . imageFlavor ) ; } catch ( Exception e ) { return null ; } } | Gets an image from Clipboard . |
32,282 | public static BufferedImage rotate ( BufferedImage image , double angle , int cx , int cy ) { int width = image . getWidth ( null ) ; int height = image . getHeight ( null ) ; int minX , minY , maxX , maxY ; minX = minY = maxX = maxY = 0 ; int [ ] corners = { 0 , 0 , width , 0 , width , height , 0 , height } ; double t... | Rotates image . |
32,283 | public static void writeFile ( byte [ ] data , File outFile ) throws IOException { if ( outFile . getParentFile ( ) != null ) { outFile . getParentFile ( ) . mkdirs ( ) ; } try ( FileOutputStream fos = new FileOutputStream ( outFile ) ) { fos . write ( data ) ; } } | Writes byte array to file . |
32,284 | public static String getConstantName ( Object value , Class c ) { for ( Field f : c . getDeclaredFields ( ) ) { int mod = f . getModifiers ( ) ; if ( Modifier . isStatic ( mod ) && Modifier . isPublic ( mod ) && Modifier . isFinal ( mod ) ) { try { if ( f . get ( null ) . equals ( value ) ) { return f . getName ( ) ; }... | Gets user - friendly name of the public static final constant defined in a class or an interface for display purpose . |
32,285 | protected void setImage ( int xsize , int ysize , ByteBuffer buf , Rectangle rect , int bpp ) { int bytespp = bpp / 8 ; int bytespl = ( int ) Math . ceil ( xsize * bpp / 8.0 ) ; api . TessBaseAPISetImage ( handle , buf , xsize , ysize , bytespp , bytespl ) ; if ( rect != null && ! rect . isEmpty ( ) ) { api . TessBaseA... | Sets image to be processed . |
32,286 | protected String getOCRText ( String filename , int pageNum ) { if ( filename != null && ! filename . isEmpty ( ) ) { api . TessBaseAPISetInputName ( handle , filename ) ; } Pointer utf8Text = renderedFormat == RenderedFormat . HOCR ? api . TessBaseAPIGetHOCRText ( handle , pageNum - 1 ) : api . TessBaseAPIGetUTF8Text ... | Gets recognized text . |
32,287 | private TessResultRenderer createRenderers ( String outputbase , List < RenderedFormat > formats ) { TessResultRenderer renderer = null ; for ( RenderedFormat format : formats ) { switch ( format ) { case TEXT : if ( renderer == null ) { renderer = api . TessTextRendererCreate ( outputbase ) ; } else { api . TessResult... | Creates renderers for given formats . |
32,288 | private List < Word > getRecognizedWords ( int pageIteratorLevel ) { List < Word > words = new ArrayList < Word > ( ) ; try { TessResultIterator ri = api . TessBaseAPIGetIterator ( handle ) ; TessPageIterator pi = api . TessResultIteratorGetPageIterator ( ri ) ; api . TessPageIteratorBegin ( pi ) ; do { Pointer ptr = a... | Gets result words at specified page iterator level from recognized pages . |
32,289 | protected void initInstanceRevisionAndJanitor ( ) throws Exception { databaseRevision = new DatabaseRevision ( ) ; long localFileRevision = 0L ; if ( getRevision ( ) != null ) { InstanceRevision currentFileRevision = new FileRevision ( new File ( getRevision ( ) ) , true ) ; localFileRevision = currentFileRevision . ge... | Initialize the instance revision manager and the janitor thread . |
32,290 | protected void append ( AppendRecord record , InputStream in , int length ) throws JournalException { try { conHelper . exec ( insertRevisionStmtSQL , record . getRevision ( ) , getId ( ) , record . getProducerId ( ) , new StreamWrapper ( in , length ) ) ; } catch ( SQLException e ) { String msg = "Unable to append rev... | We have already saved away the revision for this record . |
32,291 | private void checkLocalRevisionSchema ( ) throws Exception { InputStream localRevisionDDLStream = null ; InputStream in = org . apache . jackrabbit . core . journal . DatabaseJournal . class . getResourceAsStream ( databaseType + ".ddl" ) ; try { BufferedReader reader = new BufferedReader ( new InputStreamReader ( in )... | Checks if the local revision schema objects exist and creates them if they don t exist yet . |
32,292 | public StringIndex getNameIndex ( ) { try { if ( nameIndex == null ) { FileSystemResource res = new FileSystemResource ( context . getFileSystem ( ) , RES_NAME_INDEX ) ; if ( res . exists ( ) ) { nameIndex = super . getNameIndex ( ) ; } else { nameIndex = createDbNameIndex ( ) ; } } return nameIndex ; } catch ( Excepti... | Returns the local name index |
32,293 | protected Object [ ] getKey ( NodeId id ) { if ( getStorageModel ( ) == SM_BINARY_KEYS ) { return new Object [ ] { id . getRawBytes ( ) } ; } else { return new Object [ ] { id . getMostSignificantBits ( ) , id . getLeastSignificantBits ( ) } ; } } | Constructs a parameter list for a PreparedStatement for the given node identifier . |
32,294 | private NodePropBundle readBundle ( NodeId id , ResultSet rs , int column ) throws SQLException { try { InputStream in ; if ( rs . getMetaData ( ) . getColumnType ( column ) == Types . BLOB ) { in = rs . getBlob ( column ) . getBinaryStream ( ) ; } else { in = rs . getBinaryStream ( column ) ; } try { return binding . ... | Reads and parses a bundle from the BLOB in the given column of the current row of the given result set . This is a helper method to circumvent issues JCR - 1039 and JCR - 1474 . |
32,295 | protected void buildSQLStatements ( ) { if ( getStorageModel ( ) == SM_BINARY_KEYS ) { bundleInsertSQL = "insert into " + schemaObjectPrefix + "BUNDLE (BUNDLE_DATA, NODE_ID) values (?, ?)" ; bundleUpdateSQL = "update " + schemaObjectPrefix + "BUNDLE set BUNDLE_DATA = ? where NODE_ID = ?" ; bundleSelectSQL = "select BUN... | Initializes the SQL strings . |
32,296 | private void fetchRecord ( ) throws SQLException { if ( rs . next ( ) ) { long revision = rs . getLong ( 1 ) ; String journalId = rs . getString ( 2 ) ; String producerId = rs . getString ( 3 ) ; DataInputStream dataIn = new DataInputStream ( rs . getBinaryStream ( 4 ) ) ; record = new ReadRecord ( journalId , producer... | Fetch the next record . |
32,297 | private static void close ( ReadRecord record ) { if ( record != null ) { try { record . close ( ) ; } catch ( IOException e ) { String msg = "Error while closing record." ; log . warn ( msg , e ) ; } } } | Close a record . |
32,298 | public void setTableSpace ( String tableSpace ) { if ( tableSpace != null && tableSpace . length ( ) > 0 ) { this . tableSpace = "on " + tableSpace . trim ( ) ; } else { this . tableSpace = "" ; } } | Sets the MS SQL table space . |
32,299 | public AttrReq addAttrReq ( String name ) throws InvalidArgumentException { if ( name == null || name . isEmpty ( ) ) { throw new InvalidArgumentException ( "name may not be null or empty." ) ; } return new AttrReq ( name ) ; } | Add attribute to certificate . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.