Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe65d23
commit 7f2931f
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/main/java/org/usergrid/vx/experimental/IntraMetaData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.usergrid.vx.experimental; | ||
|
||
public class IntraMetaData { | ||
public String keyspace; | ||
public String columnfamily; | ||
public String type; | ||
|
||
public IntraMetaData(){ | ||
|
||
} | ||
|
||
public IntraMetaData(String ks,String cf,String ty){ | ||
keyspace=ks; | ||
columnfamily = cf; | ||
type= ty; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result | ||
+ ((columnfamily == null) ? 0 : columnfamily.hashCode()); | ||
result = prime * result + ((keyspace == null) ? 0 : keyspace.hashCode()); | ||
result = prime * result + ((type == null) ? 0 : type.hashCode()); | ||
return result; | ||
} | ||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
IntraMetaData other = (IntraMetaData) obj; | ||
if (columnfamily == null) { | ||
if (other.columnfamily != null) | ||
return false; | ||
} else if (!columnfamily.equals(other.columnfamily)) | ||
return false; | ||
if (keyspace == null) { | ||
if (other.keyspace != null) | ||
return false; | ||
} else if (!keyspace.equals(other.keyspace)) | ||
return false; | ||
if (type == null) { | ||
if (other.type != null) | ||
return false; | ||
} else if (!type.equals(other.type)) | ||
return false; | ||
return true; | ||
} | ||
|
||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/org/usergrid/vx/experimental/TypeHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.usergrid.vx.experimental; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.charset.CharacterCodingException; | ||
|
||
import org.apache.cassandra.utils.ByteBufferUtil; | ||
|
||
public class TypeHelper { | ||
public static Object getTypedIfPossible(IntraState state, String type, ByteBuffer bb){ | ||
IntraMetaData imd = new IntraMetaData(state.currentKeyspace,state.currentColumnFamily,type); | ||
String s = state.meta.get(imd); | ||
|
||
if (s == null){ | ||
return bb; | ||
} else if (s.equals("UTF-8")){ | ||
try { | ||
return ByteBufferUtil.string(bb); | ||
} catch (Exception ex){ throw new RuntimeException(ex); } | ||
} else { | ||
throw new RuntimeException("Do not know what to do"); | ||
} | ||
} | ||
} |