Search in sources :

Example 26 with TimestampType

use of org.voltdb.types.TimestampType in project voltdb by VoltDB.

the class LoadS method callProcedure.

private static void callProcedure(org.voltdb.client.Client myApp, int countoflines, String s_pk, String v1, String ts1, String v2, String v3, String v4, String v5, String v6, String int1, String int2, String int3, String int4, String int5, String int6, String v7, String int7, String v8, String v9, String v10, String v11, String bigint1, String v12, String bigint2, String bigint3, String decimal1, String decimal2, String decimal3, String decimal4, String bigint4, String bigint5, String v13, String bigint6, String bigint7, String bigint8) throws NoConnectionsException, IOException {
    boolean queued = false;
    long s_pk_temp = 0;
    if (s_pk != null) {
        s_pk_temp = Long.parseLong(s_pk);
    }
    int int1_temp = 0;
    if ((int1 != null) && (!"".equals(int1))) {
        int1_temp = Integer.parseInt(int1);
    }
    int int2_temp = 0;
    if ((int2 != null) && (!"".equals(int2))) {
        int2_temp = Integer.parseInt(int2);
    }
    int int3_temp = 0;
    if ((int3 != null) && (!"".equals(int3))) {
        int3_temp = Integer.parseInt(int3);
    }
    int int4_temp = 0;
    if ((int4 != null) && (!"".equals(int4))) {
        int4_temp = new Integer(int4);
    }
    int int5_temp = 0;
    if ((int5 != null) && (!"".equals(int5))) {
        int5_temp = Integer.parseInt(int5);
    }
    int int6_temp = 0;
    if ((int6 != null) && (!"".equals(int6))) {
        int6_temp = Integer.parseInt(int6);
    }
    long bigint1_temp = 0;
    if ((bigint1 != null) && (!"".equals(bigint1))) {
        bigint1_temp = Long.parseLong(bigint1);
    }
    long bigint2_temp = 0;
    if ((bigint2 != null) && (!"".equals(bigint2))) {
        bigint2_temp = Long.parseLong(bigint2);
    }
    long bigint3_temp = 0;
    if ((bigint3 != null) && (!"".equals(bigint3))) {
        bigint3_temp = Long.parseLong(bigint3);
    }
    BigDecimal decimal1_temp = null;
    if ((decimal1 != null) && (!"".equals(decimal1))) {
        decimal1_temp = new BigDecimal(decimal1);
    }
    BigDecimal decimal2_temp = null;
    if ((decimal2 != null) && (!"".equals(decimal2))) {
        decimal2_temp = new BigDecimal(decimal2);
    }
    BigDecimal decimal3_temp = null;
    if ((decimal3 != null) && (!"".equals(decimal3))) {
        decimal3_temp = new BigDecimal(decimal3);
    }
    BigDecimal decimal4_temp = null;
    if ((decimal4 != null) && (!"".equals(decimal4))) {
        decimal4_temp = new BigDecimal(decimal4);
    }
    long bigint4_temp = 0;
    ;
    if ((bigint4 != null) && (!"".equals(bigint4))) {
        bigint4_temp = Long.parseLong(bigint4);
    }
    long bigint5_temp = 0;
    ;
    if ((bigint5 != null) && (!"".equals(bigint5))) {
        bigint5_temp = Long.parseLong(bigint5);
    }
    long bigint6_temp = 0;
    ;
    if ((bigint6 != null) && (!"".equals(bigint6))) {
        bigint6_temp = Long.parseLong(bigint6);
    }
    long bigint7_temp = 0;
    ;
    if ((bigint7 != null) && (!"".equals(bigint7))) {
        bigint7_temp = Long.parseLong(bigint7);
    }
    long bigint8_temp = 0;
    ;
    if ((bigint8 != null) && (!"".equals(bigint8))) {
        bigint8_temp = Long.parseLong(bigint8);
    }
    int int7_temp = 0;
    if ((int7 != null) && (!"".equals(int7))) {
        int7_temp = Integer.parseInt(int7);
    }
    TimestampType ts1_temp = null;
    if ((ts1 != null) && (!"".equals(ts1))) {
        SimpleDateFormat sdf = new SimpleDateFormat("MMddyyyy");
        Date ts1_temp_temp = null;
        try {
            ts1_temp_temp = sdf.parse(ts1);
            ts1_temp = new TimestampType(ts1_temp_temp.getTime() * 1000);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    myApp.callProcedure(new MyAsyncCallback(), "InsertS", s_pk_temp, v1, ts1_temp, v2, v3, v4, v5, v6, int1_temp, int2_temp, int3_temp, int4_temp, int5_temp, int6_temp, v7, int7_temp, v8, v9, v10, v11, bigint1_temp, v12, bigint2_temp, bigint3_temp, decimal1_temp, decimal2_temp, decimal3_temp, decimal4_temp, bigint4_temp, bigint5_temp, v13, bigint6_temp, bigint7_temp, bigint8_temp);
    if ((countoflines % 25000) == 0) {
        System.out.printf("On Line %,d\n", countoflines);
    }
}
Also used : TimestampType(org.voltdb.types.TimestampType) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) BigDecimal(java.math.BigDecimal) Date(java.util.Date)

Example 27 with TimestampType

use of org.voltdb.types.TimestampType in project voltdb by VoltDB.

the class VoltDBOsmSink method process.

public void process(NodeContainer nodeContainer) {
    Node node;
    node = nodeContainer.getEntity();
    double lat = node.getLatitude();
    double lng = node.getLongitude();
    String pointText = "POINT(" + lng + " " + lat + ")";
    // keep track of the nodes so we can build polygons later
    if (enableBboxBuilder || enableLinestringBuilder) {
        wayGeometryBuilder.addNodeLocation(node);
    }
    try {
        client.callProcedure(new InsertCallback(), INS_NODE_PROC, node.getId(), node.getVersion(), node.getUser().getId(), new TimestampType(node.getTimestamp().getTime()), node.getChangesetId(), pointText);
    } catch (NoConnectionsException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    Collection<Tag> tags = node.getTags();
    for (Tag tag : tags) {
        // System.out.println(INS_NODE_TAG_PROC+","+node.getId()+","+tag.getKey()+","+tag.getValue());
        try {
            client.callProcedure(new InsertCallback(), INS_NODE_TAG_PROC, node.getId(), tag.getKey(), tag.getValue());
        } catch (NoConnectionsException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : NoConnectionsException(org.voltdb.client.NoConnectionsException) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) TimestampType(org.voltdb.types.TimestampType) LineString(org.postgis.LineString) IOException(java.io.IOException) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Example 28 with TimestampType

use of org.voltdb.types.TimestampType in project voltdb by VoltDB.

the class ProcToTestTypeConversion method getInListParameter.

private Object getInListParameter(byte valueTypeToPopulateWith, boolean strTs) {
    VoltType toType = VoltType.get(valueTypeToPopulateWith);
    switch(toType) {
        case TINYINT:
            byte[] tinyValue = { m_byteVal, m_byteVal };
            return tinyValue;
        case SMALLINT:
            short[] shortValue = { m_shortVal, m_shortVal };
            return shortValue;
        case INTEGER:
            int[] intValue = { m_intVal, m_intVal };
            return intValue;
        case BIGINT:
            long[] bigintValue = { m_bigIntVal, m_bigIntVal };
            return bigintValue;
        case FLOAT:
            double[] floatValue = { m_floatVal, m_floatVal };
            return floatValue;
        case DECIMAL:
            BigDecimal[] bigdecValue = { m_bigDecVal, m_bigDecVal };
            return bigdecValue;
        case TIMESTAMP:
            TimestampType[] tsValue = { m_tsVal, m_tsVal };
            return tsValue;
        case STRING:
            String str = strTs ? m_strTs : m_strNum;
            String[] strValue = { str, str };
            return strValue;
        case VARBINARY:
            byte[][] binValue = { { m_byteVal, m_byteVal }, { m_byteVal, m_byteVal } };
            return binValue;
        case GEOGRAPHY_POINT:
            GeographyPointValue[] ptValue = { m_pt, m_pt };
            return ptValue;
        case GEOGRAPHY:
            GeographyValue[] polyValue = { m_poly, m_poly };
            return polyValue;
        default:
            assert (false);
            break;
    }
    return null;
}
Also used : GeographyValue(org.voltdb.types.GeographyValue) BigDecimal(java.math.BigDecimal) VoltType(org.voltdb.VoltType) TimestampType(org.voltdb.types.TimestampType) GeographyPointValue(org.voltdb.types.GeographyPointValue)

Example 29 with TimestampType

use of org.voltdb.types.TimestampType in project voltdb by VoltDB.

the class TestParameterSet method testRoundtrip.

public void testRoundtrip() throws IOException {
    Byte byteparam = new Byte((byte) 2);
    Short shortparam = new Short(Short.MAX_VALUE);
    Integer intparam = new Integer(Integer.MIN_VALUE);
    Long longparam = new Long(Long.MAX_VALUE - 1);
    Double doubleparam = new Double(Double.MAX_VALUE - 1);
    String stringparam = new String("ABCDE");
    // current time
    TimestampType dateparam = new TimestampType();
    BigDecimal bigdecimalparam = new BigDecimal(7654321).setScale(VoltDecimalHelper.kDefaultScale);
    VoltTable volttableparam = new VoltTable(new VoltTable.ColumnInfo("foo", VoltType.INTEGER));
    volttableparam.addRow(Integer.MAX_VALUE);
    byte[] bytearray = new byte[] { (byte) 'f', (byte) 'o', (byte) 'o' };
    short[] shortarray = new short[] { Short.MAX_VALUE, Short.MIN_VALUE, (short) 5 };
    int[] intarray = new int[] { Integer.MAX_VALUE, Integer.MIN_VALUE, 5 };
    double[] doublearray = new double[] { Double.MAX_VALUE, Double.MIN_VALUE, 5.5 };
    String[] stringarray = new String[] { "ABC", "DEF", "HIJ" };
    TimestampType[] datearray = new TimestampType[] { new TimestampType(), new TimestampType(), new TimestampType() };
    BigDecimal bdtmp1 = new BigDecimal(7654321).setScale(VoltDecimalHelper.kDefaultScale);
    BigDecimal bdtmp2 = new BigDecimal(654321).setScale(VoltDecimalHelper.kDefaultScale);
    BigDecimal bdtmp3 = new BigDecimal(54321).setScale(VoltDecimalHelper.kDefaultScale);
    BigDecimal[] bigdecimalarray = new BigDecimal[] { bdtmp1, bdtmp2, bdtmp3 };
    VoltTable vttmp1 = new VoltTable(new VoltTable.ColumnInfo("foo", VoltType.INTEGER), new VoltTable.ColumnInfo("bar", VoltType.STRING));
    vttmp1.addRow(Integer.MAX_VALUE, "ry@nlikestheyankees");
    VoltTable vttmp2 = new VoltTable(new VoltTable.ColumnInfo("bar", VoltType.INTEGER), new VoltTable.ColumnInfo("bar", VoltType.STRING));
    vttmp2.addRow(Integer.MIN_VALUE, null);
    VoltTable vttmp3 = new VoltTable(new VoltTable.ColumnInfo("far", VoltType.INTEGER), new VoltTable.ColumnInfo("bar", VoltType.STRING));
    vttmp3.addRow(new Integer(5), "");
    VoltTable[] volttablearray = new VoltTable[] { vttmp1, vttmp2, vttmp3 };
    assertTrue(bigdecimalparam.scale() == VoltDecimalHelper.kDefaultScale);
    assertTrue(bdtmp1.scale() == VoltDecimalHelper.kDefaultScale);
    assertTrue(bdtmp2.scale() == VoltDecimalHelper.kDefaultScale);
    assertTrue(bdtmp3.scale() == VoltDecimalHelper.kDefaultScale);
    ParameterSet pset = ParameterSet.fromArrayNoCopy(byteparam, shortparam, intparam, longparam, doubleparam, stringparam, dateparam, bigdecimalparam, volttableparam, bytearray, shortarray, intarray, doublearray, stringarray, datearray, bigdecimalarray, volttablearray);
    ByteBuffer buf = ByteBuffer.allocate(pset.getSerializedSize());
    pset.flattenToBuffer(buf);
    buf.flip();
    ParameterSet pset2 = ParameterSet.fromByteBuffer(buf);
    Object[] pset1array = pset.toArray();
    Object[] pset2array = pset2.toArray();
    assertTrue(Arrays.deepEquals(pset1array, pset2array));
}
Also used : ByteBuffer(java.nio.ByteBuffer) BigDecimal(java.math.BigDecimal) TimestampType(org.voltdb.types.TimestampType)

Example 30 with TimestampType

use of org.voltdb.types.TimestampType in project voltdb by VoltDB.

the class TestParameterConverter method testStringToTimestamp.

public void testStringToTimestamp() throws Exception {
    TimestampType t = new TimestampType();
    Object r = ParameterConverter.tryToMakeCompatible(TimestampType.class, t);
    assertTrue("expect timestamp", r.getClass() == TimestampType.class);
    assertEquals(t, r);
}
Also used : TimestampType(org.voltdb.types.TimestampType)

Aggregations

TimestampType (org.voltdb.types.TimestampType)127 VoltTable (org.voltdb.VoltTable)37 BigDecimal (java.math.BigDecimal)30 Test (org.junit.Test)23 Client (org.voltdb.client.Client)19 ArrayList (java.util.ArrayList)16 IOException (java.io.IOException)11 GeographyValue (org.voltdb.types.GeographyValue)11 GeographyPointValue (org.voltdb.types.GeographyPointValue)10 Date (java.util.Date)9 File (java.io.File)7 VoltTableRow (org.voltdb.VoltTableRow)7 ProcCallException (org.voltdb.client.ProcCallException)7 ByteBuffer (java.nio.ByteBuffer)5 SimpleDateFormat (java.text.SimpleDateFormat)5 ColumnInfo (org.voltdb.VoltTable.ColumnInfo)5 ClientResponse (org.voltdb.client.ClientResponse)5 Random (java.util.Random)4 VoltType (org.voltdb.VoltType)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2