_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q167000
RisonParser._skipString
validation
protected void _skipString() throws IOException, JsonParseException { _tokenIncomplete = false; int inputPtr = _inputPtr; int inputLen = _inputEnd; char[] inputBuffer = _inputBuffer; while (true) { if (inputPtr >= inputLen) { _inputPt...
java
{ "resource": "" }
q167001
RisonParser._matchToken
validation
protected void _matchToken(String matchStr, int i) throws IOException, JsonParseException { final int len = matchStr.length(); do { if (_inputPtr >= _inputEnd) { if (!loadMore()) { _reportInvalidEOFInValue(); } ...
java
{ "resource": "" }
q167002
RisonParser._decodeBase64
validation
protected byte[] _decodeBase64(Base64Variant b64variant) throws IOException, JsonParseException { ByteArrayBuilder builder = _getByteArrayBuilder(); //main_loop: while (true) { // first, we'll skip preceding white space, if any char ch; do { ...
java
{ "resource": "" }
q167003
IdentifierUtils.isIdStrict
validation
public static boolean isIdStrict(String string) { int len = string.length(); if (len == 0) { return false; } if (!isIdStartStrict(string.charAt(0))) { return false; } for (int i = 1; i < len; i++) { if (!isIdCharStrict(string.charAt(i))...
java
{ "resource": "" }
q167004
IdentifierUtils.isIdStrict
validation
public static boolean isIdStrict(char[] chars, int offset, int len) { if (len == 0) { return false; } int end = offset + len; if (!isIdStartStrict(chars[offset++])) { return false; } while (offset < end) { if (!isIdCharStrict(chars[offs...
java
{ "resource": "" }
q167005
RisonGenerator._writeString
validation
private void _writeString(char[] text, int offset, int len) throws IOException, JsonGenerationException { /* Let's just find longest spans of non-escapable * content, and for each see if it makes sense * to copy them, or write through */ len += offset; // -> len m...
java
{ "resource": "" }
q167006
RisonGenerator._prependOrWrite
validation
private int _prependOrWrite(char[] buffer, int ptr, char esc) throws IOException, JsonGenerationException { if (ptr > 0) { // fits, just prepend buffer[--ptr] = esc; } else { // won't fit, write _writer.write(esc); } return ptr; }
java
{ "resource": "" }
q167007
RisonGenerator._appendCharacterEscape
validation
private void _appendCharacterEscape(char esc, char ch) throws IOException, JsonGenerationException { if ((_outputTail + 1) >= _outputEnd) { _flushBuffer(); } _outputBuffer[_outputTail++] = esc; _outputBuffer[_outputTail++] = ch; }
java
{ "resource": "" }
q167008
ThriftToPig.setConversionProperties
validation
public static void setConversionProperties(Configuration conf) { if (conf != null) { useEnumId = conf.getBoolean(USE_ENUM_ID_CONF_KEY, false); LOG.debug("useEnumId is set to " + useEnumId); } }
java
{ "resource": "" }
q167009
ThriftToPig.toPigScript
validation
public static String toPigScript(Class<? extends TBase<?, ?>> thriftClass, Class<? extends LoadFunc> pigLoader) { StringBuilder sb = new StringBuilder(); /* we are commenting out explicit schema specification. The schema is * included mainly to help the readers of the pig...
java
{ "resource": "" }
q167010
ThriftToPig.stringifySchema
validation
public static void stringifySchema(StringBuilder sb, Schema schema, byte type, StringBuilder prefix) throws FrontendException{ // this is a modified version of {...
java
{ "resource": "" }
q167011
LuceneIndexRecordReader.openIndex
validation
protected IndexReader openIndex(Path path, Configuration conf) throws IOException { return DirectoryReader.open(new LuceneHdfsDirectory(path, path.getFileSystem(conf))); }
java
{ "resource": "" }
q167012
LuceneIndexRecordReader.getProgress
validation
@Override public float getProgress() { if (numIndexes < 1) { return 1.0f; } float indexProgress = (float) currentIndexPathIter.previousIndex() / (float) numIndexes; float queriesProgress = 1.0f; if (queries.size() > 0) { queriesProgress = (float) currentQueryIter.previousIndex() / (f...
java
{ "resource": "" }
q167013
ProtobufToPig.toTuple
validation
public Tuple toTuple(Message msg) { if (msg == null) { // Pig tuples deal gracefully with nulls. // Also, we can be called with null here in recursive calls. return null; } Descriptor msgDescriptor = msg.getDescriptorForType(); Tuple tuple = tupleFactory_.newTuple(msgDescriptor.getFie...
java
{ "resource": "" }
q167014
ProtobufToPig.messageToTuple
validation
@SuppressWarnings("unchecked") protected Object messageToTuple(FieldDescriptor fieldDescriptor, Object fieldValue) { if (fieldValue == null) { // protobufs unofficially ensures values are not null. just in case: return null; } assert fieldDescriptor.getType() == FieldDescriptor.Type.MESSAGE : ...
java
{ "resource": "" }
q167015
ProtobufToPig.singleFieldToTuple
validation
@SuppressWarnings("unchecked") protected Object singleFieldToTuple(FieldDescriptor fieldDescriptor, Object fieldValue) { assert fieldDescriptor.getType() != FieldDescriptor.Type.MESSAGE : "messageToFieldSchema called with field of type " + fieldDescriptor.getType(); if (fieldDescriptor.isRepeated()) { ...
java
{ "resource": "" }
q167016
ProtobufToPig.coerceToPigTypes
validation
private Object coerceToPigTypes(FieldDescriptor fieldDescriptor, Object fieldValue) { if (fieldDescriptor.getType() == FieldDescriptor.Type.ENUM && fieldValue != null) { EnumValueDescriptor enumValueDescriptor = (EnumValueDescriptor)fieldValue; return enumValueDescriptor.getName(); } else if (fieldD...
java
{ "resource": "" }
q167017
ProtobufToPig.toSchema
validation
public Schema toSchema(Descriptor msgDescriptor) { Schema schema = new Schema(); try { // Walk through all the possible fields in the message. for (FieldDescriptor fieldDescriptor : msgDescriptor.getFields()) { if (fieldDescriptor.getType() == FieldDescriptor.Type.MESSAGE) { schem...
java
{ "resource": "" }
q167018
ProtobufToPig.messageToFieldSchema
validation
private FieldSchema messageToFieldSchema(FieldDescriptor fieldDescriptor) throws FrontendException { assert fieldDescriptor.getType() == FieldDescriptor.Type.MESSAGE : "messageToFieldSchema called with field of type " + fieldDescriptor.getType(); Schema innerSchema = toSchema(fieldDescriptor.getMessageType());...
java
{ "resource": "" }
q167019
ProtobufToPig.singleFieldToFieldSchema
validation
private FieldSchema singleFieldToFieldSchema(FieldDescriptor fieldDescriptor) throws FrontendException { assert fieldDescriptor.getType() != FieldDescriptor.Type.MESSAGE : "singleFieldToFieldSchema called with field of type " + fieldDescriptor.getType(); if (fieldDescriptor.isRepeated()) { Schema itemSch...
java
{ "resource": "" }
q167020
ProtobufToPig.toPigScript
validation
public String toPigScript(Descriptor msgDescriptor, String loaderClassName) { StringBuffer sb = new StringBuffer(); final int initialTabOffset = 3; sb.append("raw_data = load '$INPUT_FILES' using " + loaderClassName + "()").append("\n"); sb.append(tabs(initialTabOffset)).append("as (").append("\n"); ...
java
{ "resource": "" }
q167021
ProtobufToPig.toPigScriptInternal
validation
private StringBuffer toPigScriptInternal(Descriptor msgDescriptor, int numTabs) { StringBuffer sb = new StringBuffer(); try { // Walk through all the possible fields in the message. for (FieldDescriptor fieldDescriptor : msgDescriptor.getFields()) { // We have to add a comma after every line...
java
{ "resource": "" }
q167022
ProtobufToPig.messageToPigScript
validation
private StringBuffer messageToPigScript(FieldDescriptor fieldDescriptor, int numTabs, boolean isLast) throws FrontendException { assert fieldDescriptor.getType() == FieldDescriptor.Type.MESSAGE : "messageToPigScript called with field of type " + fieldDescriptor.getType(); if (fieldDescriptor.isRepeated()) { ...
java
{ "resource": "" }
q167023
ProtobufToPig.singleFieldToPigScript
validation
private StringBuffer singleFieldToPigScript(FieldDescriptor fieldDescriptor, int numTabs, boolean isLast) throws FrontendException { assert fieldDescriptor.getType() != FieldDescriptor.Type.MESSAGE : "singleFieldToPigScript called with field of type " + fieldDescriptor.getType(); if (fieldDescriptor.isRepeated...
java
{ "resource": "" }
q167024
TStructDescriptor.getInstance
validation
public static TStructDescriptor getInstance(Class<? extends TBase<?, ?>> tClass) { synchronized (structMap) { TStructDescriptor desc = structMap.get(tClass); if (desc == null) { desc = new TStructDescriptor(); desc.tClass = tClass; structMap.put(tClass, desc); desc.build(...
java
{ "resource": "" }
q167025
TStructDescriptor.extractEnumMap
validation
static private Map<String, TEnum> extractEnumMap(Class<? extends TEnum> enumClass) { ImmutableMap.Builder<String, TEnum> builder = ImmutableMap.builder(); for(TEnum e : enumClass.getEnumConstants()) { builder.put(e.toString(), e); } return builder.build(); }
java
{ "resource": "" }
q167026
LuceneIndexOutputFormat.newIndexDirFilter
validation
public static PathFilter newIndexDirFilter(Configuration conf) { return new PathFilters.CompositePathFilter( PathFilters.newExcludeFilesFilter(conf), PathFilters.EXCLUDE_HIDDEN_PATHS_FILTER, new PathFilter() { @Override public boolean accept(Path path) { return path.getNa...
java
{ "resource": "" }
q167027
Protobufs.useDynamicProtoMessage
validation
public static boolean useDynamicProtoMessage(Class<?> protoClass) { return protoClass == null || protoClass.getCanonicalName().equals(DynamicMessage.class.getCanonicalName()); }
java
{ "resource": "" }
q167028
Protobufs.getTypeRef
validation
public static<M extends Message> TypeRef<M> getTypeRef(String protoClassName) { return new TypeRef<M>(getProtobufClass(protoClassName)){}; }
java
{ "resource": "" }
q167029
LzoRecordReader.getProgress
validation
@Override public float getProgress() { if (start_ == end_) { return 0.0f; } else { return Math.min(1.0f, (pos_ - start_) / (float) (end_ - start_)); } }
java
{ "resource": "" }
q167030
BinaryWritable.serialize
validation
private byte[] serialize() { if (messageBytes == null && message != null) { checkConverter(); messageBytes = converter.toBytes(message); if (messageBytes == null) { // should we throw an IOException instead? LOG.warn("Could not serialize " + message.getClass()); } else { ...
java
{ "resource": "" }
q167031
DeprecatedInputFormatWrapper.setInputFormat
validation
public static void setInputFormat(Class<?> realInputFormatClass, Configuration conf) { conf.setClass("mapred.input.format.class", DeprecatedInputFormatWrapper.class, org.apache.hadoop.mapred.InputFormat.class); HadoopUtils.setClassConf(conf, CLASS_CONF_KEY, realInputFormatClass); }
java
{ "resource": "" }
q167032
HadoopUtils.setClassConf
validation
public static void setClassConf(Configuration conf, String configKey, Class<?> clazz) { String existingClass = conf.get(configKey); String className = clazz.getName(); if (existingClass != null && !existingClass.equals(class...
java
{ "resource": "" }
q167033
HadoopUtils.writeStringListToConfAsJson
validation
public static void writeStringListToConfAsJson(String key, List<String> list, Configuration conf) { Preconditions.checkNotNull(list); conf.set(key, JSONArray.toJSONString(list)); }
java
{ "resource": "" }
q167034
HadoopUtils.readStringListFromConfAsJson
validation
@SuppressWarnings("unchecked") public static List<String> readStringListFromConfAsJson(String key, Configuration conf) { String json = conf.get(key); if (json == null) { return null; } return Lists.<String>newArrayList(((JSONArray) JSONValue.parse(json))); }
java
{ "resource": "" }
q167035
HadoopUtils.writeStringListToConfAsBase64
validation
public static void writeStringListToConfAsBase64(String key, List<String> list, Configuration conf) { Preconditions.checkNotNull(list); Iterator<String> iter = list.iterator(); StringBuilder sb = new StringBuilder(); while(iter.hasNext()) { byte[] bytes = Base64.encodeBase64(iter.next().getByt...
java
{ "resource": "" }
q167036
HadoopUtils.readStringListFromConfAsBase64
validation
@SuppressWarnings("unchecked") public static List<String> readStringListFromConfAsBase64(String key, Configuration conf) { String b64List = conf.get(key); if (b64List == null) { return null; } List<String> strings = Lists.newArrayList(); for (String b64 : COMMA_SPLITTER.split(b64List)) { ...
java
{ "resource": "" }
q167037
ThriftUtils.verifyAncestry
validation
private static void verifyAncestry(Class<?> tClass) { if (!TBase.class.isAssignableFrom(tClass)) { Utils.ensureClassLoaderConsistency(TBase.class, tClass.getClassLoader()); throw new ClassCastException(tClass.getName() + " is not a Thrift class"); } }
java
{ "resource": "" }
q167038
ThriftUtils.getFieldValue
validation
public static <M> M getFieldValue(Object containingObject, String fieldName, Class<M> fieldClass) { return getFieldValue(containingObject.getClass(), containingObject, fieldName, fieldClass); }
java
{ "resource": "" }
q167039
ThriftUtils.getFieldValue
validation
public static <M> M getFieldValue(Class<?> containingClass, String fieldName, Class<M> fieldClass) { return getFieldValue(containingClass, null, fieldName, fieldClass); }
java
{ "resource": "" }
q167040
ThriftUtils.getFieldValueType
validation
public static Class<?> getFieldValueType(Field field) { switch (field.getType()) { case TType.BOOL: return Boolean.class; case TType.BYTE: return Byte.class; case TType.DOUBLE: return Double.class; case TType.ENUM: return field.getEnumClass(); case TType...
java
{ "resource": "" }
q167041
ThriftUtils.writeFieldNoTag
validation
public static void writeFieldNoTag(TProtocol proto, Field field, Object value) throws TException { if (value == null) { return; } Field innerField = null; switch (field.getType()) { case TType.LIST: innerField =...
java
{ "resource": "" }
q167042
PigToProtobuf.tupleToMessage
validation
public static Message tupleToMessage(Builder builder, Tuple tuple) { return tupleToMessage(builder, builder.getDescriptorForType().getFields(), tuple); }
java
{ "resource": "" }
q167043
PigToProtobuf.tupleFieldToSingleField
validation
private static Object tupleFieldToSingleField(FieldDescriptor fieldDescriptor, Object tupleField) { // type convertion should match with ProtobufToPig.getPigScriptDataType switch (fieldDescriptor.getType()) { case ENUM: return toEnumValueDescriptor(fieldDescriptor, (String) tupleField); case BOOL:...
java
{ "resource": "" }
q167044
PigToProtobuf.addField
validation
private static void addField(DescriptorProto.Builder builder, String name, int fieldId, Type type) { FieldDescriptorProto.Builder fdBuilder = FieldDescriptorProto.newBuilder() .setName(name) .setNumber(fieldId) .setType(type); builder.addField(fdBuilder.build()); }
java
{ "resource": "" }
q167045
PigToProtobuf.pigTypeToProtoType
validation
private static Type pigTypeToProtoType(byte pigTypeId) { switch(pigTypeId) { case DataType.BOOLEAN: return Type.TYPE_BOOL; case DataType.INTEGER: return Type.TYPE_INT32; case DataType.LONG: return Type.TYPE_INT64; case DataType.FLOAT: return T...
java
{ "resource": "" }
q167046
PigToThrift.toThrift
validation
@SuppressWarnings("unchecked") private static TBase<?, ?> toThrift(TStructDescriptor tDesc, Tuple tuple) { int size = tDesc.getFields().size(); int tupleSize = tuple.size(); @SuppressWarnings("rawtypes") TBase tObj = newTInstance(tDesc.getThriftClass()); for(int i = 0; i<size && i<tupleSize; i++) ...
java
{ "resource": "" }
q167047
PigToThrift.toThriftValue
validation
@SuppressWarnings("unchecked") public static Object toThriftValue(Field thriftField, Object pigValue) { try { switch (thriftField.getType()) { case TType.BOOL: return Boolean.valueOf(((Integer)pigValue) != 0); case TType.BYTE : return ((Integer)pigValue).byteValue(); case T...
java
{ "resource": "" }
q167048
PigToThrift.newTInstance
validation
private static TBase<?, ?> newTInstance(Class<?> tClass) { try { return (TBase<?, ?>) tClass.newInstance(); } catch (Exception e) { // not expected. throw new RuntimeException(e); } }
java
{ "resource": "" }
q167049
DelegateCombineFileInputFormat.setCombinedInputFormatDelegate
validation
public static void setCombinedInputFormatDelegate(Configuration conf, Class<? extends InputFormat> clazz) { HadoopUtils.setClassConf(conf, COMBINED_INPUT_FORMAT_DELEGATE, clazz); }
java
{ "resource": "" }
q167050
LuceneIndexInputFormat.findSplits
validation
protected PriorityQueue<LuceneIndexInputSplit> findSplits(Configuration conf) throws IOException { PriorityQueue<LuceneIndexInputSplit> splits = new PriorityQueue<LuceneIndexInputSplit>(); List<Path> indexDirs = Lists.newLinkedList(); // find all indexes nested under all the input paths // (which happe...
java
{ "resource": "" }
q167051
LuceneIndexInputFormat.setInputPaths
validation
public static void setInputPaths(List<Path> paths, Configuration conf) throws IOException { Preconditions.checkNotNull(paths); Preconditions.checkArgument(!paths.isEmpty()); String[] pathStrs = new String[paths.size()]; int i = 0; for (Path p : paths) { FileSystem fs = p.getFileSystem(conf); ...
java
{ "resource": "" }
q167052
LuceneIndexInputFormat.getInputPaths
validation
public static Path[] getInputPaths(Configuration conf) { String[] pathStrs = Preconditions.checkNotNull(conf.getStrings(INPUT_PATHS_KEY), "You must call LuceneIndexInputFormat.setInputPaths()"); Path[] paths = new Path[pathStrs.length]; for (int i = 0; i < pathStrs.length; i++) { paths[i] = ne...
java
{ "resource": "" }
q167053
CompositeInputSplit.add
validation
public void add(InputSplit split) throws IOException, InterruptedException { splits.add(split); totalSplitSizes += split.getLength(); locations = null; }
java
{ "resource": "" }
q167054
CompositeInputSplit.getLocations
validation
public String[] getLocations() throws IOException, InterruptedException { if (locations == null) { Map<String, Integer> hosts = new HashMap<String, Integer>(); for (InputSplit s : splits) { String[] hints = s.getLocations(); if (hints != null) { for (String host : hints) { ...
java
{ "resource": "" }
q167055
PigTokenHelper.evaluateDelimiter
validation
public static byte evaluateDelimiter(String inputDelimiter) { if (inputDelimiter.length() == 1) { return inputDelimiter.getBytes()[0]; } else if (inputDelimiter.length() > 1 && inputDelimiter.charAt(0) == '\\') { switch (inputDelimiter.charAt(1)) { case 't': return (byte)'\t'; c...
java
{ "resource": "" }
q167056
ResourceSchemaUtil.createResourceFieldSchema
validation
public static ResourceFieldSchema createResourceFieldSchema(RequiredField field) throws IOException { ResourceFieldSchema schema = new ResourceFieldSchema().setName(field.getAlias()).setType(field.getType()); List<RequiredField> subFields = field.getSubFields(); if (subFields != null && !subFi...
java
{ "resource": "" }
q167057
ProtobufComparator.readFully
validation
public static void readFully(InputStream in, ByteArrayOutputStream out, byte[] buffer) { try { int numRead = 0; while ((numRead = in.read(buffer, 0, buffer.length)) != -1) { out.write(buffer, 0, numRead); } out.flush(); } catch (IOException e) { throw new RuntimeException(e...
java
{ "resource": "" }
q167058
LzoBaseRegexLoader.getNext
validation
@Override public Tuple getNext() throws IOException { if (reader == null) { return null; } Pattern pattern = getPattern(); Matcher matcher = pattern.matcher(""); Object lineObj; String line; Tuple t = null; // Read lines until a match is found, making sure there's no reading past the /...
java
{ "resource": "" }
q167059
Codecs.createStandardBase64
validation
public static Base64 createStandardBase64() { /* with constructor Base64() in commons-codec-1.4 * encode() inserts a newline after every 76 characters. * Base64(0) disables that incompatibility. */ try { return Base64.class.getConstructor(int.class).newInstance(0); ...
java
{ "resource": "" }
q167060
ProtobufConverter.newInstance
validation
public static <M extends Message> ProtobufConverter<M> newInstance(Class<M> protoClass) { return new ProtobufConverter<M>(new TypeRef<M>(protoClass){}); }
java
{ "resource": "" }
q167061
BinaryBlockReader.readNext
validation
public boolean readNext(BinaryWritable<M> writable) throws IOException { byte[] blob = readNextProtoBytes(); if (blob != null) { writable.set(protoConverter_.fromBytes(blob)); return true; } return false; }
java
{ "resource": "" }
q167062
BinaryBlockReader.readNextProtoBytes
validation
public byte[] readNextProtoBytes() throws IOException { while (true) { if (!setupNewBlockIfNeeded()) { return null; } int blobIndex = curBlobs_.size() - numLeftToReadThisBlock_; numLeftToReadThisBlock_--; byte[] blob = curBlobs_.get(blobIndex).toByteArray(); if (blob.len...
java
{ "resource": "" }
q167063
BinaryBlockReader.readNextProtoBytes
validation
public boolean readNextProtoBytes(BytesWritable writable) throws IOException { byte[] blob = readNextProtoBytes(); if (blob != null) { writable.set(blob, 0, blob.length); return true; } return false; }
java
{ "resource": "" }
q167064
HadoopCompat.newTaskAttemptContext
validation
public static TaskAttemptContext newTaskAttemptContext( Configuration conf, TaskAttemptID taskAttemptId) { return (TaskAttemptContext) newInstance(TASK_CONTEXT_CONSTRUCTOR, conf, taskAttemptId); }
java
{ "resource": "" }
q167065
HadoopCompat.newMapContext
validation
public static MapContext newMapContext(Configuration conf, TaskAttemptID taskAttemptID, RecordReader recordReader, RecordWriter recordWriter, OutputCommitte...
java
{ "resource": "" }
q167066
ThriftWritable.newInstance
validation
public static <M extends TBase<?, ?>> ThriftWritable<M> newInstance(Class<M> tClass) { return new ThriftWritable<M>(new TypeRef<M>(tClass){}); }
java
{ "resource": "" }
q167067
TypeRef.newInstance
validation
@SuppressWarnings("unchecked") public T newInstance() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { if (constructor_ == null) { constructor_ = getRawClass().getConstructor(); } return (T)constructor_.newInstance(); }
java
{ "resource": "" }
q167068
TypeRef.safeNewInstance
validation
public T safeNewInstance() { try { return newInstance(); } catch (NoSuchMethodException e) { throw new IllegalArgumentException(e); } catch (IllegalAccessException e) { throw new IllegalArgumentException(e); } catch (InvocationTargetException e) { throw new IllegalArgumentExcepti...
java
{ "resource": "" }
q167069
ThriftToDynamicProto.getBuilder
validation
public Message.Builder getBuilder(Class<? extends TBase<?, ?>> thriftClass) { return messageBuilderMap.get(protoMessageType(thriftClass)).clone(); }
java
{ "resource": "" }
q167070
ThriftToDynamicProto.mapEntryProtoBuilder
validation
private Message.Builder mapEntryProtoBuilder(TStructDescriptor descriptor, Field field) { return messageBuilderMap.get(mapProtoMessageType(descriptor, field)).clone(); }
java
{ "resource": "" }
q167071
ThriftToDynamicProto.mapDescriptorProtoBuilder
validation
private DescriptorProtos.DescriptorProto.Builder mapDescriptorProtoBuilder( Field field, String typeName) throws DescriptorValidationException { DescriptorProtos.DescriptorProto.Builder mapBuilder = DescriptorProtos.DescriptorProto.newBuilder().setName(typeName); Field keyField = field.getMapKeyField...
java
{ "resource": "" }
q167072
ThriftToDynamicProto.resolveMessageTypeName
validation
private String resolveMessageTypeName(TStructDescriptor descriptor) throws DescriptorValidationException { String typeName = protoMessageType(descriptor.getThriftClass()); // Anytime we have a new message typeName, we make sure that we have a builder for it. // If not, we create one. DescriptorProt...
java
{ "resource": "" }
q167073
ThriftToDynamicProto.convert
validation
@SuppressWarnings("unchecked") public Message convert(T thriftObj) { return doConvert((TBase<?, ?>) Preconditions.checkNotNull(thriftObj, "Can not convert a null object")); }
java
{ "resource": "" }
q167074
ThriftToDynamicProto.doConvert
validation
@SuppressWarnings("unchecked") public <F extends TFieldIdEnum> Message doConvert(TBase<?, F> thriftObj) { if (thriftObj == null) { return null; } Class<TBase<?, F>> clazz = (Class<TBase<?, F>>) thriftObj.getClass(); checkState(clazz); Message.Builder builder = getBuilder(clazz); TStructDescript...
java
{ "resource": "" }
q167075
ThriftToDynamicProto.buildMapEntryMessage
validation
private Message buildMapEntryMessage(Message.Builder mapBuilder, Field field, Object mapKey, Object mapValue) { FieldDescriptor keyFieldDescriptor = mapBuilder.getDescriptorForType().findFieldByName(MAP_KEY_FIELD_NAME); FieldDescriptor valueFieldDescriptor = ma...
java
{ "resource": "" }
q167076
ThriftToDynamicProto.mapProtoMessageType
validation
private String mapProtoMessageType(TStructDescriptor descriptor, Field field) { return String.format("%s_%s", protoMessageType(descriptor.getThriftClass()), field.getName()); }
java
{ "resource": "" }
q167077
HdfsUtils.walkPath
validation
public static void walkPath(Path path, FileSystem fs, PathFilter filter, PathVisitor visitor) throws IOException { FileStatus fileStatus = fs.getFileStatus(path); if (filter.accept(path)) { visitor.visit(fileStatus...
java
{ "resource": "" }
q167078
HdfsUtils.collectPaths
validation
public static void collectPaths(Path path, FileSystem fs, PathFilter filter, final List<Path> accumulator) throws IOException { walkPath(path, fs, filter, new PathVisitor() { @Override public void visi...
java
{ "resource": "" }
q167079
HdfsUtils.getDirectorySize
validation
public static long getDirectorySize(Path path, FileSystem fs, PathFilter filter) throws IOException { PathSizeVisitor visitor = new PathSizeVisitor(); PathFilter composite = new PathFilters.CompositePathFilter( PathFilters.newExcludeDirectoriesFilter(fs.getConf()), filter); walkPath(path, ...
java
{ "resource": "" }
q167080
RCFileOutputFormat.setColumnNumber
validation
public static void setColumnNumber(Configuration conf, int columnNum) { assert columnNum > 0; conf.setInt(RCFile.COLUMN_NUMBER_CONF_STR, columnNum); }
java
{ "resource": "" }
q167081
CombinedSequenceFile.updateJobConfForLocalSettings
validation
private static void updateJobConfForLocalSettings(JobConf conf) { String localSetCompressionEnabled = conf.get(COMPRESS_ENABLE); if(localSetCompressionEnabled != null) { conf.set(MR_COMPRESS_ENABLE, localSetCompressionEnabled); } String localSetCompressionType = conf.get(COMPRESS_TYPE); if(lo...
java
{ "resource": "" }
q167082
ProtobufReflectionUtil.parseMethodFor
validation
public static Method parseMethodFor(Class<Message> klass) { try { return klass.getMethod("parseDelimitedFrom", new Class[] {InputStream.class }); } catch (SecurityException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } }
java
{ "resource": "" }
q167083
ProtobufReflectionUtil.parseMessage
validation
public static Message parseMessage(Method parseMethod, InputStream in) { try { return (Message) parseMethod.invoke(null, in); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTar...
java
{ "resource": "" }
q167084
ProtobufReflectionUtil.parseMessage
validation
public static Message parseMessage(Class<Message> klass, InputStream in) { Method parseMethod = parseMethodFor(klass); return parseMessage(parseMethod, in); }
java
{ "resource": "" }
q167085
LzoJsonStorage.putNext
validation
@Override @SuppressWarnings("unchecked") public void putNext(Tuple tuple) throws IOException { json.clear(); if (tuple != null && tuple.size() >= 1) { Map<String, Object> map = (Map<String, Object>) tuple.get(0); if (keysToKeep_ == null) { json.putAll(map); } else { for (Ma...
java
{ "resource": "" }
q167086
LzoProtobufB64LineOutputFormat.setClassConf
validation
public static <M extends Message> void setClassConf(Class<M> protoClass, Configuration jobConf) { Protobufs.setClassConf(jobConf, LzoProtobufB64LineOutputFormat.class, protoClass); }
java
{ "resource": "" }
q167087
MultiInputFormat.setTypeRef
validation
private void setTypeRef(Configuration conf) { String className = conf.get(CLASS_CONF_KEY); if (className == null) { throw new RuntimeException(CLASS_CONF_KEY + " is not set"); } Class<?> clazz = null; try { clazz = conf.getClassByName(className); } catch (ClassNotFoundException e) ...
java
{ "resource": "" }
q167088
AbstractThriftBinaryProtocol.checkContainerSize
validation
protected void checkContainerSize(int size) throws TProtocolException { if (size < 0) { throw new TProtocolException("Negative container size: " + size); } if (checkReadLength_ && (readLength_ - size) < 0) { throw new TProtocolException("Remaining message length is " + readLength_ ...
java
{ "resource": "" }
q167089
StreamSearcher.setPattern
validation
public void setPattern(byte[] pattern) { pattern_ = Arrays.copyOf(pattern, pattern.length); borders_ = new int[pattern_.length + 1]; preProcess(); }
java
{ "resource": "" }
q167090
Strings.underscore
validation
public static String underscore(String word) { String firstPattern = "([A-Z]+)([A-Z][a-z])"; String secondPattern = "([a-z\\d])([A-Z])"; String replacementPattern = "$1_$2"; // Replace package separator with slash. word = word.replaceAll("\\.", "/"); // Replace $ with two underscores for inner c...
java
{ "resource": "" }
q167091
Strings.ordinalize
validation
public static String ordinalize(int n) { int mod100 = n % 100; if (mod100 == 11 || mod100 == 12 || mod100 == 13) { return String.valueOf(n) + "th"; } switch (n % 10) { case 1: return String.valueOf(n) + "st"; case 2: return String.valueOf(n) + "nd"; case 3: ...
java
{ "resource": "" }
q167092
ProtobufWritable.newInstance
validation
public static <M extends Message> ProtobufWritable<M> newInstance(Class<M> tClass) { return new ProtobufWritable<M>(new TypeRef<M>(tClass){}); }
java
{ "resource": "" }
q167093
LzoW3CLogInputFormat.newInstance
validation
public static LzoW3CLogInputFormat newInstance(final String fieldDefinitionFile) { return new LzoW3CLogInputFormat() { @Override public RecordReader<LongWritable, MapWritable> createRecordReader(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { Re...
java
{ "resource": "" }
q167094
DeprecatedOutputFormatWrapper.setOutputFormat
validation
public static void setOutputFormat(Class<?> realOutputFormatClass, Configuration conf) { conf.setClass("mapred.output.format.class", DeprecatedOutputFormatWrapper.class, org.apache.hadoop.mapred.OutputFormat.class); HadoopUtils.setClassConf(conf, CLASS_CONF_KEY, realOutputFormatClass); }
java
{ "resource": "" }
q167095
Inflection.match
validation
public boolean match(String word) { int flags = ignoreCase_ ? Pattern.CASE_INSENSITIVE : 0; return Pattern.compile(pattern_, flags).matcher(word).find(); }
java
{ "resource": "" }
q167096
Inflection.replace
validation
public String replace(String word) { int flags = ignoreCase_ ? Pattern.CASE_INSENSITIVE : 0; return Pattern.compile(pattern_, flags).matcher(word).replaceAll(replacement_); }
java
{ "resource": "" }
q167097
Inflection.pluralize
validation
public static String pluralize(String word) { if (isUncountable(word)) { return word; } else { for (Inflection inflection : plurals_) { if (inflection.match(word)) { return inflection.replace(word); } } return word; } }
java
{ "resource": "" }
q167098
Inflection.isUncountable
validation
public static boolean isUncountable(String word) { for (String w : uncountables_) { if (w.equalsIgnoreCase(word)) { return true; } } return false; }
java
{ "resource": "" }
q167099
LzoOutputFormat.getOutputStream
validation
protected DataOutputStream getOutputStream(TaskAttemptContext job) throws IOException, InterruptedException { return LzoUtils.getIndexedLzoOutputStream( HadoopCompat.getConfiguration(job), getDefaultWorkFile(job, LzopCodec.DEFAULT_LZO_EXTENSION)); }
java
{ "resource": "" }