code stringlengths 146 466k | prompt stringlengths 54 1.5k |
|---|---|
Of course, here is the Java code you requested:
```java
@Override
public OperationHandle executeStatementAsync(SessionHandle sessionHandle, String statement,
Map<String, String> confOverlay)
throws HiveSQLException {
return executeStatementInternal(sessionHandle, statement, confOverlay, true);
... | Create a Java method that does the following: "Execute a statement asynchronously.". |
Of course, here is the Java code you requested:
```java
@Override
public OperationHandle getTypeInfo(SessionHandle sessionHandle) throws HiveSQLException {
try {
TGetTypeInfoReq req = new TGetTypeInfoReq(sessionHandle.toTSessionHandle());
TGetTypeInfoResp resp = cliService.GetTypeInfo(req);
che... | Create a Java method that does the following: "Get the type info for the session handle.". |
Of course, here is the Java code you requested:
```java
@Override
public OperationHandle getSchemas(SessionHandle sessionHandle, String catalogName,
String schemaName)
throws HiveSQLException {
try {
TGetSchemasReq req = new TGetSchemasReq(sessionHandle.toTSessionHandle());
req.setCat... | Create a Java method that does the following: "Get the schemas for the catalog and schema name.". |
Of course, here is the Java code you requested:
```java
@Override
public void closeOperation(OperationHandle opHandle)
throws HiveSQLException {
try {
TCloseOperationReq req = new TCloseOperationReq(opHandle.toTOperationHandle());
TCloseOperationResp resp = cliService.CloseOperation(req);
... | Create a Java method that does the following: "Close an operation.". |
Of course, here is the Java code you requested:
```java
synchronized String registerHandle(AbstractAppHandle handle) {
String secret = createSecret();
secretToPendingApps.put(secret, handle);
return secret;
}
```
Hope this helps! | Create a Java method that does the following: "Registers a new application handle.". |
Of course, here is the Java code you requested:
```java
void unregister(AbstractAppHandle handle) {
for (Map.Entry<String, AbstractAppHandle> e : secretToPendingApps.entrySet()) {
if (e.getValue().equals(handle)) {
String secret = e.getKey();
secretToPendingApps.remove(secret);
break;... | Create a Java method that does the following: "Unregister an application handle.". |
Of course, here is the Java code you requested:
```java
private static long[][] getCounts(
LongArray array, long numRecords, int startByteIndex, int endByteIndex) {
long[][] counts = new long[8][];
// Optimization: do a fast pre-pass to determine which byte indices we can skip for sorting.
// If all ... | Create a Java method that does the following: "Get the counts for a given range of bytes.". |
Of course, here is the Java code you requested:
```java
private static long[] transformCountsToOffsets(
long[] counts, long numRecords, long outputOffset, long bytesPerRecord,
boolean desc, boolean signed) {
assert counts.length == 256;
int start = signed ? 128 : 0; // output the negative records ... | Create a Java method that does the following: "Transform counts to offsets.". |
Of course, here is the Java code you requested:
```java
public static int sortKeyPrefixArray(
LongArray array,
long startIndex,
long numRecords,
int startByteIndex,
int endByteIndex,
boolean desc,
boolean signed) {
assert startByteIndex >= 0 : "startByteIndex (" + startByt... | Create a Java method that does the following: "Sort key prefix array.". |
Of course, here is the Java code you requested:
```java
private static long[][] getKeyPrefixArrayCounts(
LongArray array, long startIndex, long numRecords, int startByteIndex, int endByteIndex) {
long[][] counts = new long[8][];
long bitwiseMax = 0;
long bitwiseMin = -1L;
long baseOffset = array.... | Create a Java method that does the following: "Get the key prefix array counts.". |
Of course, here is the Java code you requested:
```java
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case SESSION_HANDLE:
return isSetSessionHandle();
case CATALOG_NAME:
return isSetCatalogName();
case SCH... | Create a Java method that does the following: "Checks if the specified field is set to a value of a
object.". |
Of course, here is the Java code you requested:
```java
private ByteBuf nextBufferForFrame(int bytesToRead) {
ByteBuf buf = buffers.getFirst();
ByteBuf frame;
if (buf.readableBytes() > bytesToRead) {
frame = buf.retain().readSlice(bytesToRead);
totalSize -= bytesToRead;
} else {
fram... | Create a Java method that does the following: "Returns the next frame of the buffer that contains the specified number of bytes.". |
Of course, here is the Java code you requested:
```java
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case OPERATION_HANDLE:
return isSetOperationHandle();
case ORIENTATION:
return isSetOrientation();
case ... | Create a Java method that does the following: "Checks if field is set to a value of a CRAS_CORRECT_ELEMENT_SPECIFIC". |
Of course, here is the Java code you requested:
```java
private void initBatch(
MemoryMode memMode,
StructType partitionColumns,
InternalRow partitionValues) {
StructType batchSchema = new StructType();
for (StructField f: sparkSchema.fields()) {
batchSchema = batchSchema.add(f);
}
... | Create a Java method that does the following: "Initialize the batch.". |
Of course, here is the Java code you requested:
```java
public static int indexOfDomainMatch(String userName) {
if (userName == null) {
return -1;
}
int idx = userName.indexOf('/');
int idx2 = userName.indexOf('@');
int endIdx = Math.min(idx, idx2); // Use the earlier match.
// Unless at... | Create a Java method that does the following: "Gets the index of the domain match.". |
Of course, here is the Java code you requested:
```java
public static int nonNegativeHash(Object obj) {
if (obj == null) { return 0; }
int hash = obj.hashCode();
return hash != Integer.MIN_VALUE ? Math.abs(hash) : 0;
}
```
Hope this helps! | Create a Java method that does the following: "Returns the non negative hash code of the object.". |
Of course, here is the Java code you requested:
```java
public static ByteBuffer stringToBytes(String s) {
return Unpooled.wrappedBuffer(s.getBytes(StandardCharsets.UTF_8)).nioBuffer();
}
```
Hope this helps! | Create a Java method that does the following: "Converts a string to a ByteBuffer.". |
Of course, here is the Java code you requested:
```java
public static String bytesToString(ByteBuffer b) {
return Unpooled.wrappedBuffer(b).toString(StandardCharsets.UTF_8);
}
```
Hope this helps! | Create a Java method that does the following: "Convert a ByteBuffer to a String.". |
Of course, here is the Java code you requested:
```java
public static long byteStringAs(String str, ByteUnit unit) {
String lower = str.toLowerCase(Locale.ROOT).trim();
try {
Matcher m = Pattern.compile("([0-9]+)([a-z]+)?").matcher(lower);
Matcher fractionMatcher = Pattern.compile("([0-9]+\\.[0-9]... | Create a Java method that does the following: "Convert a byte string to a long.". |
Of course, here is the Java code you requested:
```java
public void reset() {
if (isConstant) return;
if (childColumns != null) {
for (ColumnVector c: childColumns) {
((WritableColumnVector) c).reset();
}
}
elementsAppended = 0;
if (numNulls > 0) {
putNotNulls(0, capacity... | Create a Java method that does the following: "Resets the column vector.". |
Of course, here is the Java code you requested:
```java
public WritableColumnVector reserveDictionaryIds(int capacity) {
if (dictionaryIds == null) {
dictionaryIds = reserveNewColumn(capacity, DataTypes.IntegerType);
} else {
dictionaryIds.reset();
dictionaryIds.reserve(capacity);
}
r... | Create a Java method that does the following: "Reserve a number of integer dictionary ids in the column vector.". |
Of course, here is the Java code you requested:
```java
public final int appendStruct(boolean isNull) {
if (isNull) {
appendNull();
for (WritableColumnVector c: childColumns) {
if (c.type instanceof StructType) {
c.appendStruct(true);
} else {
c.appendNull();
... | Create a Java method that does the following: "Append a Struct to the table.". |
Of course, here is the Java code you requested:
```java
@Override
public final ColumnarArray getArray(int rowId) {
if (isNullAt(rowId)) return null;
return new ColumnarArray(arrayData(), getArrayOffset(rowId), getArrayLength(rowId));
}
```
Hope this helps! | Create a Java method that does the following: "Gets the columnar array at the given row id.". |
Of course, here is the Java code you requested:
```java
@Override
public final ColumnarMap getMap(int rowId) {
if (isNullAt(rowId)) return null;
return new ColumnarMap(getChild(0), getChild(1), getArrayOffset(rowId), getArrayLength(rowId));
}
```
Hope this helps! | Create a Java method that does the following: "Returns a columnar map for the given row id.". |
Of course, here is the Java code you requested:
```java
public TStatus toTStatus() {
// TODO: convert sqlState, etc.
TStatus tStatus = new TStatus(TStatusCode.ERROR_STATUS);
tStatus.setSqlState(getSQLState());
tStatus.setErrorCode(getErrorCode());
tStatus.setErrorMessage(getMessage());
tStatus.... | Create a Java method that does the following: "Converts this object to a TStatus object.". |
Of course, here is the Java code you requested:
```java
public static TStatus toTStatus(Exception e) {
if (e instanceof HiveSQLException) {
return ((HiveSQLException)e).toTStatus();
}
TStatus tStatus = new TStatus(TStatusCode.ERROR_STATUS);
tStatus.setErrorMessage(e.getMessage());
tStatus.set... | Create a Java method that does the following: "Converts an exception to a TStatus object.". |
Of course, here is the Java code you requested:
```java
public static <T> TypedColumn<T, Double> avg(MapFunction<T, Double> f) {
return new TypedAverage<T>(f).toColumnJava();
}
```
Hope this helps! | Create a Java method that does the following: "Returns a typed average column.". |
Of course, here is the Java code you requested:
```java
private void readAsync() throws IOException {
stateChangeLock.lock();
final byte[] arr = readAheadBuffer.array();
try {
if (endOfStream || readInProgress) {
return;
}
checkReadException();
readAheadBuffer.position(0);
... | Create a Java method that does the following: "Read the contents of the underlying input stream asynchronously.". |
Of course, here is the Java code you requested:
```java
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case OBJECT_TYPE_PTR:
return isSetObjectTypePtr();
}
throw new IllegalStateException();
}
```
Hope this hel... | Create a Java method that does the following: "Checks if the specified field is set to a value of a CRA S Grammar.". |
Of course, here is the Java code you requested:
```java
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case TYPE:
return isSetType();
case TYPE_QUALIFIERS:
return isSetTypeQualifiers();
}
throw new Illeg... | Create a Java method that does the following: "Checks if the specified field is set to a value of a CRAsCTYPE object.". |
Of course, here is the Java code you requested:
```java
@Override
public UnsafeRow getKeyRow(int rowId) {
assert(rowId >= 0);
assert(rowId < numRows);
if (keyRowId != rowId) { // if keyRowId == rowId, desired keyRow is already cached
long offset = keyOffsets[rowId];
int klen = Platform.getInt... | Create a Java method that does the following: "Get the key row.". |
Of course, here is the Java code you requested:
```java
@Override
public UnsafeRow getValueFromKey(int rowId) {
if (keyRowId != rowId) {
getKeyRow(rowId);
}
assert(rowId >= 0);
long offset = keyRow.getBaseOffset();
int klen = keyRow.getSizeInBytes();
int vlen = Platform.getInt(base, off... | Create a Java method that does the following: "Get the value of the key.". |
Of course, here is the Java code you requested:
```java
@Override
public org.apache.spark.unsafe.KVIterator<UnsafeRow, UnsafeRow> rowIterator() {
return new org.apache.spark.unsafe.KVIterator<UnsafeRow, UnsafeRow>() {
private final UnsafeRow key = new UnsafeRow(keySchema.length());
private final Unsa... | Create a Java method that does the following: "Returns an iterator over the rows of this table.". |
Of course, here is the Java code you requested:
```java
public Iterator<InternalRow> rowIterator() {
final int maxRows = numRows;
final MutableColumnarRow row = new MutableColumnarRow(columns);
return new Iterator<InternalRow>() {
int rowId = 0;
@Override
public boolean hasNext() {
... | Create a Java method that does the following: "Returns an iterator over the rows of this table.". |
Of course, here is the Java code you requested:
```java
public long sendRpc(ByteBuffer message, RpcResponseCallback callback) {
if (logger.isTraceEnabled()) {
logger.trace("Sending RPC to {}", getRemoteAddress(channel));
}
long requestId = requestId();
handler.addRpcRequest(requestId, callback);... | Create a Java method that does the following: "Sends an RPC to the remote server.". |
Of course, here is the Java code you requested:
```java
private boolean refill() throws IOException {
if (!byteBuffer.hasRemaining()) {
byteBuffer.clear();
int nRead = 0;
while (nRead == 0) {
nRead = fileChannel.read(byteBuffer);
}
if (nRead < 0) {
return false;
... | Create a Java method that does the following: "refill the underlying file". |
Of course, here is the Java code you requested:
```java
private String getSignature(String str) {
try {
MessageDigest md = MessageDigest.getInstance(SHA_STRING);
md.update(str.getBytes());
md.update(secretBytes);
byte[] digest = md.digest();
return new Base64(0).encodeToString(digest)... | Create a Java method that does the following: "Get the signature of a string". |
Of course, here is the Java code you requested:
```java
void closeIterator(LevelDBIterator<?> it) throws IOException {
synchronized (this._db) {
DB _db = this._db.get();
if (_db != null) {
it.close();
}
}
}
```
Hope this helps! | Create a Java method that does the following: "Close the iterator.". |
Of course, here is the Java code you requested:
```java
LevelDBTypeInfo getTypeInfo(Class<?> type) throws Exception {
LevelDBTypeInfo ti = types.get(type);
if (ti == null) {
LevelDBTypeInfo tmp = new LevelDBTypeInfo(this, type, getTypeAlias(type));
ti = types.putIfAbsent(type, tmp);
if (ti ==... | Create a Java method that does the following: "Gets the type information.". |
Of course, here is the Java code you requested:
```java
public void registerApp(String appId, String shuffleSecret) {
// Always put the new secret information to make sure it's the most up to date.
// Otherwise we have to specifically look at the application attempt in addition
// to the applicationId sinc... | Create a Java method that does the following: "Register a new shuffle secret for an application.". |
Of course, here is the Java code you requested:
```java
public void registerApp(String appId, ByteBuffer shuffleSecret) {
registerApp(appId, JavaUtils.bytesToString(shuffleSecret));
}
```
Hope this helps! | Create a Java method that does the following: "Register an application with the given secret.". |
Of course, here is the Java code you requested:
```java
public static void set(Object baseObject, long baseOffset, int index) {
assert index >= 0 : "index (" + index + ") should >= 0";
final long mask = 1L << (index & 0x3f); // mod 64 and shift
final long wordOffset = baseOffset + (index >> 6) * WORD_SIZE... | Create a Java method that does the following: "Set the value of the specified index in the specified object at the specified offset.". |
Of course, here is the Java code you requested:
```java
public static boolean isSet(Object baseObject, long baseOffset, int index) {
assert index >= 0 : "index (" + index + ") should >= 0";
final long mask = 1L << (index & 0x3f); // mod 64 and shift
final long wordOffset = baseOffset + (index >> 6) * WORD... | Create a Java method that does the following: "Returns true if the value at the given offset is set.". |
Of course, here is the Java code you requested:
```java
public static boolean anySet(Object baseObject, long baseOffset, long bitSetWidthInWords) {
long addr = baseOffset;
for (int i = 0; i < bitSetWidthInWords; i++, addr += WORD_SIZE) {
if (Platform.getLong(baseObject, addr) != 0) {
return true;... | Create a Java method that does the following: "Checks if any set bits are set in the given base object.". |
Of course, here is the Java code you requested:
```java
@Override
public GetInfoValue getInfo(SessionHandle sessionHandle, GetInfoType getInfoType)
throws HiveSQLException {
return cliService.getInfo(sessionHandle, getInfoType);
}
```
Hope this helps! | Create a Java method that does the following: "Get the value of the
.". |
Of course, here is the Java code you requested:
```java
@Override
public OperationHandle executeStatement(SessionHandle sessionHandle, String statement,
Map<String, String> confOverlay) throws HiveSQLException {
return cliService.executeStatement(sessionHandle, statement, confOverlay);
}
```
Hope this h... | Create a Java method that does the following: "Execute a statement in the session.". |
Of course, here is the Java code you requested:
```java
@Override
public OperationHandle getSchemas(SessionHandle sessionHandle, String catalogName,
String schemaName) throws HiveSQLException {
return cliService.getSchemas(sessionHandle, catalogName, schemaName);
}
```
Hope this helps! | Create a Java method that does the following: "Get the schema handle for a sequence of catalog name and schema name.". |
Of course, here is the Java code you requested:
```java
@Override
public OperationHandle getTables(SessionHandle sessionHandle, String catalogName,
String schemaName, String tableName, List<String> tableTypes) throws HiveSQLException {
return cliService.getTables(sessionHandle, catalogName, schemaName, tab... | Create a Java method that does the following: "Get the tables for the sequence number.". |
Of course, here is the Java code you requested:
```java
@Override
public OperationHandle getFunctions(SessionHandle sessionHandle,
String catalogName, String schemaName, String functionName)
throws HiveSQLException {
return cliService.getFunctions(sessionHandle, catalogName, schemaName, functionN... | Create a Java method that does the following: "Get the function handle for a sequence of Hive functions.". |
Of course, here is the Java code you requested:
```java
public void start() {
if (blockIds.length == 0) {
throw new IllegalArgumentException("Zero-sized blockIds array");
}
client.sendRpc(openMessage.toByteBuffer(), new RpcResponseCallback() {
@Override
public void onSuccess(ByteBuffer r... | Create a Java method that does the following: "Starts the fetch process.". |
Of course, here is the Java code you requested:
```java
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case SESSION_HANDLE:
return isSetSessionHandle();
case OWNER:
return isSetOwner();
case RENEWER:
r... | Create a Java method that does the following: "Checks if field is set to a value of a CRAS_CTYPE object.". |
Of course, here is the Java code you requested:
```java
private String getClientNameFromCookie(Cookie[] cookies) {
// Current Cookie Name, Current Cookie Value
String currName, currValue;
// Following is the main loop which iterates through all the cookies send by the client.
// The HS2 generated cook... | Create a Java method that does the following: "Gets the client name from the cookies.". |
Of course, here is the Java code you requested:
```java
private String toCookieStr(Cookie[] cookies) {
String cookieStr = "";
for (Cookie c : cookies) {
cookieStr += c.getName() + "=" + c.getValue() + " ;\n";
}
return cookieStr;
}
```
Hope this helps! | Create a Java method that does the following: "toCookieStr This method converts a cookie array to a string.". |
Of course, here is the Java code you requested:
```java
private String validateCookie(HttpServletRequest request) throws UnsupportedEncodingException {
// Find all the valid cookies associated with the request.
Cookie[] cookies = request.getCookies();
if (cookies == null) {
if (LOG.isDebugEnabled())... | Create a Java method that does the following: "Validate the cookies associated with the request.". |
Of course, here is the Java code you requested:
```java
private Cookie createCookie(String str) throws UnsupportedEncodingException {
if (LOG.isDebugEnabled()) {
LOG.debug("Cookie name = " + AUTH_COOKIE + " value = " + str);
}
Cookie cookie = new Cookie(AUTH_COOKIE, str);
cookie.setMaxAge(cookie... | Create a Java method that does the following: "Create a Cookie object from a String.". |
Of course, here is the Java code you requested:
```java
private static String getHttpOnlyCookieHeader(Cookie cookie) {
NewCookie newCookie = new NewCookie(cookie.getName(), cookie.getValue(),
cookie.getPath(), cookie.getDomain(), cookie.getVersion(),
cookie.getComment(), cookie.getMaxAge(), cookie.getS... | Create a Java method that does the following: "Get the HttpOnly cookie header". |
Of course, here is the Java code you requested:
```java
private String doPasswdAuth(HttpServletRequest request, String authType)
throws HttpAuthenticationException {
String userName = getUsername(request, authType);
// No-op when authType is NOSASL
if (!authType.equalsIgnoreCase(HiveAuthFactory.AuthT... | Create a Java method that does the following: "Do a passive authentication for the user name and password.". |
Of course, here is the Java code you requested:
```java
private String doKerberosAuth(HttpServletRequest request)
throws HttpAuthenticationException {
// Try authenticating with the http/_HOST principal
if (httpUGI != null) {
try {
return httpUGI.doAs(new HttpKerberosServerAction(request, h... | Create a Java method that does the following: "Do the kerberos authentication.". |
Of course, here is the Java code you requested:
```java
private String getAuthHeader(HttpServletRequest request, String authType)
throws HttpAuthenticationException {
String authHeader = request.getHeader(HttpAuthUtils.AUTHORIZATION);
// Each http request must have an Authorization header
if (authHea... | Create a Java method that does the following: "Get the Authorization header from the request". |
Of course, here is the Java code you requested:
```java
static String firstNonEmptyValue(String key, Map<?, ?>... maps) {
for (Map<?, ?> map : maps) {
String value = (String) map.get(key);
if (!isEmpty(value)) {
return value;
}
}
return null;
}
```
Hope this helps! | Create a Java method that does the following: "Get the first non - empty value from the map.". |
Of course, here is the Java code you requested:
```java
static List<String> parseOptionString(String s) {
List<String> opts = new ArrayList<>();
StringBuilder opt = new StringBuilder();
boolean inOpt = false;
boolean inSingleQuote = false;
boolean inDoubleQuote = false;
boolean escapeNext = fal... | Create a Java method that does the following: "Parse a string containing a list of options.". |
Of course, here is the Java code you requested:
```java
static void checkNotNull(Object o, String arg) {
if (o == null) {
throw new IllegalArgumentException(String.format("'%s' must not be null.", arg));
}
}
```
Hope this helps! | Create a Java method that does the following: "Check that the object is not null.". |
Of course, here is the Java code you requested:
```java
static void checkState(boolean check, String msg, Object... args) {
if (!check) {
throw new IllegalStateException(String.format(msg, args));
}
}
```
Hope this helps! | Create a Java method that does the following: "Check if a check is true.". |
Of course, here is the Java code you requested:
```java
static int javaMajorVersion(String javaVersion) {
String[] version = javaVersion.split("[+.\\-]+");
int major = Integer.parseInt(version[0]);
// if major > 1, we're using the JEP-223 version string, e.g., 9-ea, 9+120
// otherwise the second number... | Create a Java method that does the following: "Get the major version number from the java version string". |
Of course, here is the Java code you requested:
```java
static String findJarsDir(String sparkHome, String scalaVersion, boolean failIfNotFound) {
// TODO: change to the correct directory once the assembly build is changed.
File libdir = new File(sparkHome, "jars");
if (!libdir.isDirectory()) {
libdi... | Create a Java method that does the following: "Find the jars directory.". |
Of course, here is the Java code you requested:
```java
public void pointTo(Object baseObject, long baseOffset, int sizeInBytes) {
// Read the number of elements from the first 8 bytes.
final long numElements = Platform.getLong(baseObject, baseOffset);
assert numElements >= 0 : "numElements (" + numElement... | Create a Java method that does the following: "Point the contents of the block to the given base object.". |
Of course, here is the Java code you requested:
```java
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case KEY_TYPE_PTR:
return isSetKeyTypePtr();
case VALUE_TYPE_PTR:
return isSetValueTypePtr();
}
thro... | Create a Java method that does the following: "Checks if field is set to a value of a CRAsCTYPE.". |
Of course, here is the Java code you requested:
```java
private RowSet prepareFromRow(List<Object> rows, RowSet rowSet) throws Exception {
for (Object row : rows) {
rowSet.addRow((Object[]) row);
}
return rowSet;
}
```
Hope this helps! | Create a Java method that does the following: "prepare from a list of rows". |
Of course, here is the Java code you requested:
```java
private HiveConf getConfigForOperation() throws HiveSQLException {
HiveConf sqlOperationConf = getParentSession().getHiveConf();
if (!getConfOverlay().isEmpty() || shouldRunAsync()) {
// clone the parent session config for this query
sqlOperat... | Create a Java method that does the following: "Get the config for this operation.". |
Of course, here is the Java code you requested:
```java
private void fetchAllOutstanding() {
// Start by retrieving our shared state within a synchronized block.
String[] blockIdsToFetch;
int numRetries;
RetryingBlockFetchListener myListener;
synchronized (this) {
blockIdsToFetch = outstandin... | Create a Java method that does the following: "Fetch all outstanding blocks.". |
Of course, here is the Java code you requested:
```java
private synchronized void initiateRetry() {
retryCount += 1;
currentListener = new RetryingBlockFetchListener();
logger.info("Retrying fetch ({}/{}) for {} outstanding blocks after {} ms",
retryCount, maxRetries, outstandingBlocksIds.size(), re... | Create a Java method that does the following: "Initiate retry.". |
Of course, here is the Java code you requested:
```java
private synchronized boolean shouldRetry(Throwable e) {
boolean isIOException = e instanceof IOException
|| (e.getCause() != null && e.getCause() instanceof IOException);
boolean hasRemainingRetries = retryCount < maxRetries;
return isIOExceptio... | Create a Java method that does the following: "Returns true if the exception should be retried.". |
Of course, here is the Java code you requested:
```java
@Override
protected UnsafeRow getValueFromKey(int rowId) {
if (keyRowId != rowId) {
getKeyRow(rowId);
}
assert(rowId >= 0);
valueRow.pointTo(base, keyRow.getBaseOffset() + klen, vlen);
return valueRow;
}
```
Hope this helps! | Create a Java method that does the following: "Override to return the value of the key.". |
Of course, here is the Java code you requested:
```java
@Override
public org.apache.spark.unsafe.KVIterator<UnsafeRow, UnsafeRow> rowIterator() {
return new org.apache.spark.unsafe.KVIterator<UnsafeRow, UnsafeRow>() {
private final UnsafeRow key = new UnsafeRow(keySchema.length());
private final Unsa... | Create a Java method that does the following: "Returns an iterator over the rows of this table.". |
Of course, here is the Java code you requested:
```java
public void writeToMemory(Object target, long targetOffset) {
Platform.copyMemory(base, offset, target, targetOffset, numBytes);
}
```
Hope this helps! | Create a Java method that does the following: "Write the contents of this object to the given target object.". |
Of course, here is the Java code you requested:
```java
public int numChars() {
int len = 0;
for (int i = 0; i < numBytes; i += numBytesForFirstByte(getByte(i))) {
len += 1;
}
return len;
}
```
Hope this helps! | Create a Java method that does the following: "Returns the number of characters in this string.". |
Of course, here is the Java code you requested:
```java
public long getPrefix() {
// Since JVMs are either 4-byte aligned or 8-byte aligned, we check the size of the string.
// If size is 0, just return 0.
// If size is between 0 and 4 (inclusive), assume data is 4-byte aligned under the hood and
// us... | Create a Java method that does the following: "Gets the prefix of the string.". |
Of course, here is the Java code you requested:
```java
public UTF8String substring(final int start, final int until) {
if (until <= start || start >= numBytes) {
return EMPTY_UTF8;
}
int i = 0;
int c = 0;
while (i < numBytes && c < start) {
i += numBytesForFirstByte(getByte(i));
... | Create a Java method that does the following: "Returns a substring of this string.". |
Of course, here is the Java code you requested:
```java
public boolean contains(final UTF8String substring) {
if (substring.numBytes == 0) {
return true;
}
byte first = substring.getByte(0);
for (int i = 0; i <= numBytes - substring.numBytes; i++) {
if (getByte(i) == first && matchAt(subst... | Create a Java method that does the following: "Check if this string contains the substring.". |
Of course, here is the Java code you requested:
```java
public UTF8String toUpperCase() {
if (numBytes == 0) {
return EMPTY_UTF8;
}
byte[] bytes = new byte[numBytes];
bytes[0] = (byte) Character.toTitleCase(getByte(0));
for (int i = 0; i < numBytes; i++) {
byte b = getByte(i);
if... | Create a Java method that does the following: "Get the upper case of this string.". |
Of course, here is the Java code you requested:
```java
public UTF8String toLowerCase() {
if (numBytes == 0) {
return EMPTY_UTF8;
}
byte[] bytes = new byte[numBytes];
bytes[0] = (byte) Character.toTitleCase(getByte(0));
for (int i = 0; i < numBytes; i++) {
byte b = getByte(i);
if... | Create a Java method that does the following: "Returns a UTF8String that is lower case.". |
Of course, here is the Java code you requested:
```java
public UTF8String trimRight(UTF8String trimString) {
if (trimString == null) return null;
int charIdx = 0;
// number of characters from the source string
int numChars = 0;
// array of character length for the source string
int[] stringChar... | Create a Java method that does the following: "Trims the given string from the right side of the source string.". |
Of course, here is the Java code you requested:
```java
public int indexOf(UTF8String v, int start) {
if (v.numBytes() == 0) {
return 0;
}
// locate to the start position.
int i = 0; // position in byte
int c = 0; // position in character
while (i < numBytes && c < start) {
i += nu... | Create a Java method that does the following: "Gets the index of the first occurrence of v in this string.". |
Of course, here is the Java code you requested:
```java
public boolean toLong(LongWrapper toLongResult) {
if (numBytes == 0) {
return false;
}
byte b = getByte(0);
final boolean negative = b == '-';
int offset = 0;
if (negative || b == '+') {
offset++;
if (numBytes == 1) {
... | Create a Java method that does the following: "Returns true if the data is a long.". |
Of course, here is the Java code you requested:
```java
public int levenshteinDistance(UTF8String other) {
// Implementation adopted from org.apache.common.lang3.StringUtils.getLevenshteinDistance
int n = numChars();
int m = other.numChars();
if (n == 0) {
return m;
} else if (m == 0) {
... | Create a Java method that does the following: "Returns the levenshtein distance between this and other.". |
Of course, here is the Java code you requested:
```java
public UTF8String soundex() {
if (numBytes == 0) {
return EMPTY_UTF8;
}
byte b = getByte(0);
if ('a' <= b && b <= 'z') {
b -= 32;
} else if (b < 'A' || 'Z' < b) {
// first character must be a letter
return this;
}
... | Create a Java method that does the following: "Returns a new UTF8String that contains all of the characters in this string.". |
Of course, here is the Java code you requested:
```java
@Override
public void run() {
try {
// Server thread pool
// Start with minWorkerThreads, expand till maxWorkerThreads and reject subsequent requests
String threadPoolName = "HiveServer2-HttpHandler-Pool";
ThreadPoolExecutor executor... | Create a Java method that does the following: "Run the server.". |
Of course, here is the Java code you requested:
```java
private long getMemoryUsage() {
long totalPageSize = 0;
for (MemoryBlock page : allocatedPages) {
totalPageSize += page.size();
}
return ((inMemSorter == null) ? 0 : inMemSorter.getMemoryUsage()) + totalPageSize;
}
```
Hope this helps! | Create a Java method that does the following: "Get the memory usage of the in - memory sorter.". |
Of course, here is the Java code you requested:
```java
private long freeMemory() {
updatePeakMemoryUsed();
long memoryFreed = 0;
for (MemoryBlock block : allocatedPages) {
memoryFreed += block.size();
freePage(block);
}
allocatedPages.clear();
currentPage = null;
pageCursor = 0... | Create a Java method that does the following: "Free the memory.". |
Of course, here is the Java code you requested:
```java
private void deleteSpillFiles() {
for (UnsafeSorterSpillWriter spill : spillWriters) {
File file = spill.getFile();
if (file != null && file.exists()) {
if (!file.delete()) {
logger.error("Was unable to delete spill file {}", fil... | Create a Java method that does the following: "Delete all the spill files.". |
Of course, here is the Java code you requested:
```java
private void acquireNewPageIfNecessary(int required) {
if (currentPage == null ||
pageCursor + required > currentPage.getBaseOffset() + currentPage.size()) {
// TODO: try to find space on previous pages
currentPage = allocatePage(required);
... | Create a Java method that does the following: "Acquires a new page if necessary.". |
Of course, here is the Java code you requested:
```java
public void insertKVRecord(Object keyBase, long keyOffset, int keyLen,
Object valueBase, long valueOffset, int valueLen, long prefix, boolean prefixIsNull)
throws IOException {
growPointerArrayIfNecessary();
int uaoSize = UnsafeAlignedOffset.ge... | Create a Java method that does the following: "Insert a single KeyValue record into the record store.". |
Of course, here is the Java code you requested:
```java
public UnsafeSorterIterator getSortedIterator() throws IOException {
assert(recordComparatorSupplier != null);
if (spillWriters.isEmpty()) {
assert(inMemSorter != null);
readingIterator = new SpillableIterator(inMemSorter.getSortedIterator());... | Create a Java method that does the following: "Get a sorted iterator for this reader.". |
Of course, here is the Java code you requested:
```java
public static Pair<Long, Integer> parseStreamChunkId(String streamChunkId) {
String[] array = streamChunkId.split("_");
assert array.length == 2:
"Stream id and chunk index should be specified.";
long streamId = Long.valueOf(array[0]);
int c... | Create a Java method that does the following: "Parses a chunk id.". |
Of course, here is the Java code you requested:
```java
public long registerStream(String appId, Iterator<ManagedBuffer> buffers, Channel channel) {
long myStreamId = nextStreamId.getAndIncrement();
streams.put(myStreamId, new StreamState(appId, buffers, channel));
return myStreamId;
}
```
Hope this hel... | Create a Java method that does the following: "Registers a new stream.". |
Of course, here is the Java code you requested:
```java
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case START_ROW_OFFSET:
return isSetStartRowOffset();
case ROWS:
return isSetRows();
case COLUMNS:
... | Create a Java method that does the following: "Checks if the specified field is set to a value of a CRA S Grammar.". |
Of course, here is the Java code you requested:
```java
void grow(int neededSize) {
if (neededSize < 0) {
throw new IllegalArgumentException(
"Cannot grow BufferHolder by size " + neededSize + " because the size is negative");
}
if (neededSize > ARRAY_MAX - totalSize()) {
throw new Ille... | Create a Java method that does the following: "Grows the BufferHolder by the specified size.". |
Of course, here is the Java code you requested:
```java
public synchronized byte[] firstToken() {
if (saslClient != null && saslClient.hasInitialResponse()) {
try {
return saslClient.evaluateChallenge(new byte[0]);
} catch (SaslException e) {
throw Throwables.propagate(e);
}
}... | Create a Java method that does the following: "Returns the first token.". |
Of course, here is the Java code you requested:
```java
public synchronized byte[] response(byte[] token) {
try {
return saslClient != null ? saslClient.evaluateChallenge(token) : new byte[0];
} catch (SaslException e) {
throw Throwables.propagate(e);
}
}
```
Hope this helps! | Create a Java method that does the following: "Evaluate the SASL challenge.". |
Of course, here is the Java code you requested:
```java
@Override
public Object[] array() {
DataType dt = data.dataType();
Object[] list = new Object[length];
try {
for (int i = 0; i < length; i++) {
if (!data.isNullAt(offset + i)) {
list[i] = get(i, dt);
}
}
r... | Create a Java method that does the following: "Override the array method to return an array of the array.". |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.