SparseItem { public LongList indexes() { return indexesView; }  SparseItem addCategoricalIndex(long index); SparseItem addNumericalIndex(long index, double value); LongList indexes(); double getValue(int i); SparseItem label(double label); LongList categoricalIndexes(); LongList numericalIndexes(); DoubleList numericalValues(); SparseItem id(String id); double label(); void clear(); String id(); void write(LineBytesBuffer line); void read(LineBytesBuffer line); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); double scalarMultiply(DoubleArrayList weights); SparseItem copyCategoricalFeaturesFrom(SparseItem item);  }
@Test public void testWriteRead() throws Exception { SparseItem item = createSparseItem("-1 |C1 1005 |banner_pos 1 |site_id 0a742914 |site_domain 510bd839 |site_category f028772b " + "|app_id ecad2386 |app_domain 7801e8d9 |app_category 07d7df22 |device_id a99f214a |device_ip 0cff710f " + "|device_model 76dc4769 |device_type 1 |device_conn_type 0 |C14 8330 |C15 320 |C16 50 |C17 761 |C18 3 " + "|C19 175 |C20 100075"); assertEquals(20, item.indexes().stream().distinct().count()); testWriteRead(item); }
@Test public void testWriteRead2() throws Exception { String line1 = "1 |сat1 feature1:2 |сat2 feature2:100.55 фича3:-123.4 | cat3 feature4 feature5:-17"; SparseItem item = createSparseItem(line1); assertEquals(5, item.indexes().stream().distinct().count()); testWriteRead(item); }