@Override public int size() { return list.size(); }
public byte[] toArray( int offset, int len ) { synchronized( mutex ) { return list.toArray( offset, len ); } } public byte[] toArray( byte[] dest, int offset, int len ) {
public void add( byte[] vals ) { synchronized( mutex ) { list.add( vals ); } } public void add( byte[] vals, int offset, int length ) {
@Override public Byte set( int index, Byte value ) { byte previous_value = list.set( index, value ); if ( previous_value == list.getNoEntryValue() ) return null; else return Byte.valueOf( previous_value ); }
@Override public Byte remove( int index ) { byte previous_value = list.removeAt( index ); if ( previous_value == list.getNoEntryValue() ) return null; else return Byte.valueOf( previous_value ); }
@Override public Byte get( int index ) { byte value = list.get( index ); if ( value == list.getNoEntryValue() ) return null; else return Byte.valueOf( value ); }
/** * Replaces the current buffer data with the list of bytes in the give {@link gnu.trove.list.TByteList} This method arbitrarily creates data for the ByteBuffer regardless of the data type of the * vertex attribute. * * @param list to set */ public void setData(TByteList list) { this.buffer = CausticUtil.createByteBuffer(list.size()); this.buffer.put(list.toArray()); }
@Override public EntityData.Value deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { EntityData.Value.Builder value = EntityData.Value.newBuilder(); if (json.isJsonPrimitive()) { extractPrimitive(value, json); } else if (json.isJsonObject()) { extractMap(json, context, value); } else if (json.isJsonArray()) { JsonArray jsonArray = json.getAsJsonArray(); TByteList byteList = new TByteArrayList(); for (JsonElement element : jsonArray) { if (element.isJsonArray()) { value.addValue((EntityData.Value) context.deserialize(element, EntityData.Value.class)); } else if (element.isJsonObject()) { value.addValue((EntityData.Value) context.deserialize(element, EntityData.Value.class)); } else if (element.isJsonPrimitive()) { extractPrimitive(value, element); if (element.getAsJsonPrimitive().isNumber()) { try { byteList.add(element.getAsByte()); } catch (NumberFormatException nfe) { byteList.add((byte) 0); } } } } value.setBytes(ByteString.copyFrom(byteList.toArray())); } return value.build(); }
/** * Add a vertex, specifying its coordinates in fixed-point lat and lon. * @return the index of the new vertex. */ public int addVertexFixed (int fixedLat, int fixedLon) { int vertexIndex = vertexFlags.size(); fixedLats.add(fixedLat); fixedLons.add(fixedLon); vertexFlags.add((byte)0); return vertexIndex; }
public static ConfigurationSpaceName[] fromBytes(TByteList enumListAsBytes) { if (enumListAsBytes == null) return null; ConfigurationSpaceName[] enumArray = new ConfigurationSpaceName[enumListAsBytes.size()]; for (int i = 0; i < enumListAsBytes.size(); i++) enumArray[i] = fromByte(enumListAsBytes.get(i)); return enumArray; }
public TByteList subList( int fromIndex, int toIndex ) { synchronized( mutex ) { return new TSynchronizedByteList( list.subList( fromIndex, toIndex ), mutex ); } }
public byte get( int index ) { synchronized( mutex ) { return list.get( index ); } } public byte set( int index, byte element) {
public int binarySearch( byte value ) { synchronized( mutex ) { return list.binarySearch( value ); } } public int binarySearch( byte value, int fromIndex, int toIndex ) {
public byte set( int index, byte element) { synchronized( mutex ) { return list.set( index, element ); } } public void set( int offset, byte[] values ) {
public void fill( byte val ) { synchronized( mutex ) { list.fill( val ); } } public void fill( int fromIndex, int toIndex, byte val ) {
public boolean forEachDescending( TByteProcedure procedure ) { synchronized( mutex ) { return list.forEachDescending( procedure ); } }
public TByteLinkedList(TByteList list) { no_entry_value = list.getNoEntryValue(); // for (TByteIterator iterator = list.iterator(); iterator.hasNext();) { byte next = iterator.next(); add(next); } }
private static EntityData.RunLengthEncoding8 runLengthEncode8(TeraArray array) { EntityData.RunLengthEncoding8.Builder builder = EntityData.RunLengthEncoding8.newBuilder(); TByteList values = new TByteArrayList(16384); byte lastItem = (byte) array.get(0, 0, 0); int counter = 0; for (int y = 0; y < array.getSizeY(); ++y) { for (int z = 0; z < array.getSizeZ(); ++z) { for (int x = 0; x < array.getSizeX(); ++x) { byte item = (byte) array.get(x, y, z); if (lastItem != item) { builder.addRunLengths(counter); values.add(lastItem); lastItem = item; counter = 1; } else { counter++; } } } } if (lastItem != 0) { builder.addRunLengths(counter); values.add(lastItem); } builder.setValues(ByteString.copyFrom(values.toArray())); return builder.build(); }
/** * Add a vertex, specifying its coordinates in fixed-point lat and lon. * @return the index of the new vertex. */ public int addVertexFixed (int fixedLat, int fixedLon) { int vertexIndex = vertexFlags.size(); fixedLats.add(fixedLat); fixedLons.add(fixedLon); vertexFlags.add((byte)0); return vertexIndex; }