idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
26,900 | private static JsonArray toJsonArray ( Collection < String > values ) { JsonArray array = new JsonArray ( ) ; for ( String value : values ) { array . add ( value ) ; } return array ; } | Helper function to create JsonArray from collection . |
26,901 | public void setBody ( String body ) { super . setBody ( body ) ; this . jsonValue = JsonValue . readFrom ( body ) ; } | Sets the body of this request to a given JSON string . |
26,902 | public Info changeMessage ( String newMessage ) { Info newInfo = new Info ( ) ; newInfo . setMessage ( newMessage ) ; URL url = COMMENT_URL_TEMPLATE . build ( this . getAPI ( ) . getBaseURL ( ) , this . getID ( ) ) ; BoxJSONRequest request = new BoxJSONRequest ( this . getAPI ( ) , url , "PUT" ) ; request . setBody ( n... | Changes the message of this comment . |
26,903 | public BoxComment . Info reply ( String message ) { JsonObject itemJSON = new JsonObject ( ) ; itemJSON . add ( "type" , "comment" ) ; itemJSON . add ( "id" , this . getID ( ) ) ; JsonObject requestJSON = new JsonObject ( ) ; requestJSON . add ( "item" , itemJSON ) ; if ( BoxComment . messageContainsMention ( message )... | Replies to this comment with another message . |
26,904 | public void put ( String key , String value ) { synchronized ( this . cache ) { this . cache . put ( key , value ) ; } } | Add an entry to the cache . |
26,905 | public URL buildWithQuery ( String base , String queryString , Object ... values ) { String urlString = String . format ( base + this . template , values ) + queryString ; URL url = null ; try { url = new URL ( urlString ) ; } catch ( MalformedURLException e ) { assert false : "An invalid URL template indicates a bug i... | Build a URL with Query String and URL Parameters . |
26,906 | public BoxFileUploadSessionPart uploadPart ( InputStream stream , long offset , int partSize , long totalSizeOfFile ) { URL uploadPartURL = this . sessionInfo . getSessionEndpoints ( ) . getUploadPartEndpoint ( ) ; BoxAPIRequest request = new BoxAPIRequest ( this . getAPI ( ) , uploadPartURL , HttpMethod . PUT ) ; requ... | Uploads chunk of a stream to an open upload session . |
26,907 | public BoxFileUploadSessionPart uploadPart ( byte [ ] data , long offset , int partSize , long totalSizeOfFile ) { URL uploadPartURL = this . sessionInfo . getSessionEndpoints ( ) . getUploadPartEndpoint ( ) ; BoxAPIRequest request = new BoxAPIRequest ( this . getAPI ( ) , uploadPartURL , HttpMethod . PUT ) ; request .... | Uploads bytes to an open upload session . |
26,908 | public BoxFileUploadSessionPartList listParts ( int offset , int limit ) { URL listPartsURL = this . sessionInfo . getSessionEndpoints ( ) . getListPartsEndpoint ( ) ; URLTemplate template = new URLTemplate ( listPartsURL . toString ( ) ) ; QueryStringBuilder builder = new QueryStringBuilder ( ) ; builder . appendParam... | Returns a list of all parts that have been uploaded to an upload session . |
26,909 | public BoxFile . Info commit ( String digest , List < BoxFileUploadSessionPart > parts , Map < String , String > attributes , String ifMatch , String ifNoneMatch ) { URL commitURL = this . sessionInfo . getSessionEndpoints ( ) . getCommitEndpoint ( ) ; BoxJSONRequest request = new BoxJSONRequest ( this . getAPI ( ) , c... | Commit an upload session after all parts have been uploaded creating the new file or the version . |
26,910 | public BoxFileUploadSession . Info getStatus ( ) { URL statusURL = this . sessionInfo . getSessionEndpoints ( ) . getStatusEndpoint ( ) ; BoxJSONRequest request = new BoxJSONRequest ( this . getAPI ( ) , statusURL , HttpMethod . GET ) ; BoxJSONResponse response = ( BoxJSONResponse ) request . send ( ) ; JsonObject json... | Get the status of the upload session . It contains the number of parts that are processed so far the total number of parts required for the commit and expiration date and time of the upload session . |
26,911 | public void abort ( ) { URL abortURL = this . sessionInfo . getSessionEndpoints ( ) . getAbortEndpoint ( ) ; BoxJSONRequest request = new BoxJSONRequest ( this . getAPI ( ) , abortURL , HttpMethod . DELETE ) ; request . send ( ) ; } | Abort an upload session discarding any chunks that were uploaded to it . |
26,912 | public String getHeaderField ( String fieldName ) { if ( this . headers == null ) { if ( this . connection != null ) { return this . connection . getHeaderField ( fieldName ) ; } else { return null ; } } else { return this . headers . get ( fieldName ) ; } } | Gets the value of the given header field . |
26,913 | private InputStream getErrorStream ( ) { InputStream errorStream = this . connection . getErrorStream ( ) ; if ( errorStream != null ) { final String contentEncoding = this . connection . getContentEncoding ( ) ; if ( contentEncoding != null && contentEncoding . equalsIgnoreCase ( "gzip" ) ) { try { errorStream = new G... | Returns the response error stream handling the case when it contains gzipped data . |
26,914 | public void updateInfo ( BoxWebLink . Info info ) { URL url = WEB_LINK_URL_TEMPLATE . build ( this . getAPI ( ) . getBaseURL ( ) , this . getID ( ) ) ; BoxJSONRequest request = new BoxJSONRequest ( this . getAPI ( ) , url , "PUT" ) ; request . setBody ( info . getPendingChanges ( ) ) ; String body = info . getPendingCh... | Updates the information about this weblink with any info fields that have been modified locally . |
26,915 | public static BoxStoragePolicyAssignment . Info create ( BoxAPIConnection api , String policyID , String userID ) { URL url = STORAGE_POLICY_ASSIGNMENT_URL_TEMPLATE . build ( api . getBaseURL ( ) ) ; BoxJSONRequest request = new BoxJSONRequest ( api , url , HttpMethod . POST ) ; JsonObject requestJSON = new JsonObject ... | Create a BoxStoragePolicyAssignment for a BoxStoragePolicy . |
26,916 | public static BoxStoragePolicyAssignment . Info getAssignmentForTarget ( final BoxAPIConnection api , String resolvedForType , String resolvedForID ) { QueryStringBuilder builder = new QueryStringBuilder ( ) ; builder . appendParam ( "resolved_for_type" , resolvedForType ) . appendParam ( "resolved_for_id" , resolvedFo... | Returns a BoxStoragePolicyAssignment information . |
26,917 | public void delete ( ) { URL url = STORAGE_POLICY_ASSIGNMENT_WITH_ID_URL_TEMPLATE . build ( this . getAPI ( ) . getBaseURL ( ) , this . getID ( ) ) ; BoxAPIRequest request = new BoxAPIRequest ( this . getAPI ( ) , url , HttpMethod . DELETE ) ; request . send ( ) ; } | Deletes this BoxStoragePolicyAssignment . |
26,918 | public static Iterable < BoxGroup . Info > getAllGroupsByName ( final BoxAPIConnection api , String name ) { final QueryStringBuilder builder = new QueryStringBuilder ( ) ; if ( name == null || name . trim ( ) . isEmpty ( ) ) { throw new BoxAPIException ( "Searching groups by name requires a non NULL or non empty name"... | Gets an iterable of all the groups in the enterprise that are starting with the given name string . |
26,919 | public Collection < BoxGroupMembership . Info > getMemberships ( ) { final BoxAPIConnection api = this . getAPI ( ) ; final String groupID = this . getID ( ) ; Iterable < BoxGroupMembership . Info > iter = new Iterable < BoxGroupMembership . Info > ( ) { public Iterator < BoxGroupMembership . Info > iterator ( ) { URL ... | Gets information about all of the group memberships for this group . Does not support paging . |
26,920 | public BoxGroupMembership . Info addMembership ( BoxUser user , Role role ) { BoxAPIConnection api = this . getAPI ( ) ; JsonObject requestJSON = new JsonObject ( ) ; requestJSON . add ( "user" , new JsonObject ( ) . add ( "id" , user . getID ( ) ) ) ; requestJSON . add ( "group" , new JsonObject ( ) . add ( "id" , thi... | Adds a member to this group with the specified role . |
26,921 | public static BoxTermsOfService . Info create ( BoxAPIConnection api , BoxTermsOfService . TermsOfServiceStatus termsOfServiceStatus , BoxTermsOfService . TermsOfServiceType termsOfServiceType , String text ) { URL url = ALL_TERMS_OF_SERVICES_URL_TEMPLATE . build ( api . getBaseURL ( ) ) ; BoxJSONRequest request = new ... | Creates a new Terms of Services . |
26,922 | public static List < BoxTermsOfService . Info > getAllTermsOfServices ( final BoxAPIConnection api , BoxTermsOfService . TermsOfServiceType termsOfServiceType ) { QueryStringBuilder builder = new QueryStringBuilder ( ) ; if ( termsOfServiceType != null ) { builder . appendParam ( "tos_type" , termsOfServiceType . toStr... | Retrieves a list of Terms of Service that belong to your Enterprise as an Iterable . |
26,923 | public static Map < String , Map < String , Metadata > > parseAndPopulateMetadataMap ( JsonObject jsonObject ) { Map < String , Map < String , Metadata > > metadataMap = new HashMap < String , Map < String , Metadata > > ( ) ; for ( JsonObject . Member templateMember : jsonObject ) { if ( templateMember . getValue ( ) ... | Creates a map of metadata from json . |
26,924 | public static List < Representation > parseRepresentations ( JsonObject jsonObject ) { List < Representation > representations = new ArrayList < Representation > ( ) ; for ( JsonValue representationJson : jsonObject . get ( "entries" ) . asArray ( ) ) { Representation representation = new Representation ( representatio... | Parse representations from a file object response . |
26,925 | public void updateInfo ( BoxTermsOfServiceUserStatus . Info info ) { URL url = TERMS_OF_SERVICE_USER_STATUSES_TEMPLATE . build ( this . getAPI ( ) . getBaseURL ( ) , this . getID ( ) ) ; BoxJSONRequest request = new BoxJSONRequest ( this . getAPI ( ) , url , "PUT" ) ; request . setBody ( info . getPendingChanges ( ) ) ... | Updates the information about the user status for this terms of service with any info fields that have been modified locally . |
26,926 | public List < BoxAPIResponse > execute ( List < BoxAPIRequest > requests ) { this . prepareRequest ( requests ) ; BoxJSONResponse batchResponse = ( BoxJSONResponse ) send ( ) ; return this . parseResponse ( batchResponse ) ; } | Execute a set of API calls as batch request . |
26,927 | protected void prepareRequest ( List < BoxAPIRequest > requests ) { JsonObject body = new JsonObject ( ) ; JsonArray requestsJSONArray = new JsonArray ( ) ; for ( BoxAPIRequest request : requests ) { JsonObject batchRequest = new JsonObject ( ) ; batchRequest . add ( "method" , request . getMethod ( ) ) ; batchRequest ... | Prepare a batch api request using list of individual reuests . |
26,928 | protected List < BoxAPIResponse > parseResponse ( BoxJSONResponse batchResponse ) { JsonObject responseJSON = JsonObject . readFrom ( batchResponse . getJSON ( ) ) ; List < BoxAPIResponse > responses = new ArrayList < BoxAPIResponse > ( ) ; Iterator < JsonValue > responseIterator = responseJSON . get ( "responses" ) . ... | Parses btch api response to create a list of BoxAPIResponse objects . |
26,929 | private static void generateJson ( CellScanner cellScanner , Function < Bytes , String > encoder , PrintStream out ) throws JsonIOException { Gson gson = new GsonBuilder ( ) . serializeNulls ( ) . setDateFormat ( DateFormat . LONG ) . setFieldNamingPolicy ( FieldNamingPolicy . LOWER_CASE_WITH_UNDERSCORES ) . setVersion... | Generate JSON format as result of the scan . |
26,930 | public static TxInfo getTransactionInfo ( Environment env , Bytes prow , Column pcol , long startTs ) { IteratorSetting is = new IteratorSetting ( 10 , RollbackCheckIterator . class ) ; RollbackCheckIterator . setLocktime ( is , startTs ) ; Entry < Key , Value > entry = ColumnUtil . checkColumn ( env , is , prow , pcol... | determine the what state a transaction is in by inspecting the primary column |
26,931 | public static boolean oracleExists ( CuratorFramework curator ) { boolean exists = false ; try { exists = curator . checkExists ( ) . forPath ( ZookeeperPath . ORACLE_SERVER ) != null && ! curator . getChildren ( ) . forPath ( ZookeeperPath . ORACLE_SERVER ) . isEmpty ( ) ; } catch ( Exception nne ) { if ( nne instance... | Checks to see if an Oracle Server exists . |
26,932 | public void waitForAsyncFlush ( ) { long numAdded = asyncBatchesAdded . get ( ) ; synchronized ( this ) { while ( numAdded > asyncBatchesProcessed ) { try { wait ( ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( e ) ; } } } } | waits for all async mutations that were added before this was called to be flushed . Does not wait for async mutations added after call . |
26,933 | public static Span exact ( Bytes row ) { Objects . requireNonNull ( row ) ; return new Span ( row , true , row , true ) ; } | Creates a span that covers an exact row |
26,934 | public static Span exact ( CharSequence row ) { Objects . requireNonNull ( row ) ; return exact ( Bytes . of ( row ) ) ; } | Creates a Span that covers an exact row . String parameters will be encoded as UTF - 8 |
26,935 | public static Span prefix ( Bytes rowPrefix ) { Objects . requireNonNull ( rowPrefix ) ; Bytes fp = followingPrefix ( rowPrefix ) ; return new Span ( rowPrefix , true , fp == null ? Bytes . EMPTY : fp , false ) ; } | Returns a Span that covers all rows beginning with a prefix . |
26,936 | public static Span prefix ( CharSequence rowPrefix ) { Objects . requireNonNull ( rowPrefix ) ; return prefix ( Bytes . of ( rowPrefix ) ) ; } | Returns a Span that covers all rows beginning with a prefix String parameters will be encoded as UTF - 8 |
26,937 | public void load ( InputStream in ) { try { PropertiesConfiguration config = new PropertiesConfiguration ( ) ; config . setDelimiterParsingDisabled ( true ) ; config . load ( in ) ; ( ( CompositeConfiguration ) internalConfig ) . addConfiguration ( config ) ; } catch ( ConfigurationException e ) { throw new IllegalArgu... | Loads configuration from InputStream . Later loads have lower priority . |
26,938 | public void load ( File file ) { try { PropertiesConfiguration config = new PropertiesConfiguration ( ) ; config . setDelimiterParsingDisabled ( true ) ; config . load ( file ) ; ( ( CompositeConfiguration ) internalConfig ) . addConfiguration ( config ) ; } catch ( ConfigurationException e ) { throw new IllegalArgumen... | Loads configuration from File . Later loads have lower priority . |
26,939 | public static long getTxInfoCacheWeight ( FluoConfiguration conf ) { long size = conf . getLong ( TX_INFO_CACHE_WEIGHT , TX_INFO_CACHE_WEIGHT_DEFAULT ) ; if ( size <= 0 ) { throw new IllegalArgumentException ( "Cache size must be positive for " + TX_INFO_CACHE_WEIGHT ) ; } return size ; } | Gets the txinfo cache weight |
26,940 | public static long getVisibilityCacheWeight ( FluoConfiguration conf ) { long size = conf . getLong ( VISIBILITY_CACHE_WEIGHT , VISIBILITY_CACHE_WEIGHT_DEFAULT ) ; if ( size <= 0 ) { throw new IllegalArgumentException ( "Cache size must be positive for " + VISIBILITY_CACHE_WEIGHT ) ; } return size ; } | Gets the visibility cache weight |
26,941 | public static String parseServers ( String zookeepers ) { int slashIndex = zookeepers . indexOf ( "/" ) ; if ( slashIndex != - 1 ) { return zookeepers . substring ( 0 , slashIndex ) ; } return zookeepers ; } | Parses server section of Zookeeper connection string |
26,942 | public static String parseRoot ( String zookeepers ) { int slashIndex = zookeepers . indexOf ( "/" ) ; if ( slashIndex != - 1 ) { return zookeepers . substring ( slashIndex ) . trim ( ) ; } return "/" ; } | Parses chroot section of Zookeeper connection string |
26,943 | public static long getGcTimestamp ( String zookeepers ) { ZooKeeper zk = null ; try { zk = new ZooKeeper ( zookeepers , 30000 , null ) ; long start = System . currentTimeMillis ( ) ; while ( ! zk . getState ( ) . isConnected ( ) && System . currentTimeMillis ( ) - start < 30000 ) { Uninterruptibles . sleepUninterruptib... | Retrieves the GC timestamp set by the Oracle from zookeeper |
26,944 | public static Bytes toBytes ( Text t ) { return Bytes . of ( t . getBytes ( ) , 0 , t . getLength ( ) ) ; } | Convert from Hadoop Text to Bytes |
26,945 | public static void configure ( Job conf , SimpleConfiguration config ) { try { FluoConfiguration fconfig = new FluoConfiguration ( config ) ; try ( Environment env = new Environment ( fconfig ) ) { long ts = env . getSharedResources ( ) . getTimestampTracker ( ) . allocateTimestamp ( ) . getTxTimestamp ( ) ; conf . get... | Configure properties needed to connect to a Fluo application |
26,946 | private void readUnread ( CommitData cd , Consumer < Entry < Key , Value > > locksSeen ) { Map < Bytes , Set < Column > > columnsToRead = new HashMap < > ( ) ; for ( Entry < Bytes , Set < Column > > entry : cd . getRejected ( ) . entrySet ( ) ) { Set < Column > rowColsRead = columnsRead . get ( entry . getKey ( ) ) ; i... | This function helps handle the following case |
26,947 | public byte byteAt ( int i ) { if ( i < 0 ) { throw new IndexOutOfBoundsException ( "i < 0, " + i ) ; } if ( i >= length ) { throw new IndexOutOfBoundsException ( "i >= length, " + i + " >= " + length ) ; } return data [ offset + i ] ; } | Gets a byte within this sequence of bytes |
26,948 | public Bytes subSequence ( int start , int end ) { if ( start > end || start < 0 || end > length ) { throw new IndexOutOfBoundsException ( "Bad start and/end start = " + start + " end=" + end + " offset=" + offset + " length=" + length ) ; } return new Bytes ( data , offset + start , end - start ) ; } | Returns a portion of the Bytes object |
26,949 | public byte [ ] toArray ( ) { byte [ ] copy = new byte [ length ] ; System . arraycopy ( data , offset , copy , 0 , length ) ; return copy ; } | Returns a byte array containing a copy of the bytes |
26,950 | public boolean contentEquals ( byte [ ] bytes , int offset , int len ) { Preconditions . checkArgument ( len >= 0 && offset >= 0 && offset + len <= bytes . length ) ; return contentEqualsUnchecked ( bytes , offset , len ) ; } | Returns true if this Bytes object equals another . This method checks it s arguments . |
26,951 | private boolean contentEqualsUnchecked ( byte [ ] bytes , int offset , int len ) { if ( length != len ) { return false ; } return compareToUnchecked ( bytes , offset , len ) == 0 ; } | Returns true if this Bytes object equals another . This method doesn t check it s arguments . |
26,952 | public static final Bytes of ( byte [ ] array ) { Objects . requireNonNull ( array ) ; if ( array . length == 0 ) { return EMPTY ; } byte [ ] copy = new byte [ array . length ] ; System . arraycopy ( array , 0 , copy , 0 , array . length ) ; return new Bytes ( copy ) ; } | Creates a Bytes object by copying the data of the given byte array |
26,953 | public static final Bytes of ( byte [ ] data , int offset , int length ) { Objects . requireNonNull ( data ) ; if ( length == 0 ) { return EMPTY ; } byte [ ] copy = new byte [ length ] ; System . arraycopy ( data , offset , copy , 0 , length ) ; return new Bytes ( copy ) ; } | Creates a Bytes object by copying the data of a subsequence of the given byte array |
26,954 | public static final Bytes of ( ByteBuffer bb ) { Objects . requireNonNull ( bb ) ; if ( bb . remaining ( ) == 0 ) { return EMPTY ; } byte [ ] data ; if ( bb . hasArray ( ) ) { data = Arrays . copyOfRange ( bb . array ( ) , bb . position ( ) + bb . arrayOffset ( ) , bb . limit ( ) + bb . arrayOffset ( ) ) ; } else { dat... | Creates a Bytes object by copying the data of the given ByteBuffer . |
26,955 | public static final Bytes of ( CharSequence cs ) { if ( cs instanceof String ) { return of ( ( String ) cs ) ; } Objects . requireNonNull ( cs ) ; if ( cs . length ( ) == 0 ) { return EMPTY ; } ByteBuffer bb = StandardCharsets . UTF_8 . encode ( CharBuffer . wrap ( cs ) ) ; if ( bb . hasArray ( ) ) { return new Bytes (... | Creates a Bytes object by copying the data of the CharSequence and encoding it using UTF - 8 . |
26,956 | public static final Bytes of ( String s ) { Objects . requireNonNull ( s ) ; if ( s . isEmpty ( ) ) { return EMPTY ; } byte [ ] data = s . getBytes ( StandardCharsets . UTF_8 ) ; return new Bytes ( data , s ) ; } | Creates a Bytes object by copying the value of the given String |
26,957 | public static final Bytes of ( String s , Charset c ) { Objects . requireNonNull ( s ) ; Objects . requireNonNull ( c ) ; if ( s . isEmpty ( ) ) { return EMPTY ; } byte [ ] data = s . getBytes ( c ) ; return new Bytes ( data ) ; } | Creates a Bytes object by copying the value of the given String with a given charset |
26,958 | public boolean startsWith ( Bytes prefix ) { Objects . requireNonNull ( prefix , "startWith(Bytes prefix) cannot have null parameter" ) ; if ( prefix . length > this . length ) { return false ; } else { int end = this . offset + prefix . length ; for ( int i = this . offset , j = prefix . offset ; i < end ; i ++ , j ++... | Checks if this has the passed prefix |
26,959 | public boolean endsWith ( Bytes suffix ) { Objects . requireNonNull ( suffix , "endsWith(Bytes suffix) cannot have null parameter" ) ; int startOffset = this . length - suffix . length ; if ( startOffset < 0 ) { return false ; } else { int end = startOffset + this . offset + suffix . length ; for ( int i = startOffset ... | Checks if this has the passed suffix |
26,960 | public void copyTo ( int start , int end , byte [ ] dest , int destPos ) { arraycopy ( start , dest , destPos , end - start ) ; } | Copy a subsequence of Bytes to specific byte array . Uses the specified offset in the dest byte array to start the copy . |
26,961 | public void copyTo ( ColumnBuffer dest , LongPredicate timestampTest ) { dest . clear ( ) ; if ( key != null ) { dest . key = new Key ( key ) ; } for ( int i = 0 ; i < timeStamps . size ( ) ; i ++ ) { long time = timeStamps . get ( i ) ; if ( timestampTest . test ( time ) ) { dest . add ( time , values . get ( i ) ) ; ... | Clears the dest ColumnBuffer and inserts all entries in dest where the timestamp passes the timestampTest . |
26,962 | public static AccumuloClient getClient ( FluoConfiguration config ) { return Accumulo . newClient ( ) . to ( config . getAccumuloInstance ( ) , config . getAccumuloZookeepers ( ) ) . as ( config . getAccumuloUser ( ) , config . getAccumuloPassword ( ) ) . build ( ) ; } | Creates Accumulo connector given FluoConfiguration |
26,963 | public static byte [ ] encode ( byte [ ] ba , int offset , long v ) { ba [ offset + 0 ] = ( byte ) ( v >>> 56 ) ; ba [ offset + 1 ] = ( byte ) ( v >>> 48 ) ; ba [ offset + 2 ] = ( byte ) ( v >>> 40 ) ; ba [ offset + 3 ] = ( byte ) ( v >>> 32 ) ; ba [ offset + 4 ] = ( byte ) ( v >>> 24 ) ; ba [ offset + 5 ] = ( byte ) (... | Encode a long into a byte array at an offset |
26,964 | public static long decodeLong ( byte [ ] ba , int offset ) { return ( ( ( ( long ) ba [ offset + 0 ] << 56 ) + ( ( long ) ( ba [ offset + 1 ] & 255 ) << 48 ) + ( ( long ) ( ba [ offset + 2 ] & 255 ) << 40 ) + ( ( long ) ( ba [ offset + 3 ] & 255 ) << 32 ) + ( ( long ) ( ba [ offset + 4 ] & 255 ) << 24 ) + ( ( ba [ offs... | Decode long from byte array at offset |
26,965 | public static byte [ ] concat ( Bytes ... listOfBytes ) { int offset = 0 ; int size = 0 ; for ( Bytes b : listOfBytes ) { size += b . length ( ) + checkVlen ( b . length ( ) ) ; } byte [ ] data = new byte [ size ] ; for ( Bytes b : listOfBytes ) { offset = writeVint ( data , offset , b . length ( ) ) ; b . copyTo ( 0 ,... | Concatenates of list of Bytes objects to create a byte array |
26,966 | public static int writeVint ( byte [ ] dest , int offset , int i ) { if ( i >= - 112 && i <= 127 ) { dest [ offset ++ ] = ( byte ) i ; } else { int len = - 112 ; if ( i < 0 ) { i ^= - 1L ; len = - 120 ; } long tmp = i ; while ( tmp != 0 ) { tmp = tmp >> 8 ; len -- ; } dest [ offset ++ ] = ( byte ) len ; len = ( len < -... | Writes a vInt directly to a byte array |
26,967 | public static int checkVlen ( int i ) { int count = 0 ; if ( i >= - 112 && i <= 127 ) { return 1 ; } else { int len = - 112 ; if ( i < 0 ) { i ^= - 1L ; len = - 120 ; } long tmp = i ; while ( tmp != 0 ) { tmp = tmp >> 8 ; len -- ; } count ++ ; len = ( len < - 120 ) ? - ( len + 120 ) : - ( len + 112 ) ; while ( len != 0... | Determines the number bytes required to store a variable length |
26,968 | private ResourceReport getResourceReport ( TwillController controller , int maxWaitMs ) { ResourceReport report = controller . getResourceReport ( ) ; int elapsed = 0 ; while ( report == null ) { report = controller . getResourceReport ( ) ; try { Thread . sleep ( 500 ) ; } catch ( InterruptedException e ) { throw new ... | Attempts to retrieves ResourceReport until maxWaitMs time is reached . Set maxWaitMs to - 1 to retry forever . |
26,969 | private void verifyApplicationName ( String name ) { if ( name == null ) { throw new IllegalArgumentException ( "Application name cannot be null" ) ; } if ( name . isEmpty ( ) ) { throw new IllegalArgumentException ( "Application name length must be > 0" ) ; } String reason = null ; char [ ] chars = name . toCharArray ... | Verifies application name . Avoids characters that Zookeeper does not like in nodes & Hadoop does not like in HDFS paths . |
26,970 | public FluoConfiguration addObservers ( Iterable < ObserverSpecification > observers ) { int next = getNextObserverId ( ) ; for ( ObserverSpecification oconf : observers ) { addObserver ( oconf , next ++ ) ; } return this ; } | Adds multiple observers using unique integer prefixes for each . |
26,971 | public FluoConfiguration clearObservers ( ) { Iterator < String > iter1 = getKeys ( OBSERVER_PREFIX . substring ( 0 , OBSERVER_PREFIX . length ( ) - 1 ) ) ; while ( iter1 . hasNext ( ) ) { String key = iter1 . next ( ) ; clearProperty ( key ) ; } return this ; } | Removes any configured observers . |
26,972 | public void print ( ) { Iterator < String > iter = getKeys ( ) ; while ( iter . hasNext ( ) ) { String key = iter . next ( ) ; log . info ( key + " = " + getRawString ( key ) ) ; } } | Logs all properties |
26,973 | public boolean hasRequiredClientProps ( ) { boolean valid = true ; valid &= verifyStringPropSet ( CONNECTION_APPLICATION_NAME_PROP , CLIENT_APPLICATION_NAME_PROP ) ; valid &= verifyStringPropSet ( ACCUMULO_USER_PROP , CLIENT_ACCUMULO_USER_PROP ) ; valid &= verifyStringPropSet ( ACCUMULO_PASSWORD_PROP , CLIENT_ACCUMULO_... | Returns true if required properties for FluoClient are set |
26,974 | public boolean hasRequiredAdminProps ( ) { boolean valid = true ; valid &= hasRequiredClientProps ( ) ; valid &= verifyStringPropSet ( ACCUMULO_TABLE_PROP , ADMIN_ACCUMULO_TABLE_PROP ) ; return valid ; } | Returns true if required properties for FluoAdmin are set |
26,975 | public boolean hasRequiredMiniFluoProps ( ) { boolean valid = true ; if ( getMiniStartAccumulo ( ) ) { valid &= verifyStringPropNotSet ( ACCUMULO_USER_PROP , CLIENT_ACCUMULO_USER_PROP ) ; valid &= verifyStringPropNotSet ( ACCUMULO_PASSWORD_PROP , CLIENT_ACCUMULO_PASSWORD_PROP ) ; valid &= verifyStringPropNotSet ( ACCUM... | Returns true if required properties for MiniFluo are set |
26,976 | public SimpleConfiguration getClientConfiguration ( ) { SimpleConfiguration clientConfig = new SimpleConfiguration ( ) ; Iterator < String > iter = getKeys ( ) ; while ( iter . hasNext ( ) ) { String key = iter . next ( ) ; if ( key . startsWith ( CONNECTION_PREFIX ) || key . startsWith ( ACCUMULO_PREFIX ) || key . sta... | Returns a SimpleConfiguration clientConfig with properties set from this configuration |
26,977 | public static void setDefaultConfiguration ( SimpleConfiguration config ) { config . setProperty ( CONNECTION_ZOOKEEPERS_PROP , CONNECTION_ZOOKEEPERS_DEFAULT ) ; config . setProperty ( CONNECTION_ZOOKEEPER_TIMEOUT_PROP , CONNECTION_ZOOKEEPER_TIMEOUT_DEFAULT ) ; config . setProperty ( DFS_ROOT_PROP , DFS_ROOT_DEFAULT ) ... | Sets all Fluo properties to their default in the given configuration . NOTE - some properties do not have defaults and will not be set . |
26,978 | public static void configure ( Job conf , SimpleConfiguration props ) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; props . save ( baos ) ; conf . getConfiguration ( ) . set ( PROPS_CONF_KEY , new String ( baos . toByteArray ( ) , StandardCharsets . UTF_8 ) ) ; } catch ( Exception e ) { throw new... | Call this method to initialize the Fluo connection props |
26,979 | public Stamp allocateTimestamp ( ) { synchronized ( this ) { Preconditions . checkState ( ! closed , "tracker closed " ) ; if ( node == null ) { Preconditions . checkState ( allocationsInProgress == 0 , "expected allocationsInProgress == 0 when node == null" ) ; Preconditions . checkState ( ! updatingZk , "unexpected c... | Allocate a timestamp |
26,980 | private static boolean waitTillNoNotifications ( Environment env , TableRange range ) throws TableNotFoundException { boolean sawNotifications = false ; long retryTime = MIN_SLEEP_MS ; log . debug ( "Scanning tablet {} for notifications" , range ) ; long start = System . currentTimeMillis ( ) ; while ( hasNotifications... | Wait until a range has no notifications . |
26,981 | private static void waitUntilFinished ( FluoConfiguration config ) { try ( Environment env = new Environment ( config ) ) { List < TableRange > ranges = getRanges ( env ) ; outer : while ( true ) { long ts1 = env . getSharedResources ( ) . getOracleClient ( ) . getStamp ( ) . getTxTimestamp ( ) ; for ( TableRange range... | Wait until a scan of the table completes without seeing notifications AND without the Oracle issuing any timestamps during the scan . |
26,982 | public static Range toRange ( Span span ) { return new Range ( toKey ( span . getStart ( ) ) , span . isStartInclusive ( ) , toKey ( span . getEnd ( ) ) , span . isEndInclusive ( ) ) ; } | Converts a Fluo Span to Accumulo Range |
26,983 | public static Key toKey ( RowColumn rc ) { if ( ( rc == null ) || ( rc . getRow ( ) . equals ( Bytes . EMPTY ) ) ) { return null ; } Text row = ByteUtil . toText ( rc . getRow ( ) ) ; if ( ( rc . getColumn ( ) . equals ( Column . EMPTY ) ) || ! rc . getColumn ( ) . isFamilySet ( ) ) { return new Key ( row ) ; } Text cf... | Converts from a Fluo RowColumn to a Accumulo Key |
26,984 | public static Span toSpan ( Range range ) { return new Span ( toRowColumn ( range . getStartKey ( ) ) , range . isStartKeyInclusive ( ) , toRowColumn ( range . getEndKey ( ) ) , range . isEndKeyInclusive ( ) ) ; } | Converts an Accumulo Range to a Fluo Span |
26,985 | public static RowColumn toRowColumn ( Key key ) { if ( key == null ) { return RowColumn . EMPTY ; } if ( ( key . getRow ( ) == null ) || key . getRow ( ) . getLength ( ) == 0 ) { return RowColumn . EMPTY ; } Bytes row = ByteUtil . toBytes ( key . getRow ( ) ) ; if ( ( key . getColumnFamily ( ) == null ) || key . getCol... | Converts from an Accumulo Key to a Fluo RowColumn |
26,986 | public FluoKeyValueGenerator set ( RowColumnValue rcv ) { setRow ( rcv . getRow ( ) ) ; setColumn ( rcv . getColumn ( ) ) ; setValue ( rcv . getValue ( ) ) ; return this ; } | Set the row column and value |
26,987 | public FluoKeyValue [ ] getKeyValues ( ) { FluoKeyValue kv = keyVals [ 0 ] ; kv . setKey ( new Key ( row , fam , qual , vis , ColumnType . WRITE . encode ( 1 ) ) ) ; kv . getValue ( ) . set ( WriteValue . encode ( 0 , false , false ) ) ; kv = keyVals [ 1 ] ; kv . setKey ( new Key ( row , fam , qual , vis , ColumnType .... | Translates the Fluo row column and value set into the persistent format that is stored in Accumulo . |
26,988 | public RowColumn following ( ) { if ( row . equals ( Bytes . EMPTY ) ) { return RowColumn . EMPTY ; } else if ( col . equals ( Column . EMPTY ) ) { return new RowColumn ( followingBytes ( row ) ) ; } else if ( ! col . isQualifierSet ( ) ) { return new RowColumn ( row , new Column ( followingBytes ( col . getFamily ( ) ... | Returns a RowColumn following the current one |
26,989 | public FluoMutationGenerator put ( Column col , CharSequence value ) { return put ( col , value . toString ( ) . getBytes ( StandardCharsets . UTF_8 ) ) ; } | Puts value at given column |
26,990 | public static CuratorFramework newAppCurator ( FluoConfiguration config ) { return newCurator ( config . getAppZookeepers ( ) , config . getZookeeperTimeout ( ) , config . getZookeeperSecret ( ) ) ; } | Creates a curator built using Application s zookeeper connection string . Root path will start at Fluo application chroot . |
26,991 | public static CuratorFramework newFluoCurator ( FluoConfiguration config ) { return newCurator ( config . getInstanceZookeepers ( ) , config . getZookeeperTimeout ( ) , config . getZookeeperSecret ( ) ) ; } | Creates a curator built using Fluo s zookeeper connection string . Root path will start at Fluo chroot . |
26,992 | public static CuratorFramework newCurator ( String zookeepers , int timeout , String secret ) { final ExponentialBackoffRetry retry = new ExponentialBackoffRetry ( 1000 , 10 ) ; if ( secret . isEmpty ( ) ) { return CuratorFrameworkFactory . newClient ( zookeepers , timeout , timeout , retry ) ; } else { return CuratorF... | Creates a curator built using the given zookeeper connection string and timeout |
26,993 | public static void startAndWait ( PersistentNode node , int maxWaitSec ) { node . start ( ) ; int waitTime = 0 ; try { while ( node . waitForInitialCreate ( 1 , TimeUnit . SECONDS ) == false ) { waitTime += 1 ; log . info ( "Waited " + waitTime + " sec for ephemeral node to be created" ) ; if ( waitTime > maxWaitSec ) ... | Starts the ephemeral node and waits for it to be created |
26,994 | public static NodeCache startAppIdWatcher ( Environment env ) { try { CuratorFramework curator = env . getSharedResources ( ) . getCurator ( ) ; byte [ ] uuidBytes = curator . getData ( ) . forPath ( ZookeeperPath . CONFIG_FLUO_APPLICATION_ID ) ; if ( uuidBytes == null ) { Halt . halt ( "Fluo Application UUID not found... | Start watching the fluo app uuid . If it changes or goes away then halt the process . |
26,995 | private void readZookeeperConfig ( ) { try ( CuratorFramework curator = CuratorUtil . newAppCurator ( config ) ) { curator . start ( ) ; accumuloInstance = new String ( curator . getData ( ) . forPath ( ZookeeperPath . CONFIG_ACCUMULO_INSTANCE_NAME ) , StandardCharsets . UTF_8 ) ; accumuloInstanceID = new String ( cura... | Read configuration from zookeeper |
26,996 | public void close ( ) { status = TrStatus . CLOSED ; try { node . close ( ) ; } catch ( IOException e ) { log . error ( "Failed to close ephemeral node" ) ; throw new IllegalStateException ( e ) ; } } | Closes the transactor node by removing its node in Zookeeper |
26,997 | private static Map < String , Set < String > > expand ( Map < String , Set < String > > viewToPropNames ) { Set < String > baseProps = viewToPropNames . get ( PropertyView . BASE_VIEW ) ; if ( baseProps == null ) { baseProps = ImmutableSet . of ( ) ; } if ( ! SquigglyConfig . isFilterImplicitlyIncludeBaseFieldsInView (... | apply the base fields to other views if configured to do so . |
26,998 | public List < SquigglyNode > parse ( String filter ) { filter = StringUtils . trim ( filter ) ; if ( StringUtils . isEmpty ( filter ) ) { return Collections . emptyList ( ) ; } List < SquigglyNode > cachedNodes = CACHE . getIfPresent ( filter ) ; if ( cachedNodes != null ) { return cachedNodes ; } SquigglyExpressionLex... | Parse a filter expression . |
26,999 | public static < E > Collection < E > collectify ( ObjectMapper mapper , Object source , Class < ? extends Collection > targetCollectionType , Class < E > targetElementType ) { CollectionType collectionType = mapper . getTypeFactory ( ) . constructCollectionType ( targetCollectionType , targetElementType ) ; return obje... | Convert an object to a collection . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.