repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
lukasniemeier/mensaapp | MensaApp/src/main/java/de/lukasniemeier/mensa/ui/adapter/NavigationAdapterState.java | // Path: MensaApp/src/main/java/de/lukasniemeier/mensa/model/WeeklyMenu.java
// public class WeeklyMenu implements Serializable {
//
// private final Mensa mensa;
// private SerializableTime timestamp;
// private BiMap<SerializableTime, Menu> menuMap;
//
// public WeeklyMenu(Mensa mensa, SerializableTime timestamp) {
// this.mensa = mensa;
// this.timestamp = timestamp;
// this.menuMap = HashBiMap.create();
// }
//
// public Mensa getMensa() {
// return mensa;
// }
//
// public Time getTimestamp() {
// return timestamp.getTime();
// }
//
// public BiMap<SerializableTime, Menu> getMenus() {
// return menuMap;
// }
//
// public void addMenu(SerializableTime date, Menu menu) {
// menuMap.put(date, menu);
// }
//
// public Menu getMenu(SerializableTime date) {
// return menuMap.get(date);
// }
//
// public boolean hasMenu(SerializableTime date) {
// return menuMap.keySet().contains(date);
// }
//
// public static WeeklyMenu merge(Mensa mensa, SerializableTime timestamp, List<WeeklyMenu> menus) {
// WeeklyMenu merged = new WeeklyMenu(mensa, timestamp);
// for (WeeklyMenu weeklyMenu : menus) {
// for (Map.Entry<SerializableTime, Menu> entry : weeklyMenu.menuMap.entrySet()) {
// merged.addMenu(entry.getKey(), entry.getValue());
// }
// }
// return merged;
// }
//
// public boolean isOutdated() {
// SerializableTime now = Utils.now();
// return now.getYearDay() > timestamp.getYearDay() || now.getYear() > timestamp.getYear();
// }
// }
| import android.content.Context;
import android.support.v4.app.Fragment;
import de.lukasniemeier.mensa.model.WeeklyMenu; | package de.lukasniemeier.mensa.ui.adapter;
/**
* Created on 26.11.13.
*/
public abstract class NavigationAdapterState {
protected final NavigationAdapter stateContext;
protected final Context context;
public NavigationAdapterState(NavigationAdapter stateContext, Context context) {
this.stateContext = stateContext;
this.context = context;
}
| // Path: MensaApp/src/main/java/de/lukasniemeier/mensa/model/WeeklyMenu.java
// public class WeeklyMenu implements Serializable {
//
// private final Mensa mensa;
// private SerializableTime timestamp;
// private BiMap<SerializableTime, Menu> menuMap;
//
// public WeeklyMenu(Mensa mensa, SerializableTime timestamp) {
// this.mensa = mensa;
// this.timestamp = timestamp;
// this.menuMap = HashBiMap.create();
// }
//
// public Mensa getMensa() {
// return mensa;
// }
//
// public Time getTimestamp() {
// return timestamp.getTime();
// }
//
// public BiMap<SerializableTime, Menu> getMenus() {
// return menuMap;
// }
//
// public void addMenu(SerializableTime date, Menu menu) {
// menuMap.put(date, menu);
// }
//
// public Menu getMenu(SerializableTime date) {
// return menuMap.get(date);
// }
//
// public boolean hasMenu(SerializableTime date) {
// return menuMap.keySet().contains(date);
// }
//
// public static WeeklyMenu merge(Mensa mensa, SerializableTime timestamp, List<WeeklyMenu> menus) {
// WeeklyMenu merged = new WeeklyMenu(mensa, timestamp);
// for (WeeklyMenu weeklyMenu : menus) {
// for (Map.Entry<SerializableTime, Menu> entry : weeklyMenu.menuMap.entrySet()) {
// merged.addMenu(entry.getKey(), entry.getValue());
// }
// }
// return merged;
// }
//
// public boolean isOutdated() {
// SerializableTime now = Utils.now();
// return now.getYearDay() > timestamp.getYearDay() || now.getYear() > timestamp.getYear();
// }
// }
// Path: MensaApp/src/main/java/de/lukasniemeier/mensa/ui/adapter/NavigationAdapterState.java
import android.content.Context;
import android.support.v4.app.Fragment;
import de.lukasniemeier.mensa.model.WeeklyMenu;
package de.lukasniemeier.mensa.ui.adapter;
/**
* Created on 26.11.13.
*/
public abstract class NavigationAdapterState {
protected final NavigationAdapter stateContext;
protected final Context context;
public NavigationAdapterState(NavigationAdapter stateContext, Context context) {
this.stateContext = stateContext;
this.context = context;
}
| public int displayMenu(WeeklyMenu menu, int initialMenuIndex) { |
lukasniemeier/mensaapp | MensaApp/src/main/java/de/lukasniemeier/mensa/model/Menu.java | // Path: MensaApp/src/main/java/de/lukasniemeier/mensa/utils/SerializableTime.java
// public class SerializableTime implements Comparable<SerializableTime>, Serializable {
//
// private static Time toTime(Date date) {
// Time time = new Time();
// time.set(date.getTime());
// return time;
// }
//
// private Time timestamp;
//
// public SerializableTime(Time timestamp) {
// this.timestamp = timestamp;
// }
//
// public SerializableTime(Date date) {
// this(toTime(date));
// }
//
// public Time getTime() {
// return timestamp;
// }
//
// private void writeObject(java.io.ObjectOutputStream out)
// throws IOException {
// out.writeObject(timestamp.toMillis(false));
// }
//
// private void readObject(java.io.ObjectInputStream in)
// throws IOException, ClassNotFoundException {
// long ms = (Long) in.readObject();
// this.timestamp = new Time();
// this.timestamp.set(ms);
// }
//
// public long toMillis() {
// return timestamp.toMillis(false);
// }
//
// public int getYearDay() {
// return timestamp.yearDay;
// }
//
// public int getYear() {
// return timestamp.year;
// }
//
// public Date toDate() {
// return new Date(toMillis());
// }
//
// @Override
// public int compareTo(SerializableTime other) {
// return Time.compare(this.getTime(), other.getTime());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// SerializableTime that = (SerializableTime) o;
// return timestamp.toMillis(false) == that.timestamp.toMillis(false);
// }
//
// @Override
// public int hashCode() {
// long ht = timestamp.toMillis(false);
// return (int) ht ^ (int) (ht >> 32);
// }
// }
| import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import de.lukasniemeier.mensa.utils.SerializableTime; | package de.lukasniemeier.mensa.model;
/**
* Created on 17.09.13.
*/
public class Menu implements Serializable {
private final WeeklyMenu weeklyMenu;
private final List<Meal> meals;
public Menu(WeeklyMenu weeklyMenu) {
this.weeklyMenu = weeklyMenu;
this.meals = new ArrayList<Meal>();
}
public WeeklyMenu getWeeklyMenu() {
return weeklyMenu;
}
public List<Meal> getMeals() {
return meals;
}
public void add(Meal meal) {
meals.add(meal);
}
| // Path: MensaApp/src/main/java/de/lukasniemeier/mensa/utils/SerializableTime.java
// public class SerializableTime implements Comparable<SerializableTime>, Serializable {
//
// private static Time toTime(Date date) {
// Time time = new Time();
// time.set(date.getTime());
// return time;
// }
//
// private Time timestamp;
//
// public SerializableTime(Time timestamp) {
// this.timestamp = timestamp;
// }
//
// public SerializableTime(Date date) {
// this(toTime(date));
// }
//
// public Time getTime() {
// return timestamp;
// }
//
// private void writeObject(java.io.ObjectOutputStream out)
// throws IOException {
// out.writeObject(timestamp.toMillis(false));
// }
//
// private void readObject(java.io.ObjectInputStream in)
// throws IOException, ClassNotFoundException {
// long ms = (Long) in.readObject();
// this.timestamp = new Time();
// this.timestamp.set(ms);
// }
//
// public long toMillis() {
// return timestamp.toMillis(false);
// }
//
// public int getYearDay() {
// return timestamp.yearDay;
// }
//
// public int getYear() {
// return timestamp.year;
// }
//
// public Date toDate() {
// return new Date(toMillis());
// }
//
// @Override
// public int compareTo(SerializableTime other) {
// return Time.compare(this.getTime(), other.getTime());
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// SerializableTime that = (SerializableTime) o;
// return timestamp.toMillis(false) == that.timestamp.toMillis(false);
// }
//
// @Override
// public int hashCode() {
// long ht = timestamp.toMillis(false);
// return (int) ht ^ (int) (ht >> 32);
// }
// }
// Path: MensaApp/src/main/java/de/lukasniemeier/mensa/model/Menu.java
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import de.lukasniemeier.mensa.utils.SerializableTime;
package de.lukasniemeier.mensa.model;
/**
* Created on 17.09.13.
*/
public class Menu implements Serializable {
private final WeeklyMenu weeklyMenu;
private final List<Meal> meals;
public Menu(WeeklyMenu weeklyMenu) {
this.weeklyMenu = weeklyMenu;
this.meals = new ArrayList<Meal>();
}
public WeeklyMenu getWeeklyMenu() {
return weeklyMenu;
}
public List<Meal> getMeals() {
return meals;
}
public void add(Meal meal) {
meals.add(meal);
}
| public SerializableTime getMenuDay() { |
garmin/connectiq-apps | device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/course/Scorecard.java | // Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/AppConstants.java
// public class AppConstants {
//
// public static final int KEY_MESSAGE_TYPE = -1;
// public static final int KEY_MESSAGE_PAYLOAD = -2;
// public static final int KEY_COURSE_ID = 0;
// public static final int KEY_COURSE_NAME = 1;
// public static final int KEY_COURSE_PAR = 2;
// public static final int KEY_COURSE_TEES_PLAYED = 3;
// public static final int KEY_PLAYERS = 4;
// public static final int KEY_PLAYER_NAME = 5;
// public static final int KEY_PLAYER_ID = 6;
// public static final int KEY_PLAYER_SCORES = 11;
// public static final int KEY_HOLES = 7;
// public static final int KEY_HOLE_NUMBER = 8;
// public static final int KEY_HOLE_PAR = 9;
// public static final int KEY_HOLE_DISTANCE = 10;
//
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import com.garmin.android.apps.samples.disgolf.AppConstants; | /**
* Copyright 2015 by Garmin Ltd. or its subsidiaries.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.garmin.android.apps.samples.disgolf.course;
public class Scorecard implements Parcelable {
// ------------------------------------------------------------------------
// TYPES
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC FIELDS
// ------------------------------------------------------------------------
private static final String TAG = Scorecard.class.getSimpleName();
public static final Parcelable.Creator<Scorecard> CREATOR = new Parcelable.Creator<Scorecard>() {
@Override
public Scorecard createFromParcel(Parcel in) {
return new Scorecard(in);
}
@Override
public Scorecard[] newArray(int size) {
return new Scorecard[size];
}
};
// ------------------------------------------------------------------------
// STATIC INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC METHODS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// FIELDS
// ------------------------------------------------------------------------
private final Integer mCourseId;
private final String mCourseName;
private final List<Player> mPlayers;
// ------------------------------------------------------------------------
// INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// CONSTRUCTORS
// ------------------------------------------------------------------------
public Scorecard(@SuppressWarnings("rawtypes") HashMap dto) {
Integer value = null;
try { | // Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/AppConstants.java
// public class AppConstants {
//
// public static final int KEY_MESSAGE_TYPE = -1;
// public static final int KEY_MESSAGE_PAYLOAD = -2;
// public static final int KEY_COURSE_ID = 0;
// public static final int KEY_COURSE_NAME = 1;
// public static final int KEY_COURSE_PAR = 2;
// public static final int KEY_COURSE_TEES_PLAYED = 3;
// public static final int KEY_PLAYERS = 4;
// public static final int KEY_PLAYER_NAME = 5;
// public static final int KEY_PLAYER_ID = 6;
// public static final int KEY_PLAYER_SCORES = 11;
// public static final int KEY_HOLES = 7;
// public static final int KEY_HOLE_NUMBER = 8;
// public static final int KEY_HOLE_PAR = 9;
// public static final int KEY_HOLE_DISTANCE = 10;
//
// }
// Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/course/Scorecard.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import com.garmin.android.apps.samples.disgolf.AppConstants;
/**
* Copyright 2015 by Garmin Ltd. or its subsidiaries.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.garmin.android.apps.samples.disgolf.course;
public class Scorecard implements Parcelable {
// ------------------------------------------------------------------------
// TYPES
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC FIELDS
// ------------------------------------------------------------------------
private static final String TAG = Scorecard.class.getSimpleName();
public static final Parcelable.Creator<Scorecard> CREATOR = new Parcelable.Creator<Scorecard>() {
@Override
public Scorecard createFromParcel(Parcel in) {
return new Scorecard(in);
}
@Override
public Scorecard[] newArray(int size) {
return new Scorecard[size];
}
};
// ------------------------------------------------------------------------
// STATIC INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC METHODS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// FIELDS
// ------------------------------------------------------------------------
private final Integer mCourseId;
private final String mCourseName;
private final List<Player> mPlayers;
// ------------------------------------------------------------------------
// INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// CONSTRUCTORS
// ------------------------------------------------------------------------
public Scorecard(@SuppressWarnings("rawtypes") HashMap dto) {
Integer value = null;
try { | value = (Integer) dto.get(AppConstants.KEY_COURSE_ID); |
garmin/connectiq-apps | device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/course/Player.java | // Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/AppConstants.java
// public class AppConstants {
//
// public static final int KEY_MESSAGE_TYPE = -1;
// public static final int KEY_MESSAGE_PAYLOAD = -2;
// public static final int KEY_COURSE_ID = 0;
// public static final int KEY_COURSE_NAME = 1;
// public static final int KEY_COURSE_PAR = 2;
// public static final int KEY_COURSE_TEES_PLAYED = 3;
// public static final int KEY_PLAYERS = 4;
// public static final int KEY_PLAYER_NAME = 5;
// public static final int KEY_PLAYER_ID = 6;
// public static final int KEY_PLAYER_SCORES = 11;
// public static final int KEY_HOLES = 7;
// public static final int KEY_HOLE_NUMBER = 8;
// public static final int KEY_HOLE_PAR = 9;
// public static final int KEY_HOLE_DISTANCE = 10;
//
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.os.Parcel;
import android.os.Parcelable;
import com.garmin.android.apps.samples.disgolf.AppConstants;
import com.garmin.monkeybrains.serialization.MonkeyHash;
import com.garmin.monkeybrains.serialization.MonkeyType; | /**
* Copyright 2015 by Garmin Ltd. or its subsidiaries.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.garmin.android.apps.samples.disgolf.course;
public class Player implements IQMonkeyConversion<Player>, Parcelable {
// ------------------------------------------------------------------------
// TYPES
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC FIELDS
// ------------------------------------------------------------------------
public static final Parcelable.Creator<Player> CREATOR = new Parcelable.Creator<Player>() {
@Override
public Player createFromParcel(Parcel in) {
return new Player(in);
}
@Override
public Player[] newArray(int size) {
return new Player[size];
}
};
// ------------------------------------------------------------------------
// STATIC INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC METHODS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// FIELDS
// ------------------------------------------------------------------------
private final String mName;
private final int mId;
private final List<Integer> mScores;
// ------------------------------------------------------------------------
// INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// CONSTRUCTORS
// ------------------------------------------------------------------------
public Player(String name, int id) {
mName = name;
mId = id;
mScores = null;
}
public Player(@SuppressWarnings("rawtypes") HashMap playerDto) throws ClassCastException { | // Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/AppConstants.java
// public class AppConstants {
//
// public static final int KEY_MESSAGE_TYPE = -1;
// public static final int KEY_MESSAGE_PAYLOAD = -2;
// public static final int KEY_COURSE_ID = 0;
// public static final int KEY_COURSE_NAME = 1;
// public static final int KEY_COURSE_PAR = 2;
// public static final int KEY_COURSE_TEES_PLAYED = 3;
// public static final int KEY_PLAYERS = 4;
// public static final int KEY_PLAYER_NAME = 5;
// public static final int KEY_PLAYER_ID = 6;
// public static final int KEY_PLAYER_SCORES = 11;
// public static final int KEY_HOLES = 7;
// public static final int KEY_HOLE_NUMBER = 8;
// public static final int KEY_HOLE_PAR = 9;
// public static final int KEY_HOLE_DISTANCE = 10;
//
// }
// Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/course/Player.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.os.Parcel;
import android.os.Parcelable;
import com.garmin.android.apps.samples.disgolf.AppConstants;
import com.garmin.monkeybrains.serialization.MonkeyHash;
import com.garmin.monkeybrains.serialization.MonkeyType;
/**
* Copyright 2015 by Garmin Ltd. or its subsidiaries.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.garmin.android.apps.samples.disgolf.course;
public class Player implements IQMonkeyConversion<Player>, Parcelable {
// ------------------------------------------------------------------------
// TYPES
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC FIELDS
// ------------------------------------------------------------------------
public static final Parcelable.Creator<Player> CREATOR = new Parcelable.Creator<Player>() {
@Override
public Player createFromParcel(Parcel in) {
return new Player(in);
}
@Override
public Player[] newArray(int size) {
return new Player[size];
}
};
// ------------------------------------------------------------------------
// STATIC INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC METHODS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// FIELDS
// ------------------------------------------------------------------------
private final String mName;
private final int mId;
private final List<Integer> mScores;
// ------------------------------------------------------------------------
// INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// CONSTRUCTORS
// ------------------------------------------------------------------------
public Player(String name, int id) {
mName = name;
mId = id;
mScores = null;
}
public Player(@SuppressWarnings("rawtypes") HashMap playerDto) throws ClassCastException { | mName = (String) playerDto.get(AppConstants.KEY_PLAYER_NAME); |
garmin/connectiq-apps | device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/course/Hole.java | // Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/AppConstants.java
// public class AppConstants {
//
// public static final int KEY_MESSAGE_TYPE = -1;
// public static final int KEY_MESSAGE_PAYLOAD = -2;
// public static final int KEY_COURSE_ID = 0;
// public static final int KEY_COURSE_NAME = 1;
// public static final int KEY_COURSE_PAR = 2;
// public static final int KEY_COURSE_TEES_PLAYED = 3;
// public static final int KEY_PLAYERS = 4;
// public static final int KEY_PLAYER_NAME = 5;
// public static final int KEY_PLAYER_ID = 6;
// public static final int KEY_PLAYER_SCORES = 11;
// public static final int KEY_HOLES = 7;
// public static final int KEY_HOLE_NUMBER = 8;
// public static final int KEY_HOLE_PAR = 9;
// public static final int KEY_HOLE_DISTANCE = 10;
//
// }
| import java.util.HashMap;
import android.os.Parcel;
import android.os.Parcelable;
import com.garmin.android.apps.samples.disgolf.AppConstants;
import com.garmin.monkeybrains.serialization.MonkeyHash;
import com.garmin.monkeybrains.serialization.MonkeyType; | /**
* Copyright 2015 by Garmin Ltd. or its subsidiaries.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.garmin.android.apps.samples.disgolf.course;
public class Hole implements IQMonkeyConversion<Hole>, Parcelable {
// ------------------------------------------------------------------------
// TYPES
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC FIELDS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC METHODS
// ------------------------------------------------------------------------
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
@Override
public Hole createFromParcel(Parcel in) {
return new Hole(in);
}
@Override
public Hole[] newArray(int size) {
return new Hole[size];
}
};
// ------------------------------------------------------------------------
// FIELDS
// ------------------------------------------------------------------------
private final int mNumber;
private final int mPar;
private final int mDistance;
// ------------------------------------------------------------------------
// INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// CONSTRUCTORS
// ------------------------------------------------------------------------
public Hole(int number, int par, int distance) {
mNumber = number;
mPar = par;
mDistance = distance;
}
public Hole(Parcel in) {
mNumber = in.readInt();
mPar = in.readInt();
mDistance = in.readInt();
}
// ------------------------------------------------------------------------
// METHODS
// ------------------------------------------------------------------------
@Override
public MonkeyType toMonkeyObject() {
HashMap<Object, Object> returnVal = new HashMap<Object, Object>(); | // Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/AppConstants.java
// public class AppConstants {
//
// public static final int KEY_MESSAGE_TYPE = -1;
// public static final int KEY_MESSAGE_PAYLOAD = -2;
// public static final int KEY_COURSE_ID = 0;
// public static final int KEY_COURSE_NAME = 1;
// public static final int KEY_COURSE_PAR = 2;
// public static final int KEY_COURSE_TEES_PLAYED = 3;
// public static final int KEY_PLAYERS = 4;
// public static final int KEY_PLAYER_NAME = 5;
// public static final int KEY_PLAYER_ID = 6;
// public static final int KEY_PLAYER_SCORES = 11;
// public static final int KEY_HOLES = 7;
// public static final int KEY_HOLE_NUMBER = 8;
// public static final int KEY_HOLE_PAR = 9;
// public static final int KEY_HOLE_DISTANCE = 10;
//
// }
// Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/course/Hole.java
import java.util.HashMap;
import android.os.Parcel;
import android.os.Parcelable;
import com.garmin.android.apps.samples.disgolf.AppConstants;
import com.garmin.monkeybrains.serialization.MonkeyHash;
import com.garmin.monkeybrains.serialization.MonkeyType;
/**
* Copyright 2015 by Garmin Ltd. or its subsidiaries.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.garmin.android.apps.samples.disgolf.course;
public class Hole implements IQMonkeyConversion<Hole>, Parcelable {
// ------------------------------------------------------------------------
// TYPES
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC FIELDS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// STATIC METHODS
// ------------------------------------------------------------------------
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
@Override
public Hole createFromParcel(Parcel in) {
return new Hole(in);
}
@Override
public Hole[] newArray(int size) {
return new Hole[size];
}
};
// ------------------------------------------------------------------------
// FIELDS
// ------------------------------------------------------------------------
private final int mNumber;
private final int mPar;
private final int mDistance;
// ------------------------------------------------------------------------
// INITIALIZERS
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// CONSTRUCTORS
// ------------------------------------------------------------------------
public Hole(int number, int par, int distance) {
mNumber = number;
mPar = par;
mDistance = distance;
}
public Hole(Parcel in) {
mNumber = in.readInt();
mPar = in.readInt();
mDistance = in.readInt();
}
// ------------------------------------------------------------------------
// METHODS
// ------------------------------------------------------------------------
@Override
public MonkeyType toMonkeyObject() {
HashMap<Object, Object> returnVal = new HashMap<Object, Object>(); | returnVal.put(AppConstants.KEY_HOLE_NUMBER, mNumber); |
garmin/connectiq-apps | device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/course/Course.java | // Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/AppConstants.java
// public class AppConstants {
//
// public static final int KEY_MESSAGE_TYPE = -1;
// public static final int KEY_MESSAGE_PAYLOAD = -2;
// public static final int KEY_COURSE_ID = 0;
// public static final int KEY_COURSE_NAME = 1;
// public static final int KEY_COURSE_PAR = 2;
// public static final int KEY_COURSE_TEES_PLAYED = 3;
// public static final int KEY_PLAYERS = 4;
// public static final int KEY_PLAYER_NAME = 5;
// public static final int KEY_PLAYER_ID = 6;
// public static final int KEY_PLAYER_SCORES = 11;
// public static final int KEY_HOLES = 7;
// public static final int KEY_HOLE_NUMBER = 8;
// public static final int KEY_HOLE_PAR = 9;
// public static final int KEY_HOLE_DISTANCE = 10;
//
// }
| import android.os.Parcel;
import android.os.Parcelable;
import com.garmin.android.apps.samples.disgolf.AppConstants;
import com.garmin.monkeybrains.serialization.MonkeyHash;
import com.garmin.monkeybrains.serialization.MonkeyType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; | in.readList(mPlayers, Player.class.getClassLoader());
}
// ------------------------------------------------------------------------
// METHODS
// ------------------------------------------------------------------------
public void addHole(Hole hole) {
mHoles.add(hole);
}
public void setHoles(List<Hole> holes) {
mHoles = holes;
}
public void addPlayer(Player player) {
mPlayers.add(player);
}
public void setPlayers(List<Player> players) {
mPlayers = players;
}
public String getCourseName() {
return mCourseName;
}
@Override
public MonkeyType toMonkeyObject() {
HashMap<Object, Object> returnVal = new HashMap<Object, Object>(); | // Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/AppConstants.java
// public class AppConstants {
//
// public static final int KEY_MESSAGE_TYPE = -1;
// public static final int KEY_MESSAGE_PAYLOAD = -2;
// public static final int KEY_COURSE_ID = 0;
// public static final int KEY_COURSE_NAME = 1;
// public static final int KEY_COURSE_PAR = 2;
// public static final int KEY_COURSE_TEES_PLAYED = 3;
// public static final int KEY_PLAYERS = 4;
// public static final int KEY_PLAYER_NAME = 5;
// public static final int KEY_PLAYER_ID = 6;
// public static final int KEY_PLAYER_SCORES = 11;
// public static final int KEY_HOLES = 7;
// public static final int KEY_HOLE_NUMBER = 8;
// public static final int KEY_HOLE_PAR = 9;
// public static final int KEY_HOLE_DISTANCE = 10;
//
// }
// Path: device-apps/disc-golf/disc-golf-android/app/src/main/java/com/garmin/android/apps/samples/disgolf/course/Course.java
import android.os.Parcel;
import android.os.Parcelable;
import com.garmin.android.apps.samples.disgolf.AppConstants;
import com.garmin.monkeybrains.serialization.MonkeyHash;
import com.garmin.monkeybrains.serialization.MonkeyType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
in.readList(mPlayers, Player.class.getClassLoader());
}
// ------------------------------------------------------------------------
// METHODS
// ------------------------------------------------------------------------
public void addHole(Hole hole) {
mHoles.add(hole);
}
public void setHoles(List<Hole> holes) {
mHoles = holes;
}
public void addPlayer(Player player) {
mPlayers.add(player);
}
public void setPlayers(List<Player> players) {
mPlayers = players;
}
public String getCourseName() {
return mCourseName;
}
@Override
public MonkeyType toMonkeyObject() {
HashMap<Object, Object> returnVal = new HashMap<Object, Object>(); | returnVal.put(AppConstants.KEY_COURSE_ID, mCourseId); |
sbt-compiler-maven-plugin/sbt-compiler-maven-plugin | sbt-compilers/sbt-compiler-sbt013/src/main/java/com/google/code/sbt/compiler/sbt013/SBT013Position.java | // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/SourcePosition.java
// public interface SourcePosition
// {
//
// /**
// * One-based line number or value less than one if line number not specified.
// *
// * @return line number
// */
// int getLine();
//
// /**
// * Line content or empty string if line number not specified.
// *
// * @return line content
// */
// String getLineContent();
//
// /**
// * Zero-based offset in characters from the beginning of the file or value less than zero if not specified.
// *
// * @return file offset
// */
// int getOffset();
//
// /**
// * One-based position in the line or value less than one if position not specified.
// *
// * @return position in the line
// */
// int getPointer();
//
// /**
// * File.
// *
// * @return file
// */
// File getFile();
//
// }
| import com.google.code.sbt.compiler.api.SourcePosition;
import java.io.File;
import xsbti.Maybe;
import xsbti.Position; | /*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.sbt013;
/**
* SBT <a href="http://www.scala-sbt.org/0.13.15/api/index.html#xsbti.Position">xsbti.Position</a>
* wrapper around {@link SourcePosition} delegate.
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
public class SBT013Position
implements Position
{ | // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/SourcePosition.java
// public interface SourcePosition
// {
//
// /**
// * One-based line number or value less than one if line number not specified.
// *
// * @return line number
// */
// int getLine();
//
// /**
// * Line content or empty string if line number not specified.
// *
// * @return line content
// */
// String getLineContent();
//
// /**
// * Zero-based offset in characters from the beginning of the file or value less than zero if not specified.
// *
// * @return file offset
// */
// int getOffset();
//
// /**
// * One-based position in the line or value less than one if position not specified.
// *
// * @return position in the line
// */
// int getPointer();
//
// /**
// * File.
// *
// * @return file
// */
// File getFile();
//
// }
// Path: sbt-compilers/sbt-compiler-sbt013/src/main/java/com/google/code/sbt/compiler/sbt013/SBT013Position.java
import com.google.code.sbt.compiler.api.SourcePosition;
import java.io.File;
import xsbti.Maybe;
import xsbti.Position;
/*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.sbt013;
/**
* SBT <a href="http://www.scala-sbt.org/0.13.15/api/index.html#xsbti.Position">xsbti.Position</a>
* wrapper around {@link SourcePosition} delegate.
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
public class SBT013Position
implements Position
{ | private SourcePosition sourcePosition; |
sbt-compiler-maven-plugin/sbt-compiler-maven-plugin | sbt-compilers/sbt-compiler-sbt012/src/main/java/com/google/code/sbt/compiler/sbt012/SBT012Logger.java | // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/CompilerLogger.java
// public interface CompilerLogger
// {
// /**
// * Returns true if <b>debug</b> log level is enabled.
// *
// * @return true if <b>debug</b> log level is enabled
// */
// boolean isDebugEnabled();
//
// /**
// * Sends a message in <b>debug</b> log level.
// *
// * @param content debug message
// */
// void debug( String content );
//
// /**
// * Sends a throwable in the <b>debug</b> log level.
// * <br>
// * The stack trace for this throwable will be output.
// *
// * @param throwable debug throwable
// */
// void debug( Throwable throwable );
//
// /**
// * Returns true if <b>info</b> log level is enabled.
// *
// * @return true if <b>info</b> log level is enabled
// */
// boolean isInfoEnabled();
//
// /**
// * Sends a message in <b>info</b> log level.
// *
// * @param content info message
// */
// void info( String content );
//
// /**
// * Returns true if <b>warn</b> log level is enabled.
// *
// * @return true if <b>warn</b> log level is enabled
// */
// boolean isWarnEnabled();
//
// /**
// * Sends a message in <b>warn</b> log level.
// *
// * @param content warning message
// */
// void warn( String content );
//
// /**
// * Returns true if <b>error</b> log level is enabled.
// *
// * @return true if <b>error</b> log level is enabled
// */
// boolean isErrorEnabled();
//
// /**
// * Sends a message in the <b>error</b> log level.
// *
// * @param content error message
// */
// void error( String content );
//
// }
| import com.google.code.sbt.compiler.api.CompilerLogger;
import xsbti.F0;
import xsbti.Logger; | /*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.sbt012;
/**
* SBT <a href="http://www.scala-sbt.org/0.12.4/api/index.html#xsbti.Logger">xsbti.Logger</a>
* wrapper around {@link CompilerLogger} delegate.
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
public class SBT012Logger
implements Logger
{
| // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/CompilerLogger.java
// public interface CompilerLogger
// {
// /**
// * Returns true if <b>debug</b> log level is enabled.
// *
// * @return true if <b>debug</b> log level is enabled
// */
// boolean isDebugEnabled();
//
// /**
// * Sends a message in <b>debug</b> log level.
// *
// * @param content debug message
// */
// void debug( String content );
//
// /**
// * Sends a throwable in the <b>debug</b> log level.
// * <br>
// * The stack trace for this throwable will be output.
// *
// * @param throwable debug throwable
// */
// void debug( Throwable throwable );
//
// /**
// * Returns true if <b>info</b> log level is enabled.
// *
// * @return true if <b>info</b> log level is enabled
// */
// boolean isInfoEnabled();
//
// /**
// * Sends a message in <b>info</b> log level.
// *
// * @param content info message
// */
// void info( String content );
//
// /**
// * Returns true if <b>warn</b> log level is enabled.
// *
// * @return true if <b>warn</b> log level is enabled
// */
// boolean isWarnEnabled();
//
// /**
// * Sends a message in <b>warn</b> log level.
// *
// * @param content warning message
// */
// void warn( String content );
//
// /**
// * Returns true if <b>error</b> log level is enabled.
// *
// * @return true if <b>error</b> log level is enabled
// */
// boolean isErrorEnabled();
//
// /**
// * Sends a message in the <b>error</b> log level.
// *
// * @param content error message
// */
// void error( String content );
//
// }
// Path: sbt-compilers/sbt-compiler-sbt012/src/main/java/com/google/code/sbt/compiler/sbt012/SBT012Logger.java
import com.google.code.sbt.compiler.api.CompilerLogger;
import xsbti.F0;
import xsbti.Logger;
/*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.sbt012;
/**
* SBT <a href="http://www.scala-sbt.org/0.12.4/api/index.html#xsbti.Logger">xsbti.Logger</a>
* wrapper around {@link CompilerLogger} delegate.
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
public class SBT012Logger
implements Logger
{
| private CompilerLogger compilerLogger; |
sbt-compiler-maven-plugin/sbt-compiler-maven-plugin | sbt-compiler-maven-plugin/src/main/java/com/google/code/sbt/compiler/plugin/SourcePositionMapperCollection.java | // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/SourcePosition.java
// public interface SourcePosition
// {
//
// /**
// * One-based line number or value less than one if line number not specified.
// *
// * @return line number
// */
// int getLine();
//
// /**
// * Line content or empty string if line number not specified.
// *
// * @return line content
// */
// String getLineContent();
//
// /**
// * Zero-based offset in characters from the beginning of the file or value less than zero if not specified.
// *
// * @return file offset
// */
// int getOffset();
//
// /**
// * One-based position in the line or value less than one if position not specified.
// *
// * @return position in the line
// */
// int getPointer();
//
// /**
// * File.
// *
// * @return file
// */
// File getFile();
//
// }
//
// Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/SourcePositionMapper.java
// public interface SourcePositionMapper
// {
//
// /**
// * Sets source files character set name (encoding).
// *
// * @param charsetName source files character set name
// */
// void setCharsetName( String charsetName );
//
// /**
// * Performs mapping from the position in generated source file to the position in original source file it was
// * generated from.<br>
// * <br>
// * Returns:
// * <ul>
// * <li>position in original source file</li>
// * <li>
// * {@code null} value if file of the input position is not recognized as generated file supported by this
// * mapper.</li>
// * </ul>
// *
// * @param p compilation error/warning position in generated file
// * @return position in original source file or {@code null} value if file of the input position is not recognized as
// * generated file supported by this mapper
// * @throws IOException I/O exception during generated or original source file reading
// */
// SourcePosition map( SourcePosition p ) throws IOException;
//
// }
| import java.io.IOException;
import java.util.Collection;
import com.google.code.sbt.compiler.api.SourcePosition;
import com.google.code.sbt.compiler.api.SourcePositionMapper; | /*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.plugin;
/**
* Wwrapper for a collection of source position mappers.<br>
* <br>
* When mapping the position it iterates over contained mappers until one of them returns
* not {@code null} result.
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
public class SourcePositionMapperCollection
implements SourcePositionMapper
{
private Collection<SourcePositionMapper> mappers;
/**
* Creates source position mappers collection.
*
* @param mappers source position mappers
*/
public SourcePositionMapperCollection( Collection<SourcePositionMapper> mappers )
{
this.mappers = mappers;
}
/**
* {@inheritDoc}
*/
@Override
public void setCharsetName( String charsetName )
{
for ( SourcePositionMapper mapper: mappers )
{
mapper.setCharsetName( charsetName );
}
}
/**
* {@inheritDoc}
*/
@Override | // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/SourcePosition.java
// public interface SourcePosition
// {
//
// /**
// * One-based line number or value less than one if line number not specified.
// *
// * @return line number
// */
// int getLine();
//
// /**
// * Line content or empty string if line number not specified.
// *
// * @return line content
// */
// String getLineContent();
//
// /**
// * Zero-based offset in characters from the beginning of the file or value less than zero if not specified.
// *
// * @return file offset
// */
// int getOffset();
//
// /**
// * One-based position in the line or value less than one if position not specified.
// *
// * @return position in the line
// */
// int getPointer();
//
// /**
// * File.
// *
// * @return file
// */
// File getFile();
//
// }
//
// Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/SourcePositionMapper.java
// public interface SourcePositionMapper
// {
//
// /**
// * Sets source files character set name (encoding).
// *
// * @param charsetName source files character set name
// */
// void setCharsetName( String charsetName );
//
// /**
// * Performs mapping from the position in generated source file to the position in original source file it was
// * generated from.<br>
// * <br>
// * Returns:
// * <ul>
// * <li>position in original source file</li>
// * <li>
// * {@code null} value if file of the input position is not recognized as generated file supported by this
// * mapper.</li>
// * </ul>
// *
// * @param p compilation error/warning position in generated file
// * @return position in original source file or {@code null} value if file of the input position is not recognized as
// * generated file supported by this mapper
// * @throws IOException I/O exception during generated or original source file reading
// */
// SourcePosition map( SourcePosition p ) throws IOException;
//
// }
// Path: sbt-compiler-maven-plugin/src/main/java/com/google/code/sbt/compiler/plugin/SourcePositionMapperCollection.java
import java.io.IOException;
import java.util.Collection;
import com.google.code.sbt.compiler.api.SourcePosition;
import com.google.code.sbt.compiler.api.SourcePositionMapper;
/*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.plugin;
/**
* Wwrapper for a collection of source position mappers.<br>
* <br>
* When mapping the position it iterates over contained mappers until one of them returns
* not {@code null} result.
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
public class SourcePositionMapperCollection
implements SourcePositionMapper
{
private Collection<SourcePositionMapper> mappers;
/**
* Creates source position mappers collection.
*
* @param mappers source position mappers
*/
public SourcePositionMapperCollection( Collection<SourcePositionMapper> mappers )
{
this.mappers = mappers;
}
/**
* {@inheritDoc}
*/
@Override
public void setCharsetName( String charsetName )
{
for ( SourcePositionMapper mapper: mappers )
{
mapper.setCharsetName( charsetName );
}
}
/**
* {@inheritDoc}
*/
@Override | public SourcePosition map( SourcePosition sp ) throws IOException |
sbt-compiler-maven-plugin/sbt-compiler-maven-plugin | sbt-compilers/sbt-compiler-sbt013/src/main/java/com/google/code/sbt/compiler/sbt013/SBT013AnalysisProcessor.java | // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/Analysis.java
// public interface Analysis
// {
// /**
// * Returns all source files.
// *
// * @return all source files
// */
// Set<File> getSourceFiles();
//
// /**
// * Returns source file's compilation time.
// *
// * @param sourceFile source file
// *
// * @return source file's compilation time
// */
// long getCompilationTime( File sourceFile );
//
// /**
// * Returns source file's compilation products (class files).
// *
// * @param sourceFile source file
// *
// * @return source file's compilation products (class files).
// */
// Set<File> getProducts( File sourceFile );
//
// /**
// * Updates class file time stamp written in incremental compilation analysis
// * to the value returned by {@link File#lastModified()}.
// *
// * Not all compilers store file time stamps in the analysis,
// * but for the ones that do it, it's important that this information
// * is always up to date.
// *
// * Class file is changed if it is processed after compilation.
// * If it's new time stamp will not be stored in the analysis cache file
// * the next time compilation runs, SBT compiler will unnecessarily recompile the file.
// *
// * @param classFile class file
// */
// void updateClassFileTimestamp( File classFile );
//
// /**
// * Stores incremental compilation analysis in the file.
// *
// * @param analysisCacheFile the file to store analysis in
// */
// void writeToFile( File analysisCacheFile );
//
// /**
// * Returns SBT native incremental compilation object.
// *
// * @return SBT native incremental compilation
// */
// Object unwrap();
//
// }
//
// Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/AnalysisProcessor.java
// public interface AnalysisProcessor
// {
// /**
// * Returns information if this compiler stores class file time stamps
// * in the incremental compilation analysis.
// *
// * @return information if class file time stamps are stored in the analysis
// */
// boolean areClassFileTimestampsSupported();
//
// /**
// * Reads incremental compilation analysis from cache file.
// *
// * @param analysisCacheFile the file to read analysis from
// *
// * @return incremental compilation analysis object
// */
// Analysis readFromFile( File analysisCacheFile );
//
// }
| import java.io.File;
import com.typesafe.zinc.Compiler;
import com.google.code.sbt.compiler.api.Analysis;
import com.google.code.sbt.compiler.api.AnalysisProcessor;
import org.codehaus.plexus.component.annotations.Component; | /*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.sbt013;
/**
* SBT 0.13.x compatible analysis processor
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
@Component( role = AnalysisProcessor.class, hint = "sbt013", description = "SBT 0.13.x analysis processor" )
public class SBT013AnalysisProcessor
implements AnalysisProcessor
{
/**
* {@inheritDoc}
*/
@Override
public boolean areClassFileTimestampsSupported()
{
return true;
}
/**
* {@inheritDoc}
*/
@Override | // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/Analysis.java
// public interface Analysis
// {
// /**
// * Returns all source files.
// *
// * @return all source files
// */
// Set<File> getSourceFiles();
//
// /**
// * Returns source file's compilation time.
// *
// * @param sourceFile source file
// *
// * @return source file's compilation time
// */
// long getCompilationTime( File sourceFile );
//
// /**
// * Returns source file's compilation products (class files).
// *
// * @param sourceFile source file
// *
// * @return source file's compilation products (class files).
// */
// Set<File> getProducts( File sourceFile );
//
// /**
// * Updates class file time stamp written in incremental compilation analysis
// * to the value returned by {@link File#lastModified()}.
// *
// * Not all compilers store file time stamps in the analysis,
// * but for the ones that do it, it's important that this information
// * is always up to date.
// *
// * Class file is changed if it is processed after compilation.
// * If it's new time stamp will not be stored in the analysis cache file
// * the next time compilation runs, SBT compiler will unnecessarily recompile the file.
// *
// * @param classFile class file
// */
// void updateClassFileTimestamp( File classFile );
//
// /**
// * Stores incremental compilation analysis in the file.
// *
// * @param analysisCacheFile the file to store analysis in
// */
// void writeToFile( File analysisCacheFile );
//
// /**
// * Returns SBT native incremental compilation object.
// *
// * @return SBT native incremental compilation
// */
// Object unwrap();
//
// }
//
// Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/AnalysisProcessor.java
// public interface AnalysisProcessor
// {
// /**
// * Returns information if this compiler stores class file time stamps
// * in the incremental compilation analysis.
// *
// * @return information if class file time stamps are stored in the analysis
// */
// boolean areClassFileTimestampsSupported();
//
// /**
// * Reads incremental compilation analysis from cache file.
// *
// * @param analysisCacheFile the file to read analysis from
// *
// * @return incremental compilation analysis object
// */
// Analysis readFromFile( File analysisCacheFile );
//
// }
// Path: sbt-compilers/sbt-compiler-sbt013/src/main/java/com/google/code/sbt/compiler/sbt013/SBT013AnalysisProcessor.java
import java.io.File;
import com.typesafe.zinc.Compiler;
import com.google.code.sbt.compiler.api.Analysis;
import com.google.code.sbt.compiler.api.AnalysisProcessor;
import org.codehaus.plexus.component.annotations.Component;
/*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.sbt013;
/**
* SBT 0.13.x compatible analysis processor
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
@Component( role = AnalysisProcessor.class, hint = "sbt013", description = "SBT 0.13.x analysis processor" )
public class SBT013AnalysisProcessor
implements AnalysisProcessor
{
/**
* {@inheritDoc}
*/
@Override
public boolean areClassFileTimestampsSupported()
{
return true;
}
/**
* {@inheritDoc}
*/
@Override | public Analysis readFromFile( File analysisCacheFile ) |
sbt-compiler-maven-plugin/sbt-compiler-maven-plugin | sbt-compilers/sbt-compiler-sbt012/src/main/java/com/google/code/sbt/compiler/sbt012/SBT012AnalysisProcessor.java | // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/Analysis.java
// public interface Analysis
// {
// /**
// * Returns all source files.
// *
// * @return all source files
// */
// Set<File> getSourceFiles();
//
// /**
// * Returns source file's compilation time.
// *
// * @param sourceFile source file
// *
// * @return source file's compilation time
// */
// long getCompilationTime( File sourceFile );
//
// /**
// * Returns source file's compilation products (class files).
// *
// * @param sourceFile source file
// *
// * @return source file's compilation products (class files).
// */
// Set<File> getProducts( File sourceFile );
//
// /**
// * Updates class file time stamp written in incremental compilation analysis
// * to the value returned by {@link File#lastModified()}.
// *
// * Not all compilers store file time stamps in the analysis,
// * but for the ones that do it, it's important that this information
// * is always up to date.
// *
// * Class file is changed if it is processed after compilation.
// * If it's new time stamp will not be stored in the analysis cache file
// * the next time compilation runs, SBT compiler will unnecessarily recompile the file.
// *
// * @param classFile class file
// */
// void updateClassFileTimestamp( File classFile );
//
// /**
// * Stores incremental compilation analysis in the file.
// *
// * @param analysisCacheFile the file to store analysis in
// */
// void writeToFile( File analysisCacheFile );
//
// /**
// * Returns SBT native incremental compilation object.
// *
// * @return SBT native incremental compilation
// */
// Object unwrap();
//
// }
//
// Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/AnalysisProcessor.java
// public interface AnalysisProcessor
// {
// /**
// * Returns information if this compiler stores class file time stamps
// * in the incremental compilation analysis.
// *
// * @return information if class file time stamps are stored in the analysis
// */
// boolean areClassFileTimestampsSupported();
//
// /**
// * Reads incremental compilation analysis from cache file.
// *
// * @param analysisCacheFile the file to read analysis from
// *
// * @return incremental compilation analysis object
// */
// Analysis readFromFile( File analysisCacheFile );
//
// }
| import java.io.File;
import com.typesafe.zinc.Compiler;
import com.google.code.sbt.compiler.api.Analysis;
import com.google.code.sbt.compiler.api.AnalysisProcessor;
import org.codehaus.plexus.component.annotations.Component; | /*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.sbt012;
/**
* SBT 0.12.x compatible analysis processor
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
@Component( role = AnalysisProcessor.class, hint = "sbt012", description = "SBT 0.12.x analysis processor" )
public class SBT012AnalysisProcessor
implements AnalysisProcessor
{
/**
* {@inheritDoc}
*/
@Override
public boolean areClassFileTimestampsSupported()
{
return false;
}
/**
* {@inheritDoc}
*/
@Override | // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/Analysis.java
// public interface Analysis
// {
// /**
// * Returns all source files.
// *
// * @return all source files
// */
// Set<File> getSourceFiles();
//
// /**
// * Returns source file's compilation time.
// *
// * @param sourceFile source file
// *
// * @return source file's compilation time
// */
// long getCompilationTime( File sourceFile );
//
// /**
// * Returns source file's compilation products (class files).
// *
// * @param sourceFile source file
// *
// * @return source file's compilation products (class files).
// */
// Set<File> getProducts( File sourceFile );
//
// /**
// * Updates class file time stamp written in incremental compilation analysis
// * to the value returned by {@link File#lastModified()}.
// *
// * Not all compilers store file time stamps in the analysis,
// * but for the ones that do it, it's important that this information
// * is always up to date.
// *
// * Class file is changed if it is processed after compilation.
// * If it's new time stamp will not be stored in the analysis cache file
// * the next time compilation runs, SBT compiler will unnecessarily recompile the file.
// *
// * @param classFile class file
// */
// void updateClassFileTimestamp( File classFile );
//
// /**
// * Stores incremental compilation analysis in the file.
// *
// * @param analysisCacheFile the file to store analysis in
// */
// void writeToFile( File analysisCacheFile );
//
// /**
// * Returns SBT native incremental compilation object.
// *
// * @return SBT native incremental compilation
// */
// Object unwrap();
//
// }
//
// Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/AnalysisProcessor.java
// public interface AnalysisProcessor
// {
// /**
// * Returns information if this compiler stores class file time stamps
// * in the incremental compilation analysis.
// *
// * @return information if class file time stamps are stored in the analysis
// */
// boolean areClassFileTimestampsSupported();
//
// /**
// * Reads incremental compilation analysis from cache file.
// *
// * @param analysisCacheFile the file to read analysis from
// *
// * @return incremental compilation analysis object
// */
// Analysis readFromFile( File analysisCacheFile );
//
// }
// Path: sbt-compilers/sbt-compiler-sbt012/src/main/java/com/google/code/sbt/compiler/sbt012/SBT012AnalysisProcessor.java
import java.io.File;
import com.typesafe.zinc.Compiler;
import com.google.code.sbt.compiler.api.Analysis;
import com.google.code.sbt.compiler.api.AnalysisProcessor;
import org.codehaus.plexus.component.annotations.Component;
/*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.sbt012;
/**
* SBT 0.12.x compatible analysis processor
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
@Component( role = AnalysisProcessor.class, hint = "sbt012", description = "SBT 0.12.x analysis processor" )
public class SBT012AnalysisProcessor
implements AnalysisProcessor
{
/**
* {@inheritDoc}
*/
@Override
public boolean areClassFileTimestampsSupported()
{
return false;
}
/**
* {@inheritDoc}
*/
@Override | public Analysis readFromFile( File analysisCacheFile ) |
sbt-compiler-maven-plugin/sbt-compiler-maven-plugin | sbt-compilers/sbt-compiler-sbt013/src/main/java/com/google/code/sbt/compiler/sbt013/SBT013Logger.java | // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/CompilerLogger.java
// public interface CompilerLogger
// {
// /**
// * Returns true if <b>debug</b> log level is enabled.
// *
// * @return true if <b>debug</b> log level is enabled
// */
// boolean isDebugEnabled();
//
// /**
// * Sends a message in <b>debug</b> log level.
// *
// * @param content debug message
// */
// void debug( String content );
//
// /**
// * Sends a throwable in the <b>debug</b> log level.
// * <br>
// * The stack trace for this throwable will be output.
// *
// * @param throwable debug throwable
// */
// void debug( Throwable throwable );
//
// /**
// * Returns true if <b>info</b> log level is enabled.
// *
// * @return true if <b>info</b> log level is enabled
// */
// boolean isInfoEnabled();
//
// /**
// * Sends a message in <b>info</b> log level.
// *
// * @param content info message
// */
// void info( String content );
//
// /**
// * Returns true if <b>warn</b> log level is enabled.
// *
// * @return true if <b>warn</b> log level is enabled
// */
// boolean isWarnEnabled();
//
// /**
// * Sends a message in <b>warn</b> log level.
// *
// * @param content warning message
// */
// void warn( String content );
//
// /**
// * Returns true if <b>error</b> log level is enabled.
// *
// * @return true if <b>error</b> log level is enabled
// */
// boolean isErrorEnabled();
//
// /**
// * Sends a message in the <b>error</b> log level.
// *
// * @param content error message
// */
// void error( String content );
//
// }
| import com.google.code.sbt.compiler.api.CompilerLogger;
import xsbti.F0;
import xsbti.Logger; | /*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.sbt013;
/**
* SBT <a href="http://www.scala-sbt.org/0.13.15/api/index.html#xsbti.Logger">xsbti.Logger</a>
* wrapper around {@link CompilerLogger} delegate.
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
public class SBT013Logger
implements Logger
{
private static final String MISLEADING_WARNING_MESSAGE =
"Pruning sources from previous analysis, due to incompatible CompileSetup.";
| // Path: sbt-compiler-api/src/main/java/com/google/code/sbt/compiler/api/CompilerLogger.java
// public interface CompilerLogger
// {
// /**
// * Returns true if <b>debug</b> log level is enabled.
// *
// * @return true if <b>debug</b> log level is enabled
// */
// boolean isDebugEnabled();
//
// /**
// * Sends a message in <b>debug</b> log level.
// *
// * @param content debug message
// */
// void debug( String content );
//
// /**
// * Sends a throwable in the <b>debug</b> log level.
// * <br>
// * The stack trace for this throwable will be output.
// *
// * @param throwable debug throwable
// */
// void debug( Throwable throwable );
//
// /**
// * Returns true if <b>info</b> log level is enabled.
// *
// * @return true if <b>info</b> log level is enabled
// */
// boolean isInfoEnabled();
//
// /**
// * Sends a message in <b>info</b> log level.
// *
// * @param content info message
// */
// void info( String content );
//
// /**
// * Returns true if <b>warn</b> log level is enabled.
// *
// * @return true if <b>warn</b> log level is enabled
// */
// boolean isWarnEnabled();
//
// /**
// * Sends a message in <b>warn</b> log level.
// *
// * @param content warning message
// */
// void warn( String content );
//
// /**
// * Returns true if <b>error</b> log level is enabled.
// *
// * @return true if <b>error</b> log level is enabled
// */
// boolean isErrorEnabled();
//
// /**
// * Sends a message in the <b>error</b> log level.
// *
// * @param content error message
// */
// void error( String content );
//
// }
// Path: sbt-compilers/sbt-compiler-sbt013/src/main/java/com/google/code/sbt/compiler/sbt013/SBT013Logger.java
import com.google.code.sbt.compiler.api.CompilerLogger;
import xsbti.F0;
import xsbti.Logger;
/*
* Copyright 2013-2017 Grzegorz Slowikowski (gslowikowski at gmail dot com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.google.code.sbt.compiler.sbt013;
/**
* SBT <a href="http://www.scala-sbt.org/0.13.15/api/index.html#xsbti.Logger">xsbti.Logger</a>
* wrapper around {@link CompilerLogger} delegate.
*
* @author <a href="mailto:gslowikowski@gmail.com">Grzegorz Slowikowski</a>
*/
public class SBT013Logger
implements Logger
{
private static final String MISLEADING_WARNING_MESSAGE =
"Pruning sources from previous analysis, due to incompatible CompileSetup.";
| private CompilerLogger compilerLogger; |
pokermania/pokereval | java/org/pokersource/util/test/NestedLoopEnumerationTest.java | // Path: java/org/pokersource/util/NestedLoopEnumeration.java
// public class NestedLoopEnumeration implements Enumeration {
// private int[] next; // our private copy of the next element
// private int[] elem; // a copy of the next element we return in next()
// private int[] limits; // loop limits for each dimension
//
// /** Initializes a nested loop iterator with limits.length dimensions.
// @param limits limits[i] is the upper limit of the ith nested loop (the
// loop runs from 0 to limits[i]-1 inclusive)
// */
// public NestedLoopEnumeration(int[] limits) {
// this.limits = limits;
// next = new int[limits.length];
// elem = new int[limits.length];
// for (int i = 0; i < limits.length; i++) {
// if (limits[i] <= 0)
// throw new IllegalArgumentException("limits must be positive");
// next[i] = 0;
// }
// }
//
// public boolean hasMoreElements() {
// return (next != null);
// }
//
// /** Return an integer array listing the next loop indices for each
// dimension.
// @return An object of int[] type; the ith value is the loop variable
// for the ith nested loop.
// */
// public Object nextElement() {
// if (next == null)
// return null;
// for (int i = 0; i < next.length; i++)
// elem[i] = next[i];
// next[limits.length - 1]++; // increment least-significant dimension
// for (int i = limits.length - 1; i >= 0; i--) { // check for carries
// if (next[i] == limits[i]) { // need to carry
// next[i] = 0; // rollover to zero
// if (i > 0)
// next[i - 1]++; // carry to next higher dimension
// else
// next = null; // no more elements
// }
// }
// return elem;
// }
// }
| import junit.framework.TestCase;
import org.pokersource.util.NestedLoopEnumeration; | // $Id$
package org.pokersource.util.test;
/**
@author Michael Maurer <<a href="mailto:mjmaurer@yahoo.com">mjmaurer@yahoo.com</a>>
*/
public class NestedLoopEnumerationTest extends TestCase {
public NestedLoopEnumerationTest(String name) {
super(name);
}
public static void main(String args[]) {
junit.textui.TestRunner.run(NestedLoopEnumerationTest.class);
}
public void testBasic() {
int[] limits = {2, 3, 2};
int[][] expected = {
{0, 0, 0},
{0, 0, 1},
{0, 1, 0},
{0, 1, 1},
{0, 2, 0},
{0, 2, 1},
{1, 0, 0},
{1, 0, 1},
{1, 1, 0},
{1, 1, 1},
{1, 2, 0},
{1, 2, 1}
}; | // Path: java/org/pokersource/util/NestedLoopEnumeration.java
// public class NestedLoopEnumeration implements Enumeration {
// private int[] next; // our private copy of the next element
// private int[] elem; // a copy of the next element we return in next()
// private int[] limits; // loop limits for each dimension
//
// /** Initializes a nested loop iterator with limits.length dimensions.
// @param limits limits[i] is the upper limit of the ith nested loop (the
// loop runs from 0 to limits[i]-1 inclusive)
// */
// public NestedLoopEnumeration(int[] limits) {
// this.limits = limits;
// next = new int[limits.length];
// elem = new int[limits.length];
// for (int i = 0; i < limits.length; i++) {
// if (limits[i] <= 0)
// throw new IllegalArgumentException("limits must be positive");
// next[i] = 0;
// }
// }
//
// public boolean hasMoreElements() {
// return (next != null);
// }
//
// /** Return an integer array listing the next loop indices for each
// dimension.
// @return An object of int[] type; the ith value is the loop variable
// for the ith nested loop.
// */
// public Object nextElement() {
// if (next == null)
// return null;
// for (int i = 0; i < next.length; i++)
// elem[i] = next[i];
// next[limits.length - 1]++; // increment least-significant dimension
// for (int i = limits.length - 1; i >= 0; i--) { // check for carries
// if (next[i] == limits[i]) { // need to carry
// next[i] = 0; // rollover to zero
// if (i > 0)
// next[i - 1]++; // carry to next higher dimension
// else
// next = null; // no more elements
// }
// }
// return elem;
// }
// }
// Path: java/org/pokersource/util/test/NestedLoopEnumerationTest.java
import junit.framework.TestCase;
import org.pokersource.util.NestedLoopEnumeration;
// $Id$
package org.pokersource.util.test;
/**
@author Michael Maurer <<a href="mailto:mjmaurer@yahoo.com">mjmaurer@yahoo.com</a>>
*/
public class NestedLoopEnumerationTest extends TestCase {
public NestedLoopEnumerationTest(String name) {
super(name);
}
public static void main(String args[]) {
junit.textui.TestRunner.run(NestedLoopEnumerationTest.class);
}
public void testBasic() {
int[] limits = {2, 3, 2};
int[][] expected = {
{0, 0, 0},
{0, 0, 1},
{0, 1, 0},
{0, 1, 1},
{0, 2, 0},
{0, 2, 1},
{1, 0, 0},
{1, 0, 1},
{1, 1, 0},
{1, 1, 1},
{1, 2, 0},
{1, 2, 1}
}; | NestedLoopEnumeration enumerate = new NestedLoopEnumeration(limits); |
raydac/j-j-jvm | uistubgen/src/main/java/com/igormaznitsa/jjjvm/stubgen/jjjvmwrapper/main.java | // Path: uistubgen/src/main/java/com/igormaznitsa/jjjvm/stubgen/utils/SplashDialog.java
// public class SplashDialog extends JDialog implements Runnable {
//
// private static final long serialVersionUID = 1812332099452703575L;
//
// protected final long delay;
//
// public SplashDialog(final String splashImagePath, final long delayToShow) {
// super();
//
// this.delay = delayToShow;
//
// if (delayToShow <= 0) {
// throw new IllegalArgumentException("Delay is less than zero or equ");
// }
//
// setModal(true);
// setUndecorated(true);
// setResizable(false);
//
// final JPanel panel = new JPanel(new BorderLayout());
//
// final URL imgUrl = ClassLoader.getSystemResource(splashImagePath);
// if (imgUrl == null) {
// throw new IllegalArgumentException("Can't load splash image " + splashImagePath);
// }
// final ImageIcon splashImage = new ImageIcon(imgUrl);
// panel.add(new JLabel(splashImage), BorderLayout.CENTER);
// setContentPane(panel);
//
// final Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
// pack();
//
// setLocation((scrSize.width - getWidth()) / 2, (scrSize.height - getHeight()) / 2);
// setAlwaysOnTop(true);
//
// new Thread(this).start();
// new Thread(new Runnable() {
// @Override
// public void run() {
// setVisible(true);
// }
// }
// ).start();
// }
//
// @Override
// public void run() {
// while (!isVisible() && !Thread.currentThread().isInterrupted()) {
// Thread.yield();
// }
//
// if (Thread.currentThread().isInterrupted()) {
// dispose();
// return;
// }
//
// try {
// Thread.sleep(this.delay);
// }
// catch (Throwable thr) {
// }
// finally {
// this.dispose();
// }
// }
// }
| import com.igormaznitsa.jjjvm.stubgen.utils.SplashDialog;
import javax.swing.SwingUtilities; | /*
* Copyright 2015 Igor Maznitsa (http://www.igormaznitsa.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.igormaznitsa.jjjvm.stubgen.jjjvmwrapper;
public class main {
public static final String APPLICATION = "MJVM Stub Generator";
public static final String VERSION = "1.0.5";
public static final String AUTHOR = "Igor Maznitsa (rrg4400@gmail.com)";
public static final void main(String... _args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { | // Path: uistubgen/src/main/java/com/igormaznitsa/jjjvm/stubgen/utils/SplashDialog.java
// public class SplashDialog extends JDialog implements Runnable {
//
// private static final long serialVersionUID = 1812332099452703575L;
//
// protected final long delay;
//
// public SplashDialog(final String splashImagePath, final long delayToShow) {
// super();
//
// this.delay = delayToShow;
//
// if (delayToShow <= 0) {
// throw new IllegalArgumentException("Delay is less than zero or equ");
// }
//
// setModal(true);
// setUndecorated(true);
// setResizable(false);
//
// final JPanel panel = new JPanel(new BorderLayout());
//
// final URL imgUrl = ClassLoader.getSystemResource(splashImagePath);
// if (imgUrl == null) {
// throw new IllegalArgumentException("Can't load splash image " + splashImagePath);
// }
// final ImageIcon splashImage = new ImageIcon(imgUrl);
// panel.add(new JLabel(splashImage), BorderLayout.CENTER);
// setContentPane(panel);
//
// final Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
// pack();
//
// setLocation((scrSize.width - getWidth()) / 2, (scrSize.height - getHeight()) / 2);
// setAlwaysOnTop(true);
//
// new Thread(this).start();
// new Thread(new Runnable() {
// @Override
// public void run() {
// setVisible(true);
// }
// }
// ).start();
// }
//
// @Override
// public void run() {
// while (!isVisible() && !Thread.currentThread().isInterrupted()) {
// Thread.yield();
// }
//
// if (Thread.currentThread().isInterrupted()) {
// dispose();
// return;
// }
//
// try {
// Thread.sleep(this.delay);
// }
// catch (Throwable thr) {
// }
// finally {
// this.dispose();
// }
// }
// }
// Path: uistubgen/src/main/java/com/igormaznitsa/jjjvm/stubgen/jjjvmwrapper/main.java
import com.igormaznitsa.jjjvm.stubgen.utils.SplashDialog;
import javax.swing.SwingUtilities;
/*
* Copyright 2015 Igor Maznitsa (http://www.igormaznitsa.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.igormaznitsa.jjjvm.stubgen.jjjvmwrapper;
public class main {
public static final String APPLICATION = "MJVM Stub Generator";
public static final String VERSION = "1.0.5";
public static final String AUTHOR = "Igor Maznitsa (rrg4400@gmail.com)";
public static final void main(String... _args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { | new SplashDialog("images/splash.jpg", 3000L); |
raydac/j-j-jvm | uistubgen/src/main/java/com/igormaznitsa/jjjvm/stubgen/jjjvmwrapper/ClassItemProperties.java | // Path: uistubgen/src/main/java/com/igormaznitsa/jjjvm/stubgen/jjjvmwrapper/model/ClassItem.java
// public class ClassItem implements StorageItem {
//
// protected boolean enabled;
// protected String className;
//
// protected JavaClass jclazz;
// protected String internalClassID;
//
// protected PackageItem parent;
//
// public ClassItem(final PackageItem packageItem, final JavaClass jclazz) {
// this.className = jclazz.getClassName();
// this.jclazz = jclazz;
// this.parent = packageItem;
//
// final int lastDotIndex = className.lastIndexOf('.');
// if (lastDotIndex >= 0) {
// this.className = className.substring(lastDotIndex + 1);
// }
//
// this.enabled = true;
//
// this.internalClassID = jclazz.getClassName();
// }
//
// public PackageItem getPackage() {
// return parent;
// }
//
// public JavaClass getJavaClass() {
// return jclazz;
// }
//
// @Override
// public boolean isEnabled() {
// return enabled;
// }
//
// @Override
// public void setEnabled(final boolean value) {
// this.enabled = value;
// }
//
// @Override
// public boolean equals(final Object obj) {
// if (obj == null || !(obj instanceof ClassItem)) {
// return false;
// }
// return this.internalClassID.equals(((ClassItem) obj).internalClassID);
// }
//
// @Override
// public int hashCode() {
// return this.internalClassID.hashCode();
// }
//
// @Override
// public String toString() {
// return this.className;
// }
//
// @Override
// public String getName() {
// return this.className;
// }
// }
| import com.igormaznitsa.jjjvm.stubgen.jjjvmwrapper.model.ClassItem;
import javax.swing.DefaultComboBoxModel;
import org.apache.bcel.classfile.JavaClass; | .addComponent(panelMethods, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)
.addComponent(panelFields, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox checkboxAbstract;
private javax.swing.JCheckBox checkboxFinal;
private javax.swing.JCheckBox checkboxInterface;
private javax.swing.JCheckBox checkboxPublic;
private javax.swing.JCheckBox checkboxStrictFP;
private javax.swing.JCheckBox checkboxSuper;
private javax.swing.JPanel jPanel2;
private javax.swing.JLabel labelClassName;
private javax.swing.JLabel labelCompilerVersion;
private javax.swing.JLabel labelPackage;
private javax.swing.JLabel labelSuperclass;
private javax.swing.JList listFields;
private javax.swing.JList listInterfaces;
private javax.swing.JList listMethods;
private javax.swing.JScrollPane panelFields;
private javax.swing.JScrollPane panelInterfaces;
private javax.swing.JScrollPane panelMethods;
private javax.swing.JPanel panwlVisibility;
private javax.swing.JTextField textFieldClassName;
private javax.swing.JTextField textFieldCompilerVersion;
private javax.swing.JTextField textFieldPackage;
private javax.swing.JTextField textFieldSuperclass;
// End of variables declaration//GEN-END:variables
| // Path: uistubgen/src/main/java/com/igormaznitsa/jjjvm/stubgen/jjjvmwrapper/model/ClassItem.java
// public class ClassItem implements StorageItem {
//
// protected boolean enabled;
// protected String className;
//
// protected JavaClass jclazz;
// protected String internalClassID;
//
// protected PackageItem parent;
//
// public ClassItem(final PackageItem packageItem, final JavaClass jclazz) {
// this.className = jclazz.getClassName();
// this.jclazz = jclazz;
// this.parent = packageItem;
//
// final int lastDotIndex = className.lastIndexOf('.');
// if (lastDotIndex >= 0) {
// this.className = className.substring(lastDotIndex + 1);
// }
//
// this.enabled = true;
//
// this.internalClassID = jclazz.getClassName();
// }
//
// public PackageItem getPackage() {
// return parent;
// }
//
// public JavaClass getJavaClass() {
// return jclazz;
// }
//
// @Override
// public boolean isEnabled() {
// return enabled;
// }
//
// @Override
// public void setEnabled(final boolean value) {
// this.enabled = value;
// }
//
// @Override
// public boolean equals(final Object obj) {
// if (obj == null || !(obj instanceof ClassItem)) {
// return false;
// }
// return this.internalClassID.equals(((ClassItem) obj).internalClassID);
// }
//
// @Override
// public int hashCode() {
// return this.internalClassID.hashCode();
// }
//
// @Override
// public String toString() {
// return this.className;
// }
//
// @Override
// public String getName() {
// return this.className;
// }
// }
// Path: uistubgen/src/main/java/com/igormaznitsa/jjjvm/stubgen/jjjvmwrapper/ClassItemProperties.java
import com.igormaznitsa.jjjvm.stubgen.jjjvmwrapper.model.ClassItem;
import javax.swing.DefaultComboBoxModel;
import org.apache.bcel.classfile.JavaClass;
.addComponent(panelMethods, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)
.addComponent(panelFields, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox checkboxAbstract;
private javax.swing.JCheckBox checkboxFinal;
private javax.swing.JCheckBox checkboxInterface;
private javax.swing.JCheckBox checkboxPublic;
private javax.swing.JCheckBox checkboxStrictFP;
private javax.swing.JCheckBox checkboxSuper;
private javax.swing.JPanel jPanel2;
private javax.swing.JLabel labelClassName;
private javax.swing.JLabel labelCompilerVersion;
private javax.swing.JLabel labelPackage;
private javax.swing.JLabel labelSuperclass;
private javax.swing.JList listFields;
private javax.swing.JList listInterfaces;
private javax.swing.JList listMethods;
private javax.swing.JScrollPane panelFields;
private javax.swing.JScrollPane panelInterfaces;
private javax.swing.JScrollPane panelMethods;
private javax.swing.JPanel panwlVisibility;
private javax.swing.JTextField textFieldClassName;
private javax.swing.JTextField textFieldCompilerVersion;
private javax.swing.JTextField textFieldPackage;
private javax.swing.JTextField textFieldSuperclass;
// End of variables declaration//GEN-END:variables
| public void setModel(final ClassItem classItem) { |
DataSketches/experimental | src/main/java/com/yahoo/memory4/AllocateDirect.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import sun.misc.Cleaner;
import static com.yahoo.memory4.UnsafeUtil.unsafe; | /*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
/**
* @author Lee Rhodes
*/
final class AllocateDirect extends WritableMemoryImpl implements WritableResourceHandler {
private final Cleaner cleaner;
/**
* Base Constructor for allocate native memory.
*
* <p>Allocates and provides access to capacityBytes directly in native (off-heap) memory
* leveraging the Memory interface.
* The allocated memory will be 8-byte aligned, but may not be page aligned.
* @param state contains the capacity and optionally the MemoryRequest
*/
private AllocateDirect(final MemoryState state) {
super(state);
this.cleaner = Cleaner.create(this, new Deallocator(state));
}
static WritableMemoryImpl allocDirect(final MemoryState state) { | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/AllocateDirect.java
import sun.misc.Cleaner;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
/*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
/**
* @author Lee Rhodes
*/
final class AllocateDirect extends WritableMemoryImpl implements WritableResourceHandler {
private final Cleaner cleaner;
/**
* Base Constructor for allocate native memory.
*
* <p>Allocates and provides access to capacityBytes directly in native (off-heap) memory
* leveraging the Memory interface.
* The allocated memory will be 8-byte aligned, but may not be page aligned.
* @param state contains the capacity and optionally the MemoryRequest
*/
private AllocateDirect(final MemoryState state) {
super(state);
this.cleaner = Cleaner.create(this, new Deallocator(state));
}
static WritableMemoryImpl allocDirect(final MemoryState state) { | state.putNativeBaseOffset(unsafe.allocateMemory(state.getCapacity())); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/AllocateDirectWritableMap.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;
import sun.misc.Cleaner;
import sun.nio.ch.FileChannelImpl; | final long fileOffset = state.getFileOffset();
final long capacity = state.getCapacity();
checkOffsetAndCapacity(fileOffset, capacity);
final File file = state.getFile();
if (isFileReadOnly(file)) {
throw new ReadOnlyMemoryException("File is read-only.");
}
final String mode = "rw";
final RandomAccessFile raf = new RandomAccessFile(file, mode);
final FileChannel fc = raf.getChannel();
final long nativeBaseOffset = map(fc, fileOffset, capacity);
state.putNativeBaseOffset(nativeBaseOffset);
// len can be more than the file.length
raf.setLength(capacity);
final MappedByteBuffer mbb = createDummyMbbInstance(nativeBaseOffset);
return new AllocateDirectWritableMap(state, raf, mbb);
}
@Override
public WritableMemory get() {
return this;
}
@Override
public void load() {
madvise();
// Read a byte from each page to bring it into memory. | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/AllocateDirectWritableMap.java
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;
import sun.misc.Cleaner;
import sun.nio.ch.FileChannelImpl;
final long fileOffset = state.getFileOffset();
final long capacity = state.getCapacity();
checkOffsetAndCapacity(fileOffset, capacity);
final File file = state.getFile();
if (isFileReadOnly(file)) {
throw new ReadOnlyMemoryException("File is read-only.");
}
final String mode = "rw";
final RandomAccessFile raf = new RandomAccessFile(file, mode);
final FileChannel fc = raf.getChannel();
final long nativeBaseOffset = map(fc, fileOffset, capacity);
state.putNativeBaseOffset(nativeBaseOffset);
// len can be more than the file.length
raf.setLength(capacity);
final MappedByteBuffer mbb = createDummyMbbInstance(nativeBaseOffset);
return new AllocateDirectWritableMap(state, raf, mbb);
}
@Override
public WritableMemory get() {
return this;
}
@Override
public void load() {
madvise();
// Read a byte from each page to bring it into memory. | final int ps = unsafe.pageSize(); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | final MemoryState state = new MemoryState();
state.putCapacity(capacityBytes);
state.putMemoryRequest(memReq);
return (WritableResourceHandler) AllocateDirect.allocDirect(state);
}
//REGIONS
/**
* Returns a writable region of this WritableMemory
* @param offsetBytes the starting offset with respect to this WritableMemory
* @param capacityBytes the capacity of the region in bytes
* @return a writable region of this WritableMemory
*/
public abstract WritableMemory writableRegion(long offsetBytes, long capacityBytes);
/**
* Returns a read-only version of this memory
* @return a read-only version of this memory
*/
public abstract Memory asReadOnly();
//ALLOCATE HEAP VIA AUTOMATIC BYTE ARRAY
/**
* Creates on-heap WritableMemory with the given capacity
* @param capacityBytes the given capacity in bytes
* @return WritableMemory for write operations
*/
public static WritableMemory allocate(final int capacityBytes) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(new byte[capacityBytes]); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
final MemoryState state = new MemoryState();
state.putCapacity(capacityBytes);
state.putMemoryRequest(memReq);
return (WritableResourceHandler) AllocateDirect.allocDirect(state);
}
//REGIONS
/**
* Returns a writable region of this WritableMemory
* @param offsetBytes the starting offset with respect to this WritableMemory
* @param capacityBytes the capacity of the region in bytes
* @return a writable region of this WritableMemory
*/
public abstract WritableMemory writableRegion(long offsetBytes, long capacityBytes);
/**
* Returns a read-only version of this memory
* @return a read-only version of this memory
*/
public abstract Memory asReadOnly();
//ALLOCATE HEAP VIA AUTOMATIC BYTE ARRAY
/**
* Creates on-heap WritableMemory with the given capacity
* @param capacityBytes the given capacity in bytes
* @return WritableMemory for write operations
*/
public static WritableMemory allocate(final int capacityBytes) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(new byte[capacityBytes]); | state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | /**
* Returns a read-only version of this memory
* @return a read-only version of this memory
*/
public abstract Memory asReadOnly();
//ALLOCATE HEAP VIA AUTOMATIC BYTE ARRAY
/**
* Creates on-heap WritableMemory with the given capacity
* @param capacityBytes the given capacity in bytes
* @return WritableMemory for write operations
*/
public static WritableMemory allocate(final int capacityBytes) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(new byte[capacityBytes]);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(capacityBytes);
return new WritableMemoryImpl(state);
}
//ACCESS PRIMITIVE HEAP ARRAYS for write
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
* Returns a read-only version of this memory
* @return a read-only version of this memory
*/
public abstract Memory asReadOnly();
//ALLOCATE HEAP VIA AUTOMATIC BYTE ARRAY
/**
* Creates on-heap WritableMemory with the given capacity
* @param capacityBytes the given capacity in bytes
* @return WritableMemory for write operations
*/
public static WritableMemory allocate(final int capacityBytes) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(new byte[capacityBytes]);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(capacityBytes);
return new WritableMemoryImpl(state);
}
//ACCESS PRIMITIVE HEAP ARRAYS for write
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | * Returns a read-only version of this memory
* @return a read-only version of this memory
*/
public abstract Memory asReadOnly();
//ALLOCATE HEAP VIA AUTOMATIC BYTE ARRAY
/**
* Creates on-heap WritableMemory with the given capacity
* @param capacityBytes the given capacity in bytes
* @return WritableMemory for write operations
*/
public static WritableMemory allocate(final int capacityBytes) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(new byte[capacityBytes]);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(capacityBytes);
return new WritableMemoryImpl(state);
}
//ACCESS PRIMITIVE HEAP ARRAYS for write
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
* Returns a read-only version of this memory
* @return a read-only version of this memory
*/
public abstract Memory asReadOnly();
//ALLOCATE HEAP VIA AUTOMATIC BYTE ARRAY
/**
* Creates on-heap WritableMemory with the given capacity
* @param capacityBytes the given capacity in bytes
* @return WritableMemory for write operations
*/
public static WritableMemory allocate(final int capacityBytes) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(new byte[capacityBytes]);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(capacityBytes);
return new WritableMemoryImpl(state);
}
//ACCESS PRIMITIVE HEAP ARRAYS for write
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET); | state.putCapacity(arr.length << BOOLEAN_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | state.putUnsafeObject(new byte[capacityBytes]);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(capacityBytes);
return new WritableMemoryImpl(state);
}
//ACCESS PRIMITIVE HEAP ARRAYS for write
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
state.putUnsafeObject(new byte[capacityBytes]);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(capacityBytes);
return new WritableMemoryImpl(state);
}
//ACCESS PRIMITIVE HEAP ARRAYS for write
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET); | state.putCapacity(arr.length << BYTE_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static WritableMemory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static WritableMemory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static WritableMemory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static WritableMemory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET); | state.putCapacity(arr.length << CHAR_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static WritableMemory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static WritableMemory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static WritableMemory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static WritableMemory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET); | state.putCapacity(arr.length << SHORT_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static WritableMemory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET); | state.putCapacity(arr.length << INT_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static WritableMemory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET); | state.putCapacity(arr.length << LONG_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static WritableMemory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET); | state.putCapacity(arr.length << FLOAT_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET);
state.putCapacity(arr.length << FLOAT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final double[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET);
state.putCapacity(arr.length << FLOAT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final double[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_DOUBLE_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/WritableMemory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET);
state.putCapacity(arr.length << FLOAT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final double[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_DOUBLE_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
// Path: src/main/java/com/yahoo/memory4/WritableMemory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static WritableMemory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET);
state.putCapacity(arr.length << FLOAT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for write operations
* @param arr the given primitive array
* @return WritableMemory for write operations
*/
public static WritableMemory wrap(final double[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_DOUBLE_BASE_OFFSET); | state.putCapacity(arr.length << DOUBLE_SHIFT); |
DataSketches/experimental | src/test/java/com/yahoo/memory4/AllocateDirectMapTest.java | // Path: src/main/java/com/yahoo/memory4/ResourceHandler.java
// enum ResourceType { MEMORY_MAPPED_FILE, NATIVE_MEMORY }
| import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.File;
import org.testng.annotations.Test;
import com.yahoo.memory4.ResourceHandler.ResourceType; | /*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
public class AllocateDirectMapTest {
@Test
public void simpleMap() throws Exception {
File file = new File(getClass().getClassLoader().getResource("GettysburgAddress.txt").getFile());
try (ResourceHandler rh = Memory.map(file)) { | // Path: src/main/java/com/yahoo/memory4/ResourceHandler.java
// enum ResourceType { MEMORY_MAPPED_FILE, NATIVE_MEMORY }
// Path: src/test/java/com/yahoo/memory4/AllocateDirectMapTest.java
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.File;
import org.testng.annotations.Test;
import com.yahoo.memory4.ResourceHandler.ResourceType;
/*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
public class AllocateDirectMapTest {
@Test
public void simpleMap() throws Exception {
File file = new File(getClass().getClassLoader().getResource("GettysburgAddress.txt").getFile());
try (ResourceHandler rh = Memory.map(file)) { | ResourceType type = rh.getResourceType(); |
DataSketches/experimental | src/test/java/com/yahoo/memory4/UtilTest.java | // Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String characterPad(final String s, final int fieldLength, final char padChar,
// final boolean postpend) {
// final char[] chArr = s.toCharArray();
// final int sLen = chArr.length;
// if (sLen < fieldLength) {
// final char[] out = new char[fieldLength];
// final int blanks = fieldLength - sLen;
//
// if (postpend) {
// for (int i = 0; i < sLen; i++) {
// out[i] = chArr[i];
// }
// for (int i = sLen; i < fieldLength; i++) {
// out[i] = padChar;
// }
// } else { //prepend
// for (int i = 0; i < blanks; i++) {
// out[i] = padChar;
// }
// for (int i = blanks; i < fieldLength; i++) {
// out[i] = chArr[i - blanks];
// }
// }
//
// return String.valueOf(out);
// }
// return s;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static WritableMemory memoryRequestHandler(final WritableMemory origMem,
// final long newCapacityBytes, final boolean copy) {
// final MemoryRequest memReq = origMem.getMemoryRequest();
// if (memReq == null) {
// throw new IllegalArgumentException(
// "Insufficient space. MemoryRequest callback cannot be null.");
// }
// final WritableMemory newDstMem = (copy)
// ? memReq.request(origMem, origMem.getCapacity(), newCapacityBytes)
// : memReq.request(newCapacityBytes);
//
// if (newDstMem == null) {
// throw new IllegalArgumentException(
// "Insufficient space and Memory returned by MemoryRequest cannot be null.");
// }
// final long newCap = newDstMem.getCapacity(); //may be more than requested, but not less.
// if (newCap < newCapacityBytes) {
// memReq.closeRequest(newDstMem);
// throw new IllegalArgumentException(
// "Insufficient space. Memory returned by MemoryRequest is not the requested capacity: "
// + "Returned: " + newCap + " < Requested: " + newCapacityBytes);
// }
//
// if (copy) { //copy and request free.
// origMem.copyTo(0, newDstMem, 0, Math.min(origMem.getCapacity(), newCap));
// memReq.closeRequest(origMem, newDstMem);
// }
// return newDstMem;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String zeroPad(final String s, final int fieldLength) {
// return characterPad(s, fieldLength, '0', false);
// }
| import static com.yahoo.memory4.Util.characterPad;
import static com.yahoo.memory4.Util.memoryRequestHandler;
import static com.yahoo.memory4.Util.zeroPad;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test; | /*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
public class UtilTest {
@Test
public void checkGoodCallback() {
int k = 128;
GoodMemoryManager goodMM = new GoodMemoryManager();
WritableMemory origMem = goodMM.request(k);
//expand X 2 | // Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String characterPad(final String s, final int fieldLength, final char padChar,
// final boolean postpend) {
// final char[] chArr = s.toCharArray();
// final int sLen = chArr.length;
// if (sLen < fieldLength) {
// final char[] out = new char[fieldLength];
// final int blanks = fieldLength - sLen;
//
// if (postpend) {
// for (int i = 0; i < sLen; i++) {
// out[i] = chArr[i];
// }
// for (int i = sLen; i < fieldLength; i++) {
// out[i] = padChar;
// }
// } else { //prepend
// for (int i = 0; i < blanks; i++) {
// out[i] = padChar;
// }
// for (int i = blanks; i < fieldLength; i++) {
// out[i] = chArr[i - blanks];
// }
// }
//
// return String.valueOf(out);
// }
// return s;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static WritableMemory memoryRequestHandler(final WritableMemory origMem,
// final long newCapacityBytes, final boolean copy) {
// final MemoryRequest memReq = origMem.getMemoryRequest();
// if (memReq == null) {
// throw new IllegalArgumentException(
// "Insufficient space. MemoryRequest callback cannot be null.");
// }
// final WritableMemory newDstMem = (copy)
// ? memReq.request(origMem, origMem.getCapacity(), newCapacityBytes)
// : memReq.request(newCapacityBytes);
//
// if (newDstMem == null) {
// throw new IllegalArgumentException(
// "Insufficient space and Memory returned by MemoryRequest cannot be null.");
// }
// final long newCap = newDstMem.getCapacity(); //may be more than requested, but not less.
// if (newCap < newCapacityBytes) {
// memReq.closeRequest(newDstMem);
// throw new IllegalArgumentException(
// "Insufficient space. Memory returned by MemoryRequest is not the requested capacity: "
// + "Returned: " + newCap + " < Requested: " + newCapacityBytes);
// }
//
// if (copy) { //copy and request free.
// origMem.copyTo(0, newDstMem, 0, Math.min(origMem.getCapacity(), newCap));
// memReq.closeRequest(origMem, newDstMem);
// }
// return newDstMem;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String zeroPad(final String s, final int fieldLength) {
// return characterPad(s, fieldLength, '0', false);
// }
// Path: src/test/java/com/yahoo/memory4/UtilTest.java
import static com.yahoo.memory4.Util.characterPad;
import static com.yahoo.memory4.Util.memoryRequestHandler;
import static com.yahoo.memory4.Util.zeroPad;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
/*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
public class UtilTest {
@Test
public void checkGoodCallback() {
int k = 128;
GoodMemoryManager goodMM = new GoodMemoryManager();
WritableMemory origMem = goodMM.request(k);
//expand X 2 | WritableMemory newMem = memoryRequestHandler(origMem, 2 * k, true); |
DataSketches/experimental | src/test/java/com/yahoo/memory4/UtilTest.java | // Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String characterPad(final String s, final int fieldLength, final char padChar,
// final boolean postpend) {
// final char[] chArr = s.toCharArray();
// final int sLen = chArr.length;
// if (sLen < fieldLength) {
// final char[] out = new char[fieldLength];
// final int blanks = fieldLength - sLen;
//
// if (postpend) {
// for (int i = 0; i < sLen; i++) {
// out[i] = chArr[i];
// }
// for (int i = sLen; i < fieldLength; i++) {
// out[i] = padChar;
// }
// } else { //prepend
// for (int i = 0; i < blanks; i++) {
// out[i] = padChar;
// }
// for (int i = blanks; i < fieldLength; i++) {
// out[i] = chArr[i - blanks];
// }
// }
//
// return String.valueOf(out);
// }
// return s;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static WritableMemory memoryRequestHandler(final WritableMemory origMem,
// final long newCapacityBytes, final boolean copy) {
// final MemoryRequest memReq = origMem.getMemoryRequest();
// if (memReq == null) {
// throw new IllegalArgumentException(
// "Insufficient space. MemoryRequest callback cannot be null.");
// }
// final WritableMemory newDstMem = (copy)
// ? memReq.request(origMem, origMem.getCapacity(), newCapacityBytes)
// : memReq.request(newCapacityBytes);
//
// if (newDstMem == null) {
// throw new IllegalArgumentException(
// "Insufficient space and Memory returned by MemoryRequest cannot be null.");
// }
// final long newCap = newDstMem.getCapacity(); //may be more than requested, but not less.
// if (newCap < newCapacityBytes) {
// memReq.closeRequest(newDstMem);
// throw new IllegalArgumentException(
// "Insufficient space. Memory returned by MemoryRequest is not the requested capacity: "
// + "Returned: " + newCap + " < Requested: " + newCapacityBytes);
// }
//
// if (copy) { //copy and request free.
// origMem.copyTo(0, newDstMem, 0, Math.min(origMem.getCapacity(), newCap));
// memReq.closeRequest(origMem, newDstMem);
// }
// return newDstMem;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String zeroPad(final String s, final int fieldLength) {
// return characterPad(s, fieldLength, '0', false);
// }
| import static com.yahoo.memory4.Util.characterPad;
import static com.yahoo.memory4.Util.memoryRequestHandler;
import static com.yahoo.memory4.Util.zeroPad;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test; | @Override //not used
public void closeRequest(WritableMemory memToFree, WritableMemory newMem) { }
} //end class BadMemoryManager1
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//Binary Search
@Test
public void checkBinarySearch() {
int k = 1024; //longs
WritableMemory wMem = WritableMemory.allocate(k << 3); //1024 longs
for (int i = 0; i < k; i++) { wMem.putLong(i << 3, i); }
long idx = Util.binarySearchLongs(wMem, 0, k - 1, k / 2);
long val = wMem.getLong(idx << 3);
assertEquals(idx, k/2);
assertEquals(val, k/2);
idx = Util.binarySearchLongs(wMem, 0, k - 1, k);
assertEquals(idx, -1024);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void checkBoundsTest() {
UnsafeUtil.checkBounds(999, 2, 1000);
}
@Test
public void checkPadding() {
String s = "123"; | // Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String characterPad(final String s, final int fieldLength, final char padChar,
// final boolean postpend) {
// final char[] chArr = s.toCharArray();
// final int sLen = chArr.length;
// if (sLen < fieldLength) {
// final char[] out = new char[fieldLength];
// final int blanks = fieldLength - sLen;
//
// if (postpend) {
// for (int i = 0; i < sLen; i++) {
// out[i] = chArr[i];
// }
// for (int i = sLen; i < fieldLength; i++) {
// out[i] = padChar;
// }
// } else { //prepend
// for (int i = 0; i < blanks; i++) {
// out[i] = padChar;
// }
// for (int i = blanks; i < fieldLength; i++) {
// out[i] = chArr[i - blanks];
// }
// }
//
// return String.valueOf(out);
// }
// return s;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static WritableMemory memoryRequestHandler(final WritableMemory origMem,
// final long newCapacityBytes, final boolean copy) {
// final MemoryRequest memReq = origMem.getMemoryRequest();
// if (memReq == null) {
// throw new IllegalArgumentException(
// "Insufficient space. MemoryRequest callback cannot be null.");
// }
// final WritableMemory newDstMem = (copy)
// ? memReq.request(origMem, origMem.getCapacity(), newCapacityBytes)
// : memReq.request(newCapacityBytes);
//
// if (newDstMem == null) {
// throw new IllegalArgumentException(
// "Insufficient space and Memory returned by MemoryRequest cannot be null.");
// }
// final long newCap = newDstMem.getCapacity(); //may be more than requested, but not less.
// if (newCap < newCapacityBytes) {
// memReq.closeRequest(newDstMem);
// throw new IllegalArgumentException(
// "Insufficient space. Memory returned by MemoryRequest is not the requested capacity: "
// + "Returned: " + newCap + " < Requested: " + newCapacityBytes);
// }
//
// if (copy) { //copy and request free.
// origMem.copyTo(0, newDstMem, 0, Math.min(origMem.getCapacity(), newCap));
// memReq.closeRequest(origMem, newDstMem);
// }
// return newDstMem;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String zeroPad(final String s, final int fieldLength) {
// return characterPad(s, fieldLength, '0', false);
// }
// Path: src/test/java/com/yahoo/memory4/UtilTest.java
import static com.yahoo.memory4.Util.characterPad;
import static com.yahoo.memory4.Util.memoryRequestHandler;
import static com.yahoo.memory4.Util.zeroPad;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
@Override //not used
public void closeRequest(WritableMemory memToFree, WritableMemory newMem) { }
} //end class BadMemoryManager1
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//Binary Search
@Test
public void checkBinarySearch() {
int k = 1024; //longs
WritableMemory wMem = WritableMemory.allocate(k << 3); //1024 longs
for (int i = 0; i < k; i++) { wMem.putLong(i << 3, i); }
long idx = Util.binarySearchLongs(wMem, 0, k - 1, k / 2);
long val = wMem.getLong(idx << 3);
assertEquals(idx, k/2);
assertEquals(val, k/2);
idx = Util.binarySearchLongs(wMem, 0, k - 1, k);
assertEquals(idx, -1024);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void checkBoundsTest() {
UnsafeUtil.checkBounds(999, 2, 1000);
}
@Test
public void checkPadding() {
String s = "123"; | String t = zeroPad(s, 4); |
DataSketches/experimental | src/test/java/com/yahoo/memory4/UtilTest.java | // Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String characterPad(final String s, final int fieldLength, final char padChar,
// final boolean postpend) {
// final char[] chArr = s.toCharArray();
// final int sLen = chArr.length;
// if (sLen < fieldLength) {
// final char[] out = new char[fieldLength];
// final int blanks = fieldLength - sLen;
//
// if (postpend) {
// for (int i = 0; i < sLen; i++) {
// out[i] = chArr[i];
// }
// for (int i = sLen; i < fieldLength; i++) {
// out[i] = padChar;
// }
// } else { //prepend
// for (int i = 0; i < blanks; i++) {
// out[i] = padChar;
// }
// for (int i = blanks; i < fieldLength; i++) {
// out[i] = chArr[i - blanks];
// }
// }
//
// return String.valueOf(out);
// }
// return s;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static WritableMemory memoryRequestHandler(final WritableMemory origMem,
// final long newCapacityBytes, final boolean copy) {
// final MemoryRequest memReq = origMem.getMemoryRequest();
// if (memReq == null) {
// throw new IllegalArgumentException(
// "Insufficient space. MemoryRequest callback cannot be null.");
// }
// final WritableMemory newDstMem = (copy)
// ? memReq.request(origMem, origMem.getCapacity(), newCapacityBytes)
// : memReq.request(newCapacityBytes);
//
// if (newDstMem == null) {
// throw new IllegalArgumentException(
// "Insufficient space and Memory returned by MemoryRequest cannot be null.");
// }
// final long newCap = newDstMem.getCapacity(); //may be more than requested, but not less.
// if (newCap < newCapacityBytes) {
// memReq.closeRequest(newDstMem);
// throw new IllegalArgumentException(
// "Insufficient space. Memory returned by MemoryRequest is not the requested capacity: "
// + "Returned: " + newCap + " < Requested: " + newCapacityBytes);
// }
//
// if (copy) { //copy and request free.
// origMem.copyTo(0, newDstMem, 0, Math.min(origMem.getCapacity(), newCap));
// memReq.closeRequest(origMem, newDstMem);
// }
// return newDstMem;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String zeroPad(final String s, final int fieldLength) {
// return characterPad(s, fieldLength, '0', false);
// }
| import static com.yahoo.memory4.Util.characterPad;
import static com.yahoo.memory4.Util.memoryRequestHandler;
import static com.yahoo.memory4.Util.zeroPad;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test; |
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//Binary Search
@Test
public void checkBinarySearch() {
int k = 1024; //longs
WritableMemory wMem = WritableMemory.allocate(k << 3); //1024 longs
for (int i = 0; i < k; i++) { wMem.putLong(i << 3, i); }
long idx = Util.binarySearchLongs(wMem, 0, k - 1, k / 2);
long val = wMem.getLong(idx << 3);
assertEquals(idx, k/2);
assertEquals(val, k/2);
idx = Util.binarySearchLongs(wMem, 0, k - 1, k);
assertEquals(idx, -1024);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void checkBoundsTest() {
UnsafeUtil.checkBounds(999, 2, 1000);
}
@Test
public void checkPadding() {
String s = "123";
String t = zeroPad(s, 4);
assertTrue(t.startsWith("0"));
| // Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String characterPad(final String s, final int fieldLength, final char padChar,
// final boolean postpend) {
// final char[] chArr = s.toCharArray();
// final int sLen = chArr.length;
// if (sLen < fieldLength) {
// final char[] out = new char[fieldLength];
// final int blanks = fieldLength - sLen;
//
// if (postpend) {
// for (int i = 0; i < sLen; i++) {
// out[i] = chArr[i];
// }
// for (int i = sLen; i < fieldLength; i++) {
// out[i] = padChar;
// }
// } else { //prepend
// for (int i = 0; i < blanks; i++) {
// out[i] = padChar;
// }
// for (int i = blanks; i < fieldLength; i++) {
// out[i] = chArr[i - blanks];
// }
// }
//
// return String.valueOf(out);
// }
// return s;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static WritableMemory memoryRequestHandler(final WritableMemory origMem,
// final long newCapacityBytes, final boolean copy) {
// final MemoryRequest memReq = origMem.getMemoryRequest();
// if (memReq == null) {
// throw new IllegalArgumentException(
// "Insufficient space. MemoryRequest callback cannot be null.");
// }
// final WritableMemory newDstMem = (copy)
// ? memReq.request(origMem, origMem.getCapacity(), newCapacityBytes)
// : memReq.request(newCapacityBytes);
//
// if (newDstMem == null) {
// throw new IllegalArgumentException(
// "Insufficient space and Memory returned by MemoryRequest cannot be null.");
// }
// final long newCap = newDstMem.getCapacity(); //may be more than requested, but not less.
// if (newCap < newCapacityBytes) {
// memReq.closeRequest(newDstMem);
// throw new IllegalArgumentException(
// "Insufficient space. Memory returned by MemoryRequest is not the requested capacity: "
// + "Returned: " + newCap + " < Requested: " + newCapacityBytes);
// }
//
// if (copy) { //copy and request free.
// origMem.copyTo(0, newDstMem, 0, Math.min(origMem.getCapacity(), newCap));
// memReq.closeRequest(origMem, newDstMem);
// }
// return newDstMem;
// }
//
// Path: src/main/java/com/yahoo/memory4/Util.java
// public static final String zeroPad(final String s, final int fieldLength) {
// return characterPad(s, fieldLength, '0', false);
// }
// Path: src/test/java/com/yahoo/memory4/UtilTest.java
import static com.yahoo.memory4.Util.characterPad;
import static com.yahoo.memory4.Util.memoryRequestHandler;
import static com.yahoo.memory4.Util.zeroPad;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//Binary Search
@Test
public void checkBinarySearch() {
int k = 1024; //longs
WritableMemory wMem = WritableMemory.allocate(k << 3); //1024 longs
for (int i = 0; i < k; i++) { wMem.putLong(i << 3, i); }
long idx = Util.binarySearchLongs(wMem, 0, k - 1, k / 2);
long val = wMem.getLong(idx << 3);
assertEquals(idx, k/2);
assertEquals(val, k/2);
idx = Util.binarySearchLongs(wMem, 0, k - 1, k);
assertEquals(idx, -1024);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void checkBoundsTest() {
UnsafeUtil.checkBounds(999, 2, 1000);
}
@Test
public void checkPadding() {
String s = "123";
String t = zeroPad(s, 4);
assertTrue(t.startsWith("0"));
| t = characterPad(s, 4, '0', true); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/AllocateDirectMap.java | // Path: src/main/java/com/yahoo/memory4/AllocateDirectWritableMap.java
// static final boolean isFileReadOnly(final File file) {
// if (System.getProperty("os.name").startsWith("Windows")) {
// return !file.canWrite();
// }
// //All Unix-like OSes
// final Path path = Paths.get(file.getAbsolutePath());
// PosixFileAttributes attributes = null;
// try {
// attributes = Files.getFileAttributeView(path, PosixFileAttributeView.class).readAttributes();
// } catch (final IOException e) {
// // File presence is guaranteed. Ignore
// e.printStackTrace();
// }
// if (attributes != null) {
// // A file is read-only in Linux only when it has 0444 permissions.
// // Here we are going to ignore the Owner W,E bits to allow root/owner testing.
// final Set<PosixFilePermission> permissions = attributes.permissions();
// int bits = 0;
// bits |= ((permissions.contains(PosixFilePermission.OWNER_READ)) ? 1 << 8 : 0);
// //bits |= ((permissions.contains(PosixFilePermission.OWNER_WRITE)) ? 1 << 7 : 0);
// //bits |= ((permissions.contains(PosixFilePermission.OWNER_EXECUTE)) ? 1 << 6 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_READ)) ? 1 << 5 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_WRITE)) ? 1 << 4 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_EXECUTE)) ? 1 << 3 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_READ)) ? 1 << 2 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_WRITE)) ? 1 << 1 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_EXECUTE)) ? 1 : 0);
// //System.out.println(Util.zeroPad(Integer.toBinaryString(bits), 32));
// //System.out.println(Util.zeroPad(Integer.toOctalString(bits), 4));
// if (bits == 0444) {
// return true;
// }
// }
// return false;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.AllocateDirectWritableMap.isFileReadOnly;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.io.FileDescriptor;
import java.io.RandomAccessFile;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import sun.misc.Cleaner;
import sun.nio.ch.FileChannelImpl; | /*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
/**
* Allocates direct memory used to memory map files for read operations
* (including those > 2GB).
*
* @author Praveenkumar Venkatesan
* @author Lee Rhodes
*/
final class AllocateDirectMap extends WritableMemoryImpl implements ResourceHandler {
//private RandomAccessFile randomAccessFile = null; //only used in writable version
private MappedByteBuffer dummyMbbInstance = null;
private final Cleaner cleaner;
private AllocateDirectMap(final MemoryState state, final RandomAccessFile raf,
final MappedByteBuffer mbb) {
super(state);
//this.randomAccessFile = raf; //only used in writable version
this.dummyMbbInstance = mbb;
this.cleaner = Cleaner.create(this,
new Deallocator(raf, state));
}
/**
* Factory method for memory mapping a file. This should be called only if read access
* is desired.
*
* <p>Memory maps a file directly in off heap leveraging native map0 method used in
* FileChannelImpl.c. The owner will have read access to that address space.</p>
*
* @param file File to be mapped
* @param offset Memory map starting from this offset in the file
* @param capacity Memory map at most capacity bytes > 0 starting from {@code offset}
* @param readOnlyRequest true if requesting method requests read-only interface.
* @return A new MemoryMappedFile
* @throws Exception file not found or RuntimeException, etc.
*/
@SuppressWarnings("resource")
static AllocateDirectMap map(final MemoryState state) throws Exception {
final long fileOffset = state.getFileOffset();
final long capacity = state.getCapacity();
checkOffsetAndCapacity(fileOffset, capacity);
final File file = state.getFile();
| // Path: src/main/java/com/yahoo/memory4/AllocateDirectWritableMap.java
// static final boolean isFileReadOnly(final File file) {
// if (System.getProperty("os.name").startsWith("Windows")) {
// return !file.canWrite();
// }
// //All Unix-like OSes
// final Path path = Paths.get(file.getAbsolutePath());
// PosixFileAttributes attributes = null;
// try {
// attributes = Files.getFileAttributeView(path, PosixFileAttributeView.class).readAttributes();
// } catch (final IOException e) {
// // File presence is guaranteed. Ignore
// e.printStackTrace();
// }
// if (attributes != null) {
// // A file is read-only in Linux only when it has 0444 permissions.
// // Here we are going to ignore the Owner W,E bits to allow root/owner testing.
// final Set<PosixFilePermission> permissions = attributes.permissions();
// int bits = 0;
// bits |= ((permissions.contains(PosixFilePermission.OWNER_READ)) ? 1 << 8 : 0);
// //bits |= ((permissions.contains(PosixFilePermission.OWNER_WRITE)) ? 1 << 7 : 0);
// //bits |= ((permissions.contains(PosixFilePermission.OWNER_EXECUTE)) ? 1 << 6 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_READ)) ? 1 << 5 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_WRITE)) ? 1 << 4 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_EXECUTE)) ? 1 << 3 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_READ)) ? 1 << 2 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_WRITE)) ? 1 << 1 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_EXECUTE)) ? 1 : 0);
// //System.out.println(Util.zeroPad(Integer.toBinaryString(bits), 32));
// //System.out.println(Util.zeroPad(Integer.toOctalString(bits), 4));
// if (bits == 0444) {
// return true;
// }
// }
// return false;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/AllocateDirectMap.java
import static com.yahoo.memory4.AllocateDirectWritableMap.isFileReadOnly;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.io.FileDescriptor;
import java.io.RandomAccessFile;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import sun.misc.Cleaner;
import sun.nio.ch.FileChannelImpl;
/*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
/**
* Allocates direct memory used to memory map files for read operations
* (including those > 2GB).
*
* @author Praveenkumar Venkatesan
* @author Lee Rhodes
*/
final class AllocateDirectMap extends WritableMemoryImpl implements ResourceHandler {
//private RandomAccessFile randomAccessFile = null; //only used in writable version
private MappedByteBuffer dummyMbbInstance = null;
private final Cleaner cleaner;
private AllocateDirectMap(final MemoryState state, final RandomAccessFile raf,
final MappedByteBuffer mbb) {
super(state);
//this.randomAccessFile = raf; //only used in writable version
this.dummyMbbInstance = mbb;
this.cleaner = Cleaner.create(this,
new Deallocator(raf, state));
}
/**
* Factory method for memory mapping a file. This should be called only if read access
* is desired.
*
* <p>Memory maps a file directly in off heap leveraging native map0 method used in
* FileChannelImpl.c. The owner will have read access to that address space.</p>
*
* @param file File to be mapped
* @param offset Memory map starting from this offset in the file
* @param capacity Memory map at most capacity bytes > 0 starting from {@code offset}
* @param readOnlyRequest true if requesting method requests read-only interface.
* @return A new MemoryMappedFile
* @throws Exception file not found or RuntimeException, etc.
*/
@SuppressWarnings("resource")
static AllocateDirectMap map(final MemoryState state) throws Exception {
final long fileOffset = state.getFileOffset();
final long capacity = state.getCapacity();
checkOffsetAndCapacity(fileOffset, capacity);
final File file = state.getFile();
| if (isFileReadOnly(file)) { |
DataSketches/experimental | src/main/java/com/yahoo/memory4/AllocateDirectMap.java | // Path: src/main/java/com/yahoo/memory4/AllocateDirectWritableMap.java
// static final boolean isFileReadOnly(final File file) {
// if (System.getProperty("os.name").startsWith("Windows")) {
// return !file.canWrite();
// }
// //All Unix-like OSes
// final Path path = Paths.get(file.getAbsolutePath());
// PosixFileAttributes attributes = null;
// try {
// attributes = Files.getFileAttributeView(path, PosixFileAttributeView.class).readAttributes();
// } catch (final IOException e) {
// // File presence is guaranteed. Ignore
// e.printStackTrace();
// }
// if (attributes != null) {
// // A file is read-only in Linux only when it has 0444 permissions.
// // Here we are going to ignore the Owner W,E bits to allow root/owner testing.
// final Set<PosixFilePermission> permissions = attributes.permissions();
// int bits = 0;
// bits |= ((permissions.contains(PosixFilePermission.OWNER_READ)) ? 1 << 8 : 0);
// //bits |= ((permissions.contains(PosixFilePermission.OWNER_WRITE)) ? 1 << 7 : 0);
// //bits |= ((permissions.contains(PosixFilePermission.OWNER_EXECUTE)) ? 1 << 6 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_READ)) ? 1 << 5 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_WRITE)) ? 1 << 4 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_EXECUTE)) ? 1 << 3 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_READ)) ? 1 << 2 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_WRITE)) ? 1 << 1 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_EXECUTE)) ? 1 : 0);
// //System.out.println(Util.zeroPad(Integer.toBinaryString(bits), 32));
// //System.out.println(Util.zeroPad(Integer.toOctalString(bits), 4));
// if (bits == 0444) {
// return true;
// }
// }
// return false;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.AllocateDirectWritableMap.isFileReadOnly;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.io.FileDescriptor;
import java.io.RandomAccessFile;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import sun.misc.Cleaner;
import sun.nio.ch.FileChannelImpl; | final long capacity = state.getCapacity();
checkOffsetAndCapacity(fileOffset, capacity);
final File file = state.getFile();
if (isFileReadOnly(file)) {
state.setResourceReadOnly(); //The file itself could be writable
}
final String mode = "rw"; //we can't map it unless we use rw mode
final RandomAccessFile raf = new RandomAccessFile(file, mode);
final FileChannel fc = raf.getChannel();
final long nativeBaseOffset = map(fc, fileOffset, capacity);
state.putNativeBaseOffset(nativeBaseOffset);
// len can be more than the file.length
raf.setLength(capacity);
final MappedByteBuffer mbb = createDummyMbbInstance(nativeBaseOffset);
return new AllocateDirectMap(state, raf, mbb);
}
@Override
public Memory get() {
return this;
}
@Override
public void load() {
madvise();
// Read a byte from each page to bring it into memory. | // Path: src/main/java/com/yahoo/memory4/AllocateDirectWritableMap.java
// static final boolean isFileReadOnly(final File file) {
// if (System.getProperty("os.name").startsWith("Windows")) {
// return !file.canWrite();
// }
// //All Unix-like OSes
// final Path path = Paths.get(file.getAbsolutePath());
// PosixFileAttributes attributes = null;
// try {
// attributes = Files.getFileAttributeView(path, PosixFileAttributeView.class).readAttributes();
// } catch (final IOException e) {
// // File presence is guaranteed. Ignore
// e.printStackTrace();
// }
// if (attributes != null) {
// // A file is read-only in Linux only when it has 0444 permissions.
// // Here we are going to ignore the Owner W,E bits to allow root/owner testing.
// final Set<PosixFilePermission> permissions = attributes.permissions();
// int bits = 0;
// bits |= ((permissions.contains(PosixFilePermission.OWNER_READ)) ? 1 << 8 : 0);
// //bits |= ((permissions.contains(PosixFilePermission.OWNER_WRITE)) ? 1 << 7 : 0);
// //bits |= ((permissions.contains(PosixFilePermission.OWNER_EXECUTE)) ? 1 << 6 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_READ)) ? 1 << 5 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_WRITE)) ? 1 << 4 : 0);
// bits |= ((permissions.contains(PosixFilePermission.GROUP_EXECUTE)) ? 1 << 3 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_READ)) ? 1 << 2 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_WRITE)) ? 1 << 1 : 0);
// bits |= ((permissions.contains(PosixFilePermission.OTHERS_EXECUTE)) ? 1 : 0);
// //System.out.println(Util.zeroPad(Integer.toBinaryString(bits), 32));
// //System.out.println(Util.zeroPad(Integer.toOctalString(bits), 4));
// if (bits == 0444) {
// return true;
// }
// }
// return false;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/AllocateDirectMap.java
import static com.yahoo.memory4.AllocateDirectWritableMap.isFileReadOnly;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.io.FileDescriptor;
import java.io.RandomAccessFile;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import sun.misc.Cleaner;
import sun.nio.ch.FileChannelImpl;
final long capacity = state.getCapacity();
checkOffsetAndCapacity(fileOffset, capacity);
final File file = state.getFile();
if (isFileReadOnly(file)) {
state.setResourceReadOnly(); //The file itself could be writable
}
final String mode = "rw"; //we can't map it unless we use rw mode
final RandomAccessFile raf = new RandomAccessFile(file, mode);
final FileChannel fc = raf.getChannel();
final long nativeBaseOffset = map(fc, fileOffset, capacity);
state.putNativeBaseOffset(nativeBaseOffset);
// len can be more than the file.length
raf.setLength(capacity);
final MappedByteBuffer mbb = createDummyMbbInstance(nativeBaseOffset);
return new AllocateDirectMap(state, raf, mbb);
}
@Override
public Memory get() {
return this;
}
@Override
public void load() {
madvise();
// Read a byte from each page to bring it into memory. | final int ps = unsafe.pageSize(); |
DataSketches/experimental | src/test/java/com/yahoo/memory4/AllocateDirectWritableMapTest.java | // Path: src/main/java/com/yahoo/memory4/AllocateDirectWritableMap.java
// static final void checkOffsetAndCapacity(final long offset, final long capacity) {
// if (((offset) | (capacity - 1L) | (offset + capacity)) < 0) {
// throw new IllegalArgumentException(
// "offset: " + offset + ", capacity: " + capacity
// + ", offset + capacity: " + (offset + capacity));
// }
// }
//
// Path: src/main/java/com/yahoo/memory4/ResourceHandler.java
// enum ResourceType { MEMORY_MAPPED_FILE, NATIVE_MEMORY }
| import static com.yahoo.memory4.AllocateDirectWritableMap.checkOffsetAndCapacity;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import org.testng.annotations.Test;
import com.yahoo.memory4.ResourceHandler.ResourceType; | public void simpleMap2() throws Exception {
File file = new File(getClass().getClassLoader().getResource("GettysburgAddress.txt").getFile());
try (WritableResourceHandler rh = WritableMemory.map(file)) {
rh.close();
}
}
@Test
public void testForce() throws Exception {
String origStr = "Corectng spellng mistks";
File origFile = createFile("force_original.txt", origStr); //23
origFile.setWritable(true, false);
long origBytes = origFile.length();
String correctStr = "Correcting spelling mistakes"; //28
byte[] correctByteArr = correctStr.getBytes(UTF_8);
long corrBytes = correctByteArr.length;
try (ResourceHandler rh = Memory.map(origFile, 0, origBytes)) {
Memory map = rh.get();
rh.load();
assertTrue(rh.isLoaded());
//confirm orig string
byte[] buf = new byte[(int)origBytes];
map.getByteArray(0, buf, 0, (int)origBytes);
String bufStr = new String(buf, UTF_8);
assertEquals(bufStr, origStr);
}
try (WritableResourceHandler wrh = WritableMemory.map(origFile, 0, corrBytes)) { //longer
WritableMemory wMap = wrh.get(); | // Path: src/main/java/com/yahoo/memory4/AllocateDirectWritableMap.java
// static final void checkOffsetAndCapacity(final long offset, final long capacity) {
// if (((offset) | (capacity - 1L) | (offset + capacity)) < 0) {
// throw new IllegalArgumentException(
// "offset: " + offset + ", capacity: " + capacity
// + ", offset + capacity: " + (offset + capacity));
// }
// }
//
// Path: src/main/java/com/yahoo/memory4/ResourceHandler.java
// enum ResourceType { MEMORY_MAPPED_FILE, NATIVE_MEMORY }
// Path: src/test/java/com/yahoo/memory4/AllocateDirectWritableMapTest.java
import static com.yahoo.memory4.AllocateDirectWritableMap.checkOffsetAndCapacity;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import org.testng.annotations.Test;
import com.yahoo.memory4.ResourceHandler.ResourceType;
public void simpleMap2() throws Exception {
File file = new File(getClass().getClassLoader().getResource("GettysburgAddress.txt").getFile());
try (WritableResourceHandler rh = WritableMemory.map(file)) {
rh.close();
}
}
@Test
public void testForce() throws Exception {
String origStr = "Corectng spellng mistks";
File origFile = createFile("force_original.txt", origStr); //23
origFile.setWritable(true, false);
long origBytes = origFile.length();
String correctStr = "Correcting spelling mistakes"; //28
byte[] correctByteArr = correctStr.getBytes(UTF_8);
long corrBytes = correctByteArr.length;
try (ResourceHandler rh = Memory.map(origFile, 0, origBytes)) {
Memory map = rh.get();
rh.load();
assertTrue(rh.isLoaded());
//confirm orig string
byte[] buf = new byte[(int)origBytes];
map.getByteArray(0, buf, 0, (int)origBytes);
String bufStr = new String(buf, UTF_8);
assertEquals(bufStr, origStr);
}
try (WritableResourceHandler wrh = WritableMemory.map(origFile, 0, corrBytes)) { //longer
WritableMemory wMap = wrh.get(); | ResourceType type = wrh.getResourceType(); |
DataSketches/experimental | src/test/java/com/yahoo/memory4/AllocateDirectWritableMapTest.java | // Path: src/main/java/com/yahoo/memory4/AllocateDirectWritableMap.java
// static final void checkOffsetAndCapacity(final long offset, final long capacity) {
// if (((offset) | (capacity - 1L) | (offset + capacity)) < 0) {
// throw new IllegalArgumentException(
// "offset: " + offset + ", capacity: " + capacity
// + ", offset + capacity: " + (offset + capacity));
// }
// }
//
// Path: src/main/java/com/yahoo/memory4/ResourceHandler.java
// enum ResourceType { MEMORY_MAPPED_FILE, NATIVE_MEMORY }
| import static com.yahoo.memory4.AllocateDirectWritableMap.checkOffsetAndCapacity;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import org.testng.annotations.Test;
import com.yahoo.memory4.ResourceHandler.ResourceType; | Memory map = rh.get();
rh.load();
assertTrue(rh.isLoaded());
//confirm orig string
byte[] buf = new byte[(int)origBytes];
map.getByteArray(0, buf, 0, (int)origBytes);
String bufStr = new String(buf, UTF_8);
assertEquals(bufStr, origStr);
}
try (WritableResourceHandler wrh = WritableMemory.map(origFile, 0, corrBytes)) { //longer
WritableMemory wMap = wrh.get();
ResourceType type = wrh.getResourceType();
wrh.isResourceType(type);
wrh.load();
assertTrue(wrh.isLoaded());
// over write content
wMap.putByteArray(0, correctByteArr, 0, (int)corrBytes);
wrh.force();
//confirm correct string
byte[] buf = new byte[(int)corrBytes];
wMap.getByteArray(0, buf, 0, (int)corrBytes);
String bufStr = new String(buf, UTF_8);
assertEquals(bufStr, correctStr);
}
}
@Test
public void checkOffsetNCapacity() {
try { | // Path: src/main/java/com/yahoo/memory4/AllocateDirectWritableMap.java
// static final void checkOffsetAndCapacity(final long offset, final long capacity) {
// if (((offset) | (capacity - 1L) | (offset + capacity)) < 0) {
// throw new IllegalArgumentException(
// "offset: " + offset + ", capacity: " + capacity
// + ", offset + capacity: " + (offset + capacity));
// }
// }
//
// Path: src/main/java/com/yahoo/memory4/ResourceHandler.java
// enum ResourceType { MEMORY_MAPPED_FILE, NATIVE_MEMORY }
// Path: src/test/java/com/yahoo/memory4/AllocateDirectWritableMapTest.java
import static com.yahoo.memory4.AllocateDirectWritableMap.checkOffsetAndCapacity;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import org.testng.annotations.Test;
import com.yahoo.memory4.ResourceHandler.ResourceType;
Memory map = rh.get();
rh.load();
assertTrue(rh.isLoaded());
//confirm orig string
byte[] buf = new byte[(int)origBytes];
map.getByteArray(0, buf, 0, (int)origBytes);
String bufStr = new String(buf, UTF_8);
assertEquals(bufStr, origStr);
}
try (WritableResourceHandler wrh = WritableMemory.map(origFile, 0, corrBytes)) { //longer
WritableMemory wMap = wrh.get();
ResourceType type = wrh.getResourceType();
wrh.isResourceType(type);
wrh.load();
assertTrue(wrh.isLoaded());
// over write content
wMap.putByteArray(0, correctByteArr, 0, (int)corrBytes);
wrh.force();
//confirm correct string
byte[] buf = new byte[(int)corrBytes];
wMap.getByteArray(0, buf, 0, (int)corrBytes);
String bufStr = new String(buf, UTF_8);
assertEquals(bufStr, correctStr);
}
}
@Test
public void checkOffsetNCapacity() {
try { | checkOffsetAndCapacity(-1, 1); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | * Returns a read only region of this Memory.
* @param offsetBytes the starting offset with respect to this Memory
* @param capacityBytes the capacity of the region in bytes
* @return a read only region of this Memory
*/
public abstract Memory region(long offsetBytes, long capacityBytes);
//ACCESS PRIMITIVE HEAP ARRAYS for readOnly
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
* Returns a read only region of this Memory.
* @param offsetBytes the starting offset with respect to this Memory
* @param capacityBytes the capacity of the region in bytes
* @return a read only region of this Memory
*/
public abstract Memory region(long offsetBytes, long capacityBytes);
//ACCESS PRIMITIVE HEAP ARRAYS for readOnly
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | * @param offsetBytes the starting offset with respect to this Memory
* @param capacityBytes the capacity of the region in bytes
* @return a read only region of this Memory
*/
public abstract Memory region(long offsetBytes, long capacityBytes);
//ACCESS PRIMITIVE HEAP ARRAYS for readOnly
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
* @param offsetBytes the starting offset with respect to this Memory
* @param capacityBytes the capacity of the region in bytes
* @return a read only region of this Memory
*/
public abstract Memory region(long offsetBytes, long capacityBytes);
//ACCESS PRIMITIVE HEAP ARRAYS for readOnly
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET); | state.putCapacity(arr.length << BYTE_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static Memory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static Memory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static Memory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static Memory wrap(final boolean[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BOOLEAN_BASE_OFFSET);
state.putCapacity(arr.length << BOOLEAN_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET); | state.putCapacity(arr.length << CHAR_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static Memory wrap(final byte[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET);
state.putCapacity(arr.length << BYTE_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET); | state.putCapacity(arr.length << SHORT_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static Memory wrap(final char[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_CHAR_BASE_OFFSET);
state.putCapacity(arr.length << CHAR_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET); | state.putCapacity(arr.length << INT_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static Memory wrap(final short[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_SHORT_BASE_OFFSET);
state.putCapacity(arr.length << SHORT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET); | state.putCapacity(arr.length << LONG_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static Memory wrap(final int[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_INT_BASE_OFFSET);
state.putCapacity(arr.length << INT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET); | state.putCapacity(arr.length << FLOAT_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | */
public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET);
state.putCapacity(arr.length << FLOAT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final double[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
*/
public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET);
state.putCapacity(arr.length << FLOAT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final double[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr); | state.putUnsafeObjectHeader(ARRAY_DOUBLE_BASE_OFFSET); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET);
state.putCapacity(arr.length << FLOAT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final double[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_DOUBLE_BASE_OFFSET); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public static Memory wrap(final long[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_LONG_BASE_OFFSET);
state.putCapacity(arr.length << LONG_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final float[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_FLOAT_BASE_OFFSET);
state.putCapacity(arr.length << FLOAT_SHIFT);
return new WritableMemoryImpl(state);
}
/**
* Wraps the given primitive array for read operations
* @param arr the given primitive array
* @return Memory for read operations
*/
public static Memory wrap(final double[] arr) {
final MemoryState state = new MemoryState();
state.putUnsafeObject(arr);
state.putUnsafeObjectHeader(ARRAY_DOUBLE_BASE_OFFSET); | state.putCapacity(arr.length << DOUBLE_SHIFT); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | * @return true if the backing resource is read only
*/
public abstract boolean isResourceReadOnly();
/**
* Returns true if this Memory is valid() and has not been closed.
* @return true if this Memory is valid() and has not been closed.
*/
public abstract boolean isValid();
/**
* Returns a formatted hex string of a range of this Memory.
* Used primarily for testing.
* @param header descriptive header
* @param offsetBytes offset bytes relative to this Memory start
* @param lengthBytes number of bytes to convert to a hex string
* @return a formatted hex string in a human readable array
*/
public abstract String toHexString(String header, long offsetBytes, int lengthBytes);
/**
* Returns a formatted hex string of an area of this Memory.
* Used primarily for testing.
* @param preamble a descriptive header
* @param offsetBytes offset bytes relative to the Memory start
* @param lengthBytes number of bytes to convert to a hex string
* @return a formatted hex string in a human readable array
*/
static String toHex(final String preamble, final long offsetBytes, final int lengthBytes,
final MemoryState state) { | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
* @return true if the backing resource is read only
*/
public abstract boolean isResourceReadOnly();
/**
* Returns true if this Memory is valid() and has not been closed.
* @return true if this Memory is valid() and has not been closed.
*/
public abstract boolean isValid();
/**
* Returns a formatted hex string of a range of this Memory.
* Used primarily for testing.
* @param header descriptive header
* @param offsetBytes offset bytes relative to this Memory start
* @param lengthBytes number of bytes to convert to a hex string
* @return a formatted hex string in a human readable array
*/
public abstract String toHexString(String header, long offsetBytes, int lengthBytes);
/**
* Returns a formatted hex string of an area of this Memory.
* Used primarily for testing.
* @param preamble a descriptive header
* @param offsetBytes offset bytes relative to the Memory start
* @param lengthBytes number of bytes to convert to a hex string
* @return a formatted hex string in a human readable array
*/
static String toHex(final String preamble, final long offsetBytes, final int lengthBytes,
final MemoryState state) { | assertBounds(offsetBytes, lengthBytes, state.getCapacity()); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Memory.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder; | * Used primarily for testing.
* @param header descriptive header
* @param offsetBytes offset bytes relative to this Memory start
* @param lengthBytes number of bytes to convert to a hex string
* @return a formatted hex string in a human readable array
*/
public abstract String toHexString(String header, long offsetBytes, int lengthBytes);
/**
* Returns a formatted hex string of an area of this Memory.
* Used primarily for testing.
* @param preamble a descriptive header
* @param offsetBytes offset bytes relative to the Memory start
* @param lengthBytes number of bytes to convert to a hex string
* @return a formatted hex string in a human readable array
*/
static String toHex(final String preamble, final long offsetBytes, final int lengthBytes,
final MemoryState state) {
assertBounds(offsetBytes, lengthBytes, state.getCapacity());
final StringBuilder sb = new StringBuilder();
final Object uObj = state.getUnsafeObject();
final String uObjStr = (uObj == null) ? "null"
: uObj.getClass().getSimpleName() + ", " + (uObj.hashCode() & 0XFFFFFFFFL);
final ByteBuffer bb = state.getByteBuffer();
final String bbStr = (bb == null) ? "null"
: bb.getClass().getSimpleName() + ", " + (bb.hashCode() & 0XFFFFFFFFL);
final MemoryRequest memReq = state.getMemoryRequest();
final String memReqStr = (memReq == null) ? "null"
: memReq.getClass().getSimpleName() + ", " + (memReq.hashCode() & 0XFFFFFFFFL);
final long cumBaseOffset = state.getCumBaseOffset(); | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BOOLEAN_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_CHAR_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_DOUBLE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_FLOAT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_INT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_LONG_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_SHORT_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BOOLEAN_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int BYTE_SHIFT = 0;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int CHAR_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int DOUBLE_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int FLOAT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int INT_SHIFT = 2;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int LONG_SHIFT = 3;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final String LS = System.getProperty("line.separator");
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int SHORT_SHIFT = 1;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/main/java/com/yahoo/memory4/Memory.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BOOLEAN_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_CHAR_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_DOUBLE_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_FLOAT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_INT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_LONG_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_SHORT_BASE_OFFSET;
import static com.yahoo.memory4.UnsafeUtil.BOOLEAN_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.BYTE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.CHAR_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.DOUBLE_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.FLOAT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.INT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LONG_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.LS;
import static com.yahoo.memory4.UnsafeUtil.SHORT_SHIFT;
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
* Used primarily for testing.
* @param header descriptive header
* @param offsetBytes offset bytes relative to this Memory start
* @param lengthBytes number of bytes to convert to a hex string
* @return a formatted hex string in a human readable array
*/
public abstract String toHexString(String header, long offsetBytes, int lengthBytes);
/**
* Returns a formatted hex string of an area of this Memory.
* Used primarily for testing.
* @param preamble a descriptive header
* @param offsetBytes offset bytes relative to the Memory start
* @param lengthBytes number of bytes to convert to a hex string
* @return a formatted hex string in a human readable array
*/
static String toHex(final String preamble, final long offsetBytes, final int lengthBytes,
final MemoryState state) {
assertBounds(offsetBytes, lengthBytes, state.getCapacity());
final StringBuilder sb = new StringBuilder();
final Object uObj = state.getUnsafeObject();
final String uObjStr = (uObj == null) ? "null"
: uObj.getClass().getSimpleName() + ", " + (uObj.hashCode() & 0XFFFFFFFFL);
final ByteBuffer bb = state.getByteBuffer();
final String bbStr = (bb == null) ? "null"
: bb.getClass().getSimpleName() + ", " + (bb.hashCode() & 0XFFFFFFFFL);
final MemoryRequest memReq = state.getMemoryRequest();
final String memReqStr = (memReq == null) ? "null"
: memReq.getClass().getSimpleName() + ", " + (memReq.hashCode() & 0XFFFFFFFFL);
final long cumBaseOffset = state.getCumBaseOffset(); | sb.append(preamble).append(LS); |
DataSketches/experimental | src/test/java/com/yahoo/memory4/MemoryPerformance.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
| import static com.yahoo.memory4.UnsafeUtil.unsafe;
import static java.lang.Math.pow;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.LongBuffer;
import com.yahoo.memory.AllocMemory;
import com.yahoo.memory.NativeMemory;
import com.yahoo.sketches.Util; | //Must do write trial first
private static final long trial_HeapArrayByIndex(final long[] array, final int arrLongs,
final boolean read) {
final long checkSum = (arrLongs * (arrLongs - 1L)) / 2L;
final long startTime_nS, stopTime_nS;
if (read) {
//Timing interval for a single trial
long trialSum = 0;
startTime_nS = System.nanoTime();
for (int i = 0; i < arrLongs; i++) { trialSum += array[i]; }
stopTime_nS = System.nanoTime();
if (trialSum != checkSum) {
throw new IllegalStateException("Bad checksum: " + trialSum + " != " + checkSum);
}
} else { //write
startTime_nS = System.nanoTime();
for (int i = 0; i < arrLongs; i++) { array[i] = i; }
stopTime_nS = System.nanoTime();
}
return stopTime_nS - startTime_nS;
}
/*************************************/
// UNSAFE DIRECT
/*************************************/
private void testNativeArrayByUnsafe() {
Point p = new Point(ppo_, minGI_ - 1, 1 << lgMinLongs_, 1 << lgMaxTrials_); //just below start
Point.printHeader();
while ((p = getNextPoint(p)) != null) { //an array size point | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final Unsafe unsafe;
// Path: src/test/java/com/yahoo/memory4/MemoryPerformance.java
import static com.yahoo.memory4.UnsafeUtil.unsafe;
import static java.lang.Math.pow;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.LongBuffer;
import com.yahoo.memory.AllocMemory;
import com.yahoo.memory.NativeMemory;
import com.yahoo.sketches.Util;
//Must do write trial first
private static final long trial_HeapArrayByIndex(final long[] array, final int arrLongs,
final boolean read) {
final long checkSum = (arrLongs * (arrLongs - 1L)) / 2L;
final long startTime_nS, stopTime_nS;
if (read) {
//Timing interval for a single trial
long trialSum = 0;
startTime_nS = System.nanoTime();
for (int i = 0; i < arrLongs; i++) { trialSum += array[i]; }
stopTime_nS = System.nanoTime();
if (trialSum != checkSum) {
throw new IllegalStateException("Bad checksum: " + trialSum + " != " + checkSum);
}
} else { //write
startTime_nS = System.nanoTime();
for (int i = 0; i < arrLongs; i++) { array[i] = i; }
stopTime_nS = System.nanoTime();
}
return stopTime_nS - startTime_nS;
}
/*************************************/
// UNSAFE DIRECT
/*************************************/
private void testNativeArrayByUnsafe() {
Point p = new Point(ppo_, minGI_ - 1, 1 << lgMinLongs_, 1 << lgMaxTrials_); //just below start
Point.printHeader();
while ((p = getNextPoint(p)) != null) { //an array size point | final long address = unsafe.allocateMemory(p.arrLongs << 3); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/AccessByteBuffer.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_INDEX_SCALE; // 1
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_INDEX_SCALE;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET; | /*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
/**
* @author Lee Rhodes
*/
final class AccessByteBuffer extends WritableMemoryImpl {
private AccessByteBuffer(final MemoryState state) {
super(state);
}
//The provided ByteBuffer may be either readOnly or writable
static WritableMemoryImpl wrap(final MemoryState state) {
final ByteBuffer byteBuf = state.getByteBuffer();
state.putCapacity(byteBuf.capacity());
final boolean readOnlyBB = byteBuf.isReadOnly();
final boolean direct = byteBuf.isDirect();
if (readOnlyBB) {
state.setResourceReadOnly();
//READ-ONLY DIRECT
if (direct) {
//address() is already adjusted for direct slices, so regionOffset = 0
state.putNativeBaseOffset(((sun.nio.ch.DirectBuffer) byteBuf).address());
return new AccessByteBuffer(state);
}
//READ-ONLY HEAP
//The messy acquisition of arrayOffset() and array() created from a RO slice()
final Object unsafeObj;
final long regionOffset;
try {
Field field = ByteBuffer.class.getDeclaredField("offset");
field.setAccessible(true);
//includes the slice() offset for heap. | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_INDEX_SCALE; // 1
// Path: src/main/java/com/yahoo/memory4/AccessByteBuffer.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_INDEX_SCALE;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
/*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
/**
* @author Lee Rhodes
*/
final class AccessByteBuffer extends WritableMemoryImpl {
private AccessByteBuffer(final MemoryState state) {
super(state);
}
//The provided ByteBuffer may be either readOnly or writable
static WritableMemoryImpl wrap(final MemoryState state) {
final ByteBuffer byteBuf = state.getByteBuffer();
state.putCapacity(byteBuf.capacity());
final boolean readOnlyBB = byteBuf.isReadOnly();
final boolean direct = byteBuf.isDirect();
if (readOnlyBB) {
state.setResourceReadOnly();
//READ-ONLY DIRECT
if (direct) {
//address() is already adjusted for direct slices, so regionOffset = 0
state.putNativeBaseOffset(((sun.nio.ch.DirectBuffer) byteBuf).address());
return new AccessByteBuffer(state);
}
//READ-ONLY HEAP
//The messy acquisition of arrayOffset() and array() created from a RO slice()
final Object unsafeObj;
final long regionOffset;
try {
Field field = ByteBuffer.class.getDeclaredField("offset");
field.setAccessible(true);
//includes the slice() offset for heap. | regionOffset = ((Integer)field.get(byteBuf)).longValue() * ARRAY_BYTE_INDEX_SCALE; |
DataSketches/experimental | src/main/java/com/yahoo/memory4/AccessByteBuffer.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_INDEX_SCALE; // 1
| import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_INDEX_SCALE;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET; | /*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
/**
* @author Lee Rhodes
*/
final class AccessByteBuffer extends WritableMemoryImpl {
private AccessByteBuffer(final MemoryState state) {
super(state);
}
//The provided ByteBuffer may be either readOnly or writable
static WritableMemoryImpl wrap(final MemoryState state) {
final ByteBuffer byteBuf = state.getByteBuffer();
state.putCapacity(byteBuf.capacity());
final boolean readOnlyBB = byteBuf.isReadOnly();
final boolean direct = byteBuf.isDirect();
if (readOnlyBB) {
state.setResourceReadOnly();
//READ-ONLY DIRECT
if (direct) {
//address() is already adjusted for direct slices, so regionOffset = 0
state.putNativeBaseOffset(((sun.nio.ch.DirectBuffer) byteBuf).address());
return new AccessByteBuffer(state);
}
//READ-ONLY HEAP
//The messy acquisition of arrayOffset() and array() created from a RO slice()
final Object unsafeObj;
final long regionOffset;
try {
Field field = ByteBuffer.class.getDeclaredField("offset");
field.setAccessible(true);
//includes the slice() offset for heap.
regionOffset = ((Integer)field.get(byteBuf)).longValue() * ARRAY_BYTE_INDEX_SCALE;
field = ByteBuffer.class.getDeclaredField("hb"); //the backing byte[] from HeapByteBuffer
field.setAccessible(true);
unsafeObj = field.get(byteBuf);
}
catch (final IllegalAccessException | NoSuchFieldException e) {
throw new RuntimeException(
"Could not get offset/byteArray from OnHeap ByteBuffer instance: " + e.getClass());
} | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_BASE_OFFSET;
//
// Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static final int ARRAY_BYTE_INDEX_SCALE; // 1
// Path: src/main/java/com/yahoo/memory4/AccessByteBuffer.java
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_INDEX_SCALE;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import static com.yahoo.memory4.UnsafeUtil.ARRAY_BYTE_BASE_OFFSET;
/*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
/**
* @author Lee Rhodes
*/
final class AccessByteBuffer extends WritableMemoryImpl {
private AccessByteBuffer(final MemoryState state) {
super(state);
}
//The provided ByteBuffer may be either readOnly or writable
static WritableMemoryImpl wrap(final MemoryState state) {
final ByteBuffer byteBuf = state.getByteBuffer();
state.putCapacity(byteBuf.capacity());
final boolean readOnlyBB = byteBuf.isReadOnly();
final boolean direct = byteBuf.isDirect();
if (readOnlyBB) {
state.setResourceReadOnly();
//READ-ONLY DIRECT
if (direct) {
//address() is already adjusted for direct slices, so regionOffset = 0
state.putNativeBaseOffset(((sun.nio.ch.DirectBuffer) byteBuf).address());
return new AccessByteBuffer(state);
}
//READ-ONLY HEAP
//The messy acquisition of arrayOffset() and array() created from a RO slice()
final Object unsafeObj;
final long regionOffset;
try {
Field field = ByteBuffer.class.getDeclaredField("offset");
field.setAccessible(true);
//includes the slice() offset for heap.
regionOffset = ((Integer)field.get(byteBuf)).longValue() * ARRAY_BYTE_INDEX_SCALE;
field = ByteBuffer.class.getDeclaredField("hb"); //the backing byte[] from HeapByteBuffer
field.setAccessible(true);
unsafeObj = field.get(byteBuf);
}
catch (final IllegalAccessException | NoSuchFieldException e) {
throw new RuntimeException(
"Could not get offset/byteArray from OnHeap ByteBuffer instance: " + e.getClass());
} | state.putUnsafeObjectHeader(ARRAY_BYTE_BASE_OFFSET); |
DataSketches/experimental | src/test/java/com/yahoo/memory4/AllocateDirectTest.java | // Path: src/main/java/com/yahoo/memory4/ResourceHandler.java
// enum ResourceType { MEMORY_MAPPED_FILE, NATIVE_MEMORY }
| import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import com.yahoo.memory4.ResourceHandler.ResourceType; | /*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
public class AllocateDirectTest {
@Test
public void checkAllocateDirect() {
int longs = 32;
int bytes = longs << 3;
WritableResourceHandler wh = WritableMemory.allocateDirect(bytes);
WritableMemory wMem1 = wh.get();
for (int i = 0; i<longs; i++) {
wMem1.putLong(i << 3, i);
assertEquals(wMem1.getLong(i << 3), i);
}
wMem1.toHexString("Test", 0, 32 * 8);
wh.load();
assertFalse(wh.isLoaded());
wh.force(); | // Path: src/main/java/com/yahoo/memory4/ResourceHandler.java
// enum ResourceType { MEMORY_MAPPED_FILE, NATIVE_MEMORY }
// Path: src/test/java/com/yahoo/memory4/AllocateDirectTest.java
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.Test;
import com.yahoo.memory4.ResourceHandler.ResourceType;
/*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
public class AllocateDirectTest {
@Test
public void checkAllocateDirect() {
int longs = 32;
int bytes = longs << 3;
WritableResourceHandler wh = WritableMemory.allocateDirect(bytes);
WritableMemory wMem1 = wh.get();
for (int i = 0; i<longs; i++) {
wMem1.putLong(i << 3, i);
assertEquals(wMem1.getLong(i << 3), i);
}
wMem1.toHexString("Test", 0, 32 * 8);
wh.load();
assertFalse(wh.isLoaded());
wh.force(); | assertEquals(wh.getResourceType(), ResourceType.NATIVE_MEMORY); |
DataSketches/experimental | src/main/java/com/yahoo/memory4/Util.java | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
| import static com.yahoo.memory4.UnsafeUtil.assertBounds; | /*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
final class Util {
/**
* Searches a range of the specified array of longs for the specified value using the binary
* search algorithm. The range must be sorted method) prior to making this call.
* If it is not sorted, the results are undefined. If the range contains
* multiple elements with the specified value, there is no guarantee which one will be found.
* @param mem the Memory to be searched
* @param fromLongIndex the index of the first element (inclusive) to be searched
* @param toLongIndex the index of the last element (exclusive) to be searched
* @param key the value to be searched for
* @return index of the search key, if it is contained in the array within the specified range;
* otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which
* the key would be inserted into the array: the index of the first element in the range greater
* than the key, or toIndex if all elements in the range are less than the specified key.
* Note that this guarantees that the return value will be ≥ 0 if and only if the key is found.
*/
public static long binarySearchLongs(final Memory mem, final long fromLongIndex,
final long toLongIndex, final long key) { | // Path: src/main/java/com/yahoo/memory4/UnsafeUtil.java
// public static void assertBounds(final long reqOff, final long reqLen, final long allocSize) {
// assert ((reqOff | reqLen | (reqOff + reqLen) | (allocSize - (reqOff + reqLen))) >= 0) :
// "reqOffset: " + reqOff + ", reqLength: " + reqLen
// + ", (reqOff + reqLen): " + (reqOff + reqLen) + ", allocSize: " + allocSize;
// }
// Path: src/main/java/com/yahoo/memory4/Util.java
import static com.yahoo.memory4.UnsafeUtil.assertBounds;
/*
* Copyright 2017, Yahoo! Inc. Licensed under the terms of the
* Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.memory4;
final class Util {
/**
* Searches a range of the specified array of longs for the specified value using the binary
* search algorithm. The range must be sorted method) prior to making this call.
* If it is not sorted, the results are undefined. If the range contains
* multiple elements with the specified value, there is no guarantee which one will be found.
* @param mem the Memory to be searched
* @param fromLongIndex the index of the first element (inclusive) to be searched
* @param toLongIndex the index of the last element (exclusive) to be searched
* @param key the value to be searched for
* @return index of the search key, if it is contained in the array within the specified range;
* otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which
* the key would be inserted into the array: the index of the first element in the range greater
* than the key, or toIndex if all elements in the range are less than the specified key.
* Note that this guarantees that the return value will be ≥ 0 if and only if the key is found.
*/
public static long binarySearchLongs(final Memory mem, final long fromLongIndex,
final long toLongIndex, final long key) { | assertBounds(fromLongIndex << 3, (toLongIndex - fromLongIndex) << 3, mem.getCapacity()); |
fpmoles/talks-spring-intro-workshop | code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
| import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; | package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
@Service
public class InventoryService {
| // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
@Service
public class InventoryService {
| private final ItemRepository itemRepository; |
fpmoles/talks-spring-intro-workshop | code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
| import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; | package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
@Service
public class InventoryService {
private final ItemRepository itemRepository; | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
@Service
public class InventoryService {
private final ItemRepository itemRepository; | private final PersonRepository personRepository; |
fpmoles/talks-spring-intro-workshop | code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
| import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; | package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
@Service
public class InventoryService {
private final ItemRepository itemRepository;
private final PersonRepository personRepository;
@Autowired
public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
super();
this.itemRepository = itemRepository;
this.personRepository = personRepository;
}
| // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
@Service
public class InventoryService {
private final ItemRepository itemRepository;
private final PersonRepository personRepository;
@Autowired
public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
super();
this.itemRepository = itemRepository;
this.personRepository = personRepository;
}
| public Inventory getInventory(long personId){ |
fpmoles/talks-spring-intro-workshop | code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
| import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; | package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
@Service
public class InventoryService {
private final ItemRepository itemRepository;
private final PersonRepository personRepository;
@Autowired
public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
super();
this.itemRepository = itemRepository;
this.personRepository = personRepository;
}
public Inventory getInventory(long personId){
return new Inventory();
}
public Inventory updateInventory(Inventory inventory){
return inventory;
}
| // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
@Service
public class InventoryService {
private final ItemRepository itemRepository;
private final PersonRepository personRepository;
@Autowired
public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
super();
this.itemRepository = itemRepository;
this.personRepository = personRepository;
}
public Inventory getInventory(long personId){
return new Inventory();
}
public Inventory updateInventory(Inventory inventory){
return inventory;
}
| public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){ |
fpmoles/talks-spring-intro-workshop | code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/web/service/ServiceController.java | // Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
| import com.frankmoley.talks.spring.intro.service.UserService;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; | package com.frankmoley.talks.spring.intro.web.service;
@RestController
@RequestMapping("/api")
public class ServiceController {
| // Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/web/service/ServiceController.java
import com.frankmoley.talks.spring.intro.service.UserService;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
package com.frankmoley.talks.spring.intro.web.service;
@RestController
@RequestMapping("/api")
public class ServiceController {
| private final UserService userService; |
fpmoles/talks-spring-intro-workshop | code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/web/service/ServiceController.java | // Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
| import com.frankmoley.talks.spring.intro.service.UserService;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; | package com.frankmoley.talks.spring.intro.web.service;
@RestController
@RequestMapping("/api")
public class ServiceController {
private final UserService userService;
@Autowired
public ServiceController(UserService userService){
super();
this.userService=userService;
}
@GetMapping("/users") | // Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/web/service/ServiceController.java
import com.frankmoley.talks.spring.intro.service.UserService;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
package com.frankmoley.talks.spring.intro.web.service;
@RestController
@RequestMapping("/api")
public class ServiceController {
private final UserService userService;
@Autowired
public ServiceController(UserService userService){
super();
this.userService=userService;
}
@GetMapping("/users") | public List<User> getUsers(){ |
fpmoles/talks-spring-intro-workshop | code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/web/app/AppController.java | // Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
| import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; | package com.frankmoley.talks.spring.intro.web.app;
@Controller
@RequestMapping(value="/")
public class AppController {
| // Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/web/app/AppController.java
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
package com.frankmoley.talks.spring.intro.web.app;
@Controller
@RequestMapping(value="/")
public class AppController {
| private final UserService userService; |
fpmoles/talks-spring-intro-workshop | code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
| import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.UUID; | package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
@Service
public class UserService {
| // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.UUID;
package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
@Service
public class UserService {
| private final PersonRepository personRepository; |
fpmoles/talks-spring-intro-workshop | code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
| import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.UUID; | package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
@Service
public class UserService {
private final PersonRepository personRepository;
@Autowired
public UserService(PersonRepository personRepository){
super();
this.personRepository = personRepository;
}
@Loggable | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.UUID;
package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
@Service
public class UserService {
private final PersonRepository personRepository;
@Autowired
public UserService(PersonRepository personRepository){
super();
this.personRepository = personRepository;
}
@Loggable | public User getUser(String emailAddress){ |
fpmoles/talks-spring-intro-workshop | code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java | // Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
| import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment; | package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
@ComponentScan(basePackages = {"com.frankmoley.talks.spring.intro"})
public class ApplicationConfig {
@Autowired
private Environment environment;
public static void main(String[] args){
ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class); | // Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
@ComponentScan(basePackages = {"com.frankmoley.talks.spring.intro"})
public class ApplicationConfig {
@Autowired
private Environment environment;
public static void main(String[] args){
ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class); | InventoryService service = context.getBean(InventoryService.class); |
fpmoles/talks-spring-intro-workshop | code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java | // Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
| import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment; | package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
@ComponentScan(basePackages = {"com.frankmoley.talks.spring.intro"})
public class ApplicationConfig {
@Autowired
private Environment environment;
public static void main(String[] args){
ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class);
InventoryService service = context.getBean(InventoryService.class); | // Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
@ComponentScan(basePackages = {"com.frankmoley.talks.spring.intro"})
public class ApplicationConfig {
@Autowired
private Environment environment;
public static void main(String[] args){
ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class);
InventoryService service = context.getBean(InventoryService.class); | UserService userService = context.getBean(UserService.class); |
fpmoles/talks-spring-intro-workshop | code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/aspect/LoggableAspect.java
// @Aspect
// public class LoggableAspect {
//
// private static final Logger LOGGER = LoggerFactory.getLogger("AuditLogger");
//
// @Pointcut("@annotation(Loggable)")
// public void executeLogging(){}
//
// @Around("executeLogging()")
// public Object adviseLogging(ProceedingJoinPoint joinPoint) throws Throwable{
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Object returnValue = null;
// try {
// returnValue = joinPoint.proceed();
// return returnValue;
// }finally {
// stopWatch.stop();
// StringBuilder message = new StringBuilder();
// message.append("method=").append(joinPoint.getSignature().getName()).append("|");
// message.append("time=").append(stopWatch.getTotalTimeMillis()).append("ms|");
// Object[] args = joinPoint.getArgs();
// if(null!=args && args.length>0){
// message.append("args={");
// boolean first=true;
// Arrays.asList(args).forEach(arg->{
// if(!first){
// message.append("|");
// }
// message.append(arg);
// });
// message.append("}");
// }
// LOGGER.info(message.toString());
//
// }
//
// }
// }
//
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
| import com.frankmoley.talks.spring.intro.aspect.LoggableAspect;
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource; | package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
public class ApplicationConfig {
@Bean | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/aspect/LoggableAspect.java
// @Aspect
// public class LoggableAspect {
//
// private static final Logger LOGGER = LoggerFactory.getLogger("AuditLogger");
//
// @Pointcut("@annotation(Loggable)")
// public void executeLogging(){}
//
// @Around("executeLogging()")
// public Object adviseLogging(ProceedingJoinPoint joinPoint) throws Throwable{
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Object returnValue = null;
// try {
// returnValue = joinPoint.proceed();
// return returnValue;
// }finally {
// stopWatch.stop();
// StringBuilder message = new StringBuilder();
// message.append("method=").append(joinPoint.getSignature().getName()).append("|");
// message.append("time=").append(stopWatch.getTotalTimeMillis()).append("ms|");
// Object[] args = joinPoint.getArgs();
// if(null!=args && args.length>0){
// message.append("args={");
// boolean first=true;
// Arrays.asList(args).forEach(arg->{
// if(!first){
// message.append("|");
// }
// message.append(arg);
// });
// message.append("}");
// }
// LOGGER.info(message.toString());
//
// }
//
// }
// }
//
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java
import com.frankmoley.talks.spring.intro.aspect.LoggableAspect;
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
public class ApplicationConfig {
@Bean | public PersonRepository personRepository(){ |
fpmoles/talks-spring-intro-workshop | code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/aspect/LoggableAspect.java
// @Aspect
// public class LoggableAspect {
//
// private static final Logger LOGGER = LoggerFactory.getLogger("AuditLogger");
//
// @Pointcut("@annotation(Loggable)")
// public void executeLogging(){}
//
// @Around("executeLogging()")
// public Object adviseLogging(ProceedingJoinPoint joinPoint) throws Throwable{
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Object returnValue = null;
// try {
// returnValue = joinPoint.proceed();
// return returnValue;
// }finally {
// stopWatch.stop();
// StringBuilder message = new StringBuilder();
// message.append("method=").append(joinPoint.getSignature().getName()).append("|");
// message.append("time=").append(stopWatch.getTotalTimeMillis()).append("ms|");
// Object[] args = joinPoint.getArgs();
// if(null!=args && args.length>0){
// message.append("args={");
// boolean first=true;
// Arrays.asList(args).forEach(arg->{
// if(!first){
// message.append("|");
// }
// message.append(arg);
// });
// message.append("}");
// }
// LOGGER.info(message.toString());
//
// }
//
// }
// }
//
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
| import com.frankmoley.talks.spring.intro.aspect.LoggableAspect;
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource; | package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/aspect/LoggableAspect.java
// @Aspect
// public class LoggableAspect {
//
// private static final Logger LOGGER = LoggerFactory.getLogger("AuditLogger");
//
// @Pointcut("@annotation(Loggable)")
// public void executeLogging(){}
//
// @Around("executeLogging()")
// public Object adviseLogging(ProceedingJoinPoint joinPoint) throws Throwable{
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Object returnValue = null;
// try {
// returnValue = joinPoint.proceed();
// return returnValue;
// }finally {
// stopWatch.stop();
// StringBuilder message = new StringBuilder();
// message.append("method=").append(joinPoint.getSignature().getName()).append("|");
// message.append("time=").append(stopWatch.getTotalTimeMillis()).append("ms|");
// Object[] args = joinPoint.getArgs();
// if(null!=args && args.length>0){
// message.append("args={");
// boolean first=true;
// Arrays.asList(args).forEach(arg->{
// if(!first){
// message.append("|");
// }
// message.append(arg);
// });
// message.append("}");
// }
// LOGGER.info(message.toString());
//
// }
//
// }
// }
//
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java
import com.frankmoley.talks.spring.intro.aspect.LoggableAspect;
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean | public ItemRepository itemRepository(){ |
fpmoles/talks-spring-intro-workshop | code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/aspect/LoggableAspect.java
// @Aspect
// public class LoggableAspect {
//
// private static final Logger LOGGER = LoggerFactory.getLogger("AuditLogger");
//
// @Pointcut("@annotation(Loggable)")
// public void executeLogging(){}
//
// @Around("executeLogging()")
// public Object adviseLogging(ProceedingJoinPoint joinPoint) throws Throwable{
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Object returnValue = null;
// try {
// returnValue = joinPoint.proceed();
// return returnValue;
// }finally {
// stopWatch.stop();
// StringBuilder message = new StringBuilder();
// message.append("method=").append(joinPoint.getSignature().getName()).append("|");
// message.append("time=").append(stopWatch.getTotalTimeMillis()).append("ms|");
// Object[] args = joinPoint.getArgs();
// if(null!=args && args.length>0){
// message.append("args={");
// boolean first=true;
// Arrays.asList(args).forEach(arg->{
// if(!first){
// message.append("|");
// }
// message.append(arg);
// });
// message.append("}");
// }
// LOGGER.info(message.toString());
//
// }
//
// }
// }
//
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
| import com.frankmoley.talks.spring.intro.aspect.LoggableAspect;
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource; | package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean
public ItemRepository itemRepository(){
return new ItemRepository();
}
@Bean | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/aspect/LoggableAspect.java
// @Aspect
// public class LoggableAspect {
//
// private static final Logger LOGGER = LoggerFactory.getLogger("AuditLogger");
//
// @Pointcut("@annotation(Loggable)")
// public void executeLogging(){}
//
// @Around("executeLogging()")
// public Object adviseLogging(ProceedingJoinPoint joinPoint) throws Throwable{
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Object returnValue = null;
// try {
// returnValue = joinPoint.proceed();
// return returnValue;
// }finally {
// stopWatch.stop();
// StringBuilder message = new StringBuilder();
// message.append("method=").append(joinPoint.getSignature().getName()).append("|");
// message.append("time=").append(stopWatch.getTotalTimeMillis()).append("ms|");
// Object[] args = joinPoint.getArgs();
// if(null!=args && args.length>0){
// message.append("args={");
// boolean first=true;
// Arrays.asList(args).forEach(arg->{
// if(!first){
// message.append("|");
// }
// message.append(arg);
// });
// message.append("}");
// }
// LOGGER.info(message.toString());
//
// }
//
// }
// }
//
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java
import com.frankmoley.talks.spring.intro.aspect.LoggableAspect;
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean
public ItemRepository itemRepository(){
return new ItemRepository();
}
@Bean | public InventoryService inventoryService(){ |
fpmoles/talks-spring-intro-workshop | code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/aspect/LoggableAspect.java
// @Aspect
// public class LoggableAspect {
//
// private static final Logger LOGGER = LoggerFactory.getLogger("AuditLogger");
//
// @Pointcut("@annotation(Loggable)")
// public void executeLogging(){}
//
// @Around("executeLogging()")
// public Object adviseLogging(ProceedingJoinPoint joinPoint) throws Throwable{
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Object returnValue = null;
// try {
// returnValue = joinPoint.proceed();
// return returnValue;
// }finally {
// stopWatch.stop();
// StringBuilder message = new StringBuilder();
// message.append("method=").append(joinPoint.getSignature().getName()).append("|");
// message.append("time=").append(stopWatch.getTotalTimeMillis()).append("ms|");
// Object[] args = joinPoint.getArgs();
// if(null!=args && args.length>0){
// message.append("args={");
// boolean first=true;
// Arrays.asList(args).forEach(arg->{
// if(!first){
// message.append("|");
// }
// message.append(arg);
// });
// message.append("}");
// }
// LOGGER.info(message.toString());
//
// }
//
// }
// }
//
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
| import com.frankmoley.talks.spring.intro.aspect.LoggableAspect;
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource; | package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean
public ItemRepository itemRepository(){
return new ItemRepository();
}
@Bean
public InventoryService inventoryService(){
return new InventoryService(itemRepository(), personRepository());
}
@Bean | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/aspect/LoggableAspect.java
// @Aspect
// public class LoggableAspect {
//
// private static final Logger LOGGER = LoggerFactory.getLogger("AuditLogger");
//
// @Pointcut("@annotation(Loggable)")
// public void executeLogging(){}
//
// @Around("executeLogging()")
// public Object adviseLogging(ProceedingJoinPoint joinPoint) throws Throwable{
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Object returnValue = null;
// try {
// returnValue = joinPoint.proceed();
// return returnValue;
// }finally {
// stopWatch.stop();
// StringBuilder message = new StringBuilder();
// message.append("method=").append(joinPoint.getSignature().getName()).append("|");
// message.append("time=").append(stopWatch.getTotalTimeMillis()).append("ms|");
// Object[] args = joinPoint.getArgs();
// if(null!=args && args.length>0){
// message.append("args={");
// boolean first=true;
// Arrays.asList(args).forEach(arg->{
// if(!first){
// message.append("|");
// }
// message.append(arg);
// });
// message.append("}");
// }
// LOGGER.info(message.toString());
//
// }
//
// }
// }
//
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java
import com.frankmoley.talks.spring.intro.aspect.LoggableAspect;
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean
public ItemRepository itemRepository(){
return new ItemRepository();
}
@Bean
public InventoryService inventoryService(){
return new InventoryService(itemRepository(), personRepository());
}
@Bean | public LoggableAspect loggableAspect(){return new LoggableAspect();} |
fpmoles/talks-spring-intro-workshop | code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/aspect/LoggableAspect.java
// @Aspect
// public class LoggableAspect {
//
// private static final Logger LOGGER = LoggerFactory.getLogger("AuditLogger");
//
// @Pointcut("@annotation(Loggable)")
// public void executeLogging(){}
//
// @Around("executeLogging()")
// public Object adviseLogging(ProceedingJoinPoint joinPoint) throws Throwable{
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Object returnValue = null;
// try {
// returnValue = joinPoint.proceed();
// return returnValue;
// }finally {
// stopWatch.stop();
// StringBuilder message = new StringBuilder();
// message.append("method=").append(joinPoint.getSignature().getName()).append("|");
// message.append("time=").append(stopWatch.getTotalTimeMillis()).append("ms|");
// Object[] args = joinPoint.getArgs();
// if(null!=args && args.length>0){
// message.append("args={");
// boolean first=true;
// Arrays.asList(args).forEach(arg->{
// if(!first){
// message.append("|");
// }
// message.append(arg);
// });
// message.append("}");
// }
// LOGGER.info(message.toString());
//
// }
//
// }
// }
//
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
| import com.frankmoley.talks.spring.intro.aspect.LoggableAspect;
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource; | package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean
public ItemRepository itemRepository(){
return new ItemRepository();
}
@Bean
public InventoryService inventoryService(){
return new InventoryService(itemRepository(), personRepository());
}
@Bean
public LoggableAspect loggableAspect(){return new LoggableAspect();}
@Bean | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/aspect/LoggableAspect.java
// @Aspect
// public class LoggableAspect {
//
// private static final Logger LOGGER = LoggerFactory.getLogger("AuditLogger");
//
// @Pointcut("@annotation(Loggable)")
// public void executeLogging(){}
//
// @Around("executeLogging()")
// public Object adviseLogging(ProceedingJoinPoint joinPoint) throws Throwable{
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// Object returnValue = null;
// try {
// returnValue = joinPoint.proceed();
// return returnValue;
// }finally {
// stopWatch.stop();
// StringBuilder message = new StringBuilder();
// message.append("method=").append(joinPoint.getSignature().getName()).append("|");
// message.append("time=").append(stopWatch.getTotalTimeMillis()).append("ms|");
// Object[] args = joinPoint.getArgs();
// if(null!=args && args.length>0){
// message.append("args={");
// boolean first=true;
// Arrays.asList(args).forEach(arg->{
// if(!first){
// message.append("|");
// }
// message.append(arg);
// });
// message.append("}");
// }
// LOGGER.info(message.toString());
//
// }
//
// }
// }
//
// Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
//
// Path: code/exercise_4/exercise/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
// @Service
// public class UserService {
//
// private final PersonRepository personRepository;
//
// @Autowired
// public UserService(PersonRepository personRepository){
// super();
// this.personRepository = personRepository;
// }
//
// @Loggable
// public User getUser(String emailAddress){
// User user = new User();
// user.setUsername("BigLebowski");
// user.setPersonId(UUID.randomUUID().toString());
// return user;
// }
// }
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java
import com.frankmoley.talks.spring.intro.aspect.LoggableAspect;
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import com.frankmoley.talks.spring.intro.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
@EnableAspectJAutoProxy
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean
public ItemRepository itemRepository(){
return new ItemRepository();
}
@Bean
public InventoryService inventoryService(){
return new InventoryService(itemRepository(), personRepository());
}
@Bean
public LoggableAspect loggableAspect(){return new LoggableAspect();}
@Bean | public UserService userService(){return new UserService(personRepository());} |
fpmoles/talks-spring-intro-workshop | code/exercise_2/exercise/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
| import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource; | package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
public class ApplicationConfig {
@Bean | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
// Path: code/exercise_2/exercise/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
public class ApplicationConfig {
@Bean | public PersonRepository personRepository(){ |
fpmoles/talks-spring-intro-workshop | code/exercise_2/exercise/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
| import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource; | package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
// Path: code/exercise_2/exercise/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean | public ItemRepository itemRepository(){ |
fpmoles/talks-spring-intro-workshop | code/exercise_2/exercise/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
| import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource; | package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean
public ItemRepository itemRepository(){
return new ItemRepository();
}
@Bean | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
// @Service
// public class InventoryService {
//
// private final ItemRepository itemRepository;
// private final PersonRepository personRepository;
//
// @Autowired
// public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
// super();
// this.itemRepository = itemRepository;
// this.personRepository = personRepository;
// }
//
// public Inventory getInventory(long personId){
// return new Inventory();
// }
//
// public Inventory updateInventory(Inventory inventory){
// return inventory;
// }
//
// public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){
// return new DetailedInventoryItem();
// }
//
// }
// Path: code/exercise_2/exercise/src/main/java/com/frankmoley/talks/spring/intro/config/ApplicationConfig.java
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.InventoryService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
package com.frankmoley.talks.spring.intro.config;
@Configuration
@PropertySource("classpath:application.properties")
public class ApplicationConfig {
@Bean
public PersonRepository personRepository(){
return new PersonRepository();
}
@Bean
public ItemRepository itemRepository(){
return new ItemRepository();
}
@Bean | public InventoryService inventoryService(){ |
fpmoles/talks-spring-intro-workshop | code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
| import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import java.util.UUID; | package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
public class UserService {
private final PersonRepository personRepository;
public UserService(PersonRepository personRepository){
super();
this.personRepository = personRepository;
}
@Loggable | // Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import java.util.UUID;
package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
public class UserService {
private final PersonRepository personRepository;
public UserService(PersonRepository personRepository){
super();
this.personRepository = personRepository;
}
@Loggable | public User getUser(String emailAddress){ |
fpmoles/talks-spring-intro-workshop | code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/entity/PersonEntity.java
// public class PersonEntity {
// private long id;
// private String firstName;
// private String lastName;
// private String emailAddress;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
| import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.entity.PersonEntity;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID; | package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
@Service
public class UserService {
| // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/entity/PersonEntity.java
// public class PersonEntity {
// private long id;
// private String firstName;
// private String lastName;
// private String emailAddress;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.entity.PersonEntity;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
@Service
public class UserService {
| private final PersonRepository personRepository; |
fpmoles/talks-spring-intro-workshop | code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/entity/PersonEntity.java
// public class PersonEntity {
// private long id;
// private String firstName;
// private String lastName;
// private String emailAddress;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
| import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.entity.PersonEntity;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID; | package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
@Service
public class UserService {
private final PersonRepository personRepository;
@Autowired
public UserService(PersonRepository personRepository){
super();
this.personRepository = personRepository;
}
@Loggable | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/entity/PersonEntity.java
// public class PersonEntity {
// private long id;
// private String firstName;
// private String lastName;
// private String emailAddress;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.entity.PersonEntity;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
@Service
public class UserService {
private final PersonRepository personRepository;
@Autowired
public UserService(PersonRepository personRepository){
super();
this.personRepository = personRepository;
}
@Loggable | public User getUser(String emailAddress){ |
fpmoles/talks-spring-intro-workshop | code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/entity/PersonEntity.java
// public class PersonEntity {
// private long id;
// private String firstName;
// private String lastName;
// private String emailAddress;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
| import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.entity.PersonEntity;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID; | package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
@Service
public class UserService {
private final PersonRepository personRepository;
@Autowired
public UserService(PersonRepository personRepository){
super();
this.personRepository = personRepository;
}
@Loggable
public User getUser(String emailAddress){
User user = new User();
user.setUsername("BigLebowski");
user.setPersonId(UUID.randomUUID().toString());
return user;
}
@Loggable
public List<User> getAllUsers(){ | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/entity/PersonEntity.java
// public class PersonEntity {
// private long id;
// private String firstName;
// private String lastName;
// private String emailAddress;
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/User.java
// public class User {
// private String username;
// private String personId;
//
// public String getUsername() {
// return username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPersonId() {
// return personId;
// }
//
// public void setPersonId(String personId) {
// this.personId = personId;
// }
// }
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/UserService.java
import com.frankmoley.talks.spring.intro.aspect.Loggable;
import com.frankmoley.talks.spring.intro.data.entity.PersonEntity;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
package com.frankmoley.talks.spring.intro.service;
/**
* Service offerings for authentication and user interactions.
*/
@Service
public class UserService {
private final PersonRepository personRepository;
@Autowired
public UserService(PersonRepository personRepository){
super();
this.personRepository = personRepository;
}
@Loggable
public User getUser(String emailAddress){
User user = new User();
user.setUsername("BigLebowski");
user.setPersonId(UUID.randomUUID().toString());
return user;
}
@Loggable
public List<User> getAllUsers(){ | Iterable<PersonEntity> entities = this.personRepository.findAll(); |
fpmoles/talks-spring-intro-workshop | code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
| import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory; | package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
public class InventoryService {
private final ItemRepository itemRepository; | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory;
package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
public class InventoryService {
private final ItemRepository itemRepository; | private final PersonRepository personRepository; |
fpmoles/talks-spring-intro-workshop | code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
| import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory; | package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
public class InventoryService {
private final ItemRepository itemRepository;
private final PersonRepository personRepository;
public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
super();
this.itemRepository = itemRepository;
this.personRepository = personRepository;
}
| // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory;
package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
public class InventoryService {
private final ItemRepository itemRepository;
private final PersonRepository personRepository;
public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
super();
this.itemRepository = itemRepository;
this.personRepository = personRepository;
}
| public Inventory getInventory(long personId){ |
fpmoles/talks-spring-intro-workshop | code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java | // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
| import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory; | package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
public class InventoryService {
private final ItemRepository itemRepository;
private final PersonRepository personRepository;
public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
super();
this.itemRepository = itemRepository;
this.personRepository = personRepository;
}
public Inventory getInventory(long personId){
return new Inventory();
}
public Inventory updateInventory(Inventory inventory){
return inventory;
}
| // Path: code/exercise_3/exercise/src/main/java/com/frankmoley/talks/spring/intro/data/repository/ItemRepository.java
// @Repository
// public class ItemRepository {
// //TODO later
// }
//
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/data/repository/PersonRepository.java
// public class PersonRepository {
// //TODO Later
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/DetailedInventoryItem.java
// public class DetailedInventoryItem extends InventoryItem{
// private String description;
// private Double cost;
// private Date acquired;
// private String model;
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public Date getAcquired() {
// return acquired;
// }
//
// public void setAcquired(Date acquired) {
// this.acquired = acquired;
// }
//
// public String getModel() {
// return model;
// }
//
// public void setModel(String model) {
// this.model = model;
// }
//
// public Double getCost() {
// return cost;
// }
//
// public void setCost(Double cost) {
// this.cost = cost;
// }
// }
//
// Path: code/exercise_4/solution/src/main/java/com/frankmoley/talks/spring/intro/service/domain/model/Inventory.java
// public class Inventory {
// private String emailAddress;
// private String firstName;
// private long personId;
// List<InventoryItem> items;
//
// public String getEmailAddress() {
// return emailAddress;
// }
//
// public void setEmailAddress(String emailAddress) {
// this.emailAddress = emailAddress;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public long getPersonId() {
// return personId;
// }
//
// public void setPersonId(long personId) {
// this.personId = personId;
// }
//
// public List<InventoryItem> getItems() {
// return items;
// }
//
// public void setItems(List<InventoryItem> items) {
// this.items = items;
// }
// }
// Path: code/exercise_2/solution/src/main/java/com/frankmoley/talks/spring/intro/service/InventoryService.java
import com.frankmoley.talks.spring.intro.data.repository.ItemRepository;
import com.frankmoley.talks.spring.intro.data.repository.PersonRepository;
import com.frankmoley.talks.spring.intro.service.domain.model.DetailedInventoryItem;
import com.frankmoley.talks.spring.intro.service.domain.model.Inventory;
package com.frankmoley.talks.spring.intro.service;
/**
* The inventory service manages all of the user inventory information including adding, updating, and retrieving the relevant details of the user and his or her items.
*/
public class InventoryService {
private final ItemRepository itemRepository;
private final PersonRepository personRepository;
public InventoryService(ItemRepository itemRepository, PersonRepository personRepository){
super();
this.itemRepository = itemRepository;
this.personRepository = personRepository;
}
public Inventory getInventory(long personId){
return new Inventory();
}
public Inventory updateInventory(Inventory inventory){
return inventory;
}
| public DetailedInventoryItem getDetailedInventoryItem(long personId, long itemId){ |
jjhesk/ToolBarLib | advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/V3/LiveIcon.java | // Path: advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/V3/layout/CLayO.java
// public class CLayO implements manifestlayout, View.OnClickListener {
// private LayoutAsset layoutRes;
// private Context mContext;
//
// public interface OnInteract {
// void OnClick(int resId);
// }
//
// private TopBarManager.Builder topBuilder;
// private OnInteract customListener;
//
// public CLayO(final LayoutAsset layoutR, Context c, TopBarManager.Builder mb, OnInteract b) {
// this(layoutR, c, mb);
// customListener = b;
// }
//
// public CLayO(final LayoutAsset layoutR, Context c, TopBarManager.Builder mb) {
// this.layoutRes = layoutR;
// this.mContext = c;
// this.topBuilder = mb;
// if (mb.customListener != null) {
// customListener = mb.customListener;
// }
// }
//
// @Override
// public void init(Toolbar toolbar) {
// Toolbar.LayoutParams layoutParams = new Toolbar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// layoutParams.gravity = Gravity.TOP;
// toolbar.addView(inflate(), layoutParams);
// }
//
// private TextView numberView;
//
// @Override
// public View inflate() {
// final View t = ToolbarHelper.generateView(layoutRes.getResourceId(), mContext);
// if (layoutRes == LayoutAsset.i_logo_ii) {
// ImageView k1 = (ImageView) t.findViewById(R.id.i_kl1);
// ImageView k2 = (ImageView) t.findViewById(R.id.i_kr1);
// ImageView k3 = (ImageView) t.findViewById(R.id.i_kr2);
// ImageView k4 = (ImageView) t.findViewById(R.id.logo_k);
// if (topBuilder.getCompanyLogoRes() != 0)
// k4.setImageResource(topBuilder.getCompanyLogoRes());
// final int[] overrides = topBuilder.getOverrideIcons_i_t_ii();
// if (overrides[0] != 0)
// k1.setImageResource(overrides[0]);
//
// if (overrides[1] != 0)
// k2.setImageResource(overrides[1]);
//
// if (overrides[2] != 0)
// k3.setImageResource(overrides[2]);
//
// k1.setOnClickListener(this);
// k2.setOnClickListener(this);
// k3.setOnClickListener(this);
// } else if (layoutRes == LayoutAsset.i_logo_ir) {
// ImageView k1 = (ImageView) t.findViewById(R.id.i_kl1);
// ImageView k2 = (ImageView) t.findViewById(R.id.i_kr2);
// FrameLayout dynamic_button_frame = (FrameLayout) t.findViewById(R.id.liveicon_counterpanel);
// ImageView k3 = (ImageView) t.findViewById(R.id.liveiconloc);
// ImageView k4 = (ImageView) t.findViewById(R.id.logo_k);
//
// if (topBuilder.getCompanyLogoRes() != 0)
// k4.setImageResource(topBuilder.getCompanyLogoRes());
// final int[] overrides = topBuilder.getOverrideIcons_i_t_ii();
// if (overrides[0] != 0)
// k1.setImageResource(overrides[0]);
//
// if (overrides[1] != 0)
// k2.setImageResource(overrides[1]);
//
// if (overrides[2] != 0)
// k3.setImageResource(overrides[2]);
// numberView = (TextView) t.findViewById(R.id.liveicon_text);
// k1.setOnClickListener(this);
// k2.setOnClickListener(this);
// dynamic_button_frame.setOnClickListener(this);
// }
//
// return t;
// }
//
// private SearchCustom mSearchCustom;
//
// public SearchCustom getSearchObject() {
// return mSearchCustom;
// }
//
// public void updateNumber(String tt) {
// numberView.setText(tt);
// }
//
// /**
// * Called when a view has been clicked.
// *
// * @param v The view that was clicked.
// */
// @Override
// public void onClick(View v) {
// if (customListener != null)
// customListener.OnClick(v.getId());
// }
// }
| import android.app.Activity;
import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.hkm.advancedtoolbar.R;
import com.hkm.advancedtoolbar.V3.layout.CLayO; | package com.hkm.advancedtoolbar.V3;
/**
* Created by hesk on 29/7/15.
*/
@Deprecated
public class LiveIcon {
private int layout, icon;
private TextView holder;
private ImageView image_view;
private String holder_text = "w99";
private Activity activity; | // Path: advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/V3/layout/CLayO.java
// public class CLayO implements manifestlayout, View.OnClickListener {
// private LayoutAsset layoutRes;
// private Context mContext;
//
// public interface OnInteract {
// void OnClick(int resId);
// }
//
// private TopBarManager.Builder topBuilder;
// private OnInteract customListener;
//
// public CLayO(final LayoutAsset layoutR, Context c, TopBarManager.Builder mb, OnInteract b) {
// this(layoutR, c, mb);
// customListener = b;
// }
//
// public CLayO(final LayoutAsset layoutR, Context c, TopBarManager.Builder mb) {
// this.layoutRes = layoutR;
// this.mContext = c;
// this.topBuilder = mb;
// if (mb.customListener != null) {
// customListener = mb.customListener;
// }
// }
//
// @Override
// public void init(Toolbar toolbar) {
// Toolbar.LayoutParams layoutParams = new Toolbar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// layoutParams.gravity = Gravity.TOP;
// toolbar.addView(inflate(), layoutParams);
// }
//
// private TextView numberView;
//
// @Override
// public View inflate() {
// final View t = ToolbarHelper.generateView(layoutRes.getResourceId(), mContext);
// if (layoutRes == LayoutAsset.i_logo_ii) {
// ImageView k1 = (ImageView) t.findViewById(R.id.i_kl1);
// ImageView k2 = (ImageView) t.findViewById(R.id.i_kr1);
// ImageView k3 = (ImageView) t.findViewById(R.id.i_kr2);
// ImageView k4 = (ImageView) t.findViewById(R.id.logo_k);
// if (topBuilder.getCompanyLogoRes() != 0)
// k4.setImageResource(topBuilder.getCompanyLogoRes());
// final int[] overrides = topBuilder.getOverrideIcons_i_t_ii();
// if (overrides[0] != 0)
// k1.setImageResource(overrides[0]);
//
// if (overrides[1] != 0)
// k2.setImageResource(overrides[1]);
//
// if (overrides[2] != 0)
// k3.setImageResource(overrides[2]);
//
// k1.setOnClickListener(this);
// k2.setOnClickListener(this);
// k3.setOnClickListener(this);
// } else if (layoutRes == LayoutAsset.i_logo_ir) {
// ImageView k1 = (ImageView) t.findViewById(R.id.i_kl1);
// ImageView k2 = (ImageView) t.findViewById(R.id.i_kr2);
// FrameLayout dynamic_button_frame = (FrameLayout) t.findViewById(R.id.liveicon_counterpanel);
// ImageView k3 = (ImageView) t.findViewById(R.id.liveiconloc);
// ImageView k4 = (ImageView) t.findViewById(R.id.logo_k);
//
// if (topBuilder.getCompanyLogoRes() != 0)
// k4.setImageResource(topBuilder.getCompanyLogoRes());
// final int[] overrides = topBuilder.getOverrideIcons_i_t_ii();
// if (overrides[0] != 0)
// k1.setImageResource(overrides[0]);
//
// if (overrides[1] != 0)
// k2.setImageResource(overrides[1]);
//
// if (overrides[2] != 0)
// k3.setImageResource(overrides[2]);
// numberView = (TextView) t.findViewById(R.id.liveicon_text);
// k1.setOnClickListener(this);
// k2.setOnClickListener(this);
// dynamic_button_frame.setOnClickListener(this);
// }
//
// return t;
// }
//
// private SearchCustom mSearchCustom;
//
// public SearchCustom getSearchObject() {
// return mSearchCustom;
// }
//
// public void updateNumber(String tt) {
// numberView.setText(tt);
// }
//
// /**
// * Called when a view has been clicked.
// *
// * @param v The view that was clicked.
// */
// @Override
// public void onClick(View v) {
// if (customListener != null)
// customListener.OnClick(v.getId());
// }
// }
// Path: advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/V3/LiveIcon.java
import android.app.Activity;
import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.hkm.advancedtoolbar.R;
import com.hkm.advancedtoolbar.V3.layout.CLayO;
package com.hkm.advancedtoolbar.V3;
/**
* Created by hesk on 29/7/15.
*/
@Deprecated
public class LiveIcon {
private int layout, icon;
private TextView holder;
private ImageView image_view;
private String holder_text = "w99";
private Activity activity; | private CLayO usingOClay; |
jjhesk/ToolBarLib | advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/socialbar/Hg.java | // Path: advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/Util/ErrorMessage.java
// public class ErrorMessage extends DialogFragment {
// private static Runnable onclickrun;
//
// public static void alert(final String message, FragmentManager manager) {
// ErrorMessage.message(message).show(manager, "errorMessageOnce");
// }
//
// public static void alert(final String message, FragmentManager manager, Runnable onclickrun) {
// ErrorMessage.onclickrun = onclickrun;
// ErrorMessage.message(message).show(manager, "errorMessageOnce");
// }
//
// public static Bundle getMessageBundle(final String mes) {
// Bundle h = new Bundle();
// h.putString("message", mes);
// return h;
// }
//
// public static ErrorMessage message(final String mes) {
// Bundle h = new Bundle();
// h.putString("message", mes);
// ErrorMessage e = new ErrorMessage();
// e.setArguments(h);
// return e;
// }
//
//
// protected void onNoticedErrorMessage(DialogInterface dialog, int id, String original_message) {
// }
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// // Use the Builder class for convenient dialog construction
// AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// builder.setMessage(getArguments().getString("message"))
// .setNeutralButton("try again", new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// onNoticedErrorMessage(dialog, id, getArguments().getString("message"));
// dialog.dismiss();
// if (ErrorMessage.onclickrun != null) {
// ErrorMessage.onclickrun.run();
// ErrorMessage.onclickrun = null;
// }
// }
// });
// // Create the AlertDialog object and return it
// return builder.create();
// }
// }
| import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import com.hkm.advancedtoolbar.R;
import com.hkm.advancedtoolbar.Util.ErrorMessage; | package com.hkm.advancedtoolbar.socialbar;
/**
* Created by hesk on 24/7/15.
* com.facebook.messenger.intents.ShareIntentHandler
* com.facebook.orca
* jp.naver.line.android.activity.selectchat.SelectChatActivity
* jp.naver.line.android
* com.pinterest.activity.create.PinItActivity
* com.pinterest
*/
public enum Hg {
pintrest("com.pinterest", R.drawable.pinterest, R.id.social_bar_pinterest),
facebook("com.facebook.katana", R.drawable.fb, R.id.social_bar_facebook),
whatsapp("com.whatsapp", R.drawable.whatsapp, R.id.social_bar_whatsapp),
twitter("com.twitter.android", R.drawable.twitter, R.id.social_bar_twitter),
message("com.tencent.mm.ui.tools.ShareToTimeLineUI", R.drawable.message, R.id.social_bar_sms);
private String package_name;
private int drawbable, extn;
Hg(final String packagename, final @DrawableRes int fl, final @IdRes int extn) {
this.package_name = packagename;
this.drawbable = fl;
this.extn = extn;
}
public String getPackageName() {
return package_name;
}
@DrawableRes
public int getDrawable() {
return drawbable;
}
@IdRes
public int Id() {
return extn;
}
public void alert(@Nullable FragmentManager g, @Nullable Context context) {
if (g == null || context == null) return;
String message = context.getString(R.string.not_found_share_app); | // Path: advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/Util/ErrorMessage.java
// public class ErrorMessage extends DialogFragment {
// private static Runnable onclickrun;
//
// public static void alert(final String message, FragmentManager manager) {
// ErrorMessage.message(message).show(manager, "errorMessageOnce");
// }
//
// public static void alert(final String message, FragmentManager manager, Runnable onclickrun) {
// ErrorMessage.onclickrun = onclickrun;
// ErrorMessage.message(message).show(manager, "errorMessageOnce");
// }
//
// public static Bundle getMessageBundle(final String mes) {
// Bundle h = new Bundle();
// h.putString("message", mes);
// return h;
// }
//
// public static ErrorMessage message(final String mes) {
// Bundle h = new Bundle();
// h.putString("message", mes);
// ErrorMessage e = new ErrorMessage();
// e.setArguments(h);
// return e;
// }
//
//
// protected void onNoticedErrorMessage(DialogInterface dialog, int id, String original_message) {
// }
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState) {
// // Use the Builder class for convenient dialog construction
// AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// builder.setMessage(getArguments().getString("message"))
// .setNeutralButton("try again", new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// onNoticedErrorMessage(dialog, id, getArguments().getString("message"));
// dialog.dismiss();
// if (ErrorMessage.onclickrun != null) {
// ErrorMessage.onclickrun.run();
// ErrorMessage.onclickrun = null;
// }
// }
// });
// // Create the AlertDialog object and return it
// return builder.create();
// }
// }
// Path: advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/socialbar/Hg.java
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import com.hkm.advancedtoolbar.R;
import com.hkm.advancedtoolbar.Util.ErrorMessage;
package com.hkm.advancedtoolbar.socialbar;
/**
* Created by hesk on 24/7/15.
* com.facebook.messenger.intents.ShareIntentHandler
* com.facebook.orca
* jp.naver.line.android.activity.selectchat.SelectChatActivity
* jp.naver.line.android
* com.pinterest.activity.create.PinItActivity
* com.pinterest
*/
public enum Hg {
pintrest("com.pinterest", R.drawable.pinterest, R.id.social_bar_pinterest),
facebook("com.facebook.katana", R.drawable.fb, R.id.social_bar_facebook),
whatsapp("com.whatsapp", R.drawable.whatsapp, R.id.social_bar_whatsapp),
twitter("com.twitter.android", R.drawable.twitter, R.id.social_bar_twitter),
message("com.tencent.mm.ui.tools.ShareToTimeLineUI", R.drawable.message, R.id.social_bar_sms);
private String package_name;
private int drawbable, extn;
Hg(final String packagename, final @DrawableRes int fl, final @IdRes int extn) {
this.package_name = packagename;
this.drawbable = fl;
this.extn = extn;
}
public String getPackageName() {
return package_name;
}
@DrawableRes
public int getDrawable() {
return drawbable;
}
@IdRes
public int Id() {
return extn;
}
public void alert(@Nullable FragmentManager g, @Nullable Context context) {
if (g == null || context == null) return;
String message = context.getString(R.string.not_found_share_app); | ErrorMessage.alert(message, g); |
jjhesk/ToolBarLib | advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/ToolbarHelper.java | // Path: advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/V3/LayoutAsset.java
// @Deprecated
// public enum LayoutAsset {
// classic_1(R.layout.material_search_ios_classic),
// classic_2(R.layout.material_search_ios),
// classic_3(R.layout.material_search_ios_simple),
// //button title/logo button button
// i_logo_ii(R.layout.i_t_ii),
// //button title/logo button dynamic_button
// i_logo_ir(R.layout.i_t_ir),
// //title/logo button dynamic_button
// i_logo_ir2(R.layout.i_t_ir2),
// material(R.layout.search_material);
//
// private final int id;
//
// LayoutAsset(int id) {
// this.id = id;
// }
//
// public int getResourceId() {
// return id;
// }
// }
| import android.content.Context;
import android.content.res.Resources;
import android.support.annotation.LayoutRes;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.hkm.advancedtoolbar.V3.LayoutAsset; | package com.hkm.advancedtoolbar;
/**
* Created by hesk on 17/7/15.
*/
public class ToolbarHelper {
public static View generateView(final @LayoutRes int layout, Context ctx) {
return LayoutInflater.from(ctx).inflate(layout, null);
}
| // Path: advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/V3/LayoutAsset.java
// @Deprecated
// public enum LayoutAsset {
// classic_1(R.layout.material_search_ios_classic),
// classic_2(R.layout.material_search_ios),
// classic_3(R.layout.material_search_ios_simple),
// //button title/logo button button
// i_logo_ii(R.layout.i_t_ii),
// //button title/logo button dynamic_button
// i_logo_ir(R.layout.i_t_ir),
// //title/logo button dynamic_button
// i_logo_ir2(R.layout.i_t_ir2),
// material(R.layout.search_material);
//
// private final int id;
//
// LayoutAsset(int id) {
// this.id = id;
// }
//
// public int getResourceId() {
// return id;
// }
// }
// Path: advancedtoolbar/src/main/java/com/hkm/advancedtoolbar/ToolbarHelper.java
import android.content.Context;
import android.content.res.Resources;
import android.support.annotation.LayoutRes;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.hkm.advancedtoolbar.V3.LayoutAsset;
package com.hkm.advancedtoolbar;
/**
* Created by hesk on 17/7/15.
*/
public class ToolbarHelper {
public static View generateView(final @LayoutRes int layout, Context ctx) {
return LayoutInflater.from(ctx).inflate(layout, null);
}
| public static View renewView(Context activity, Toolbar toolbar, LayoutAsset layoutId) { |
pmarques/SocketIO-Server | SocketIO-API/src/main/java/eu/k2c/socket/io/server/api/SocketIOOutbound.java | // Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOException.java
// public class SocketIOException extends IOException {
// private static final long serialVersionUID = 1L;
//
// public SocketIOException() {
// super();
// }
//
// public SocketIOException(final String message) {
// super(message);
// }
//
// public SocketIOException(final Throwable cause) {
// super(cause);
// }
//
// public SocketIOException(final String message, final Throwable cause) {
// super(message, cause);
// }
// }
| import eu.k2c.socket.io.server.exceptions.SocketIOException; | /**
* Copyright (C) 2011 K2C @ Patrick Marques <patrickfmarques@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright holders
* shall not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization.
*/
package eu.k2c.socket.io.server.api;
/**
* @author "Patrick F. Marques <patrick.marques@k2c.eu>"
*/
public interface SocketIOOutbound {
/**
* Terminate the connection. This method may return before the connection
* disconnect completes. The onDisconnect() method of the associated
* SocketInbound will be called when the disconnect is completed. The
* onDisconnect() method may be called during the invocation of this method.
*/
void disconnect();
/**
* Initiate an orderly close of the connection. The state will be changed to
* CLOSING so no new messages can be sent, but messages may still arrive
* until the distant end has acknowledged the close.
*/
void close();
ConnectionState getConnectionState();
/**
* Send a text message to the client. This method will block if the message
* will not fit in the outbound buffer. If the socket is closed, becomes
* closed, or times out, while trying to send the message, the
* SocketClosedException will be thrown.
*
* @param message
* The message to send
* @param endPoint
* The message endPoint
*
* @throws SocketIOException
*/ | // Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOException.java
// public class SocketIOException extends IOException {
// private static final long serialVersionUID = 1L;
//
// public SocketIOException() {
// super();
// }
//
// public SocketIOException(final String message) {
// super(message);
// }
//
// public SocketIOException(final Throwable cause) {
// super(cause);
// }
//
// public SocketIOException(final String message, final Throwable cause) {
// super(message, cause);
// }
// }
// Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/api/SocketIOOutbound.java
import eu.k2c.socket.io.server.exceptions.SocketIOException;
/**
* Copyright (C) 2011 K2C @ Patrick Marques <patrickfmarques@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright holders
* shall not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization.
*/
package eu.k2c.socket.io.server.api;
/**
* @author "Patrick F. Marques <patrick.marques@k2c.eu>"
*/
public interface SocketIOOutbound {
/**
* Terminate the connection. This method may return before the connection
* disconnect completes. The onDisconnect() method of the associated
* SocketInbound will be called when the disconnect is completed. The
* onDisconnect() method may be called during the invocation of this method.
*/
void disconnect();
/**
* Initiate an orderly close of the connection. The state will be changed to
* CLOSING so no new messages can be sent, but messages may still arrive
* until the distant end has acknowledged the close.
*/
void close();
ConnectionState getConnectionState();
/**
* Send a text message to the client. This method will block if the message
* will not fit in the outbound buffer. If the socket is closed, becomes
* closed, or times out, while trying to send the message, the
* SocketClosedException will be thrown.
*
* @param message
* The message to send
* @param endPoint
* The message endPoint
*
* @throws SocketIOException
*/ | void sendMessage(final String message, final String endPoint) throws SocketIOException; |
pmarques/SocketIO-Server | SocketIO-Core/src/main/java/eu/k2c/socket/io/frames/SocketIOFrame.java | // Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOMalformedMessageException.java
// public class SocketIOMalformedMessageException extends SocketIOException {
// private static final long serialVersionUID = 1L;
// }
| import eu.k2c.socket.io.server.exceptions.SocketIOMalformedMessageException; | public SocketIOFrame(final FrameType frameType, final long messageID, final String endPoint,
final String eventName, final String data) {
this.frameType = frameType;
this.messageID = messageID;
this.socketIOHandleAck = false;
this.endPoint = endPoint;
this.data1 = eventName;
this.data2 = data;
}
/**
* Create a Socket.IO frame and define all parameters
*
* @param frameType
* @param messageID
* @param socketIOHandleAck
* @param endPoint
* @param eventName
* @param data1
*/
public SocketIOFrame(final FrameType frameType, final long messageID, final boolean socketIOHandleAck,
final String endPoint, final String eventName, final String data) {
this.frameType = frameType;
this.messageID = messageID;
this.socketIOHandleAck = socketIOHandleAck;
this.endPoint = endPoint;
this.data1 = eventName;
this.data2 = data;
}
| // Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOMalformedMessageException.java
// public class SocketIOMalformedMessageException extends SocketIOException {
// private static final long serialVersionUID = 1L;
// }
// Path: SocketIO-Core/src/main/java/eu/k2c/socket/io/frames/SocketIOFrame.java
import eu.k2c.socket.io.server.exceptions.SocketIOMalformedMessageException;
public SocketIOFrame(final FrameType frameType, final long messageID, final String endPoint,
final String eventName, final String data) {
this.frameType = frameType;
this.messageID = messageID;
this.socketIOHandleAck = false;
this.endPoint = endPoint;
this.data1 = eventName;
this.data2 = data;
}
/**
* Create a Socket.IO frame and define all parameters
*
* @param frameType
* @param messageID
* @param socketIOHandleAck
* @param endPoint
* @param eventName
* @param data1
*/
public SocketIOFrame(final FrameType frameType, final long messageID, final boolean socketIOHandleAck,
final String endPoint, final String eventName, final String data) {
this.frameType = frameType;
this.messageID = messageID;
this.socketIOHandleAck = socketIOHandleAck;
this.endPoint = endPoint;
this.data1 = eventName;
this.data2 = data;
}
| public SocketIOFrame(final FrameType frameType) throws SocketIOMalformedMessageException { |
pmarques/SocketIO-Server | SocketIO-Core/src/main/java/eu/k2c/socket/io/frames/SocketIOFrameParser.java | // Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOMalformedMessageException.java
// public class SocketIOMalformedMessageException extends SocketIOException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOUnknownMessageException.java
// public class SocketIOUnknownMessageException extends SocketIOException {
// private static final long serialVersionUID = 1L;
//
// }
| import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import eu.k2c.socket.io.server.exceptions.SocketIOMalformedMessageException;
import eu.k2c.socket.io.server.exceptions.SocketIOUnknownMessageException;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonParseException; | /**
* Copyright (C) 2011 K2C @ Patrick Marques <patrickfmarques@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright holders
* shall not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization.
*/
package eu.k2c.socket.io.frames;
/**
* @author "Patrick F. Marques <patrick.marques@k2c.eu>"
*/
public class SocketIOFrameParser {
private static final Logger LOGGER = Logger.getLogger(SocketIOFrameParser.class);
private static final JsonFactory JSONF = new JsonFactory();
| // Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOMalformedMessageException.java
// public class SocketIOMalformedMessageException extends SocketIOException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOUnknownMessageException.java
// public class SocketIOUnknownMessageException extends SocketIOException {
// private static final long serialVersionUID = 1L;
//
// }
// Path: SocketIO-Core/src/main/java/eu/k2c/socket/io/frames/SocketIOFrameParser.java
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import eu.k2c.socket.io.server.exceptions.SocketIOMalformedMessageException;
import eu.k2c.socket.io.server.exceptions.SocketIOUnknownMessageException;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonParseException;
/**
* Copyright (C) 2011 K2C @ Patrick Marques <patrickfmarques@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright holders
* shall not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization.
*/
package eu.k2c.socket.io.frames;
/**
* @author "Patrick F. Marques <patrick.marques@k2c.eu>"
*/
public class SocketIOFrameParser {
private static final Logger LOGGER = Logger.getLogger(SocketIOFrameParser.class);
private static final JsonFactory JSONF = new JsonFactory();
| public static SocketIOFrame decode(final String message) throws SocketIOMalformedMessageException, |
pmarques/SocketIO-Server | SocketIO-Core/src/main/java/eu/k2c/socket/io/frames/SocketIOFrameParser.java | // Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOMalformedMessageException.java
// public class SocketIOMalformedMessageException extends SocketIOException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOUnknownMessageException.java
// public class SocketIOUnknownMessageException extends SocketIOException {
// private static final long serialVersionUID = 1L;
//
// }
| import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import eu.k2c.socket.io.server.exceptions.SocketIOMalformedMessageException;
import eu.k2c.socket.io.server.exceptions.SocketIOUnknownMessageException;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonParseException; | /**
* Copyright (C) 2011 K2C @ Patrick Marques <patrickfmarques@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright holders
* shall not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization.
*/
package eu.k2c.socket.io.frames;
/**
* @author "Patrick F. Marques <patrick.marques@k2c.eu>"
*/
public class SocketIOFrameParser {
private static final Logger LOGGER = Logger.getLogger(SocketIOFrameParser.class);
private static final JsonFactory JSONF = new JsonFactory();
public static SocketIOFrame decode(final String message) throws SocketIOMalformedMessageException, | // Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOMalformedMessageException.java
// public class SocketIOMalformedMessageException extends SocketIOException {
// private static final long serialVersionUID = 1L;
// }
//
// Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/exceptions/SocketIOUnknownMessageException.java
// public class SocketIOUnknownMessageException extends SocketIOException {
// private static final long serialVersionUID = 1L;
//
// }
// Path: SocketIO-Core/src/main/java/eu/k2c/socket/io/frames/SocketIOFrameParser.java
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import eu.k2c.socket.io.server.exceptions.SocketIOMalformedMessageException;
import eu.k2c.socket.io.server.exceptions.SocketIOUnknownMessageException;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonParseException;
/**
* Copyright (C) 2011 K2C @ Patrick Marques <patrickfmarques@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright holders
* shall not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization.
*/
package eu.k2c.socket.io.frames;
/**
* @author "Patrick F. Marques <patrick.marques@k2c.eu>"
*/
public class SocketIOFrameParser {
private static final Logger LOGGER = Logger.getLogger(SocketIOFrameParser.class);
private static final JsonFactory JSONF = new JsonFactory();
public static SocketIOFrame decode(final String message) throws SocketIOMalformedMessageException, | SocketIOUnknownMessageException { |
pmarques/SocketIO-Server | SocketIO-Netty/src/main/java/eu/k2c/socket/io/server/SocketIOServerFactory.java | // Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/api/SocketIOInbound.java
// public interface SocketIOInbound {
//
// /**
// * Called before the connection is established. This will provide the
// * ability
// * to validate some parameters from connection string.
// *
// * @param URI
// * The SocketOutbound associated with the connection
// *
// * @return
// * - true, proceed to handshake
// * - false, fail the handshake
// */
// public boolean validate(final String URI);
//
// /**
// * Called when the connection is established. This will only ever be called
// * once.
// *
// * @param outbound
// * The SocketOutbound associated with the connection
// * @param endPoint
// * Topic where the message belongs
// */
// public void onConnect(final SocketIOOutbound outbound, final String endPoint);
//
// /**
// * Called when the socket connection is closed. This will only ever be
// * called once. This method may be called instead of onConnect() if the
// * connection handshake isn't completed successfully.
// *
// * @param reason
// * The reason for the disconnect.
// * @param errorMessage
// * Possibly non null error message associated with the reason for
// * disconnect.
// */
// public void onDisconnect(final DisconnectReason reason, final String errorMessage);
//
// /**
// * Called when the socket connection is closed. This will only ever be
// * called once. This method may be called instead of onConnect() if the
// * connection handshake isn't completed successfully.
// *
// * @param reason
// * The reason for the disconnect.
// * @param errorMessage
// * Possibly non null error message associated with the reason for
// * disconnect.
// * @param endPoint
// * Topic where the message belongs
// */
// public void onDisconnect(final DisconnectReason reason, final String errorMessage, final String endPoint);
//
// /**
// * Called one per arriving a text message.
// *
// * @param messageID
// * Unique message identifier
// * @param endPoint
// * Topic where the message belongs
// * @param message
// * Message data
// */
// public void onMessage(final long messageID, final String endPoint, final String message);
//
// /**
// * Called one per arriving a JSON message.
// *
// * @param messageID
// * Unique message identifier
// * @param endPoint
// * Topic where the message belongs
// * @param message
// * Message data in JSON format
// */
// public void onJSONMessage(final long messageID, final String endPoint, final String message);
//
// /**
// * Called to handle Socket.IO events. Only deals events which are not
// * registered in the event listener with
// * {@link SocketIOSessionEventRegister}
// *
// * @param messageID
// * Unique message identifier
// * @param endPoint
// * Topic where the message belongs
// * @param eventName
// * Name of received event
// * @param data
// * Message data in JSON format
// */
// public void onEvent(final long messageID, final String endPoint, final String eventName, final String data);
//
// /**
// * Called to handle a acknowledgment which isn't handled by the socket.io
// *
// * @param messageID
// * @param data
// */
// public void onAck(final long messageID, final String data);
//
// /**
// * Called when a error occurs
// *
// * @param endPoint
// * @param reason
// * @param advice
// */
// public void onError(final String endPoint, final String reason, final String advice);
// }
| import org.jboss.netty.channel.ChannelHandler;
import eu.k2c.socket.io.server.api.SocketIOInbound; | /**
* Copyright (C) 2011 K2C @ Patrick Marques <patrickfmarques@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright holders
* shall not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization.
*/
package eu.k2c.socket.io.server;
/**
* @author "Patrick F. Marques <patrick.marques@k2c.eu>"
*/
public final class SocketIOServerFactory {
private SocketIOServerFactory() {
}
| // Path: SocketIO-API/src/main/java/eu/k2c/socket/io/server/api/SocketIOInbound.java
// public interface SocketIOInbound {
//
// /**
// * Called before the connection is established. This will provide the
// * ability
// * to validate some parameters from connection string.
// *
// * @param URI
// * The SocketOutbound associated with the connection
// *
// * @return
// * - true, proceed to handshake
// * - false, fail the handshake
// */
// public boolean validate(final String URI);
//
// /**
// * Called when the connection is established. This will only ever be called
// * once.
// *
// * @param outbound
// * The SocketOutbound associated with the connection
// * @param endPoint
// * Topic where the message belongs
// */
// public void onConnect(final SocketIOOutbound outbound, final String endPoint);
//
// /**
// * Called when the socket connection is closed. This will only ever be
// * called once. This method may be called instead of onConnect() if the
// * connection handshake isn't completed successfully.
// *
// * @param reason
// * The reason for the disconnect.
// * @param errorMessage
// * Possibly non null error message associated with the reason for
// * disconnect.
// */
// public void onDisconnect(final DisconnectReason reason, final String errorMessage);
//
// /**
// * Called when the socket connection is closed. This will only ever be
// * called once. This method may be called instead of onConnect() if the
// * connection handshake isn't completed successfully.
// *
// * @param reason
// * The reason for the disconnect.
// * @param errorMessage
// * Possibly non null error message associated with the reason for
// * disconnect.
// * @param endPoint
// * Topic where the message belongs
// */
// public void onDisconnect(final DisconnectReason reason, final String errorMessage, final String endPoint);
//
// /**
// * Called one per arriving a text message.
// *
// * @param messageID
// * Unique message identifier
// * @param endPoint
// * Topic where the message belongs
// * @param message
// * Message data
// */
// public void onMessage(final long messageID, final String endPoint, final String message);
//
// /**
// * Called one per arriving a JSON message.
// *
// * @param messageID
// * Unique message identifier
// * @param endPoint
// * Topic where the message belongs
// * @param message
// * Message data in JSON format
// */
// public void onJSONMessage(final long messageID, final String endPoint, final String message);
//
// /**
// * Called to handle Socket.IO events. Only deals events which are not
// * registered in the event listener with
// * {@link SocketIOSessionEventRegister}
// *
// * @param messageID
// * Unique message identifier
// * @param endPoint
// * Topic where the message belongs
// * @param eventName
// * Name of received event
// * @param data
// * Message data in JSON format
// */
// public void onEvent(final long messageID, final String endPoint, final String eventName, final String data);
//
// /**
// * Called to handle a acknowledgment which isn't handled by the socket.io
// *
// * @param messageID
// * @param data
// */
// public void onAck(final long messageID, final String data);
//
// /**
// * Called when a error occurs
// *
// * @param endPoint
// * @param reason
// * @param advice
// */
// public void onError(final String endPoint, final String reason, final String advice);
// }
// Path: SocketIO-Netty/src/main/java/eu/k2c/socket/io/server/SocketIOServerFactory.java
import org.jboss.netty.channel.ChannelHandler;
import eu.k2c.socket.io.server.api.SocketIOInbound;
/**
* Copyright (C) 2011 K2C @ Patrick Marques <patrickfmarques@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright holders
* shall not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization.
*/
package eu.k2c.socket.io.server;
/**
* @author "Patrick F. Marques <patrick.marques@k2c.eu>"
*/
public final class SocketIOServerFactory {
private SocketIOServerFactory() {
}
| public static ChannelHandler create(final Class<? extends SocketIOInbound> clazz, final boolean https) { |
kaazing/netx | bbosh/src/main/java/org/kaazing/netx/bbosh/internal/BBoshSocketFactory.java | // Path: bbosh/src/main/java/org/kaazing/netx/bbosh/BBoshStrategy.java
// public abstract class BBoshStrategy {
//
// /**
// * The BBOSH connection strategy kind.
// */
// public static enum Kind {
//
// /**
// * The polling BBOSH connection strategy kind.
// */
// POLLING,
//
// /**
// * The streaming BBOSH connection strategy kind.
// */
// STREAMING
// }
//
// /**
// * Returns the BBOSH connection strategy kind.
// *
// * @return the BBOSH connection strategy kind
// */
// public abstract Kind getKind();
//
// /**
// * Returns the maximum number of concurrent in-flight HTTP requests.
// *
// * @return the maximum number of concurrent in-flight HTTP requests
// */
// public abstract int getRequests();
//
// /**
// * Returns the BBOSH connection strategy parsed from string format.
// *
// * @param strategy the string formatted BBOSH connection strategy
// *
// * @return the BBOSH connection strategy
// * @throws IllegalArgumentException if the strategy cannot be parsed
// */
// public static BBoshStrategy valueOf(String strategy) throws IllegalArgumentException {
//
// if (strategy != null && !strategy.isEmpty()) {
// switch (strategy.charAt(0)) {
// case 'p':
// Matcher pollingMatcher = Polling.PATTERN.matcher(strategy);
// if (pollingMatcher.matches()) {
// int interval = parseInt(pollingMatcher.group(1));
// TimeUnit intervalUnit = SECONDS;
// return new Polling(interval, intervalUnit);
// }
// break;
// case 's':
// Matcher streamingMatcher = Streaming.PATTERN.matcher(strategy);
// if (streamingMatcher.matches()) {
// return new Streaming();
// }
// break;
// default:
// break;
// }
// }
//
// throw new IllegalArgumentException(strategy);
// }
//
// /**
// * The {@code Polling} BBOSH connection strategy.
// *
// * An HTTP request is repeatedly made to the server at a specific interval. When the client needs to send data to the
// * server, then the HTTP request body is present. When the server needs to send data to the client, then the response
// * body is present.
// */
// public static final class Polling extends BBoshStrategy {
//
// private static final Pattern PATTERN = Pattern.compile("polling;interval=([0-9]+)s");
//
// private final int interval;
// private final TimeUnit intervalUnit;
//
// /**
// * Creates a new {@code Polling} BBOSH connection strategy.
// *
// * @param interval the time interval count
// * @param intervalUnit the time interval unit
// */
// public Polling(int interval, TimeUnit intervalUnit) {
// this.interval = interval;
// this.intervalUnit = intervalUnit;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Kind getKind() {
// return Kind.POLLING;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public int getRequests() {
// return 1;
// }
//
// /**
// * Returns a string representation of this BBOSH connection strategy.
// *
// * @return a string representation such as {@code "polling;interval=30s"}
// */
// public String toString() {
// return format("polling;interval=%d%s", interval, toLowerCase(intervalUnit.name().charAt(0)));
// }
// }
//
// /**
// * The {@code Streaming} BBOSH connection strategy.
// *
// * An HTTP request is streamed as chunks to the server and the HTTP response is streamed as chunks back to the client.
// * When the client needs to send data to the server, then a new chunk is sent on the HTTP request body.
// * When the server needs to send data to the client, then a new chunk is sent on the HTTP response body.
// */
// public static final class Streaming extends BBoshStrategy {
//
// private static final Pattern PATTERN = Pattern.compile("streaming;request=chunked");
//
// /**
// * Creates a new {@code Streaming} BBOSH connections strategy.
// */
// public Streaming() {
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Kind getKind() {
// return Kind.STREAMING;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public int getRequests() {
// return 1;
// }
//
// /**
// * Returns a string representation of this BBOSH connection strategy.
// *
// * @return the string representation {@code "streaming;request=chunked"}
// */
// public String toString() {
// return "streaming;request=chunked";
// }
// }
//
// }
| import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import org.kaazing.netx.bbosh.BBoshStrategy; | /**
* Copyright 2007-2015, Kaazing Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kaazing.netx.bbosh.internal;
final class BBoshSocketFactory {
private final URL factoryURL;
private final int initialSequenceNo;
BBoshSocketFactory(URL factoryURL) throws IOException {
this(factoryURL, 0);
}
BBoshSocketFactory(
URL factoryURL,
int initialSequenceNo) throws IOException {
this.factoryURL = factoryURL;
this.initialSequenceNo = initialSequenceNo;
}
| // Path: bbosh/src/main/java/org/kaazing/netx/bbosh/BBoshStrategy.java
// public abstract class BBoshStrategy {
//
// /**
// * The BBOSH connection strategy kind.
// */
// public static enum Kind {
//
// /**
// * The polling BBOSH connection strategy kind.
// */
// POLLING,
//
// /**
// * The streaming BBOSH connection strategy kind.
// */
// STREAMING
// }
//
// /**
// * Returns the BBOSH connection strategy kind.
// *
// * @return the BBOSH connection strategy kind
// */
// public abstract Kind getKind();
//
// /**
// * Returns the maximum number of concurrent in-flight HTTP requests.
// *
// * @return the maximum number of concurrent in-flight HTTP requests
// */
// public abstract int getRequests();
//
// /**
// * Returns the BBOSH connection strategy parsed from string format.
// *
// * @param strategy the string formatted BBOSH connection strategy
// *
// * @return the BBOSH connection strategy
// * @throws IllegalArgumentException if the strategy cannot be parsed
// */
// public static BBoshStrategy valueOf(String strategy) throws IllegalArgumentException {
//
// if (strategy != null && !strategy.isEmpty()) {
// switch (strategy.charAt(0)) {
// case 'p':
// Matcher pollingMatcher = Polling.PATTERN.matcher(strategy);
// if (pollingMatcher.matches()) {
// int interval = parseInt(pollingMatcher.group(1));
// TimeUnit intervalUnit = SECONDS;
// return new Polling(interval, intervalUnit);
// }
// break;
// case 's':
// Matcher streamingMatcher = Streaming.PATTERN.matcher(strategy);
// if (streamingMatcher.matches()) {
// return new Streaming();
// }
// break;
// default:
// break;
// }
// }
//
// throw new IllegalArgumentException(strategy);
// }
//
// /**
// * The {@code Polling} BBOSH connection strategy.
// *
// * An HTTP request is repeatedly made to the server at a specific interval. When the client needs to send data to the
// * server, then the HTTP request body is present. When the server needs to send data to the client, then the response
// * body is present.
// */
// public static final class Polling extends BBoshStrategy {
//
// private static final Pattern PATTERN = Pattern.compile("polling;interval=([0-9]+)s");
//
// private final int interval;
// private final TimeUnit intervalUnit;
//
// /**
// * Creates a new {@code Polling} BBOSH connection strategy.
// *
// * @param interval the time interval count
// * @param intervalUnit the time interval unit
// */
// public Polling(int interval, TimeUnit intervalUnit) {
// this.interval = interval;
// this.intervalUnit = intervalUnit;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Kind getKind() {
// return Kind.POLLING;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public int getRequests() {
// return 1;
// }
//
// /**
// * Returns a string representation of this BBOSH connection strategy.
// *
// * @return a string representation such as {@code "polling;interval=30s"}
// */
// public String toString() {
// return format("polling;interval=%d%s", interval, toLowerCase(intervalUnit.name().charAt(0)));
// }
// }
//
// /**
// * The {@code Streaming} BBOSH connection strategy.
// *
// * An HTTP request is streamed as chunks to the server and the HTTP response is streamed as chunks back to the client.
// * When the client needs to send data to the server, then a new chunk is sent on the HTTP request body.
// * When the server needs to send data to the client, then a new chunk is sent on the HTTP response body.
// */
// public static final class Streaming extends BBoshStrategy {
//
// private static final Pattern PATTERN = Pattern.compile("streaming;request=chunked");
//
// /**
// * Creates a new {@code Streaming} BBOSH connections strategy.
// */
// public Streaming() {
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Kind getKind() {
// return Kind.STREAMING;
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public int getRequests() {
// return 1;
// }
//
// /**
// * Returns a string representation of this BBOSH connection strategy.
// *
// * @return the string representation {@code "streaming;request=chunked"}
// */
// public String toString() {
// return "streaming;request=chunked";
// }
// }
//
// }
// Path: bbosh/src/main/java/org/kaazing/netx/bbosh/internal/BBoshSocketFactory.java
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import org.kaazing.netx.bbosh.BBoshStrategy;
/**
* Copyright 2007-2015, Kaazing Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kaazing.netx.bbosh.internal;
final class BBoshSocketFactory {
private final URL factoryURL;
private final int initialSequenceNo;
BBoshSocketFactory(URL factoryURL) throws IOException {
this(factoryURL, 0);
}
BBoshSocketFactory(
URL factoryURL,
int initialSequenceNo) throws IOException {
this.factoryURL = factoryURL;
this.initialSequenceNo = initialSequenceNo;
}
| BBoshSocket createSocket(List<BBoshStrategy> strategies, int timeout) throws IOException { |
kaazing/netx | http/src/main/java/org/kaazing/netx/http/internal/HttpRedirectPolicyUtils.java | // Path: http/src/main/java/org/kaazing/netx/http/HttpRedirectPolicy.java
// public enum HttpRedirectPolicy {
// /**
// * Do not follow HTTP redirects.
// */
// NEVER,
//
// /**
// * Follow HTTP redirect requests always regardless of the origin, domain, etc.
// */
// ALWAYS,
//
// /**
// * Follow HTTP redirect only if the redirected request is for the same
// * origin. This implies that both the scheme/protocol and the
// * <b>authority</b> should match between the current and the redirect URIs.
// * Note that authority includes the hostname and the port.
// */
// ORIGIN,
//
// /**
// * Follow HTTP redirect only if the redirected request is for the
// * same-domain, peer-domain, or sub-domain.
// * <p>
// * URIs that satisfy HttpRedirectPolicy.ORIGIN policy will implicitly
// * satisfy HttpRedirectPolicy.DOMAIN policy.
// * <p>
// * URIs with identical domains would be http://example.com:8080 and
// * https://example.com:9090.
// * <p>
// * Domains in URIs ws://marketing.example.com:8001 and
// * ws://sales.example.com:8002 are peers of each other.
// * <p>
// * Domain of the redirected URI https://east.example.com:8080 is a
// * sub-domain of the domain of the original URI
// * http://example.com:8080.
// */
// DOMAIN
// }
| import static java.util.Collections.unmodifiableMap;
import java.net.URL;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import org.kaazing.netx.http.HttpRedirectPolicy; | /**
* Copyright 2007-2015, Kaazing Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kaazing.netx.http.internal;
final class HttpRedirectPolicyUtils {
private HttpRedirectPolicyUtils() {
// utilities only
}
| // Path: http/src/main/java/org/kaazing/netx/http/HttpRedirectPolicy.java
// public enum HttpRedirectPolicy {
// /**
// * Do not follow HTTP redirects.
// */
// NEVER,
//
// /**
// * Follow HTTP redirect requests always regardless of the origin, domain, etc.
// */
// ALWAYS,
//
// /**
// * Follow HTTP redirect only if the redirected request is for the same
// * origin. This implies that both the scheme/protocol and the
// * <b>authority</b> should match between the current and the redirect URIs.
// * Note that authority includes the hostname and the port.
// */
// ORIGIN,
//
// /**
// * Follow HTTP redirect only if the redirected request is for the
// * same-domain, peer-domain, or sub-domain.
// * <p>
// * URIs that satisfy HttpRedirectPolicy.ORIGIN policy will implicitly
// * satisfy HttpRedirectPolicy.DOMAIN policy.
// * <p>
// * URIs with identical domains would be http://example.com:8080 and
// * https://example.com:9090.
// * <p>
// * Domains in URIs ws://marketing.example.com:8001 and
// * ws://sales.example.com:8002 are peers of each other.
// * <p>
// * Domain of the redirected URI https://east.example.com:8080 is a
// * sub-domain of the domain of the original URI
// * http://example.com:8080.
// */
// DOMAIN
// }
// Path: http/src/main/java/org/kaazing/netx/http/internal/HttpRedirectPolicyUtils.java
import static java.util.Collections.unmodifiableMap;
import java.net.URL;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import org.kaazing.netx.http.HttpRedirectPolicy;
/**
* Copyright 2007-2015, Kaazing Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kaazing.netx.http.internal;
final class HttpRedirectPolicyUtils {
private HttpRedirectPolicyUtils() {
// utilities only
}
| public static boolean shouldFollowRedirect(HttpRedirectPolicy redirectPolicy, URL currentURL, URL redirectURL) { |
kaazing/netx | ws/src/main/java/org/kaazing/netx/ws/internal/WebSocketExtensionFactory.java | // Path: ws/src/main/java/org/kaazing/netx/ws/internal/ext/WebSocketExtensionFactorySpi.java
// public abstract class WebSocketExtensionFactorySpi {
//
// /**
// * Returns the name of the extension that this factory will create.
// *
// * @return String name of the extension
// */
// public abstract String getExtensionName();
//
// /**
// * Creates a {@link WebSocketExtensionSpi} instance. This method is called <b>only</b> when the extension has been
// * successfully negotiated between the client and the server. If this method throws an IOException, then the negotiated
// * extension will not participate when messages are being received or sent. The format for extensionWithParams is as
// * shown below:
// *
// * {@code}
// * extension-name[;param1=value1;param2;param3=value3]
// * {@code}
// *
// * @param extensionWithParams String representation of the extension in response header format
// * @return WebSocketExtensionSpi instance
// * @throw IOException if the specified string contains invalid extension name, parameter name or parameter value
// */
// public abstract WebSocketExtensionSpi createExtension(String extensionWithParams) throws IOException;
//
// /**
// * Validates the extension name, parameter names and values in the specified string. This method is called for an enabled
// * extensions before the opening handshake to ensure that the string representation of the extension is valid. The extension
// * will not be negotiated if IOException is thrown. The format of the specified string will be as shown below:
// *
// * {@code}
// * extension-name[;param1=value1;param2;param3=value3]
// * {@code}
// *
// * @param extensionWithParams String representation of the extension in request header format
// * @throw IOException if the specified string contains invalid extension name, parameter name or parameter value
// */
// public abstract void validateExtension(String extensionWithParams) throws IOException;
// }
| import static java.lang.String.format;
import static java.util.Collections.unmodifiableMap;
import static java.util.ServiceLoader.load;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.kaazing.netx.ws.internal.ext.WebSocketExtensionFactorySpi;
import org.kaazing.netx.ws.internal.ext.WebSocketExtensionSpi; | /**
* Copyright 2007-2015, Kaazing Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kaazing.netx.ws.internal;
public final class WebSocketExtensionFactory {
private static final Pattern PATTERN_EXTENSION_FORMAT = Pattern.compile("([a-zA-Z0-9]*)(;?(.*))");
| // Path: ws/src/main/java/org/kaazing/netx/ws/internal/ext/WebSocketExtensionFactorySpi.java
// public abstract class WebSocketExtensionFactorySpi {
//
// /**
// * Returns the name of the extension that this factory will create.
// *
// * @return String name of the extension
// */
// public abstract String getExtensionName();
//
// /**
// * Creates a {@link WebSocketExtensionSpi} instance. This method is called <b>only</b> when the extension has been
// * successfully negotiated between the client and the server. If this method throws an IOException, then the negotiated
// * extension will not participate when messages are being received or sent. The format for extensionWithParams is as
// * shown below:
// *
// * {@code}
// * extension-name[;param1=value1;param2;param3=value3]
// * {@code}
// *
// * @param extensionWithParams String representation of the extension in response header format
// * @return WebSocketExtensionSpi instance
// * @throw IOException if the specified string contains invalid extension name, parameter name or parameter value
// */
// public abstract WebSocketExtensionSpi createExtension(String extensionWithParams) throws IOException;
//
// /**
// * Validates the extension name, parameter names and values in the specified string. This method is called for an enabled
// * extensions before the opening handshake to ensure that the string representation of the extension is valid. The extension
// * will not be negotiated if IOException is thrown. The format of the specified string will be as shown below:
// *
// * {@code}
// * extension-name[;param1=value1;param2;param3=value3]
// * {@code}
// *
// * @param extensionWithParams String representation of the extension in request header format
// * @throw IOException if the specified string contains invalid extension name, parameter name or parameter value
// */
// public abstract void validateExtension(String extensionWithParams) throws IOException;
// }
// Path: ws/src/main/java/org/kaazing/netx/ws/internal/WebSocketExtensionFactory.java
import static java.lang.String.format;
import static java.util.Collections.unmodifiableMap;
import static java.util.ServiceLoader.load;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.kaazing.netx.ws.internal.ext.WebSocketExtensionFactorySpi;
import org.kaazing.netx.ws.internal.ext.WebSocketExtensionSpi;
/**
* Copyright 2007-2015, Kaazing Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kaazing.netx.ws.internal;
public final class WebSocketExtensionFactory {
private static final Pattern PATTERN_EXTENSION_FORMAT = Pattern.compile("([a-zA-Z0-9]*)(;?(.*))");
| private final Map<String, WebSocketExtensionFactorySpi> factoriesRO; |
kaazing/netx | http/src/test/java/org/kaazing/netx/http/internal/HttpRedirectPolicyUtilsTest.java | // Path: http/src/main/java/org/kaazing/netx/http/internal/HttpRedirectPolicyUtils.java
// public static boolean shouldFollowRedirect(HttpRedirectPolicy redirectPolicy, URL currentURL, URL redirectURL) {
// return POLICY_CHECKERS.get(redirectPolicy).compare(currentURL, redirectURL) == 0;
// }
| import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.kaazing.netx.http.HttpRedirectPolicy.ALWAYS;
import static org.kaazing.netx.http.HttpRedirectPolicy.DOMAIN;
import static org.kaazing.netx.http.HttpRedirectPolicy.NEVER;
import static org.kaazing.netx.http.HttpRedirectPolicy.ORIGIN;
import static org.kaazing.netx.http.internal.HttpRedirectPolicyUtils.shouldFollowRedirect;
import java.net.URL;
import org.junit.Test; | /**
* Copyright 2007-2015, Kaazing Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kaazing.netx.http.internal;
public class HttpRedirectPolicyUtilsTest {
@Test
public void testAlways() throws Exception {
URL currentURL = new URL("http://example.com:8080/path");
URL redirectURL = new URL("https://example.net:9090/different/path"); | // Path: http/src/main/java/org/kaazing/netx/http/internal/HttpRedirectPolicyUtils.java
// public static boolean shouldFollowRedirect(HttpRedirectPolicy redirectPolicy, URL currentURL, URL redirectURL) {
// return POLICY_CHECKERS.get(redirectPolicy).compare(currentURL, redirectURL) == 0;
// }
// Path: http/src/test/java/org/kaazing/netx/http/internal/HttpRedirectPolicyUtilsTest.java
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.kaazing.netx.http.HttpRedirectPolicy.ALWAYS;
import static org.kaazing.netx.http.HttpRedirectPolicy.DOMAIN;
import static org.kaazing.netx.http.HttpRedirectPolicy.NEVER;
import static org.kaazing.netx.http.HttpRedirectPolicy.ORIGIN;
import static org.kaazing.netx.http.internal.HttpRedirectPolicyUtils.shouldFollowRedirect;
import java.net.URL;
import org.junit.Test;
/**
* Copyright 2007-2015, Kaazing Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kaazing.netx.http.internal;
public class HttpRedirectPolicyUtilsTest {
@Test
public void testAlways() throws Exception {
URL currentURL = new URL("http://example.com:8080/path");
URL redirectURL = new URL("https://example.net:9090/different/path"); | assertTrue(shouldFollowRedirect(ALWAYS, currentURL, redirectURL)); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.