Tensor

Java API implements Tensor data of the following types:
DT_BOOL
DT_CHAR
DT_SHORT
DT_INT
DT_LONG
DT_FLOAT
DT_DOUBLE

BasicTensor can be used to obtain Tensor data created with tensor() on DolphinDB server. The constructor on Java is not implemented yet.

Example

@Test
public void test_tensor_1() throws IOException {
    DBConnection conn = new DBConnection();
    conn.connect("192.168.0.69", 8802, "admin", "123456");
    // Create with DolphinDB function tensor()
    // Retrieve Tensor data with BasicTensor
    BasicTensor tensor = (BasicTensor) conn.run("tensor(((1..1000$50:20),(1..1000$50:20)))");
    System.out.println(entity.getString());
}

Execution result:

tensor<int[2][50][20]>([[[1,51,101,151,201,251,301,351,401,451,501...],[2,52,102,152,202,252,302,352,402,452,502...],[3,53,103,153,203,253,303,353,403,453,503...],[4,54,104,154,204,254,304,354,404,454,504...],[5,55,105,155,205,255,305,355,405,455,505...],[6,56,106,156,206,256,306,356,406,456,506...],[7,57,107,157,207,257,307,357,407,457,507...],[8,58,108,158,208,258,308,358,408,458,508...],[9,59,109,159,209,259,309,359,409,459,509...],[10,60,110,160,210,260,310,360,410,460,510...],[11,61,111,161,211,261,311,361,411,461,511...],[12,62,112,162,212,262,312,362,412,462,512...],[13,63,113,163,213,263,313,363,413,463,513...],[14,64,114,164,214,264,314,364,414,464,514...],[15,65,115,165,215,265,315,365,415,465,515...],[16,66,116,166,216,266,316,366,416,466,516...],[17,67,117,167,217,267,317,367,417,467,517...],[18,68,118,168,218,268,318,368,418,468,518...],[19,69,119,169,219,269,319,369,419,469,519...],[20,70,120,170,220,270,320,370,420,470,520...],[21,71,121,171,221,271,321,371,421,471,521...],[22,72,122,172,222,272,322,372,422,472,522...],[23,73,123,173,223,273,323,373,423,473,523...],[24,74,124,174,224,274,324,374,424,474,524...],[25,75,125,175,225,275,325,375,425,475,525...],[26,76,126,176,226,276,326,376,426,476,526...],[27,77,127,177,227,277,327,377,427,477,527...],[28,78,128,178,228,278,328,378,428,478,528...],[29,79,129,179,229,279,329,379,429,479,529...],[30,80,130,180,230,280,330,380,430,480,530...],[31,81,131,181,231,281,331,381,431,481,531...],[32,82,132,182,232,282,332,382,432,482,532...],[33,83,133,183,233,283,333,383,433,483,533...],[34,84,134,184,234,284,334,384,434,484,534...],[35,85,135,185,235,285,335,385,435,485,535...],[36,86,136,186,236,286,336,386,436,486,536...],[37,87,137,187,237,287,337,387,437,487,537...],[38,88,138,188,238,288,338,388,438,488,538...],[39,89,139,189,239,289,339,389,439,489,539...],[40,90,140,190,240,290,340,390,440,490,540...],[41,91,141,191,241,291,341,391,441,491,541...],[42,92,142,192,242,292,342,392,442,492,542...],[43,93,143,193,243,293,343,393,443,493,543...],[44,94,144,194,244,294,344,394,444,494,544...],[45,95,145,195,245,295,345,395,445,495,545...],[46,96,146,196,246,296,346,396,446,496,546...],[47,97,147,197,247,297,347,397,447,497,547...],[48,98,148,198,248,298,348,398,448,498,548...],[49,99,149,199,249,299,349,399,449,499,549...],[50,100,150,200,250,300,350,400,450,500,550...]],[[1,51,101,151,201,251,301,351,401,451,501...],[2,52,102,152,202,252,302,352,402,452,502...],[3,53,103,153,203,253,303,353,403,453,503...],[4,54,104,154,204,254,304,354,404,454,504...],[5,55,105,155,205,255,305,355,405,455,505...],[6,56,106,156,206,256,306,356,406,456,506...],[7,57,107,157,207,257,307,357,407,457,507...],[8,58,108,158,208,258,308,358,408,458,508...],[9,59,109,159,209,259,309,359,409,459,509...],[10,60,110,160,210,260,310,360,410,460,510...],[11,61,111,161,211,261,311,361,411,461,511...],[12,62,112,162,212,262,312,362,412,462,512...],[13,63,113,163,213,263,313,363,413,463,513...],[14,64,114,164,214,264,314,364,414,464,514...],[15,65,115,165,215,265,315,365,415,465,515...],[16,66,116,166,216,266,316,366,416,466,516...],[17,67,117,167,217,267,317,367,417,467,517...],[18,68,118,168,218,268,318,368,418,468,518...],[19,69,119,169,219,269,319,369,419,469,519...],[20,70,120,170,220,270,320,370,420,470,520...],[21,71,121,171,221,271,321,371,421,471,521...],[22,72,122,172,222,272,322,372,422,472,522...],[23,73,123,173,223,273,323,373,423,473,523...],[24,74,124,174,224,274,324,374,424,474,524...],[25,75,125,175,225,275,325,375,425,475,525...],[26,76,126,176,226,276,326,376,426,476,526...],[27,77,127,177,227,277,327,377,427,477,527...],[28,78,128,178,228,278,328,378,428,478,528...],[29,79,129,179,229,279,329,379,429,479,529...],[30,80,130,180,230,280,330,380,430,480,530...],[31,81,131,181,231,281,331,381,431,481,531...],[32,82,132,182,232,282,332,382,432,482,532...],[33,83,133,183,233,283,333,383,433,483,533...],[34,84,134,184,234,284,334,384,434,484,534...],[35,85,135,185,235,285,335,385,435,485,535...],[36,86,136,186,236,286,336,386,436,486,536...],[37,87,137,187,237,287,337,387,437,487,537...],[38,88,138,188,238,288,338,388,438,488,538...],[39,89,139,189,239,289,339,389,439,489,539...],[40,90,140,190,240,290,340,390,440,490,540...],[41,91,141,191,241,291,341,391,441,491,541...],[42,92,142,192,242,292,342,392,442,492,542...],[43,93,143,193,243,293,343,393,443,493,543...],[44,94,144,194,244,294,344,394,444,494,544...],[45,95,145,195,245,295,345,395,445,495,545...],[46,96,146,196,246,296,346,396,446,496,546...],[47,97,147,197,247,297,347,397,447,497,547...],[48,98,148,198,248,298,348,398,448,498,548...],[49,99,149,199,249,299,349,399,449,499,549...],[50,100,150,200,250,300,350,400,450,500,550...]]])