_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q157900
TemplateUtils.BuildExportConfig
train
public static CloudBigtableScanConfiguration BuildExportConfig(ExportOptions options) { ValueProvider<ReadRowsRequest> request = new RequestValueProvider(options); CloudBigtableScanConfiguration.Builder configBuilder = new CloudBigtableScanConfiguration.Builder() .withProjectId(options.getBi...
java
{ "resource": "" }
q157901
HBaseTracingUtilities.setupTracingConfig
train
public static void setupTracingConfig() { TracingUtilities.setupTracingConfig(); List<String> descriptors = Arrays.asList( "BigtableTable.getTableDescriptor", "BigtableTable.exists", "BigtableTable.existsAll", "BigtableTable.batch", "BigtableTable.batchCallback", "BigtableTab...
java
{ "resource": "" }
q157902
ResourceLimiter.waitForCompletions
train
private void waitForCompletions(long timeoutMs) throws InterruptedException { Long completedOperation = this.completedOperationIds.pollFirst(timeoutMs, TimeUnit.MILLISECONDS); if (completedOperation != null) { markOperationComplete(completedOperation); } }
java
{ "resource": "" }
q157903
BigtableAsyncAdmin.restoreSnapshot
train
@Override public CompletableFuture<Void> restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot) { CompletableFuture<Void> future = new CompletableFuture<>(); listSnapshots(Pattern.compile(snapshotName)).whenComplete( (snapshotDescriptions, err) -> { if (err != null) { futur...
java
{ "resource": "" }
q157904
BigtableAsyncAdmin.snapshotExists
train
private TableName snapshotExists(String snapshotName, List<SnapshotDescription> snapshotDescriptions) { if (snapshotDescriptions != null) { Optional<SnapshotDescription> descriptor = snapshotDescriptions.stream() .filter(desc -> desc.getName().equals(snapshotName)) ...
java
{ "resource": "" }
q157905
ShuffledSource.split
train
@Override public List<? extends BoundedSource<T>> split(long desiredBundleSizeBytes, PipelineOptions options) throws Exception { List<? extends BoundedSource<T>> splits = delegate.split(desiredBundleSizeBytes, options); Collections.shuffle(splits); return splits; }
java
{ "resource": "" }
q157906
SingleFilterAdapter.adapt
train
public Filters.Filter adapt(FilterAdapterContext context, Filter hbaseFilter) throws IOException { T typedFilter = getTypedFilter(hbaseFilter); return adapter.adapt(context, typedFilter); }
java
{ "resource": "" }
q157907
SingleFilterAdapter.isSupported
train
public FilterSupportStatus isSupported(FilterAdapterContext context, Filter hbaseFilter) { Preconditions.checkArgument(isFilterAProperSublcass(hbaseFilter)); return adapter.isFilterSupported(context, getTypedFilter(hbaseFilter)); }
java
{ "resource": "" }
q157908
SingleFilterAdapter.collectUnsupportedStatuses
train
public void collectUnsupportedStatuses( FilterAdapterContext context, Filter filter, List<FilterSupportStatus> statuses) { Preconditions.checkArgument(isFilterAProperSublcass(filter)); unsupportedStatusCollector.collectUnsupportedStatuses( context, unchecked(filter), st...
java
{ "resource": "" }
q157909
TracingUtilities.setupTracingConfig
train
public static void setupTracingConfig() { List<String> descriptors = new ArrayList<>(); addDescriptor(descriptors, BigtableTableAdminGrpc.getServiceDescriptor()); addDescriptor(descriptors, BigtableGrpc.getServiceDescriptor()); Tracing.getExportComponent().getSampledSpanStore().registerSpanNamesForColl...
java
{ "resource": "" }
q157910
BulkRead.add
train
public synchronized ApiFuture<FlatRow> add(Query query) { Preconditions.checkNotNull(query); ReadRowsRequest request = query.toProto(requestContext); Preconditions.checkArgument(request.getRows().getRowKeysCount() == 1); ByteString rowKey = request.getRows().getRowKeysList().get(0); Preconditions.c...
java
{ "resource": "" }
q157911
BulkRead.flush
train
public void flush() { for (Batch batch : batches.values()) { Collection<Batch> subbatches = batch.split(); for (Batch miniBatch : subbatches) { threadPool.submit(miniBatch); } } batches.clear(); }
java
{ "resource": "" }
q157912
HadoopSerializationCoder.readObject
train
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); try { serialization = serializationClass.newInstance(); } catch (IllegalAccessException | InstantiationException e) { throw new RuntimeException( "Failed to deser...
java
{ "resource": "" }
q157913
BigtableClusterUtilities.getClusterSize
train
@Deprecated public int getClusterSize(String clusterId, String zoneId) { Cluster cluster = getCluster(clusterId, zoneId); String message = String.format("Cluster %s/%s was not found.", clusterId, zoneId); Preconditions.checkNotNull(cluster, message); return cluster.getServeNodes(); }
java
{ "resource": "" }
q157914
BigtableClusterUtilities.setClusterSize
train
public void setClusterSize(String clusterId, String zoneId, int newSize) throws InterruptedException { setClusterSize(instanceName.toClusterName(clusterId).getClusterName(), newSize); }
java
{ "resource": "" }
q157915
BigtableClusterUtilities.setClusterSize
train
private void setClusterSize(String clusterName, int newSize) throws InterruptedException { Preconditions.checkArgument(newSize > 0, "Cluster size must be > 0"); logger.info("Updating cluster %s to size %d", clusterName, newSize); Operation operation = client.updateCluster(Cluster.newBuilder() ...
java
{ "resource": "" }
q157916
BigtableClusterUtilities.waitForOperation
train
public void waitForOperation(String operationName, int maxSeconds) throws InterruptedException { long endTimeMillis = TimeUnit.SECONDS.toMillis(maxSeconds) + System.currentTimeMillis(); GetOperationRequest request = GetOperationRequest.newBuilder().setName(operationName).build(); do { Thread.sleep(50...
java
{ "resource": "" }
q157917
Import.filterKv
train
public static Cell filterKv(Filter filter, Cell kv) throws IOException { // apply the filter and skip this kv if the filter doesn't apply if (filter != null) { Filter.ReturnCode code = filter.filterKeyValue(kv); if (LOG.isTraceEnabled()) { LOG.trace("Filter returned:" + code + " for the key ...
java
{ "resource": "" }
q157918
Import.addFilterAndArguments
train
public static void addFilterAndArguments(Configuration conf, Class<? extends Filter> clazz, List<String> filterArgs) { conf.set(Import.FILTER_CLASS_CONF_KEY, clazz.getName()); conf.setStrings(Import.FILTER_ARGS_CONF_KEY, filterArgs.toArray(new String[filterArgs.size()])); }
java
{ "resource": "" }
q157919
CredentialFactory.getInputStreamCredential
train
public static Credentials getInputStreamCredential(InputStream inputStream) throws IOException { GoogleCredentials credentials = GoogleCredentials.fromStream(inputStream, getHttpTransportFactory()); if (credentials instanceof ServiceAccountCredentials) { return getJwtToken((ServiceAccountCredentials)cred...
java
{ "resource": "" }
q157920
AbstractBigtableAdmin.createTable
train
protected void createTable(TableName tableName, CreateTableRequest request) throws IOException { try { tableAdminClientWrapper.createTable(request); } catch (Throwable throwable) { throw convertToTableExistsException(tableName, throwable); } }
java
{ "resource": "" }
q157921
AbstractBigtableAdmin.addColumn
train
@Deprecated public void addColumn(String tableName, HColumnDescriptor column) throws IOException { addColumn(TableName.valueOf(tableName), column); }
java
{ "resource": "" }
q157922
AbstractBigtableAdmin.snapshot
train
public void snapshot(byte[] snapshotName, byte[] tableName) throws IOException, IllegalArgumentException { snapshot(snapshotName, TableName.valueOf(tableName)); }
java
{ "resource": "" }
q157923
AbstractRetryingOperation.getAsyncResult
train
public ListenableFuture<ResultT> getAsyncResult() { Preconditions.checkState(operationTimerContext == null); operationTimerContext = rpc.getRpcMetrics().timeOperation(); run(); return completionFuture; }
java
{ "resource": "" }
q157924
OperationAccountant.awaitCompletion
train
public void awaitCompletion() throws InterruptedException { boolean performedWarning = false; while (hasInflightOperations()) { synchronized (signal) { if (hasInflightOperations()) { signal.wait(finishWaitMillis); } } long now = clock.nanoTime(); if (now >= no...
java
{ "resource": "" }
q157925
BigtableVeneerSettingsFactory.buildReadRowSettings
train
private static void buildReadRowSettings(Builder builder, BigtableOptions options) { RetrySettings retrySettings = buildIdempotentRetrySettings(builder.readRowSettings().getRetrySettings(), options); builder.readRowSettings() .setRetrySettings(retrySettings) .setRetryableCodes(buildRetr...
java
{ "resource": "" }
q157926
SingleColumnValueFilterAdapter.createValueMatchFilter
train
private Filter createValueMatchFilter( FilterAdapterContext context, SingleColumnValueFilter filter) throws IOException { ValueFilter valueFilter = new ValueFilter(filter.getOperator(), filter.getComparator()); return delegateAdapter.toFilter(context, valueFilter); }
java
{ "resource": "" }
q157927
RetryingReadRowsOperation.handleTimeoutError
train
private void handleTimeoutError(Status status) { Preconditions.checkArgument(status.getCause() instanceof StreamWaitTimeoutException, "status is not caused by a StreamWaitTimeoutException"); StreamWaitTimeoutException e = ((StreamWaitTimeoutException) status.getCause()); // Cancel the existing rpc....
java
{ "resource": "" }
q157928
ResourceLimiterStats.markThrottling
train
void markThrottling(long throttlingDurationInNanos) { throttlingTimer.update(throttlingDurationInNanos, TimeUnit.NANOSECONDS); cumulativeThrottlingTimeNanos.addAndGet(throttlingDurationInNanos); }
java
{ "resource": "" }
q157929
PatternFlattener.parsePattern
train
static List<String> parsePattern(String pattern) { List<String> parameters = new ArrayList<>(4); Matcher matcher = PARAM_REGEX.matcher(pattern); while (matcher.find()) { parameters.add(matcher.group(1)); } return parameters; }
java
{ "resource": "" }
q157930
PatternFlattener.parseParameters
train
private static List<ParameterFiller> parseParameters(List<String> parameters) { List<ParameterFiller> parameterFillers = new ArrayList<>(parameters.size()); for (String parameter : parameters) { ParameterFiller parameterFiller = parseParameter(parameter); if (parameterFiller != null) { param...
java
{ "resource": "" }
q157931
PatternFlattener.parseParameter
train
private static ParameterFiller parseParameter(String parameter) { String wrappedParameter = "{" + parameter + "}"; String trimmedParameter = parameter.trim(); ParameterFiller parameterFiller = parseDateParameter(wrappedParameter, trimmedParameter); if (parameterFiller != null) { return parameterFi...
java
{ "resource": "" }
q157932
PatternFlattener.parseDateParameter
train
static DateFiller parseDateParameter(String wrappedParameter, String trimmedParameter) { if (trimmedParameter.startsWith(PARAMETER_DATE + " ") && trimmedParameter.length() > PARAMETER_DATE.length() + 1) { String dateFormat = trimmedParameter.substring(PARAMETER_DATE.length() + 1); return new Dat...
java
{ "resource": "" }
q157933
PatternFlattener.parseLevelParameter
train
static LevelFiller parseLevelParameter(String wrappedParameter, String trimmedParameter) { if (trimmedParameter.equals(PARAMETER_LEVEL_SHORT)) { return new LevelFiller(wrappedParameter, trimmedParameter, false); } else if (trimmedParameter.equals(PARAMETER_LEVEL_LONG)) { return new LevelFiller(wrapp...
java
{ "resource": "" }
q157934
PatternFlattener.parseTagParameter
train
static TagFiller parseTagParameter(String wrappedParameter, String trimmedParameter) { if (trimmedParameter.equals(PARAMETER_TAG)) { return new TagFiller(wrappedParameter, trimmedParameter); } return null; }
java
{ "resource": "" }
q157935
PatternFlattener.parseMessageParameter
train
static MessageFiller parseMessageParameter(String wrappedParameter, String trimmedParameter) { if (trimmedParameter.equals(PARAMETER_MESSAGE)) { return new MessageFiller(wrappedParameter, trimmedParameter); } return null; }
java
{ "resource": "" }
q157936
XLogSampleApplication.initXlog
train
private void initXlog() { LogConfiguration config = new LogConfiguration.Builder() .logLevel(BuildConfig.DEBUG ? LogLevel.ALL // Specify log level, logs below this level won't be printed, default: LogLevel.ALL : LogLevel.NONE) .tag(getString(R.string.global_tag)) ...
java
{ "resource": "" }
q157937
LogUtils.formatJson
train
public static String formatJson(String json) { assertInitialization(); return XLog.sLogConfiguration.jsonFormatter.format(json); }
java
{ "resource": "" }
q157938
LogUtils.formatXml
train
public static String formatXml(String xml) { assertInitialization(); return XLog.sLogConfiguration.xmlFormatter.format(xml); }
java
{ "resource": "" }
q157939
LogUtils.formatThrowable
train
public static String formatThrowable(Throwable throwable) { assertInitialization(); return XLog.sLogConfiguration.throwableFormatter.format(throwable); }
java
{ "resource": "" }
q157940
LogUtils.formatThread
train
public static String formatThread(Thread thread) { assertInitialization(); return XLog.sLogConfiguration.threadFormatter.format(thread); }
java
{ "resource": "" }
q157941
LogUtils.formatStackTrace
train
public static String formatStackTrace(StackTraceElement[] stackTrace) { assertInitialization(); return XLog.sLogConfiguration.stackTraceFormatter.format(stackTrace); }
java
{ "resource": "" }
q157942
LogUtils.addBorder
train
public static String addBorder(String[] segments) { assertInitialization(); return XLog.sLogConfiguration.borderFormatter.format(segments); }
java
{ "resource": "" }
q157943
AndroidPrinter.printChunk
train
void printChunk(int logLevel, String tag, String msg) { android.util.Log.println(logLevel, tag, msg); }
java
{ "resource": "" }
q157944
DateFileNameGenerator.generateFileName
train
@Override public String generateFileName(int logLevel, long timestamp) { SimpleDateFormat sdf = mLocalDateFormat.get(); sdf.setTimeZone(TimeZone.getDefault()); return sdf.format(new Date(timestamp)); }
java
{ "resource": "" }
q157945
Logger.println
train
private <T> void println(int logLevel, T object) { if (logLevel < logConfiguration.logLevel) { return; } String objectString; if (object != null) { ObjectFormatter<? super T> objectFormatter = logConfiguration.getObjectFormatter(object); if (objectFormatter != null) { objectStr...
java
{ "resource": "" }
q157946
Logger.println
train
private void println(int logLevel, Object[] array) { if (logLevel < logConfiguration.logLevel) { return; } printlnInternal(logLevel, Arrays.deepToString(array)); }
java
{ "resource": "" }
q157947
Logger.printlnInternal
train
private void printlnInternal(int logLevel, String msg) { String tag = logConfiguration.tag; String thread = logConfiguration.withThread ? logConfiguration.threadFormatter.format(Thread.currentThread()) : null; String stackTrace = logConfiguration.withStackTrace ? logConfiguration.sta...
java
{ "resource": "" }
q157948
Logger.formatArgs
train
private String formatArgs(String format, Object... args) { if (format != null) { return String.format(format, args); } else { StringBuilder sb = new StringBuilder(); for (int i = 0, N = args.length; i < N; i++) { if (i != 0) { sb.append(", "); } sb.append(args...
java
{ "resource": "" }
q157949
StackTraceUtil.getCroppedRealStackTrack
train
public static StackTraceElement[] getCroppedRealStackTrack(StackTraceElement[] stackTrace, String stackTraceOrigin, int maxDepth) { return cropStackTrace(getRealStackTrack(stackTrace, stackTrace...
java
{ "resource": "" }
q157950
StackTraceUtil.getRealStackTrack
train
private static StackTraceElement[] getRealStackTrack(StackTraceElement[] stackTrace, String stackTraceOrigin) { int ignoreDepth = 0; int allDepth = stackTrace.length; String className; for (int i = allDepth - 1; i >= 0; i--) { className = stac...
java
{ "resource": "" }
q157951
StackTraceUtil.cropStackTrace
train
private static StackTraceElement[] cropStackTrace(StackTraceElement[] callStack, int maxDepth) { int realDepth = callStack.length; if (maxDepth > 0) { realDepth = Math.min(maxDepth, realDepth); } StackTraceElement[] realStack = new StackTraceElem...
java
{ "resource": "" }
q157952
MainActivity.showPermissionRequestDialog
train
private void showPermissionRequestDialog(final boolean gotoSettings) { new AlertDialog.Builder(this) .setTitle(R.string.permission_request) .setMessage(R.string.permission_explanation) .setNegativeButton(android.R.string.cancel, null) .setPositiveButton(gotoSettings ? R.string.go_to_...
java
{ "resource": "" }
q157953
MainActivity.showChangeTagDialog
train
private void showChangeTagDialog() { View view = getLayoutInflater().inflate(R.layout.dialog_change_tag, null, false); final EditText tagEditText = (EditText) view.findViewById(R.id.tag); tagEditText.setText(tagView.getText()); new AlertDialog.Builder(this) .setTitle(R.string.change_tag) ...
java
{ "resource": "" }
q157954
MainActivity.printLog
train
private void printLog() { Logger.Builder builder = new Logger.Builder(); String tag = tagView.getText().toString(); if (!TextUtils.isEmpty(tag)) { builder.tag(tag); } if (threadInfo.isChecked()) { builder.t(); } else { builder.nt(); } if (stackTraceInfo.isChecked()) ...
java
{ "resource": "" }
q157955
FilePrinter.doPrintln
train
private void doPrintln(long timeMillis, int logLevel, String tag, String msg) { String lastFileName = writer.getLastFileName(); if (lastFileName == null || fileNameGenerator.isFileNameChangeable()) { String newFileName = fileNameGenerator.generateFileName(logLevel, System.currentTimeMillis()); if (n...
java
{ "resource": "" }
q157956
FilePrinter.cleanLogFilesIfNecessary
train
private void cleanLogFilesIfNecessary() { File logDir = new File(folderPath); File[] files = logDir.listFiles(); if (files == null) { return; } for (File file : files) { if (cleanStrategy.shouldClean(file)) { file.delete(); } } }
java
{ "resource": "" }
q157957
AttributesBuilder.attributes
train
public static AttributesBuilder attributes(String[] arguments) { AttributesBuilder attributesBuilder = new AttributesBuilder(); attributesBuilder.arguments(arguments); return attributesBuilder; }
java
{ "resource": "" }
q157958
AttributesBuilder.attribute
train
public AttributesBuilder attribute(String attributeName, Object attributeValue) { this.attributes.setAttribute(attributeName, attributeValue); return this; }
java
{ "resource": "" }
q157959
OptionsBuilder.templateDirs
train
public OptionsBuilder templateDirs(File... templateDirs) { for (File templateDir : templateDirs) { this.options.setTemplateDirs(templateDir.getAbsolutePath()); } return this; }
java
{ "resource": "" }
q157960
OptionsBuilder.option
train
public OptionsBuilder option(String option, Object value) { this.options.setOption(option, value); return this; }
java
{ "resource": "" }
q157961
Attributes.setTableOfContents2
train
public void setTableOfContents2(Placement placement) { this.attributes.put(TOC_2, toAsciidoctorFlag(true)); this.attributes.put(TOC_POSITION, placement.getPosition()); }
java
{ "resource": "" }
q157962
Attributes.setTableOfContents
train
public void setTableOfContents(Placement placement) { this.attributes.put(TOC, toAsciidoctorFlag(true)); this.attributes.put(TOC_POSITION, placement.getPosition()); }
java
{ "resource": "" }
q157963
Attributes.setShowTitle
train
public void setShowTitle(boolean showTitle) { if (showTitle) { this.attributes.put(SHOW_TITLE, true); this.attributes.remove(NOTITLE); } else { this.attributes.put(NOTITLE, true); this.attributes.remove(SHOW_TITLE); } }
java
{ "resource": "" }
q157964
GlobDirectoryWalker.findIndexOfUnglobbedPart
train
private int findIndexOfUnglobbedPart(String globExpression) { int result = -1; for (int i = 0; i < globExpression.length(); i++) { switch (globExpression.charAt(i)) { case '/': case '\\': result = i; break; ...
java
{ "resource": "" }
q157965
AbstractDirectoryWalker.scan
train
@Override public List<File> scan() { File baseDirFile = new File(baseDir); List<File> includedFiles = walkDirectory(baseDirFile); return includedFiles; }
java
{ "resource": "" }
q157966
SecurityActions.setFieldValue
train
public static void setFieldValue(final Class<?> source, final Object target, final String fieldName, final Object value) throws NoSuchFieldException { try { AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() { @Override public ...
java
{ "resource": "" }
q157967
PyroProxy._processMetadata
train
private void _processMetadata(HashMap<String, Object> result) { // the collections in the result can be either an object[] or a HashSet<object>, depending on the serializer that is used Object methods = result.get("methods"); Object attrs = result.get("attrs"); Object oneways = result.get("oneways"); if(meth...
java
{ "resource": "" }
q157968
PyroProxy.getSetOfStrings
train
@SuppressWarnings("unchecked") protected HashSet<String> getSetOfStrings(Object strings) { try { return (HashSet<String>) strings; } catch (ClassCastException ex) { Collection<String> list = (Collection<String>) strings; return new HashSet<String>(list); } }
java
{ "resource": "" }
q157969
PyroProxy.call
train
public Object call(String method, Object... arguments) throws PickleException, PyroException, IOException { return internal_call(method, null, 0, true, arguments); }
java
{ "resource": "" }
q157970
PyroProxy.getattr
train
public Object getattr(String attr) throws PickleException, PyroException, IOException { return this.internal_call("__getattr__", null, 0, false, attr); }
java
{ "resource": "" }
q157971
PyroProxy.setattr
train
public void setattr(String attr, Object value) throws PickleException, PyroException, IOException { this.internal_call("__setattr__", null, 0, false, attr, value); }
java
{ "resource": "" }
q157972
PyroProxy.close
train
public void close() { if (this.sock != null) try { this.sock_in.close(); this.sock_out.close(); this.sock.close(); this.sock=null; this.sock_in=null; this.sock_out=null; } catch (IOException e) { } }
java
{ "resource": "" }
q157973
PyroProxy._handshake
train
@SuppressWarnings("unchecked") protected void _handshake() throws IOException { // do connection handshake PyroSerializer ser = PyroSerializer.getFor(Config.SERIALIZER); Map<String, Object> handshakedata = new HashMap<String, Object>(); handshakedata.put("handshake", pyroHandshake); if(Config.METADATA) h...
java
{ "resource": "" }
q157974
Message.from_header
train
public static Message from_header(byte[] header) { if(header==null || header.length!=HEADER_SIZE) throw new PyroException("header data size mismatch"); if(header[0]!='P'||header[1]!='Y'||header[2]!='R'||header[3]!='O') throw new PyroException("invalid message"); int version = ((header[4]&0xff) <...
java
{ "resource": "" }
q157975
PyroSerializer.getFor
train
public static PyroSerializer getFor(Config.SerializerType type) { switch(type) { case pickle: return pickleSerializer; case serpent: { synchronized(PyroSerializer.class) { if(serpentSerializer==null) { // try loading it try { serpentSerializer = new S...
java
{ "resource": "" }
q157976
Pickler.dumps
train
public byte[] dumps(Object o) throws PickleException, IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); dump(o, bo); bo.flush(); return bo.toByteArray(); }
java
{ "resource": "" }
q157977
Pickler.dump
train
public void dump(Object o, OutputStream stream) throws IOException, PickleException { out = stream; recurse = 0; if(useMemo) memo = new HashMap<Integer, Memo>(); out.write(Opcodes.PROTO); out.write(PROTOCOL); save(o); memo = null; // get rid of the memo table out.write(Opcodes.STOP); out.flush(); ...
java
{ "resource": "" }
q157978
Pickler.save
train
public void save(Object o) throws PickleException, IOException { recurse++; if(recurse>MAX_RECURSE_DEPTH) throw new java.lang.StackOverflowError("recursion too deep in Pickler.save (>"+MAX_RECURSE_DEPTH+")"); // null type? if(o==null) { out.write(Opcodes.NONE); recurse--; return; } // check th...
java
{ "resource": "" }
q157979
Pickler.writeMemo
train
protected void writeMemo( Object obj ) throws IOException { if(!this.useMemo) return; int hash = valueCompare ? obj.hashCode() : System.identityHashCode(obj); if(!memo.containsKey(hash)) { int memo_index = memo.size(); memo.put(hash, new Memo(obj, memo_index)); if(memo_index<=0xFF) { out.wri...
java
{ "resource": "" }
q157980
Pickler.lookupMemo
train
private boolean lookupMemo(Class<?> objectType, Object obj) throws IOException { if(!this.useMemo) return false; if(!objectType.isPrimitive()) { int hash = valueCompare ? obj.hashCode() : System.identityHashCode(obj); if(memo.containsKey(hash) && (valueCompare ? memo.get(hash).obj.equals(obj) : memo.get(ha...
java
{ "resource": "" }
q157981
Pickler.getCustomPickler
train
protected IObjectPickler getCustomPickler(Class<?> t) { IObjectPickler pickler = customPicklers.get(t); if(pickler!=null) { return pickler; // exact match } // check if there's a custom pickler registered for an interface or abstract base class // that this object implements or inherits from. for(Entry...
java
{ "resource": "" }
q157982
PrettyPrint.print
train
public static void print(Object o) throws IOException { OutputStreamWriter w=new OutputStreamWriter(System.out,"UTF-8"); print(o, w, true); w.flush(); }
java
{ "resource": "" }
q157983
Unpickler.registerConstructor
train
public static void registerConstructor(String module, String classname, IObjectConstructor constructor) { objectConstructors.put(module + "." + classname, constructor); }
java
{ "resource": "" }
q157984
Unpickler.load
train
public Object load(InputStream stream) throws PickleException, IOException { stack = new UnpickleStack(); input = stream; while (true) { short key = PickleUtils.readbyte(input); if (key == -1) throw new IOException("premature end of file"); Object value = dispatch(key); if (value != NO_RETURN_VALU...
java
{ "resource": "" }
q157985
Unpickler.close
train
public void close() { if(stack!=null) stack.clear(); if(memo!=null) memo.clear(); if(input!=null) try { input.close(); } catch (IOException e) { } }
java
{ "resource": "" }
q157986
PickleUtils.readline
train
public static String readline(InputStream input, boolean includeLF) throws IOException { StringBuilder sb = new StringBuilder(); while (true) { int c = input.read(); if (c == -1) { if (sb.length() == 0) throw new IOException("premature end of file"); break; } if (c != '\n' || inclu...
java
{ "resource": "" }
q157987
PickleUtils.readbytes_into
train
public static void readbytes_into(InputStream input, byte[] buffer, int offset, int length) throws IOException { while (length > 0) { int read = input.read(buffer, offset, length); if (read == -1) throw new IOException("expected more bytes in input stream"); offset += read; length -= read; } ...
java
{ "resource": "" }
q157988
PickleUtils.bytes_to_long
train
public static long bytes_to_long(byte[] bytes, int offset) { if(bytes.length-offset<8) throw new PickleException("too few bytes to convert to long"); long i = bytes[7+offset] & 0xff; i <<= 8; i |= bytes[6+offset] & 0xff; i <<= 8; i |= bytes[5+offset] & 0xff; i <<= 8; i |= bytes[4+offset] & 0...
java
{ "resource": "" }
q157989
PickleUtils.bytes_to_double
train
public static double bytes_to_double(byte[] bytes, int offset) { try { long result = bytes[0+offset] & 0xff; result <<= 8; result |= bytes[1+offset] & 0xff; result <<= 8; result |= bytes[2+offset] & 0xff; result <<= 8; result |= bytes[3+offset] & 0xff; result <<= 8; result |= byte...
java
{ "resource": "" }
q157990
PickleUtils.bytes_to_float
train
public static float bytes_to_float(byte[] bytes, int offset) { try { int result = bytes[0+offset] & 0xff; result <<= 8; result |= bytes[1+offset] & 0xff; result <<= 8; result |= bytes[2+offset] & 0xff; result <<= 8; result |= bytes[3+offset] & 0xff; return Float.intBitsToFloat(result)...
java
{ "resource": "" }
q157991
PickleUtils.optimizeBigint
train
public static Number optimizeBigint(BigInteger bigint) { // final BigInteger MAXINT=BigInteger.valueOf(Integer.MAX_VALUE); // final BigInteger MININT=BigInteger.valueOf(Integer.MIN_VALUE); final BigInteger MAXLONG = BigInteger.valueOf(Long.MAX_VALUE); final BigInteger MINLONG = BigInteger.valueOf(Long.MIN_V...
java
{ "resource": "" }
q157992
PickleUtils.rawStringFromBytes
train
public static String rawStringFromBytes(byte[] data) { StringBuilder str = new StringBuilder(data.length); for (byte b : data) { str.append((char) (b & 0xff)); } return str.toString(); }
java
{ "resource": "" }
q157993
PickleUtils.str2bytes
train
public static byte[] str2bytes(String str) throws IOException { byte[] b=new byte[str.length()]; for(int i=0; i<str.length(); ++i) { char c=str.charAt(i); if(c>255) throw new UnsupportedEncodingException("string contained a char > 255, cannot convert to bytes"); b[i]=(byte)c; } return b; }
java
{ "resource": "" }
q157994
IOUtil.recv
train
public static byte[] recv(InputStream in, int size) throws IOException { byte [] bytes = new byte [size]; int numRead = in.read(bytes); if(numRead==-1) { throw new IOException("premature end of data"); } while (numRead < size) { int len = in.read(bytes, numRead, size - numRead); if(len==-1)...
java
{ "resource": "" }
q157995
SuroControl.closeAndIgnoreError
train
private static void closeAndIgnoreError(Socket socket) { if(socket == null) return; try{ socket.close(); }catch(IOException e) { log.warn(String.format("Failed to close the client socket on port %d: %s. Exception ignored.", socket.getPort(), e.getMessage()), e); ...
java
{ "resource": "" }
q157996
SuroControl.respond
train
private void respond(BufferedWriter out, String response) throws IOException { out.append(response); out.append("\n"); out.flush(); }
java
{ "resource": "" }
q157997
FileWriterBase.createSequenceFile
train
public SequenceFile.Writer createSequenceFile(String newPath) throws IOException { if (codec != null) { return SequenceFile.createWriter( fs, conf, new Path(newPath), Text.class, MessageWritable.class, SequenceFile.CompressionType.BLOCK, co...
java
{ "resource": "" }
q157998
FileWriterBase.createFSDataOutputStream
train
public FSDataOutputStream createFSDataOutputStream(String path) throws IOException { return fs.create(new Path(path), false); }
java
{ "resource": "" }
q157999
FileWriterBase.createDataOutputStream
train
public DataOutputStream createDataOutputStream(FSDataOutputStream outputStream) throws IOException { if (codec != null) { return new FSDataOutputStream(codec.createOutputStream(outputStream), null); } else { return outputStream; } }
java
{ "resource": "" }