Hello fellow developer,iam getting error when running code above:
public void getConditioningQuery(String columnName,String value){
QueryResult<OrderedRows<String, String, String>> result =
(QueryResult<OrderedRows<String, String, String>>) new IndexedSlicesQuery<String, String, String>(keyspace, serializer, serializer, serializer)
.addEqualsExpression("state", "TI")
.setReturnKeysOnly()
.setColumnFamily(CF_NAME)
.setStartKey("")
.execute();
System.out.println("Result="+result.get().getList());
}
this method is to find row where state=TI.
i've added index in my column family and if i manual query in cassandra-cli,the data is show,but if im using the code using hector,im getting this error:
in my IDE=
345 [main] INFO me.prettyprint.cassandra.service.JmxMonitor - Registering JMX me.prettyprint.cassandra.service_MyCluster:ServiceType=hector,MonitorType=hector
867 [main] INFO me.prettyprint.cassandra.hector.TimingLogger - start[1306754734185] time[91] tag[WRITE.success_]
10926 [main] INFO me.prettyprint.cassandra.hector.TimingLogger - start[1306754734314] time[10021] tag[READ.fail_]
me.prettyprint.hector.api.exceptions.HTimedOutException: TimedOutException()
at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:32)
and in cassandra log=
ERROR 18:25:34,326 Fatal exception in thread Thread[ReadStage:102,5,main]
java.lang.AssertionError: No data found for NamesQueryFilter(columns=) in DecoratedKey(165611378069681836494944905825187619237, 73616e6a6f7578):QueryPath(columnFamilyName='user', superColumnName='null', columnName='null') (original filter NamesQueryFilter(columns=)) from expression 'user.state EQ TI'
at org.apache.cassandra.db.ColumnFamilyStore.scan(ColumnFamilyStore.java:1603)
at org.apache.cassandra.service.IndexScanVerbHandler.doVerb(IndexScanVerbHandler.java:42)
at org.apache.cassandra.net.MessageDeliveryTask.run(MessageDeliveryTask.java:72)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
im so confuse because the error is tell if the data in column in column family user is not found,but if im using cassandra-cli,the data is shows..
im so confuse and still stuck here..maybe my method is wrong?somebody can help me telling me what is wrong?im still google to solve this problem..thanks for your attention and sorry for my bad english :D..
It looks like you're hitting CASSANDRA-2653 if you're using 0.8-rc1 or similar. This should be fixed in the current 0.8 branch.
You can't use setReturnKeysOnly with index queries, yet. This will be fixed in a future release (see the ticket Tyler linked); in the meantime, simply let it return one or more columns as a workaround.
Related
I have example in my local hazelcast:
Map<Integer, TreeMap<Long, GenericRecord>> map = hzInstance.getReplicatedMap(TEST_MAP);
TreeMap<Long, GenericRecord> zmeny = new TreeMap<Long, GenericRecord>();
zmeny.put(1l, GenericRecordBuilder.compact("test").setString("string", "stringvalue").setInt32("integer", 123)
.build());
map.put(1, zmeny);
Map<Integer, TreeMap<Long, GenericRecord>> a = hzInstance.getReplicatedMap(TEST_MAP);
for (Entry<Integer, TreeMap<Long, GenericRecord>> ccc : a.entrySet()) {
GenericRecord record = ccc.getValue().get(1l);
System.out.println(record); // here I got exception
}
so I am inserting map of treemap to hazelcast. Problem is when I want to read this data from hazelcast. I got example:
Caused by: java.io.EOFException: Cannot read 4 bytes!
at com.hazelcast.internal.serialization.impl.ByteArrayObjectDataInput.checkAvailable(ByteArrayObjectDataInput.java:670)
at com.hazelcast.internal.serialization.impl.ByteArrayObjectDataInput.readInt(ByteArrayObjectDataInput.java:293)
at com.hazelcast.internal.serialization.impl.compact.CompactInternalGenericRecord.getInt32(CompactInternalGenericRecord.java:255)
... 59 common frames omitted
when I debug I see that record is DefaultCompactReader which can not read data. It looks like it is empty. Any advice what I am doing wrong ?
UPDATE1
compact serialization is enabled. Without it I can not even put treemap to hazelcast:
Config hzConfig = new Config();
NetworkConfig network = hzConfig.getNetworkConfig();
network.setPortAutoIncrement(false);
network.getInterfaces().setEnabled(true).addInterface("127.0.0.1");
network.getJoin().getMulticastConfig().setEnabled(false);
hzConfig.getUserCodeDeploymentConfig().setEnabled(true);
hzConfig.getSerializationConfig().getCompactSerializationConfig().setEnabled(true);
HazelcastInstance hzInstance = Hazelcast.newHazelcastInstance(hzConfig);
UPDATE2
When I debug code I can see this not working because of:
com.hazelcast.internal.serialization.impl.bufferpool.BufferPoolImpl.returnInputBuffer(BufferObjectDataInput)
which clear input buffer. StreamSerializerAdapter with TreeMap is used instead of CompactStreamSerializer
For the time being, you should enable Compact serialization explicitly, as it is still in BETA. (It will be promoted to stable status in the upcoming 5.2 release).
When you enable Compact serialization with a configuration like the below, the code snippet you shared works as expected, which I tested .
config.getSerializationConfig().getCompactSerializationConfig().setEnabled(true);
thx to mdumandag this is bug which will be fixed in 5.2
I originally had the following SQL function:
CREATE FUNCTION resolve_device(query JSONB) RETURNS JSONB...
and the following code calling the method generated by jOOQ:
final JsonArray jsonArray = jooqDWH.select(resolveDevice(queryJson)).fetchOne().value1().getAsJsonArray();
final JsonObject o = jsonArray.get(0).getAsJsonObject();
This worked fine. I needed to return a real device object rather than a JSON blob though, so I changed the SQL function to:
CREATE FUNCTION resolve_device(query JSONB) RETURNS SETOF device...
and the code to:
final ResolveDeviceRecord deviceRecord = jooqDWH.fetchOne(resolveDevice(queryJson));
but I am getting a runtime error:
org.jooq.exception.SQLDialectNotSupportedException: Type class com.google.gson.JsonElement is not supported in dialect DEFAULT
Many other parts of my code continue to work fine with the custom binding I have converting JsonElement to JSONB, but something about the change to this function's signature caused it to stop working.
I tried a few different variants of DSL.field() and DSL.val() to try to force it to be recognized but have not had any luck so far.
This could be a bug in jOOQ or a misconfiguration in your code generator. I'll update my answer once it is clear what went wrong.
Workaround:
Meanwhile, here's a workaround using plain SQL:
// Manually create a data type from your custom JSONB binding first:
final DataType<JsonObject> jsonb = SQLDataType.OTHER.asConvertedDataType(jsonBinding);
// Then, create an explicit bind variable using that data type:
final ResolveDeviceRecord deviceRecord =
jooqDWH.fetchOptional(table("resolve_device({0})", val(queryJson, jsonb)))
.map(r -> r.into(ResolveDeviceRecord.class))
.orElse(null);
I'm trying to implement loggin filter as described in this question:
How implement a login filter in JSF?
But can't get any attribute associated with currently logged user. I'm using Websphere 8.0 with build-in Apache MyFaces 2.0.3
My code is following:
String path = req.getServletPath();
HttpSession session = req.getSession(false);
I have tried to use req.getSession().getAttribute("auth");, it return null;
req.getSession().getAttribute("username") returns null too.
But when I try to debug or print by toString the session I get the following output (I've hidden private information):
(java.lang.String) # HttpSessionImpl #
{
_iSession=# com.ibm.ws.session.store.memory.MemorySession #
{
_sessionId=f7ZHa1mIEnp3CDyMammVg1U
hashCode : 73409621
create time : Sun May 31 19:34:53 IDT 2015
last access : Sun May 31 19:35:23 IDT 2015
max inactive interval : 900
user name : user:**********/uid=******,c=il,OU=**,O=********
valid session : true
new session : false
overflowed : false
app name : default_host/*********
Attribute Names=[org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementHelper.SERIALIZED_VIEW, jsf_sequence, org.apache.webbeans.web.failover, WebBeansConfigurationListener, facelets.ui.DebugOutput, javax.faces.request.charset]
_refCount=1
}
_httpSessionContext=com.ibm.ws.session.http.HttpSessionContextImpl#4cab3001
}
So I decided that session keeps the data which I need, I just don't know how to get it.
When I tried to debug it deeper I found that it contains variable: _iSession of type MemorySession and inside it there's a variable _userName which contains the required data, but again, I couldn't get it.
I've tried to cast this object to HttpSessionImpl but get an error:
could not resolve type: com.ibm.ws.session.http.HttpSessionImpl
The next step to get the required data is by using reflection, but I'm sure that it's wrong way. It should be much more convenient way to access it.
Thank you for any help.
I am getting the following error when trying to set a date value using #Date value with replaceItemValue.
The error I am getting occurs on the last line of code here:
var dt = #Date(2012,1,1);
docContractor.replaceItemValue("NewField","Hello World");
docContractor.replaceItemValue("ContractorStartDateTime",dt);
The error is:
Error while executing JavaScript action expression
Script interpreter error, line=21, col=31: [TypeError] Exception occurred calling method NotesDocument.replaceItemValue(string, Date) null
How can I fix this?
The following works:
docContractor.replaceItemValue("ContractorStartDateTime", session.createDateTime("Today"));
You can find more examples in the Notes and Domino App Dev wiki: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/NotesDateTime_sample_JavaScript_code_for_XPages
Did you try to use a NotesDateTime object instead?
Or use toString ()
Here's the problem: in short I use comb.guid identity strategy and I need all the rows made after the saved marker..
Here's dummy code example of what I am trying to get:
return session.Linq
.Where(p => p.Id.CompareTo(lastSyncedEntityIdentity)
== 1 )
.ToList();
This throws an exception saying that CompareTo is not implemented...
System.NotImplementedException occurred
Message=The method CompareTo is not implemented.
Source=NHibernate.Linq
StackTrace:
at NHibernate.Linq.Visitors.RootVisitor.VisitMethodCall(MethodCallExpression expr) in e:\horn\.horn\orm\nhcontrib\nhibernate.linq\Working-2.1\src\NHibernate.Linq\Visitors\RootVisitor.cs:line 97
InnerException:
As you can see from stack I have tried the 2.1 version from hornget trunk without any help
Any hint/clue what I have to do in order to go around this limitation which I guess is impacting most of folks using comb.guid strategy?
Thanks,
Nikola
The issue here is that the method CompareTo cannot be translated into an SQL query.
Remember that all NHibernate.Linq is doing is building an SQL Select statement from the predicate defined in a lambda expression, anything used in the lambda must be translatable to a comparable SQL statement.
so
session.Linq.Where(p => p.Id == 10299);
can be translated to
SELECT * FROM Table WHERE Table.Id = 10299
however there is no SQL command for CompareTo as this is a .net method.