當前位置: 首頁>>代碼示例>>Java>>正文


Java Utf8類代碼示例

本文整理匯總了Java中org.apache.avro.util.Utf8的典型用法代碼示例。如果您正苦於以下問題:Java Utf8類的具體用法?Java Utf8怎麽用?Java Utf8使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Utf8類屬於org.apache.avro.util包,在下文中一共展示了Utf8類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: TaskAttemptStartedEvent

import org.apache.avro.util.Utf8; //導入依賴的package包/類
/**
 * Create an event to record the start of an attempt
 * @param attemptId Id of the attempt
 * @param taskType Type of task
 * @param startTime Start time of the attempt
 * @param trackerName Name of the Task Tracker where attempt is running
 * @param httpPort The port number of the tracker
 * @param shufflePort The shuffle port number of the container
 * @param containerId The containerId for the task attempt.
 * @param locality The locality of the task attempt
 * @param avataar The avataar of the task attempt
 */
public TaskAttemptStartedEvent( TaskAttemptID attemptId,  
    TaskType taskType, long startTime, String trackerName,
    int httpPort, int shufflePort, ContainerId containerId,
    String locality, String avataar) {
  datum.attemptId = new Utf8(attemptId.toString());
  datum.taskid = new Utf8(attemptId.getTaskID().toString());
  datum.startTime = startTime;
  datum.taskType = new Utf8(taskType.name());
  datum.trackerName = new Utf8(trackerName);
  datum.httpPort = httpPort;
  datum.shufflePort = shufflePort;
  datum.containerId = new Utf8(containerId.toString());
  if (locality != null) {
    datum.locality = new Utf8(locality);
  }
  if (avataar != null) {
    datum.avataar = new Utf8(avataar);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:32,代碼來源:TaskAttemptStartedEvent.java

示例2: getDatum

import org.apache.avro.util.Utf8; //導入依賴的package包/類
public Object getDatum() {
  if (datum == null) {
    datum = new TaskAttemptFinished();
    datum.taskid = new Utf8(attemptId.getTaskID().toString());
    datum.attemptId = new Utf8(attemptId.toString());
    datum.taskType = new Utf8(taskType.name());
    datum.taskStatus = new Utf8(taskStatus);
    datum.finishTime = finishTime;
    if (rackName != null) {
      datum.rackname = new Utf8(rackName);
    }
    datum.hostname = new Utf8(hostname);
    datum.state = new Utf8(state);
    datum.counters = EventWriter.toAvro(counters);
  }
  return datum;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:18,代碼來源:TaskAttemptFinishedEvent.java

示例3: toAvro

import org.apache.avro.util.Utf8; //導入依賴的package包/類
static JhCounters toAvro(Counters counters, String name) {
  JhCounters result = new JhCounters();
  result.name = new Utf8(name);
  result.groups = new ArrayList<JhCounterGroup>(0);
  if (counters == null) return result;
  for (CounterGroup group : counters) {
    JhCounterGroup g = new JhCounterGroup();
    g.name = new Utf8(group.getName());
    g.displayName = new Utf8(group.getDisplayName());
    g.counts = new ArrayList<JhCounter>(group.size());
    for (Counter counter : group) {
      JhCounter c = new JhCounter();
      c.name = new Utf8(counter.getName());
      c.displayName = new Utf8(counter.getDisplayName());
      c.value = counter.getValue();
      g.counts.add(c);
    }
    result.groups.add(g);
  }
  return result;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:22,代碼來源:EventWriter.java

示例4: JobUnsuccessfulCompletionEvent

import org.apache.avro.util.Utf8; //導入依賴的package包/類
/**
 * Create an event to record unsuccessful completion (killed/failed) of jobs
 * @param id Job ID
 * @param finishTime Finish time of the job
 * @param finishedMaps Number of finished maps
 * @param finishedReduces Number of finished reduces
 * @param status Status of the job
 * @param diagnostics job runtime diagnostics
 */
public JobUnsuccessfulCompletionEvent(JobID id, long finishTime,
    int finishedMaps,
    int finishedReduces,
    String status,
    Iterable<String> diagnostics) {
  datum.setJobid(new Utf8(id.toString()));
  datum.setFinishTime(finishTime);
  datum.setFinishedMaps(finishedMaps);
  datum.setFinishedReduces(finishedReduces);
  datum.setJobStatus(new Utf8(status));
  if (diagnostics == null) {
    diagnostics = NODIAGS_LIST;
  }
  datum.setDiagnostics(new Utf8(Joiner.on('\n').skipNulls()
      .join(diagnostics)));
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:JobUnsuccessfulCompletionEvent.java

示例5: getDatum

import org.apache.avro.util.Utf8; //導入依賴的package包/類
public Object getDatum() {
  if(datum == null) {
    datum = new TaskFailed();
    datum.taskid = new Utf8(id.toString());
    datum.error = new Utf8(error);
    datum.finishTime = finishTime;
    datum.taskType = new Utf8(taskType.name());
    datum.failedDueToAttempt =
        failedDueToAttempt == null
        ? null
        : new Utf8(failedDueToAttempt.toString());
    datum.status = new Utf8(status);
    datum.counters = EventWriter.toAvro(counters);
  }
  return datum;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:TaskFailedEvent.java

示例6: getDatum

import org.apache.avro.util.Utf8; //導入依賴的package包/類
public Object getDatum() {
  if (datum == null) {
    datum = new JobFinished();
    datum.jobid = new Utf8(jobId.toString());
    datum.finishTime = finishTime;
    datum.finishedMaps = finishedMaps;
    datum.finishedReduces = finishedReduces;
    datum.failedMaps = failedMaps;
    datum.failedReduces = failedReduces;
    datum.mapCounters = EventWriter.toAvro(mapCounters, "MAP_COUNTERS");
    datum.reduceCounters = EventWriter.toAvro(reduceCounters,
      "REDUCE_COUNTERS");
    datum.totalCounters = EventWriter.toAvro(totalCounters, "TOTAL_COUNTERS");
  }
  return datum;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:JobFinishedEvent.java

示例7: processRequests

import org.apache.avro.util.Utf8; //導入依賴的package包/類
public void processRequests( List<Iote2eRequest> iote2eRequests ) throws Exception {
	try {
		for( Iote2eRequest iote2eRequest : iote2eRequests ) {
			if (iote2eRequest != null) {
				List<RuleEvalResult> ruleEvalResults = ruleSvc.process( iote2eRequest);
				if (ruleEvalResults != null && ruleEvalResults.size() > 0 ) {
					iote2eSvc.processRuleEvalResults( iote2eRequest, ruleEvalResults);
				}
				// Near real time temperature display
				final Utf8 sourceTypeTemperature = new Utf8("temperature");
				if( iote2eRequest.getSourceType().equals(sourceTypeTemperature) ) {
					nearRealTimeTemperature( iote2eRequest );
				}
			}
		}

	} catch (Exception e) {
		logger.error(e.getMessage(),e);
		throw e;
	}
}
 
開發者ID:petezybrick,項目名稱:iote2e,代碼行數:22,代碼來源:Iote2eRequestRouterHandlerSparkRuleImpl.java

示例8: toAvro

import org.apache.avro.util.Utf8; //導入依賴的package包/類
static JhCounters toAvro(Counters counters, String name) {
  JhCounters result = new JhCounters();
  result.setName(new Utf8(name));
  result.setGroups(new ArrayList<JhCounterGroup>(0));
  if (counters == null) return result;
  for (CounterGroup group : counters) {
    JhCounterGroup g = new JhCounterGroup();
    g.setName(new Utf8(group.getName()));
    g.setDisplayName(new Utf8(group.getDisplayName()));
    g.setCounts(new ArrayList<JhCounter>(group.size()));
    for (Counter counter : group) {
      JhCounter c = new JhCounter();
      c.setName(new Utf8(counter.getName()));
      c.setDisplayName(new Utf8(counter.getDisplayName()));
      c.setValue(counter.getValue());
      g.getCounts().add(c);
    }
    result.getGroups().add(g);
  }
  return result;
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:22,代碼來源:EventWriter.java

示例9: buildKryoRegistrations

import org.apache.avro.util.Utf8; //導入依賴的package包/類
private static <T> LinkedHashMap<String, KryoRegistration> buildKryoRegistrations(Class<T> serializedDataType) {
	final LinkedHashMap<String, KryoRegistration> registrations = new LinkedHashMap<>();

	// register Avro types.
	registrations.put(
			GenericData.Array.class.getName(),
			new KryoRegistration(
					GenericData.Array.class,
					new ExecutionConfig.SerializableSerializer<>(new Serializers.SpecificInstanceCollectionSerializerForArrayList())));
	registrations.put(Utf8.class.getName(), new KryoRegistration(Utf8.class));
	registrations.put(GenericData.EnumSymbol.class.getName(), new KryoRegistration(GenericData.EnumSymbol.class));
	registrations.put(GenericData.Fixed.class.getName(), new KryoRegistration(GenericData.Fixed.class));
	registrations.put(GenericData.StringType.class.getName(), new KryoRegistration(GenericData.StringType.class));

	// register the serialized data type
	registrations.put(serializedDataType.getName(), new KryoRegistration(serializedDataType));

	return registrations;
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:20,代碼來源:AvroSerializer.java

示例10: getDatum

import org.apache.avro.util.Utf8; //導入依賴的package包/類
public Object getDatum() {
  if (datum == null) {
    datum = new JobFinished();
    datum.setJobid(new Utf8(jobId.toString()));
    datum.setFinishTime(finishTime);
    datum.setFinishedMaps(finishedMaps);
    datum.setFinishedReduces(finishedReduces);
    datum.setFailedMaps(failedMaps);
    datum.setFailedReduces(failedReduces);
    datum.setMapCounters(EventWriter.toAvro(mapCounters, "MAP_COUNTERS"));
    datum.setReduceCounters(EventWriter.toAvro(reduceCounters,
        "REDUCE_COUNTERS"));
    datum.setTotalCounters(EventWriter.toAvro(totalCounters,
        "TOTAL_COUNTERS"));
  }
  return datum;
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:18,代碼來源:JobFinishedEvent.java

示例11: TaskAttemptStartedEvent

import org.apache.avro.util.Utf8; //導入依賴的package包/類
/**
 * Create an event to record the start of an attempt
 * @param attemptId Id of the attempt
 * @param taskType Type of task
 * @param startTime Start time of the attempt
 * @param trackerName Name of the Task Tracker where attempt is running
 * @param httpPort The port number of the tracker
 * @param shufflePort The shuffle port number of the container
 * @param containerId The containerId for the task attempt.
 * @param locality The locality of the task attempt
 * @param avataar The avataar of the task attempt
 */
public TaskAttemptStartedEvent( TaskAttemptID attemptId,  
    TaskType taskType, long startTime, String trackerName,
    int httpPort, int shufflePort, ContainerId containerId,
    String locality, String avataar) {
  datum.setAttemptId(new Utf8(attemptId.toString()));
  datum.setTaskid(new Utf8(attemptId.getTaskID().toString()));
  datum.setStartTime(startTime);
  datum.setTaskType(new Utf8(taskType.name()));
  datum.setTrackerName(new Utf8(trackerName));
  datum.setHttpPort(httpPort);
  datum.setShufflePort(shufflePort);
  datum.setContainerId(new Utf8(containerId.toString()));
  if (locality != null) {
    datum.setLocality(new Utf8(locality));
  }
  if (avataar != null) {
    datum.setAvataar(new Utf8(avataar));
  }
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:32,代碼來源:TaskAttemptStartedEvent.java

示例12: convertToTypeInformation

import org.apache.avro.util.Utf8; //導入依賴的package包/類
/**
 * Recursively converts extracted AvroTypeInfo into a RowTypeInfo nested structure with deterministic field order.
 * Replaces generic Utf8 with basic String type information.
 */
private static TypeInformation<?> convertToTypeInformation(TypeInformation<?> extracted, Schema schema) {
	if (schema.getType() == Schema.Type.RECORD) {
		final List<Schema.Field> fields = schema.getFields();
		final AvroTypeInfo<?> avroTypeInfo = (AvroTypeInfo<?>) extracted;

		final TypeInformation<?>[] types = new TypeInformation<?>[fields.size()];
		final String[] names = new String[fields.size()];
		for (int i = 0; i < fields.size(); i++) {
			final Schema.Field field = fields.get(i);
			types[i] = convertToTypeInformation(avroTypeInfo.getTypeAt(field.name()), field.schema());
			names[i] = field.name();
		}
		return new RowTypeInfo(types, names);
	} else if (extracted instanceof GenericTypeInfo<?>) {
		final GenericTypeInfo<?> genericTypeInfo = (GenericTypeInfo<?>) extracted;
		if (genericTypeInfo.getTypeClass() == Utf8.class) {
			return BasicTypeInfo.STRING_TYPE_INFO;
		}
	}
	return extracted;
}
 
開發者ID:axbaretto,項目名稱:flink,代碼行數:26,代碼來源:KafkaAvroTableSource.java

示例13: serialize

import org.apache.avro.util.Utf8; //導入依賴的package包/類
public Record serialize(AdvancedEmployee employee)
{
   Record record = new Record(schema);

   AvroUtils.put("name", employee.getName(), record);
   AvroUtils.put("age", employee.getAge(), record);
   AvroUtils.put("gender", employee.getGender(), record);

   int numberOfEmails = (employee.getMails() != null) ? employee.getMails().size() : 0;
   GenericData.Array<Utf8> emails = new GenericData.Array<>(numberOfEmails, schema.getField("emails").schema());

   for(int i = 0; i < numberOfEmails; ++i)
   {
      emails.add(new Utf8(employee.getMails().get(i)));
   }

   record.put("emails", emails);

   return record;
}
 
開發者ID:developerSid,項目名稱:AwesomeJavaLibraryExamples,代碼行數:21,代碼來源:AvroWriteSerializer.java

示例14: followingKey

import org.apache.avro.util.Utf8; //導入依賴的package包/類
/**
 * @param keyClass
 * @param bytes
 * @return
 */
@SuppressWarnings("unchecked")
static <K> K followingKey(Encoder encoder, Class<K> clazz, byte[] per) {

  if (clazz.equals(Byte.TYPE) || clazz.equals(Byte.class)) {
    return (K) Byte.valueOf(encoder.followingKey(1, per)[0]);
  } else if (clazz.equals(Boolean.TYPE) || clazz.equals(Boolean.class)) {
    throw new UnsupportedOperationException();
  } else if (clazz.equals(Short.TYPE) || clazz.equals(Short.class)) {
    return fromBytes(encoder, clazz, encoder.followingKey(2, per));
  } else if (clazz.equals(Integer.TYPE) || clazz.equals(Integer.class)) {
    return fromBytes(encoder, clazz, encoder.followingKey(4, per));
  } else if (clazz.equals(Long.TYPE) || clazz.equals(Long.class)) {
    return fromBytes(encoder, clazz, encoder.followingKey(8, per));
  } else if (clazz.equals(Float.TYPE) || clazz.equals(Float.class)) {
    return fromBytes(encoder, clazz, encoder.followingKey(4, per));
  } else if (clazz.equals(Double.TYPE) || clazz.equals(Double.class)) {
    return fromBytes(encoder, clazz, encoder.followingKey(8, per));
  } else if (clazz.equals(String.class)) {
    throw new UnsupportedOperationException();
  } else if (clazz.equals(Utf8.class)) {
    return fromBytes(encoder, clazz, Arrays.copyOf(per, per.length + 1));
  }

  throw new IllegalArgumentException("Unknown type " + clazz.getName());
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:31,代碼來源:AccumuloStore.java

示例15: fromBytes

import org.apache.avro.util.Utf8; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static <T> T fromBytes( byte[] val, Schema schema
    , SpecificDatumReader<T> datumReader, T object)
throws IOException {
  Type type = schema.getType();
  switch (type) {
  case ENUM:
    String symbol = schema.getEnumSymbols().get(val[0]);
    return (T)Enum.valueOf(ReflectData.get().getClass(schema), symbol);
  case STRING:  return (T)new Utf8(toString(val));
  case BYTES:   return (T)ByteBuffer.wrap(val);
  case INT:     return (T)Integer.valueOf(bytesToVint(val));
  case LONG:    return (T)Long.valueOf(bytesToVlong(val));
  case FLOAT:   return (T)Float.valueOf(toFloat(val));
  case DOUBLE:  return (T)Double.valueOf(toDouble(val));
  case BOOLEAN: return (T)Boolean.valueOf(val[0] != 0);
  case RECORD:  //fall
  case MAP:
  case ARRAY:   return (T)IOUtils.deserialize(val, (SpecificDatumReader<SpecificRecord>)datumReader, schema, (SpecificRecord)object);
  default: throw new RuntimeException("Unknown type: "+type);
  }
}
 
開發者ID:jianglibo,項目名稱:gora-boot,代碼行數:23,代碼來源:ByteUtils.java


注:本文中的org.apache.avro.util.Utf8類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。