JavaSparkContext sc; JavaRDD<String> data = sc.textFile("path/input.csv"); JavaSQLContext sqlContext = new JavaSQLContext(sc); JavaRDD<Record> rdd_records = sc.textFile(data).map( new Function<String, Record>() { public Record call(String line) throws Exception { // Here you can use JSON // Gson gson = new Gson(); // gson.fromJson(line, Record.class); String[] fields = line.split(","); Record sd = new Record(fields[0], fields[1], fields[2].trim(), fields[3]); return sd; } });
public Record unmarshall(JsonUnmarshallerContext context) throws Exception { Record record = new Record();
try { //if part record = query.getSingleResult(); //use the record from the fetched result. } catch(NoResultException e){ //else part //create a new record. record = new Record(); //......... entityManager.persist(record); }
if (localName.equals("date_of_week")){ Records info=new Record(); String question = attributes.getValue("data"); info.setquestion(question); list.add(info); }
synchronized (records) { Record rec = records.get(id); if (rec == null) { rec = new Record(id); records.put(id, rec); } return rec; }
public ActionResult Course(int ID) { Record model = new Record(); // Populate the model based on the course ID (for example) model.RecordHoles = db.RecordHoles.Where(c => c.CourseID == ID).ToList(); return PartialView("_Holes", model); }
record.year=12; record.val=55; recList.add(record); record = new Record(); record.year=13; record.val=77; recList.add(record);
Realm realm = getNewRealmInstance(); try { realm.executeTransaction(new Realm.Transaction() { public void execute(Realm realm) { Record newRecord = new Record().setField1(x).setField2(y); realm.insert(newRecord); } }); } finally { realm.close(); }
public static void main(final String[] args){ final Collection<Record> records = Arrays.asList( new Record("The Beatles", "White Album", 25), new Record("Roxy Music", "Stranded", 27), new Record("Bjork", "Debut", 25), new Record("David Bowie", "ChangesBowie", 39) ); System.out.println(calculateCostOfRecordCollection(records)); }
return null; Record record = new Record(); reader.beginObject(); while (reader.hasNext()) {
public class Storage { List<Record> records; public Storage() { this.records = new ArrayList<Record(); } public void addRecord(int number, int count, Object code) { records.add(new Record(number, count, code)); } }
if(myMap.containsKey("1")){ myMap.put("1", myMap.get("1").add(new Record()));//record obj }else{ List<Record> list = new ArrayList<>(); list.add(record); myMap.put("1", list)); }
List<Record> records = new ArrayList<>(); Scanner myscanner= new Scanner (new FileInputStream("myfile.txt")); while (myscanner.hasnext()){ String line = myscanner.readline(); int index = line.indexOf(' '); String name = line.substring(0, index-1);//TODO check... String address = line.substring(index); records.add(new Record(name, address); }
OuterClass myOuterClassInstance = new OuterClass(); Record[] record = new Record[100]; for (int i = 0; i < record.length; i++) record[i] = myOuterClassInstance.new Record(); //now you can safely use record[0].year = (byte)12;
ArrayList<Record> mArrayList = new ArrayList<Record>(); do { try { Record record = new Record(); List<String> values = record.getValues(); values.add(mCursor.getString(mCursor.getColumnIndex("_id"))); ... mArrayList.add(record); } catch (Exception h) { } }
JSONObject jObj = new JSONObject(results); JSONArray albums = jObj.getJSONArray("pickups"); for (int i = 0; i < albums.length(); i++) { JSONObject c = albums.getJSONObject(i); String id = c.getString("id"); Record objRecord=new Record(); objRecord.setId(c.getString("id")); objRecord.setName(c.getString("name")); objRecord.setNumber(c.getString("number")); objRecord.setTime(c.getString("time")); PickupList.arrayList.add(objRecord); }
Image img = new Image(); Record rec = new Record(); rec.getImages().add(img); // img.setRecord(rec); Looks like this is missing in your code session.save();
Workbook wb = WorkbookFactory.create(file); Sheet worksheet = wb.getSheetAt(0); String name; for(int line=1; ; line++) { Row row = worksheet.getRow(line); Cell cell0 = row.getCell(0), cell1 = row.getCell(1), cell2 = row.getCell(2); String name, year, maker; if(cell0==null||(name=cell0.getStringCellValue())==null) break; year = cell1!=null? cell1.getStringCellValue():null; maker = cell2!=null? cell2.getStringCellValue():null; Record r = new Record(name, year, maker); set.add(r); }
Record rec = new Record(); rec.addData("timestamp", timestamp); rec.addData("Value", value); rec.addData("Plans for world domination", dominationPlans);
public Record convertToRecord() { return new Record() .withApproximateArrivalTimestamp(arrivalTimestamp.toDate()) .withData(ByteBuffer.wrap(data.getBytes(StandardCharsets.UTF_8))) .withSequenceNumber(sequenceNumber) .withPartitionKey(""); }