Начало работы с Гессианом

Вы должны были положить минимальный, полный и проверяемый пример . Пожалуйста, убедитесь, что в будущем мы сможем запустить ваш код, просто вставив его в IDE. Я потратил слишком много времени на этот вопрос, ха-ха

import pandas as pd

temp = pd.DataFrame({'A' : [20, 4, 60, 4, 8], 'B' : [2, 4, 5, 6, 7]})
temp2 = pd.DataFrame({'A' : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'B' : [1, 2, 3, 10, 5, 6, 70, 8, 9, 10]})
print(temp)
print(temp2)
#     A  B
# 0  20  2
# 1   4  4
# 2  60  5
# 3   4  6
# 4   8  7

#     A   B
# 0   1   1
# 1   2   2
# 2   3   3
# 3   4  10
# 4   5   5
# 5   6   6
# 6   7  70
# 7   8   8
# 8   9   9
# 9  10  10

# Make a mapping of the values of our second mask.
mapping = dict(zip(temp2['A'], temp2['B']))

#   We apply the mapping to each row. If we find the occurence, replace, else, default.
temp['B'] = temp['A'].apply(lambda x:mapping[x] if x in mapping else 'No matching')
print(temp)
#     A            B
# 0  20  No matching
# 1   4           10
# 2  60  No matching
# 3   4           10
# 4   8            8
9
задан David Newcomb 28 September 2015 в 15:38
поделиться

2 ответа

Я не использовал Гессиан в прошлом, и я не планирую использование его в будущем также, и мои аргументы - они:

Для веб-сервиса я попытался бы действительно трудно сохранить его в простом XML. Если я выбрал бы двоичное представление XML, я буду, вероятно, использовать Fast Infoset - который является стандартом и скорее всего поддерживаемый намного большим набором клиентских API/библиотек/платформ веб-сервиса. Я знаю, что люди CXF говорили о быстром инфонаборе в своем списке рассылки, и он должен поддерживаться, даже при том, что они не зарегистрировали это на своей Wiki.

Если бы скорость является основной вещью, я, вероятно, закончил бы тем, что использовал Буферы Протокола.

2
ответ дан 4 December 2019 в 20:26
поделиться

Yes, Hessian 2.0 is the one to use. The protocol specifies how a data structure is represented binary, the spec is simple.

The Hessian web service builds on the Hessian protocol, it specifies a number of headers in the Hessian format to describe e.g. the request/response format in the Hessian protocol. It defines the content of the request, the method that should be called and so on. It is not strictly needed because nobody uses it. You can define this yourself by creating a "Request" class and a "Response" class that suits you best and serialize this using Hessian protocol.

Hessian is an alternative for Java serialization, it is slower because not directly supported by the java VM, but it is much (!) faster than XML parsing. It can be used in a cross platform way, although you will have to tweak existing implementations to make them work together, the spec has changed here and there (e.g. length specs) so that implementations tend to differ. The flip side is that it is not Human readable, you always need a tool to convert the Hessian to text.

I have used Hessian in a large corporate application where a Java rich client communicates with a back end in order to make the client JVM version independent of the server JVM version. And it worked like a charm.

Have a look at the implementation Hessian4J. It is open source so you can have complete control over it.

9
ответ дан 4 December 2019 в 20:26
поделиться