本文整理匯總了Java中org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.javaIntObjectInspector方法的典型用法代碼示例。如果您正苦於以下問題:Java PrimitiveObjectInspectorFactory.javaIntObjectInspector方法的具體用法?Java PrimitiveObjectInspectorFactory.javaIntObjectInspector怎麽用?Java PrimitiveObjectInspectorFactory.javaIntObjectInspector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory
的用法示例。
在下文中一共展示了PrimitiveObjectInspectorFactory.javaIntObjectInspector方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFeatureOutputOI
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Nonnull
protected final ObjectInspector getFeatureOutputOI(@Nonnull final FeatureType featureType)
throws UDFArgumentException {
final PrimitiveObjectInspector outputOI;
if (dense_model) {
// TODO validation
outputOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; // see DenseModel (long/string is also parsed as int)
} else {
switch (featureType) {
case STRING:
outputOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector;
break;
case INT:
outputOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
break;
case LONG:
outputOI = PrimitiveObjectInspectorFactory.javaLongObjectInspector;
break;
default:
throw new IllegalStateException("Unexpected feature type: " + featureType);
}
}
return outputOI;
}
示例2: testPA2EtaWithParameter
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void testPA2EtaWithParameter() throws UDFArgumentException {
PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF.PA2();
ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI);
ObjectInspector param = ObjectInspectorUtils.getConstantObjectInspector(
PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-c 3.0");
/* do initialize() with aggressiveness parameter */
udtf.initialize(new ObjectInspector[] {intListOI, intOI, param});
float loss = 0.1f;
PredictionResult margin1 = new PredictionResult(0.5f).squaredNorm(0.05f);
float expectedLearningRate1 = 0.4615384f;
assertEquals(expectedLearningRate1, udtf.eta(loss, margin1), 1e-5f);
PredictionResult margin2 = new PredictionResult(0.5f).squaredNorm(0.01f);
float expectedLearningRate2 = 0.5660377f;
assertEquals(expectedLearningRate2, udtf.eta(loss, margin2), 1e-5f);
}
示例3: test2Positive3NegativeSample
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void test2Positive3NegativeSample() throws Exception {
BinarizeLabelUDTF udtf = spy(new BinarizeLabelUDTF());
ObjectInspector[] argOIs = new ObjectInspector[3];
argOIs[0] = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
argOIs[1] = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
List<String> featureNames = Arrays.asList("positive", "negative", "features");
argOIs[2] = ObjectInspectorFactory.getStandardConstantListObjectInspector(
PrimitiveObjectInspectorFactory.javaStringObjectInspector, featureNames);
doNothing().when(udtf, "forward", any());
udtf.initialize(argOIs);
Object[] arguments = new Object[3];
arguments[0] = new Integer(2);
arguments[1] = new Integer(3);
arguments[2] = WritableUtils.val("a:1", "b:2");
udtf.process(arguments);
verifyPrivate(udtf, times(5)).invoke("forward", any(Object[].class));
verifyPrivate(udtf, times(2)).invoke("forward",
aryEq(new Object[] {WritableUtils.val("a:1", "b:2"), 1}));
verifyPrivate(udtf, times(3)).invoke("forward",
aryEq(new Object[] {WritableUtils.val("a:1", "b:2"), 0}));
}
示例4: testPA1Eta
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void testPA1Eta() throws UDFArgumentException {
PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF.PA1();
ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI);
ObjectInspector param = ObjectInspectorUtils.getConstantObjectInspector(
PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-c 3.0");
/* do initialize() with aggressiveness parameter */
udtf.initialize(new ObjectInspector[] {intListOI, intOI, param});
float loss = 0.1f;
PredictionResult margin1 = new PredictionResult(0.5f).squaredNorm(0.05f);
float expectedLearningRate1 = 2.0f;
assertEquals(expectedLearningRate1, udtf.eta(loss, margin1), 1e-5f);
PredictionResult margin2 = new PredictionResult(0.5f).squaredNorm(0.01f);
float expectedLearningRate2 = 3.0f;
assertEquals(expectedLearningRate2, udtf.eta(loss, margin2), 1e-5f);
}
示例5: test0Positive0NegativeSample
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void test0Positive0NegativeSample() throws Exception {
BinarizeLabelUDTF udtf = spy(new BinarizeLabelUDTF());
ObjectInspector[] argOIs = new ObjectInspector[3];
argOIs[0] = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
argOIs[1] = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
List<String> featureNames = Arrays.asList("positive", "negative", "features");
argOIs[2] = ObjectInspectorFactory.getStandardConstantListObjectInspector(
PrimitiveObjectInspectorFactory.javaStringObjectInspector, featureNames);
doNothing().when(udtf, "forward", any());
udtf.initialize(argOIs);
Object[] arguments = new Object[3];
arguments[0] = new Integer(0);
arguments[1] = new Integer(0);
arguments[2] = WritableUtils.val("a:1", "b:2");
udtf.process(arguments);
verifyPrivate(udtf, times(0)).invoke("forward", any(Object[].class));
}
示例6: testInitialize
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void testInitialize() throws UDFArgumentException {
PerceptronUDTF udtf = new PerceptronUDTF();
ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI);
/* test for INT_TYPE_NAME feature */
StructObjectInspector intListSOI = udtf.initialize(new ObjectInspector[] {intListOI, intOI});
assertEquals("struct<feature:int,weight:float>", intListSOI.getTypeName());
/* test for STRING_TYPE_NAME feature */
ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector;
ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI);
StructObjectInspector stringListSOI = udtf.initialize(new ObjectInspector[] {stringListOI,
intOI});
assertEquals("struct<feature:string,weight:float>", stringListSOI.getTypeName());
/* test for BIGINT_TYPE_NAME feature */
ObjectInspector longOI = PrimitiveObjectInspectorFactory.javaLongObjectInspector;
ListObjectInspector longListOI = ObjectInspectorFactory.getStandardListObjectInspector(longOI);
StructObjectInspector longListSOI = udtf.initialize(new ObjectInspector[] {longListOI,
intOI});
assertEquals("struct<feature:bigint,weight:float>", longListSOI.getTypeName());
}
示例7: testPA2EtaWithoutParameter
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void testPA2EtaWithoutParameter() throws UDFArgumentException {
PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF.PA2();
ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI);
/* do initialize() with aggressiveness parameter */
udtf.initialize(new ObjectInspector[] {intListOI, intOI});
float loss = 0.1f;
PredictionResult margin1 = new PredictionResult(0.5f).squaredNorm(0.05f);
float expectedLearningRate1 = 0.1818181f;
assertEquals(expectedLearningRate1, udtf.eta(loss, margin1), 1e-5f);
PredictionResult margin2 = new PredictionResult(0.5f).squaredNorm(0.01f);
float expectedLearningRate2 = 0.1960784f;
assertEquals(expectedLearningRate2, udtf.eta(loss, margin2), 1e-5f);
}
示例8: testRandInit
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void testRandInit() throws HiveException {
println("--------------------------\n testRandInit()");
OnlineMatrixFactorizationUDTF mf = new MatrixFactorizationSGDUDTF();
ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
ObjectInspector floatOI = PrimitiveObjectInspectorFactory.javaFloatObjectInspector;
ObjectInspector param = ObjectInspectorUtils.getConstantObjectInspector(
PrimitiveObjectInspectorFactory.javaStringObjectInspector, new String(
"-factor 3 -rankinit random"));
ObjectInspector[] argOIs = new ObjectInspector[] {intOI, intOI, floatOI, param};
mf.initialize(argOIs);
Assert.assertTrue(mf.rankInit == RankInitScheme.random);
float[][] rating = { {5, 3, 0, 1}, {4, 0, 0, 1}, {1, 1, 0, 5}, {1, 0, 0, 4}, {0, 1, 5, 4}};
Object[] args = new Object[3];
final int num_iters = 100;
for (int iter = 0; iter < num_iters; iter++) {
for (int row = 0; row < rating.length; row++) {
for (int col = 0, size = rating[row].length; col < size; col++) {
args[0] = row;
args[1] = col;
args[2] = (float) rating[row][col];
mf.process(args);
}
}
}
for (int row = 0; row < rating.length; row++) {
for (int col = 0, size = rating[row].length; col < size; col++) {
double predicted = mf.predict(row, col);
print(rating[row][col] + "[" + predicted + "]\t");
Assert.assertEquals(rating[row][col], predicted, 0.2d);
}
println();
}
}
示例9: testGaussianInit
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void testGaussianInit() throws HiveException {
println("--------------------------\n testGaussianInit()");
OnlineMatrixFactorizationUDTF mf = new MatrixFactorizationSGDUDTF();
ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
ObjectInspector floatOI = PrimitiveObjectInspectorFactory.javaFloatObjectInspector;
ObjectInspector param = ObjectInspectorUtils.getConstantObjectInspector(
PrimitiveObjectInspectorFactory.javaStringObjectInspector, new String(
"-factor 3 -rankinit gaussian"));
ObjectInspector[] argOIs = new ObjectInspector[] {intOI, intOI, floatOI, param};
mf.initialize(argOIs);
Assert.assertTrue(mf.rankInit == RankInitScheme.gaussian);
float[][] rating = { {5, 3, 0, 1}, {4, 0, 0, 1}, {1, 1, 0, 5}, {1, 0, 0, 4}, {0, 1, 5, 4}};
Object[] args = new Object[3];
final int num_iters = 100;
for (int iter = 0; iter < num_iters; iter++) {
for (int row = 0; row < rating.length; row++) {
for (int col = 0, size = rating[row].length; col < size; col++) {
args[0] = row;
args[1] = col;
args[2] = (float) rating[row][col];
mf.process(args);
}
}
}
for (int row = 0; row < rating.length; row++) {
for (int col = 0, size = rating[row].length; col < size; col++) {
double predicted = mf.predict(row, col);
print(rating[row][col] + "[" + predicted + "]\t");
Assert.assertEquals(rating[row][col], predicted, 0.2d);
}
println();
}
}
示例10: testPA1EtaDefaultParameter
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void testPA1EtaDefaultParameter() throws UDFArgumentException {
PassiveAggressiveUDTF udtf = new PassiveAggressiveUDTF.PA1();
ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
ListObjectInspector intListOI = ObjectInspectorFactory.getStandardListObjectInspector(intOI);
udtf.initialize(new ObjectInspector[] {intListOI, intOI});
float loss = 0.1f;
PredictionResult margin = new PredictionResult(0.5f).squaredNorm(0.05f);
float expectedLearningRate = 1.0f;
assertEquals(expectedLearningRate, udtf.eta(loss, margin), 1e-5f);
}
示例11: testInsufficientLabelColumn
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
public void testInsufficientLabelColumn() throws HiveException {
BinarizeLabelUDTF udtf = new BinarizeLabelUDTF();
ObjectInspector[] argOIs = new ObjectInspector[2];
argOIs[0] = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
List<String> featureNames = Arrays.asList("positive", "features");
argOIs[1] = ObjectInspectorFactory.getStandardConstantListObjectInspector(
PrimitiveObjectInspectorFactory.javaStringObjectInspector, featureNames);
udtf.initialize(argOIs);
}
示例12: testStringInt
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void testStringInt() throws Exception {
ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector;
ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
udf.initialize(new ObjectInspector[] {featureOI, weightOI});
Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject("f1"),
new DeferredJavaObject(2)});
Assert.assertEquals("f1:2", ret.toString());
}
示例13: testUnsupportedLossFunction
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test(expected = UDFArgumentException.class)
public void testUnsupportedLossFunction() throws Exception {
GeneralClassifierUDTF udtf = new GeneralClassifierUDTF();
ObjectInspector intOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
ObjectInspector stringOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector;
ListObjectInspector stringListOI = ObjectInspectorFactory.getStandardListObjectInspector(stringOI);
ObjectInspector params = ObjectInspectorUtils.getConstantObjectInspector(
PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-loss UnsupportedLoss");
udtf.initialize(new ObjectInspector[] {stringListOI, intOI, params});
}
示例14: testIntInt
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void testIntInt() throws Exception {
ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
udf.initialize(new ObjectInspector[] {featureOI, weightOI});
Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject(1),
new DeferredJavaObject(2)});
Assert.assertEquals("1:2", ret.toString());
}
示例15: testIntDouble
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //導入方法依賴的package包/類
@Test
public void testIntDouble() throws Exception {
ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector;
ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaDoubleObjectInspector;
udf.initialize(new ObjectInspector[] {featureOI, weightOI});
Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject(1),
new DeferredJavaObject(2.5d)});
Assert.assertEquals("1:2.5", ret.toString());
}